diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts index 72dd701d..31354817 100644 --- a/web/src/i18n/en.ts +++ b/web/src/i18n/en.ts @@ -1534,6 +1534,8 @@ export const en = { uploadCover: 'Import and Overwrite', refresh: 'Refresh Current Page', json_output: 'Support JSON formatted output', + thinking_budget_tokens: 'thinking budget tokens', + thinking_budget_tokens_max_error: "Cannot exceed the max tokens limit ({{max}})", }, userMemory: { userMemory: 'User Memory', diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts index 88b919ba..d802b731 100644 --- a/web/src/i18n/zh.ts +++ b/web/src/i18n/zh.ts @@ -864,6 +864,8 @@ export const zh = { uploadCover: '导入并覆盖', refresh: '刷新当前页', json_output: '支持JSON格式化输出', + thinking_budget_tokens: '深度思考预算Token数', + thinking_budget_tokens_max_error: "不能超过 最大令牌数 ({{max}})", }, table: { totalRecords: '共 {{total}} 条记录' diff --git a/web/src/views/ApplicationConfig/components/Chat.tsx b/web/src/views/ApplicationConfig/components/Chat.tsx index 04391532..b4fefdc9 100644 --- a/web/src/views/ApplicationConfig/components/Chat.tsx +++ b/web/src/views/ApplicationConfig/components/Chat.tsx @@ -218,17 +218,22 @@ const Chat: FC = ({ const modelChatList = [...prev] const curModelChat = modelChatList[targetIndex] const curChatMsgList = curModelChat.list || [] - const lastMsg = curChatMsgList[curChatMsgList.length - 2] - modelChatList[targetIndex] = { - ...modelChatList[targetIndex], - list: [ - ...curChatMsgList.slice(0, curChatMsgList.length - 2), - { - ...lastMsg, - ...(lastMsg.role === 'user' ? { status: 'error' } : { content: null }) - } - ] + const lastUserMsg = curChatMsgList[curChatMsgList.length - 2] + const lastAssistantMsg = curChatMsgList[curChatMsgList.length - 1] + + if (!lastAssistantMsg.meta_data?.reasoning_content || lastAssistantMsg.meta_data?.reasoning_content.length === 0) { + modelChatList[targetIndex] = { + ...modelChatList[targetIndex], + list: [ + ...curChatMsgList.slice(0, curChatMsgList.length - 2), + { + ...lastUserMsg, + ...(lastUserMsg.role === 'user' ? { status: 'error' } : { content: null }) + } + ] + } } + return [...modelChatList] } diff --git a/web/src/views/ApplicationConfig/components/ModelConfigModal.tsx b/web/src/views/ApplicationConfig/components/ModelConfigModal.tsx index 2d330e9f..9c5935c5 100644 --- a/web/src/views/ApplicationConfig/components/ModelConfigModal.tsx +++ b/web/src/views/ApplicationConfig/components/ModelConfigModal.tsx @@ -108,7 +108,8 @@ const ModelConfigModal = forwardRef( const newValues: ModelConfig = { capability: (option as Model).capability, deep_thinking: false, - json_output: false + thinking_budget_tokens: undefined, + json_output: false, } if (source === 'chat') { newValues.label = (option as Model).name @@ -124,8 +125,8 @@ const ModelConfigModal = forwardRef( useEffect(() => { const { deep_thinking: _, json_output: __, ...rest } = data?.model_parameters || {} - form.setFieldsValue(rest) - }, [values?.default_model_config_id]) + form.setFieldsValue({ ...rest }) + }, [data?.default_model_config_id]) const handleReset = () => { if (!id) return @@ -167,11 +168,36 @@ const ModelConfigModal = forwardRef( {['model', 'chat'].includes(source) && <>