fix: input form value type error (#3399)

This commit is contained in:
Archer
2024-12-15 19:58:50 +08:00
committed by GitHub
parent 3deac290bf
commit c995bccef8
3 changed files with 10 additions and 6 deletions

View File

@@ -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,

View File

@@ -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, Function> = {
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
@@ -635,7 +634,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
const entryNodes = runtimeNodes.filter((item) => 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 &&

View File

@@ -41,7 +41,8 @@ const MyNumberInput = (props: Props) => {
? register(name, {
required: props.isRequired,
min: props.min,
max: props.max
max: props.max,
valueAsNumber: true
})
: {})}
/>