feat: Improve handling of think tags
This commit is contained in:
parent
9f19493b41
commit
85efc6e96b
@ -87,13 +87,13 @@ export function withMessageThought(message: Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = message.content.trim()
|
const content = message.content.trim()
|
||||||
const thinkPattern = /<think>(.*?)<\/think>/s
|
const thinkPattern = /^<think>(.*?)<\/think>/s
|
||||||
const matches = content.match(thinkPattern)
|
const matches = content.match(thinkPattern)
|
||||||
|
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
// 处理未闭合的 think 标签情况
|
// 处理未闭合的 think 标签情况
|
||||||
if (content.startsWith('<think>')) {
|
if (content.startsWith('<think>')) {
|
||||||
message.reasoning_content = content.replace('<think>', '')
|
message.reasoning_content = content.slice(7) // '<think>'.length === 7
|
||||||
message.content = ''
|
message.content = ''
|
||||||
}
|
}
|
||||||
return message
|
return message
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user