diff options
| author | Grail Finder <wohilas@gmail.com> | 2026-02-25 16:57:55 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2026-02-25 16:57:55 +0300 |
| commit | 9f51bd385336e7b314316c372bc31de2a3c374f4 (patch) | |
| tree | baefc4ba8e5bec89d5df89c05be8d9df9d820025 /helpfuncs.go | |
| parent | b386c1181f0424418999fe143f1285d395b0db0f (diff) | |
Fix: text manipulation for multimodal messages
Diffstat (limited to 'helpfuncs.go')
| -rw-r--r-- | helpfuncs.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/helpfuncs.go b/helpfuncs.go index 8719aab..99024a0 100644 --- a/helpfuncs.go +++ b/helpfuncs.go @@ -75,15 +75,16 @@ func stripThinkingFromMsg(msg *models.RoleMsg) *models.RoleMsg { if !cfg.StripThinkingFromAPI { return msg } - // Skip user, tool, and system messages - they might contain thinking examples + // Skip user, tool, they might contain thinking and system messages - 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) + msgText := msg.GetText() + if thinkRE.MatchString(msgText) { + cleanedText := thinkRE.ReplaceAllString(msgText, "") + cleanedText = strings.TrimSpace(cleanedText) + msg.SetText(cleanedText) } return msg } |
