diff --git a/AssistentChatPipeline.cs b/AssistentChatPipeline.cs index 4170e60..b84bc41 100644 --- a/AssistentChatPipeline.cs +++ b/AssistentChatPipeline.cs @@ -729,7 +729,6 @@ public partial class SwarmAssistentExtension ctx.Remove("enabled_loras"); // alias of selected_loras — do not double-feed try { - string pid = AssistentConfig.SafeId(ctx["persona"]?.ToString()) ?? Config?.DefaultPersonaId() ?? "neutral"; JObject asst = Config?.LoadAssistant(pid) ?? new JObject(); double weight = asst["user_prefs_weight"]?.Value() ?? 1.0; int maxPrefs = asst["user_prefs_max"]?.Value() ?? 16; diff --git a/AssistentHuggingFace.cs b/AssistentHuggingFace.cs index 58ce218..51ac03b 100644 --- a/AssistentHuggingFace.cs +++ b/AssistentHuggingFace.cs @@ -137,7 +137,7 @@ public partial class SwarmAssistentExtension string cacheKey = $"hf:{datasetId}"; if (useCache) { - JObject cached = Memory.GetKvObject(KvHfDatasetCache)?[cacheKey] as JObject; + JObject cached = Memory.GetKvObject(AssistentMemory.KvHfDatasetCache)?[cacheKey] as JObject; if (cached is not null && cached["checked_at"]?.Value() > DateTimeOffset.UtcNow.AddHours(-6).ToUnixTimeMilliseconds()) { return cached; @@ -302,9 +302,9 @@ public partial class SwarmAssistentExtension result["checked_at"] = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); try { - JObject bag = Memory.GetKvObject(KvHfDatasetCache) ?? new JObject(); + JObject bag = Memory.GetKvObject(AssistentMemory.KvHfDatasetCache) ?? new JObject(); bag[cacheKey] = result; - Memory.SetKvObject(KvHfDatasetCache, bag); + Memory.SetKvObject(AssistentMemory.KvHfDatasetCache, bag); } catch (Exception ex) { diff --git a/AssistentMemory.Training.cs b/AssistentMemory.Training.cs index 08b7518..8803678 100644 --- a/AssistentMemory.Training.cs +++ b/AssistentMemory.Training.cs @@ -275,7 +275,7 @@ public sealed partial class AssistentMemory cmd.Parameters.AddWithValue("$base", (object)job["base_model"]?.ToString() ?? DBNull.Value); cmd.Parameters.AddWithValue("$out", (object)job["output_name"]?.ToString() ?? DBNull.Value); cmd.Parameters.AddWithValue("$log", (object)job["log_path"]?.ToString() ?? DBNull.Value); - cmd.Parameters.AddWithValue("$prog", (object)job["progress"]?.ToString(Newtonsoft.Json.Formatting.None) ?? job["progress_json"]?.ToString() ?? DBNull.Value); + cmd.Parameters.AddWithValue("$prog", (object)(job["progress"]?.ToString(Newtonsoft.Json.Formatting.None) ?? job["progress_json"]?.ToString()) ?? DBNull.Value); cmd.Parameters.AddWithValue("$c", job["created_at"]?.Value() ?? job["createdAt"]?.Value() ?? now); cmd.Parameters.AddWithValue("$u", now); cmd.Parameters.AddWithValue("$f", (object)(job["finished_at"]?.Value() ?? job["finishedAt"]?.Value()) ?? DBNull.Value); diff --git a/AssistentPatch.cs b/AssistentPatch.cs index 9485a51..f975ae9 100644 --- a/AssistentPatch.cs +++ b/AssistentPatch.cs @@ -10,7 +10,7 @@ public partial class SwarmAssistentExtension { static readonly Regex JsonFenceRe = new(@"```(?:json)?\s*([\s\S]*?)```", RegexOptions.IgnoreCase | RegexOptions.Compiled); - static string[] PatchKeys => _patchKeys ??= Config?.LoadPatchKeys() ?? []; + string[] PatchKeys => _patchKeys ??= Config?.LoadPatchKeys() ?? []; static string[] _patchKeys; @@ -68,7 +68,7 @@ public partial class SwarmAssistentExtension && (HasValue(obj, "triggers") || HasValue(obj, "when") || HasValue(obj, "prompt_hint") || HasValue(obj, "notes")); } - static JObject TryParsePatch(string reply) + JObject TryParsePatch(string reply) { if (string.IsNullOrWhiteSpace(reply)) { diff --git a/AssistentTraining.Agent.cs b/AssistentTraining.Agent.cs index 21418f4..8ffec7e 100644 --- a/AssistentTraining.Agent.cs +++ b/AssistentTraining.Agent.cs @@ -11,7 +11,7 @@ namespace Mrleo1nid.SwarmAssistent; /// Link training dataset samples to the live agent as retrievable "heard" examples. public partial class SwarmAssistentExtension { - static string MemoryEmbedForTraining(string personaId = null) + string MemoryEmbedForTraining(string personaId = null) { string pid = AssistentConfig.SafeId(personaId) ?? Config.DefaultPersonaId(); return Config.LoadSettings()["embed_model"]?.ToString() @@ -19,7 +19,7 @@ public partial class SwarmAssistentExtension ?? "nomic-embed-text"; } - static string MemoryBaseForTraining(JObject raw = null) + string MemoryBaseForTraining(JObject raw = null) => MemoryBaseUrl(raw?["base_url"]?.ToString()); public async Task AssistentGetDatasetAgentSettings(Session session) @@ -96,7 +96,7 @@ public partial class SwarmAssistentExtension string persona = raw?["persona"]?.ToString(); string status = approvedOnly ? "approved" : "all"; List samples = Memory.ListTrainSamples(status, persona, null, 2000); - string baseUrl = MemoryBaseForTraining(raw); + string baseUrl = MemoryBaseForTraining(raw); int linked = 0; int skipped = 0; List errors = []; diff --git a/AssistentTraining.cs b/AssistentTraining.cs index 35db077..e8bb678 100644 --- a/AssistentTraining.cs +++ b/AssistentTraining.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Linq; diff --git a/AssistentTrainingJobs.cs b/AssistentTrainingJobs.cs index 3fce3ea..c9bee12 100644 --- a/AssistentTrainingJobs.cs +++ b/AssistentTrainingJobs.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Net.Http; +using System.Net.WebSockets; using System.Text; using System.Text.RegularExpressions; using System.Threading; @@ -156,7 +158,7 @@ public partial class SwarmAssistentExtension return sb.ToString().Trim(); } - static string BuildRunnerCommand(JObject runner, string configPath, string logPath, string workDir) + string BuildRunnerCommand(JObject runner, string configPath, string logPath, string workDir) { string python = runner["python"]?.ToString()?.Trim(); if (string.IsNullOrWhiteSpace(python)) diff --git a/README.md b/README.md index 7253b98..7421ade 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ SwarmUI extension for **collaborative Krea 2** prompting via **Ollama**: chat + **Turn model:** one user message is one *turn*. A turn may fan out into nested LLM *hops* — Krea prompt prep, empty-patch retry, vision, auto-critique. Hops share one `HOP_BUDGET`, never re-read the user's text (their prompt is client-authored), and pass the busy gate that blocks new user sends. What a reply does to generation state is decided once, in `resolveTurnIntent`: the model's `actions:["generate"]` / `look_at` win, RU intent heuristics only back it up when the model forgets, and an explicit «запомни, не генерируй» vetoes both. +**Version 0.13.1** — Сборка 0.13.0: `using` для `WebSocket`/`HttpClient`, instance-методы с `Config`/`FilePath`, Sqlite dll рядом с extension (иначе вкладка не грузится / API пустые). + **Version 0.13.0** — **Реальный QLoRA-пайплайн**: `train_qlora.py` (TRL SFTTrainer + PEFT), HF-датасеты с маппингом (preset fiction title/tags→text), `max_samples`, полный post-train: safetensors → GGUF (`convert_lora_to_gguf.py`) → `ollama create` с `FROM ollama_base` + `ADAPTER`. Раннер: `builtin` + `custom`. Зависимости: `scripts/requirements-train.txt`. **Version 0.12.1** — **Услышанное → агент**: одобренные примеры датасета сразу попадают в vector memory (`kind=heard`) и в контекст чата как `heard_examples` (без QLoRA). На вкладке «Датасет»: авто-подключение при одобрении, синхронизация всех, per-sample 🔗. Агент может запросить `heard_search`. Настройки: `training-agent.json`. diff --git a/SwarmAssistentExtension.cs b/SwarmAssistentExtension.cs index d1d22d9..254c51e 100644 --- a/SwarmAssistentExtension.cs +++ b/SwarmAssistentExtension.cs @@ -33,7 +33,7 @@ public partial class SwarmAssistentExtension : Extension ExtensionAuthor = "mrleo1nid"; Description = "Collaborative Krea 2 assistant: Ollama chat, persona presets, vector memory, model cards, Generate loop."; License = "MIT"; - Version = "0.13.0"; + Version = "0.13.1"; Tags = ["tabs", "ui", "llm", "ollama", "krea", "inpaint", "memory", "training", "heard", "qlora"]; } @@ -104,7 +104,7 @@ public partial class SwarmAssistentExtension : Extension API.RegisterAPICall(AssistentLinkTrainSampleToAgent, true, PermUse); API.RegisterAPICall(AssistentUnlinkTrainSampleFromAgent, true, PermUse); API.RegisterAPICall(AssistentSyncDatasetToAgent, true, PermUse); - Logs.Init("Swarm Assistent extension loaded (0.13.0 real QLoRA pipeline)"); + Logs.Init("Swarm Assistent extension loaded (0.13.1 QLoRA pipeline)"); } int CfgInt(string key, int fallback) diff --git a/SwarmAssistentExtension.csproj b/SwarmAssistentExtension.csproj index 3c509ef..5dc607a 100644 --- a/SwarmAssistentExtension.csproj +++ b/SwarmAssistentExtension.csproj @@ -6,4 +6,19 @@ + + + true + + + + + + +