summaryrefslogtreecommitdiff
path: root/bot.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-02-21 20:28:12 +0300
committerGrail Finder <wohilas@gmail.com>2026-02-21 20:28:12 +0300
commit66ccb7a7322780a61b675e827794a8330aef3f89 (patch)
tree4a8720b836e242df34d21a093dea77a1bab24368 /bot.go
parentdeece322efbb69a78656205244a499bc76846bdc (diff)
Fix: collapsing thinking while thinking
Diffstat (limited to 'bot.go')
-rw-r--r--bot.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/bot.go b/bot.go
index b469fb3..227751d 100644
--- a/bot.go
+++ b/bot.go
@@ -1197,6 +1197,16 @@ func chatToText(messages []models.RoleMsg, showSys bool) string {
}
return "[yellow::i][thinking... (press Alt+T to expand)][-:-:-]"
})
+ // Handle incomplete thinking blocks (during streaming when </think> hasn't arrived yet)
+ if strings.Contains(text, "<think>") && !strings.Contains(text, "</think>") {
+ // Find the incomplete thinking block and replace it
+ startIdx := strings.Index(text, "<think>")
+ if startIdx != -1 {
+ content := text[startIdx+len("<think>"):]
+ placeholder := fmt.Sprintf("[yellow::i][thinking... (%d chars) (press Alt+T to expand)][-:-:-]", len(content))
+ text = text[:startIdx] + placeholder
+ }
+ }
}
return text