server (webui): Fix issue with muliple <think>
tags
This commit is contained in:
parent
19d3c8293b
commit
3ab621175a
2 changed files with 8 additions and 8 deletions
Binary file not shown.
|
@ -47,18 +47,18 @@ export default function ChatMessage({
|
|||
let actualContent = '';
|
||||
let thought = '';
|
||||
let isThinking = false;
|
||||
let thinkSplit = msg.content.split('<think>', 2);
|
||||
actualContent += thinkSplit[0];
|
||||
while (thinkSplit[1] !== undefined) {
|
||||
let [match, ...rest] = msg.content.split('<think>');
|
||||
actualContent += match;
|
||||
while (rest.length !== 0) {
|
||||
// <think> tag found
|
||||
thinkSplit = thinkSplit[1].split('</think>', 2);
|
||||
thought += thinkSplit[0];
|
||||
[match, ...rest] = rest.join('<think>').split('</think>');
|
||||
thought += thought !== '' ? '\n***\n' + match : match;
|
||||
isThinking = true;
|
||||
if (thinkSplit[1] !== undefined) {
|
||||
if (rest.length !== 0) {
|
||||
// </think> closing tag found
|
||||
isThinking = false;
|
||||
thinkSplit = thinkSplit[1].split('<think>', 2);
|
||||
actualContent += thinkSplit[0];
|
||||
[match, ...rest] = rest.join('</think>').split('<think>');
|
||||
actualContent += match;
|
||||
}
|
||||
}
|
||||
return { content: actualContent, thought, isThinking };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue