diff --git a/src/renderer/src/utils/formats.ts b/src/renderer/src/utils/formats.ts
index d0ea81b52d..5f9ffadf7a 100644
--- a/src/renderer/src/utils/formats.ts
+++ b/src/renderer/src/utils/formats.ts
@@ -101,12 +101,11 @@ const glmZeroPreviewProcessor: ThoughtProcessor = {
}
const thinkTagProcessor: ThoughtProcessor = {
- canProcess: (content: string) => content.startsWith(''),
+ canProcess: (content: string) => content.startsWith('') || content.includes(''),
process: (content: string) => {
+ // 处理正常闭合的 think 标签
const thinkPattern = /^(.*?)<\/think>/s
const matches = content.match(thinkPattern)
-
- // 处理正常闭合的 think 标签
if (matches) {
return {
reasoning: matches[1].trim(),
@@ -114,10 +113,26 @@ const thinkTagProcessor: ThoughtProcessor = {
}
}
- // 处理未闭合的 think 标签
+ // 处理只有结束标签的情况
+ if (content.includes('') && !content.startsWith('')) {
+ const parts = content.split('')
+ return {
+ reasoning: parts[0].trim(),
+ content: parts.slice(1).join('').trim()
+ }
+ }
+
+ // 处理只有开始标签的情况
+ if (content.startsWith('')) {
+ return {
+ reasoning: content.slice(7).trim(), // 跳过 '' 标签
+ content: ''
+ }
+ }
+
return {
- reasoning: content.slice(7).trim(), // 跳过 '' 标签
- content: ''
+ reasoning: '',
+ content
}
}
}