From c995bccef8f774cfe947523d041f50921371282a Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Sun, 15 Dec 2024 19:58:50 +0800 Subject: [PATCH] fix: input form value type error (#3399) --- packages/global/core/workflow/runtime/utils.ts | 10 +++++++--- packages/service/core/workflow/dispatch/index.ts | 3 +-- .../web/components/common/Input/NumberInput/index.tsx | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/global/core/workflow/runtime/utils.ts b/packages/global/core/workflow/runtime/utils.ts index a903607df..de815fe89 100644 --- a/packages/global/core/workflow/runtime/utils.ts +++ b/packages/global/core/workflow/runtime/utils.ts @@ -284,9 +284,13 @@ export const formatVariableValByType = (val: any, valueType?: WorkflowIOValueTyp if (!valueType) return val; // Value type check, If valueType invalid, return undefined if (valueType.startsWith('array') && !Array.isArray(val)) return undefined; - if (valueType === WorkflowIOValueTypeEnum.boolean && typeof val !== 'boolean') return undefined; - if (valueType === WorkflowIOValueTypeEnum.number && typeof val !== 'number') return undefined; - if (valueType === WorkflowIOValueTypeEnum.string && typeof val !== 'string') return undefined; + if (valueType === WorkflowIOValueTypeEnum.boolean) return Boolean(val); + if (valueType === WorkflowIOValueTypeEnum.number) return Number(val); + if (valueType === WorkflowIOValueTypeEnum.string) { + if (val === undefined) return 'undefined'; + if (val === null) return 'null'; + return typeof val === 'object' ? JSON.stringify(val) : String(val); + } if ( [ WorkflowIOValueTypeEnum.object, diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index bdff74cc3..53753b41b 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -73,7 +73,6 @@ import { dispatchLoopEnd } from './loop/runLoopEnd'; import { dispatchLoopStart } from './loop/runLoopStart'; import { dispatchFormInput } from './interactive/formInput'; import { dispatchToolParams } from './agent/runTool/toolParams'; -import { AppChatConfigType } from '@fastgpt/global/core/app/type'; const callbackMap: Record = { [FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart, @@ -635,7 +634,7 @@ export async function dispatchWorkFlow(data: Props): Promise item.isEntry); // reset entry runtimeNodes.forEach((item) => { - // Interactive node is not the entry node, return interactive result + // Interactively nodes will use the "isEntry", which does not need to be updated if ( item.flowNodeType !== FlowNodeTypeEnum.userSelect && item.flowNodeType !== FlowNodeTypeEnum.formInput && diff --git a/packages/web/components/common/Input/NumberInput/index.tsx b/packages/web/components/common/Input/NumberInput/index.tsx index 7c6cab7c7..13a3a47e7 100644 --- a/packages/web/components/common/Input/NumberInput/index.tsx +++ b/packages/web/components/common/Input/NumberInput/index.tsx @@ -41,7 +41,8 @@ const MyNumberInput = (props: Props) => { ? register(name, { required: props.isRequired, min: props.min, - max: props.max + max: props.max, + valueAsNumber: true }) : {})} />