Add OpenRouter chat provider; fix Windows load errors (0.17.0).

- OpenRouter as an alternative chat provider: server-side API key
  (settings.json or OPENROUTER_API_KEY), model list with vision marks and
  filter, SSE streaming, images as data URLs. Memory embeddings stay on Ollama;
  park/warm LLM are no-ops for the remote provider.
- AssistentSaveKnowledgeAttach: JArray param is not supported by SwarmUI API
  reflection and aborted registration of every later API call; use string[].
- SQLite bootstrap: preload native e_sqlite3 for the current OS/arch
  (win/osx/linux) and resolve DllImport to it.
- settings.json: shared-read + atomic write with retry to avoid Windows
  sharing violations.
- csproj: fix MSB4012 in the native SQLite copy target.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
mrleo1nid
2026-09-17 06:18:47 +03:00
co-authored by Claude Opus 5
parent f2b92e96ca
commit d67f5e396e
13 changed files with 740 additions and 56 deletions
+9 -3
View File
@@ -21,6 +21,11 @@ public partial class SwarmAssistentExtension
public async Task<JObject> AssistentListModels(Session session, string baseUrl)
{
string root = NormalizeBaseUrl(baseUrl);
return UseOpenRouter() ? await ListOpenRouterModels(root) : await ListOllamaModels(root);
}
async Task<JObject> ListOllamaModels(string root)
{
try
{
using HttpResponseMessage resp = await HttpClient.GetAsync($"{root}/api/tags");
@@ -104,6 +109,7 @@ public partial class SwarmAssistentExtension
return new JObject
{
["success"] = true,
["provider"] = ProviderOllama,
["base_url"] = root,
["models"] = models,
["memory_models"] = memoryModels,
@@ -363,7 +369,7 @@ public partial class SwarmAssistentExtension
}
catch (Exception ex)
{
return new JObject { ["error"] = $"Ollama chat failed: {ex.Message}" };
return new JObject { ["error"] = $"{ProviderLabel()} chat failed: {ex.Message}" };
}
}
@@ -388,7 +394,7 @@ public partial class SwarmAssistentExtension
await ws.SendJson(new JObject
{
["phase"] = "waiting_ollama",
["notice"] = "Waiting for Ollama…",
["notice"] = $"Waiting for {ProviderLabel()}…",
}, API.WebsocketTimeout);
}
async Task OnDelta(string delta)
@@ -435,7 +441,7 @@ public partial class SwarmAssistentExtension
}
catch (Exception ex)
{
await ws.SendJson(new JObject { ["error"] = $"Ollama chat failed: {ex.Message}" }, API.WebsocketTimeout);
await ws.SendJson(new JObject { ["error"] = $"{ProviderLabel()} chat failed: {ex.Message}" }, API.WebsocketTimeout);
}
return null;
}