fix: overwrite defalut value in tool

This commit is contained in:
Joel 2024-03-19 15:27:20 +08:00
parent 1532564601
commit 8d82d9f7ef
2 changed files with 13 additions and 9 deletions

View File

@ -65,7 +65,7 @@ const InputVarList: FC<Props> = ({
})
onChange(newValue)
}
}, [value, onChange])
}, [value, onChange, isSupportConstantValue])
return (
<div className='space-y-3'>

View File

@ -84,14 +84,18 @@ const useConfig = (id: string, payload: ToolNodeType) => {
if (!currTool)
return
const inputsWithDefaultValue = produce(inputs, (draft) => {
draft.tool_configurations = addDefaultValue(tool_configurations, toolSettingSchema)
draft.tool_parameters = toolInputVarSchema.map((item: any) => {
return {
variable: item.variable,
variable_type: VarType.static,
value: '',
}
})
if (!draft.tool_configurations || Object.keys(draft.tool_configurations).length === 0)
draft.tool_configurations = addDefaultValue(tool_configurations, toolSettingSchema)
if (!draft.tool_parameters || draft.tool_parameters.length === 0) {
draft.tool_parameters = toolInputVarSchema.map((item: any) => {
return {
variable: item.variable,
variable_type: VarType.static,
value: '',
}
})
}
})
setInputs(inputsWithDefaultValue)
// eslint-disable-next-line react-hooks/exhaustive-deps