diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-17 13:42:49 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-17 13:42:49 +0300 |
| commit | b67ae1be98f3131fa8cec9ae01d8f86fd4df8e06 (patch) | |
| tree | 2a00b4bf75cb59e6643e14e50c7f51c278411129 /helpfuncs.go | |
| parent | 372e49199b58281bf1c7f75dfa2835189bc61383 (diff) | |
Enha: filter out thinking blocks from chat history, removed {role}:
Diffstat (limited to 'helpfuncs.go')
| -rw-r--r-- | helpfuncs.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/helpfuncs.go b/helpfuncs.go index b6b5faa..cc6bfe3 100644 --- a/helpfuncs.go +++ b/helpfuncs.go @@ -23,6 +23,25 @@ func isASCII(s string) bool { return true } +// stripThinkingFromMsg removes thinking blocks from assistant messages. +// Skips user, tool, and system messages as they may contain thinking examples. +func stripThinkingFromMsg(msg models.RoleMsg) *models.RoleMsg { + if !cfg.StripThinkingFromAPI { + return &msg + } + // Skip user, tool, and system messages - they might contain thinking examples + if msg.Role == cfg.UserRole || msg.Role == cfg.ToolRole || msg.Role == "system" { + return &msg + } + // Strip thinking from assistant messages + if thinkRE.MatchString(msg.Content) { + msg.Content = thinkRE.ReplaceAllString(msg.Content, "") + // Clean up any double newlines that might result + msg.Content = strings.TrimSpace(msg.Content) + } + return &msg +} + // refreshChatDisplay updates the chat display based on current character view // It filters messages for the character the user is currently "writing as" // and updates the textView with the filtered conversation |
