diff --git a/packages/global/core/app/type.d.ts b/packages/global/core/app/type.d.ts index ec30e4b51..1008344d2 100644 --- a/packages/global/core/app/type.d.ts +++ b/packages/global/core/app/type.d.ts @@ -80,6 +80,7 @@ export type AppSimpleEditFormType = { maxToken?: number; isResponseAnswerText: boolean; maxHistories: number; + [NodeInputKeyEnum.aiChatReasoning]?: boolean; }; dataset: { datasets: SelectedDatasetType; diff --git a/packages/global/core/app/utils.ts b/packages/global/core/app/utils.ts index 1c793cfea..708964b38 100644 --- a/packages/global/core/app/utils.ts +++ b/packages/global/core/app/utils.ts @@ -16,7 +16,8 @@ export const getDefaultAppForm = (): AppSimpleEditFormType => { temperature: 0, isResponseAnswerText: true, maxHistories: 6, - maxToken: 4000 + maxToken: 4000, + aiChatReasoning: true }, dataset: { datasets: [], diff --git a/packages/service/core/workflow/dispatch/chat/oneapi.ts b/packages/service/core/workflow/dispatch/chat/oneapi.ts index 0d3482b68..4b8cc865c 100644 --- a/packages/service/core/workflow/dispatch/chat/oneapi.ts +++ b/packages/service/core/workflow/dispatch/chat/oneapi.ts @@ -88,7 +88,7 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise item.key === NodeInputKeyEnum.aiChatIsResponseText)?.value ?? true; - if (isResponseAnswerText) { + } else { + if (reasoningText) { chatAssistantResponse.push({ - type: ChatItemValueTypeEnum.text, - text: { - content: answerText + type: ChatItemValueTypeEnum.reasoning, + reasoning: { + content: reasoningText } }); } - } else if (reasoningText) { - chatAssistantResponse.push({ - type: ChatItemValueTypeEnum.reasoning, - reasoning: { - content: reasoningText + if (answerText) { + // save assistant text response + const isResponseAnswerText = + inputs.find((item) => item.key === NodeInputKeyEnum.aiChatIsResponseText)?.value ?? true; + if (isResponseAnswerText) { + chatAssistantResponse.push({ + type: ChatItemValueTypeEnum.text, + text: { + content: answerText + } + }); } - }); + } } if (rewriteHistories) { diff --git a/packages/service/core/workflow/dispatch/tools/http468.ts b/packages/service/core/workflow/dispatch/tools/http468.ts index af8b6982f..5ea110b88 100644 --- a/packages/service/core/workflow/dispatch/tools/http468.ts +++ b/packages/service/core/workflow/dispatch/tools/http468.ts @@ -244,7 +244,6 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise + { ); if (value.type === ChatItemValueTypeEnum.reasoning && value.reasoning) - return ; + return ( + + ); if (value.type === ChatItemValueTypeEnum.tool && value.tools) return ; if (value.type === ChatItemValueTypeEnum.interactive && value.interactive) { diff --git a/projects/app/src/pageComponents/app/detail/SimpleApp/EditForm.tsx b/projects/app/src/pageComponents/app/detail/SimpleApp/EditForm.tsx index 44d407692..899e4bce1 100644 --- a/projects/app/src/pageComponents/app/detail/SimpleApp/EditForm.tsx +++ b/projects/app/src/pageComponents/app/detail/SimpleApp/EditForm.tsx @@ -138,9 +138,16 @@ const EditForm = ({ model: appForm.aiSettings.model, temperature: appForm.aiSettings.temperature, maxToken: appForm.aiSettings.maxToken, - maxHistories: appForm.aiSettings.maxHistories + maxHistories: appForm.aiSettings.maxHistories, + aiChatReasoning: appForm.aiSettings.aiChatReasoning ?? true }} - onChange={({ model, temperature, maxToken, maxHistories }: SettingAIDataType) => { + onChange={({ + model, + temperature, + maxToken, + maxHistories, + aiChatReasoning = false + }) => { setAppForm((state) => ({ ...state, aiSettings: { @@ -148,7 +155,8 @@ const EditForm = ({ model, temperature, maxToken, - maxHistories: maxHistories ?? 6 + maxHistories: maxHistories ?? 6, + aiChatReasoning } })); }} diff --git a/projects/app/src/web/core/app/utils.ts b/projects/app/src/web/core/app/utils.ts index 5a8546a58..4262a4c2a 100644 --- a/projects/app/src/web/core/app/utils.ts +++ b/projects/app/src/web/core/app/utils.ts @@ -190,6 +190,13 @@ export function form2AppWorkflow( label: '', valueType: WorkflowIOValueTypeEnum.boolean, value: true + }, + { + key: NodeInputKeyEnum.aiChatReasoning, + renderTypeList: [FlowNodeInputTypeEnum.hidden], + label: '', + valueType: WorkflowIOValueTypeEnum.boolean, + value: formData.aiSettings.aiChatReasoning } ], outputs: AiChatModule.outputs