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:
+28
-1
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user