diff --git a/examples/server/public/index.html.gz b/examples/server/public/index.html.gz index f0419e181..477bc412a 100644 Binary files a/examples/server/public/index.html.gz and b/examples/server/public/index.html.gz differ diff --git a/examples/server/webui/src/main.js b/examples/server/webui/src/main.js index af1117008..4afb1e719 100644 --- a/examples/server/webui/src/main.js +++ b/examples/server/webui/src/main.js @@ -190,18 +190,25 @@ const MessageBubble = defineComponent({ }; }, splitMsgContent() { - // TODO: make it more efficient const content = this.msg.content; if (this.msg.role !== 'assistant'){ return {content}; } - const regex = /(.*?)?(?=(<\/think>)|$)/gis; - const matches = []; - let match; - while ((match = regex.exec(content)) !== null) { - matches.push(match[1]); + let actualContent = ''; + let cot = ''; + let thinkSplit = content.split("",2); + actualContent += thinkSplit[0]; + while (thinkSplit[1]!==undefined){ + // tag found + thinkSplit = thinkSplit[1].split("",2); + cot+=thinkSplit[0]; + if(thinkSplit[1]!==undefined){ + // closing tag found + thinkSplit = thinkSplit[1].split("",2); + actualContent+=thinkSplit[0]; + } } - return {content : content.replace(/.*?(<\/think>|$)/gis, ''), cot : matches.join('
') }; + return {content : actualContent, cot }; }, }, methods: {