feat(web): agent support deep thinking

This commit is contained in:
zhaoying
2026-03-31 18:07:32 +08:00
parent b40f4829cb
commit ca255304d9
12 changed files with 203 additions and 33 deletions

View File

@@ -2,7 +2,7 @@
* @Author: ZhaoYing
* @Date: 2026-02-03 16:27:39
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-03-27 17:59:07
* @Last Modified time: 2026-03-31 15:02:07
*/
/**
* Chat debugging component for application testing
@@ -141,6 +141,36 @@ const Chat: FC<ChatProps> = ({
}
}
/** Update assistant message with streaming content */
const updateAssistantReasoningMessage = (content?: string, model_config_id?: string, conversation_id?: string) => {
if (!content || !model_config_id) return
updateChatList(prev => {
const targetIndex = prev.findIndex(item => item.model_config_id === model_config_id);
if (targetIndex !== -1) {
const modelChatList = [...prev]
const curModelChat = modelChatList[targetIndex]
const curChatMsgList = curModelChat.list || []
const lastMsg = curChatMsgList[curChatMsgList.length - 1]
if (lastMsg && lastMsg.role === 'assistant') {
modelChatList[targetIndex] = {
...modelChatList[targetIndex],
conversation_id,
list: [
...curChatMsgList.slice(0, curChatMsgList.length - 1),
{
...lastMsg,
meta_data: {
reasoning_content: (lastMsg.meta_data?.reasoning_content || '') + (content || ''),
}
}
]
}
}
return [...modelChatList]
}
return prev;
})
}
/** Update assistant message with streaming content */
const updateAssistantMessage = (content?: string, model_config_id?: string, conversation_id?: string, audio_url?: string, citations?: any[]) => {
if ((!content && !audio_url && (!citations || citations?.length < 1)) || !model_config_id) return
updateChatList(prev => {
@@ -160,6 +190,7 @@ const Chat: FC<ChatProps> = ({
...lastMsg,
content: lastMsg.content + (content || ''),
meta_data: {
...(lastMsg.meta_data || {}),
...(audio_url !== undefined ? { audio_url, audio_status: 'pending' } : {}),
citations: citations || lastMsg.meta_data?.citations
}
@@ -274,6 +305,9 @@ const Chat: FC<ChatProps> = ({
};
switch (item.event) {
case 'model_reasoning':
updateAssistantReasoningMessage(content, model_config_id, conversation_id)
break;
case 'model_message':
updateAssistantMessage(content, model_config_id, conversation_id, audio_url)
break;