Skip to content

Commit e63fd8c

Browse files
committed
Fix thinking tags
1 parent 080ab94 commit e63fd8c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/sim/stores/panel/copilot/store.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,14 +1001,23 @@ function beginThinkingBlock(context: StreamingContext) {
10011001
context.currentTextBlock = null
10021002
}
10031003

1004+
/**
1005+
* Removes thinking tags from streamed content.
1006+
*/
1007+
function stripThinkingTags(text: string): string {
1008+
return text.replace(/<\/?thinking>/g, '')
1009+
}
1010+
10041011
function appendThinkingContent(context: StreamingContext, text: string) {
10051012
if (!text) return
1013+
const cleanedText = stripThinkingTags(text)
1014+
if (!cleanedText) return
10061015
if (context.currentThinkingBlock) {
1007-
context.currentThinkingBlock.content += text
1016+
context.currentThinkingBlock.content += cleanedText
10081017
} else {
10091018
context.currentThinkingBlock = contentBlockPool.get()
10101019
context.currentThinkingBlock.type = THINKING_BLOCK_TYPE
1011-
context.currentThinkingBlock.content = text
1020+
context.currentThinkingBlock.content = cleanedText
10121021
context.currentThinkingBlock.timestamp = Date.now()
10131022
context.currentThinkingBlock.startTime = Date.now()
10141023
context.contentBlocks.push(context.currentThinkingBlock)

0 commit comments

Comments
 (0)