Fix: thinking block

This commit is contained in:
Grail Finder
2025-03-10 07:02:12 +03:00
parent b653b52751
commit 10f0efbb2a

5
tui.go
View File

@@ -116,10 +116,10 @@ func colorText() {
text = thinkRE.ReplaceAllStringFunc(text, func(match string) string { text = thinkRE.ReplaceAllStringFunc(text, func(match string) string {
// Style the code block and store it // Style the code block and store it
styled := fmt.Sprintf("[red::i]%s[-:-:-]", match) styled := fmt.Sprintf("[red::i]%s[-:-:-]", match)
thinkBlocks = append(codeBlocks, styled) thinkBlocks = append(thinkBlocks, styled)
// Generate a unique placeholder (e.g., "__CODE_BLOCK_0__") // Generate a unique placeholder (e.g., "__CODE_BLOCK_0__")
id := fmt.Sprintf(placeholderThink, counterThink) id := fmt.Sprintf(placeholderThink, counterThink)
counter++ counterThink++
return id return id
}) })
// Step 2: Apply other regex styles to the non-code parts // Step 2: Apply other regex styles to the non-code parts
@@ -130,6 +130,7 @@ func colorText() {
for i, cb := range codeBlocks { for i, cb := range codeBlocks {
text = strings.Replace(text, fmt.Sprintf(placeholder, i), cb, 1) text = strings.Replace(text, fmt.Sprintf(placeholder, i), cb, 1)
} }
logger.Debug("thinking debug", "blocks", thinkBlocks)
for i, tb := range thinkBlocks { for i, tb := range thinkBlocks {
text = strings.Replace(text, fmt.Sprintf(placeholderThink, i), tb, 1) text = strings.Replace(text, fmt.Sprintf(placeholderThink, i), tb, 1)
} }