File tree 2 files changed +8
-8
lines changed 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,18 @@ export default function ChatMessage({
47
47
let actualContent = '' ;
48
48
let thought = '' ;
49
49
let isThinking = false ;
50
- let thinkSplit = msg . content . split ( '<think>' , 2 ) ;
51
- actualContent += thinkSplit [ 0 ] ;
52
- while ( thinkSplit [ 1 ] !== undefined ) {
50
+ let [ match , ... rest ] = msg . content . split ( '<think>' ) ;
51
+ actualContent += match ;
52
+ while ( rest . length != 0 ) {
53
53
// <think> tag found
54
- thinkSplit = thinkSplit [ 1 ] . split ( '</think>' , 2 ) ;
55
- thought += thinkSplit [ 0 ] ;
54
+ [ match , ... rest ] = rest . join ( '<think>' ) . split ( '</think>' ) ;
55
+ thought += thought !== '' ? '\n***\n' + match : match ;
56
56
isThinking = true ;
57
- if ( thinkSplit [ 1 ] !== undefined ) {
57
+ if ( rest . length != 0 ) {
58
58
// </think> closing tag found
59
59
isThinking = false ;
60
- thinkSplit = thinkSplit [ 1 ] . split ( '<think>' , 2 ) ;
61
- actualContent += thinkSplit [ 0 ] ;
60
+ [ match , ... rest ] = rest . join ( '</think>' ) . split ( '<think>' ) ;
61
+ actualContent += match ;
62
62
}
63
63
}
64
64
return { content : actualContent , thought, isThinking } ;
You can’t perform that action at this time.
0 commit comments