Fix HF dataset import internal error and training SQLite readiness.

Wrap AssistentImportHfDataset in try/catch, batch inserts in a transaction, clearer HF rows errors for gated datasets, EnsureTrainingReady with actionable message, and friendlier training UI errors instead of generic internal error.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-23 20:11:18 +03:00
co-authored by Cursor
parent b0f2736f65
commit 63538fe738
9 changed files with 323 additions and 155 deletions
+28 -1
View File
@@ -149,7 +149,7 @@ public sealed partial class AssistentMemory : IDisposable
}
catch (Exception ex)
{
Logs.Debug($"AssistentMemory training schema: {ex.Message}");
Logs.Error($"AssistentMemory training schema failed: {ex.Message}");
}
try
{
@@ -166,6 +166,10 @@ public sealed partial class AssistentMemory : IDisposable
bool HasColumn(string table, string column)
{
if (!HasTable(table))
{
return false;
}
using SqliteCommand cmd = _conn.CreateCommand();
cmd.CommandText = $"PRAGMA table_info({table})";
using SqliteDataReader reader = cmd.ExecuteReader();
@@ -179,6 +183,29 @@ public sealed partial class AssistentMemory : IDisposable
return false;
}
bool HasTable(string table)
{
using SqliteCommand cmd = _conn.CreateCommand();
cmd.CommandText = "SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = $n LIMIT 1";
cmd.Parameters.AddWithValue("$n", table ?? "");
return cmd.ExecuteScalar() != null;
}
internal void EnsureTrainingReady()
{
EnsureOpen();
if (!HasTable("train_samples"))
{
EnsureTrainingSchema();
}
if (!HasTable("train_samples"))
{
throw new InvalidOperationException(
"Assistent training database unavailable (train_samples). "
+ "Run gpu-rent seed-extensions and restart SwarmUI (≥0.15.6).");
}
}
void MigratePersonaColumn()
{
if (HasColumn("memories", "persona"))