feat(web): agent support deep thinking
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-03-13 17:27:52
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-03-26 15:35:13
|
||||
* @Last Modified time: 2026-03-31 16:04:15
|
||||
*/
|
||||
import { type FC, useState, useRef, useEffect } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@@ -171,6 +171,7 @@ const TestChat: FC<TestChatProps> = ({
|
||||
...lastMsg,
|
||||
content: lastMsg.content + content,
|
||||
meta_data: {
|
||||
...(lastMsg.meta_data || {}),
|
||||
audio_url: audio_url || lastMsg.meta_data?.audio_url,
|
||||
audio_status: audio_status || lastMsg.meta_data?.audio_status,
|
||||
citations: citations || lastMsg.meta_data?.citations
|
||||
@@ -180,6 +181,24 @@ const TestChat: FC<TestChatProps> = ({
|
||||
return newList
|
||||
})
|
||||
}
|
||||
const updateAssistantReasoningMessage = (content: string) => {
|
||||
if (!content) return
|
||||
if (streamLoading) setStreamLoading(false)
|
||||
setChatList(prev => {
|
||||
const newList = [...prev]
|
||||
const lastMsg = newList[newList.length - 1]
|
||||
if (lastMsg?.role === 'assistant') {
|
||||
newList[newList.length - 1] = {
|
||||
...lastMsg,
|
||||
meta_data: {
|
||||
...(lastMsg.meta_data || {}),
|
||||
reasoning_content: (lastMsg.meta_data?.reasoning_content || '') + content
|
||||
}
|
||||
}
|
||||
}
|
||||
return newList
|
||||
})
|
||||
}
|
||||
|
||||
const updateErrorAssistantMessage = (message_length: number) => {
|
||||
if (message_length > 0) return
|
||||
@@ -273,6 +292,10 @@ const TestChat: FC<TestChatProps> = ({
|
||||
case 'start':
|
||||
if (conversation_id && conversationId !== conversation_id) setConversationId(conversation_id)
|
||||
break
|
||||
case 'reasoning':
|
||||
updateAssistantReasoningMessage(content)
|
||||
if (conversation_id && conversationId !== conversation_id) setConversationId(conversation_id)
|
||||
break
|
||||
case 'message':
|
||||
updateAssistantMessage(content)
|
||||
if (conversation_id && conversationId !== conversation_id) setConversationId(conversation_id)
|
||||
|
||||
Reference in New Issue
Block a user