@@ -596,41 +596,6 @@ export default function ChatPage() {
596596 return "Good Evening"
597597 }
598598
599- const getFinalAnswer = ( content ) => {
600- if ( ! content || typeof content !== "string" ) return ""
601-
602- const answerParts = [ ]
603- const regex =
604- / ( < t h i n k (?: i n g ) ? > [ \s \S ] * ?< \/ t h i n k (?: i n g ) ? > | < t o o l _ c o d e [ ^ > ] * > [ \s \S ] * ?< \/ t o o l _ c o d e > | < t o o l _ r e s u l t [ ^ > ] * > [ \s \S ] * ?< \/ t o o l _ r e s u l t > | < a n s w e r > [ \s \S ] * ?< \/ a n s w e r > ) / g
605- let lastIndex = 0
606- let inToolCallPhase = false
607-
608- for ( const match of content . matchAll ( regex ) ) {
609- const precedingText = content . substring ( lastIndex , match . index )
610- if ( precedingText . trim ( ) && ! inToolCallPhase ) {
611- answerParts . push ( precedingText . trim ( ) )
612- }
613-
614- const tag = match [ 0 ]
615- if ( tag . startsWith ( "<tool_code" ) ) inToolCallPhase = true
616- else if ( tag . startsWith ( "<tool_result" ) ) inToolCallPhase = false
617- else if ( tag . startsWith ( "<answer>" ) ) {
618- const answerContent =
619- tag . match ( / < a n s w e r > ( [ \s \S ] * ?) < \/ a n s w e r > / ) ?. [ 1 ] || ""
620- if ( answerContent ) answerParts . push ( answerContent . trim ( ) )
621- }
622- lastIndex = match . index + tag . length
623- }
624- const remainingText = content . substring ( lastIndex )
625- if ( remainingText . trim ( ) && ! inToolCallPhase ) {
626- answerParts . push ( remainingText . trim ( ) )
627- }
628-
629- const plainText = answerParts . join ( "\n\n" )
630- if ( plainText ) return plainText
631- return content . replace ( / < [ ^ > ] + > / g, "" ) . trim ( )
632- }
633-
634599 // --- Voice Mode Handlers ---
635600 const handleStatusChange = useCallback ( ( status ) => {
636601 setConnectionStatus ( status )
@@ -918,7 +883,7 @@ export default function ChatPage() {
918883 : "the assistant" }
919884 </ p >
920885 < p className = "text-sm text-neutral-200 mt-1 truncate" >
921- { getFinalAnswer ( replyingTo . content ) }
886+ { replyingTo . content . replace ( / < [ ^ > ] + > / g , "" ) . trim ( ) }
922887 </ p >
923888 </ div >
924889 < button
@@ -1480,9 +1445,7 @@ export default function ChatPage() {
14801445 duration : 0.3
14811446 } }
14821447 >
1483- { getFinalAnswer (
1484- msg . content
1485- ) }
1448+ { msg . content }
14861449 </ motion . div >
14871450 ) ) }
14881451 </ AnimatePresence >
@@ -1533,6 +1496,9 @@ export default function ChatPage() {
15331496 role = { msg . role }
15341497 content = { msg . content }
15351498 tools = { msg . tools || [ ] }
1499+ thoughts = { msg . thoughts || [ ] }
1500+ tool_calls = { msg . tool_calls || [ ] }
1501+ tool_results = { msg . tool_results || [ ] }
15361502 onReply = { handleReply }
15371503 message = { msg }
15381504 allMessages = { displayedMessages }
0 commit comments