diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-12-26 10:01:49 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-12-26 10:01:49 +0300 |
| commit | c0ec82b579f09af020bc236eb84fa6b22d68823b (patch) | |
| tree | b3712ab57070a3e2b387c83d4585199f51fbba49 | |
| parent | 3c6f9b624ec4ef6f2e92ddb2ba794a0d8cddd6cf (diff) | |
Chore: only table switch for auto clean tool calls
| -rw-r--r-- | bot.go | 6 | ||||
| -rw-r--r-- | config.example.toml | 1 | ||||
| -rw-r--r-- | config/config.go | 1 | ||||
| -rw-r--r-- | main.go | 2 | ||||
| -rw-r--r-- | props_table.go | 3 |
5 files changed, 11 insertions, 2 deletions
@@ -88,6 +88,10 @@ func cleanNullMessages(messages []models.RoleMsg) []models.RoleMsg { } func cleanToolCalls(messages []models.RoleMsg) []models.RoleMsg { + // If AutoCleanToolCallsFromCtx is false, keep tool call messages in context + if cfg != nil && !cfg.AutoCleanToolCallsFromCtx { + return consolidateConsecutiveAssistantMessages(messages) + } cleaned := make([]models.RoleMsg, 0, len(messages)) for i, msg := range messages { // recognize the message as the tool call and remove it @@ -731,7 +735,7 @@ func cleanChatBody() { for i, msg := range chatBody.Messages { logger.Debug("cleanChatBody: before clean", "index", i, "role", msg.Role, "content_len", len(msg.Content), "has_content", msg.HasContent(), "tool_call_id", msg.ToolCallID) } - // TODO: consider case where we keep tool requests + // Tool request cleaning is now configurable via AutoCleanToolCallsFromCtx (default false) // /completion msg where part meant for user and other part tool call chatBody.Messages = cleanToolCalls(chatBody.Messages) chatBody.Messages = cleanNullMessages(chatBody.Messages) diff --git a/config.example.toml b/config.example.toml index 113b7ea..594e4da 100644 --- a/config.example.toml +++ b/config.example.toml @@ -18,6 +18,7 @@ ToolRole = "tool" AssistantRole = "assistant" SysDir = "sysprompts" ChunkLimit = 100000 +# AutoCleanToolCallsFromCtx = false # rag settings RAGBatchSize = 1 RAGWordLimit = 80 diff --git a/config/config.go b/config/config.go index 5b7cc35..112986b 100644 --- a/config/config.go +++ b/config/config.go @@ -31,6 +31,7 @@ type Config struct { WriteNextMsgAs string WriteNextMsgAsCompletionAgent string SkipLLMResp bool + AutoCleanToolCallsFromCtx bool `toml:"AutoCleanToolCallsFromCtx"` // embeddings RAGEnabled bool `toml:"RAGEnabled"` EmbedURL string `toml:"EmbedURL"` @@ -18,7 +18,7 @@ var ( currentLocalModelIndex = 0 // Index to track current llama.cpp model shellMode = false // indexLine = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | card's char: [orange:-:b]%s[-:-:-] (ctrl+s) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10)\nAPI_URL: [orange:-:b]%s[-:-:-] (ctrl+v) | ThinkUse: [orange:-:b]%v[-:-:-] (ctrl+p) | Log Level: [orange:-:b]%v[-:-:-] (ctrl+p) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q)" - indexLineCompletion = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | card's char: [orange:-:b]%s[-:-:-] (ctrl+s) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10)\nAPI_URL: [orange:-:b]%s[-:-:-] (ctrl+v) | Insert <think>: [orange:-:b]%v[-:-:-] (ctrl+p) | Log Level: [orange:-:b]%v[-:-:-] (ctrl+p) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | Bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role_inject [orange:-:b]%v[-:-:-]" + indexLineCompletion = "F12 to show keys help | bot resp mode: [orange:-:b]%v[-:-:-] (F6) | card's char: [orange:-:b]%s[-:-:-] (ctrl+s) | chat: [orange:-:b]%s[-:-:-] (F1) | toolUseAdviced: [orange:-:b]%v[-:-:-] (ctrl+k) | model: [orange:-:b]%s[-:-:-] (ctrl+l) | skip LLM resp: [orange:-:b]%v[-:-:-] (F10) | Insert <think>: [orange:-:b]%v[-:-:-] (ctrl+p) | Log Level: [orange:-:b]%v[-:-:-] (ctrl+p) | Recording: [orange:-:b]%v[-:-:-] (ctrl+r) | Writing as: [orange:-:b]%s[-:-:-] (ctrl+q) | Bot will write as [orange:-:b]%s[-:-:-] (ctrl+x) | role_inject [orange:-:b]%v[-:-:-]" focusSwitcher = map[tview.Primitive]tview.Primitive{} ) diff --git a/props_table.go b/props_table.go index 0c49056..d86e0b4 100644 --- a/props_table.go +++ b/props_table.go @@ -129,6 +129,9 @@ func makePropsTable(props map[string]float32) *tview.Table { addCheckboxRow("TTS Enabled", cfg.TTS_ENABLED, func(checked bool) { cfg.TTS_ENABLED = checked }) + addCheckboxRow("Auto clean tool calls from context", cfg.AutoCleanToolCallsFromCtx, func(checked bool) { + cfg.AutoCleanToolCallsFromCtx = checked + }) // Add dropdowns logLevels := []string{"Debug", "Info", "Warn"} addListPopupRow("Set log level", logLevels, GetLogLevel(), func(option string) { |
