Private
Public Access
1
0

Add adjustable context size, custom chatbot name, and cat icon for AI chat

Settings > AI tab now includes context size slider (2048–131072) with VRAM
estimate and a chatbot name field. ChatService reads both dynamically instead
of hardcoding num_ctx=16384 and "Purrse AI". Chat panel FAB and empty state
use mdi-cat icon to match the rest of the app.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-13 14:38:07 -05:00
parent 0ad8e472f7
commit 688dd333dc
11 changed files with 1696 additions and 12 deletions
+10 -3
View File
@@ -113,6 +113,8 @@ public class ChatService : IChatService
var settings = await _db.AiCategorizationSettings.FirstOrDefaultAsync(s => s.UserId == userId);
var ollamaUrl = settings?.OllamaUrl ?? "http://localhost:11434";
var modelName = settings?.ModelName ?? "llama3.1:8b";
var chatContextSize = settings?.ChatContextSize ?? 16384;
var chatBotName = settings?.ChatBotName;
// Save user message
var userMessage = new ChatMessage
@@ -130,10 +132,15 @@ public class ChatService : IChatService
var ollamaMessages = new List<OllamaToolMessage>();
// System prompt
var systemPrompt = string.Format(SystemPromptTemplate, DateTime.UtcNow.ToString("yyyy-MM-dd"));
if (!string.IsNullOrWhiteSpace(chatBotName))
{
systemPrompt += $"\nYour name is {chatBotName}.";
}
ollamaMessages.Add(new OllamaToolMessage
{
Role = "system",
Content = string.Format(SystemPromptTemplate, DateTime.UtcNow.ToString("yyyy-MM-dd"))
Content = systemPrompt
});
// Last 20 conversation messages
@@ -199,7 +206,7 @@ public class ChatService : IChatService
Messages = ollamaMessages,
Stream = false,
Tools = tools,
Options = new OllamaRequestOptions { NumCtx = 16384 }
Options = new OllamaRequestOptions { NumCtx = chatContextSize }
};
var response = await CallOllamaAsync(ollamaUrl, ollamaRequest);
@@ -272,7 +279,7 @@ public class ChatService : IChatService
Messages = ollamaMessages,
Stream = false,
Tools = null, // drop tools so the model focuses on the page data
Options = new OllamaRequestOptions { NumCtx = 16384 }
Options = new OllamaRequestOptions { NumCtx = chatContextSize }
};
var retryResponse = await CallOllamaAsync(ollamaUrl, retryRequest);
rawContent = retryResponse?.Message?.Content;