MCPcopy Create free account
hub / github.com/xerrors/Yuxi / parseAssistantMessageBody

Method parseAssistantMessageBody

web/src/utils/messageProcessor.js:291–306  ·  view source on GitHub ↗

* 解析助手消息正文与推理内容,保持渲染和列表拆分使用同一套规则。 * @param {Object} message - AI 消息对象 * @returns {{content: string, reasoningContent: string}}

(message)

Source from the content-addressed store, hash-verified

289 * @returns {{content: string, reasoningContent: string}}
290 */
291 static parseAssistantMessageBody(message) {
292 let content = typeof message?.content === 'string' ? message.content.trim() : ''
293 let reasoningContent = message?.additional_kwargs?.reasoning_content || ''
294
295 if (!reasoningContent && content) {
296 const thinkRegex = /<think>(.*?)<\/think>|<think>(.*?)$/s
297 const thinkMatch = content.match(thinkRegex)
298
299 if (thinkMatch) {
300 reasoningContent = (thinkMatch[1] || thinkMatch[2] || '').trim()
301 content = content.replace(thinkMatch[0], '').trim()
302 }
303 }
304
305 return { content, reasoningContent }
306 }
307
308 /**
309 * 合并消息块

Callers 2

hasVisibleAssistantBodyFunction · 0.80
runFunction · 0.80

Calls

no outgoing calls

Tested by 1

runFunction · 0.64