Show loading progress and send num_ctx 16384 so vision chat fits.

Livebar and waiting_ollama phase while the model loads into GPU; bump context past Ollama's 4096 default that truncated Assistent packs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-21 20:47:10 +03:00
co-authored by Cursor
parent 3380206c6a
commit 57b2023a50
4 changed files with 441 additions and 40 deletions
+15 -1
View File
@@ -43,6 +43,8 @@ public class SwarmAssistentExtension : Extension
const int MaxCivitaiHops = 2;
const int MaxLorasInInventory = 120;
const int MaxWildcardsInInventory = 80;
/// <summary>Ollama default num_ctx is 4096; Assistent system+inventory+vision exceeds that.</summary>
const int DefaultNumCtx = 16384;
static readonly Regex JsonFenceRe = new(@"```(?:json)?\s*([\s\S]*?)```", RegexOptions.IgnoreCase | RegexOptions.Compiled);
@@ -53,7 +55,7 @@ public class SwarmAssistentExtension : Extension
ExtensionAuthor = "mrleo1nid";
Description = "Collaborative Krea 2 assistant via Ollama: chat, vision, img2img/inpaint, Generate loop, Civitai Confirm.";
License = "MIT";
Version = "0.3.1";
Version = "0.3.4";
Tags = ["tabs", "ui", "llm", "ollama", "krea", "inpaint"];
}
@@ -581,6 +583,10 @@ public class SwarmAssistentExtension : Extension
["model"] = modelName,
["stream"] = stream,
["messages"] = new JArray(ollamaMessages),
["options"] = new JObject
{
["num_ctx"] = DefaultNumCtx,
},
};
using StringContent content = new(payload.ToString(Newtonsoft.Json.Formatting.None), Encoding.UTF8, "application/json");
using HttpRequestMessage req = new(HttpMethod.Post, $"{root}/api/chat") { Content = content };
@@ -718,6 +724,14 @@ public class SwarmAssistentExtension : Extension
string packName = (pack ?? "write_prompt").Trim();
try
{
if (ws.State == WebSocketState.Open)
{
await ws.SendJson(new JObject
{
["phase"] = "waiting_ollama",
["notice"] = "Loading model into GPU…",
}, API.WebsocketTimeout);
}
async Task OnDelta(string delta)
{
if (ws.State == WebSocketState.Open)