Private
Public Access
1
0

Increase Ollama context window to 16k tokens

Ollama defaults to 2048 tokens which is far too small for page context
data + 15 tool definitions + conversation history. Added num_ctx=16384
via the options field on all Ollama requests. With Qwen at ~4GB and
7GB VRAM free this fits comfortably.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-12 19:25:24 -05:00
parent f5d6e9f98e
commit 401147009a
2 changed files with 14 additions and 2 deletions
+4 -2
View File
@@ -198,7 +198,8 @@ public class ChatService : IChatService
Model = modelName,
Messages = ollamaMessages,
Stream = false,
Tools = tools
Tools = tools,
Options = new OllamaRequestOptions { NumCtx = 16384 }
};
var response = await CallOllamaAsync(ollamaUrl, ollamaRequest);
@@ -270,7 +271,8 @@ public class ChatService : IChatService
Model = modelName,
Messages = ollamaMessages,
Stream = false,
Tools = null // drop tools so the model focuses on the page data
Tools = null, // drop tools so the model focuses on the page data
Options = new OllamaRequestOptions { NumCtx = 16384 }
};
var retryResponse = await CallOllamaAsync(ollamaUrl, retryRequest);
rawContent = retryResponse?.Message?.Content;