diff --git a/web/app/components/workflow/nodes/tool/node.tsx b/web/app/components/workflow/nodes/tool/node.tsx index 0603e5a31a..c9de133972 100644 --- a/web/app/components/workflow/nodes/tool/node.tsx +++ b/web/app/components/workflow/nodes/tool/node.tsx @@ -1,32 +1,23 @@ import type { FC } from 'react' import React from 'react' import type { ToolNodeType } from './types' -import { VarType } from './types' -import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import type { NodeProps } from '@/app/components/workflow/types' const Node: FC> = ({ data, }) => { - const { tool_parameters: tool_inputs } = data + const { tool_configurations } = data return (
- {tool_inputs.map((input, index) => ( + {Object.keys(tool_configurations || {}).map((key, index) => (
- {input.variable} + {key}
- {input.variable_type === VarType.selector - ? ( -
- -
{input.value_selector?.slice(0, -1)[0]}
-
- ) - : input.value} + {tool_configurations[key]}
diff --git a/web/app/components/workflow/nodes/tool/panel.tsx b/web/app/components/workflow/nodes/tool/panel.tsx index 9ba8b861c2..5a5573c264 100644 --- a/web/app/components/workflow/nodes/tool/panel.tsx +++ b/web/app/components/workflow/nodes/tool/panel.tsx @@ -47,8 +47,6 @@ const Panel: FC> = ({ runResult, } = useConfig(id, data) - console.log(inputs) - if (isLoading) { return
diff --git a/web/app/components/workflow/nodes/tool/use-config.ts b/web/app/components/workflow/nodes/tool/use-config.ts index 5c1c44e7eb..e28528266d 100644 --- a/web/app/components/workflow/nodes/tool/use-config.ts +++ b/web/app/components/workflow/nodes/tool/use-config.ts @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next' import produce from 'immer' import { useBoolean } from 'ahooks' import { useStore } from '../../store' -import { type ToolNodeType, type ToolVarInput } from './types' +import { type ToolNodeType, type ToolVarInput, VarType } from './types' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import { CollectionType } from '@/app/components/tools/types' @@ -67,6 +67,7 @@ const useConfig = (id: string, payload: ToolNodeType) => { const [currTool, setCurrTool] = useState(null) const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : [] + const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm') // use setting const toolSettingSchema = formSchemas.filter((item: any) => item.form !== 'llm') const toolSettingValue = (() => { @@ -82,11 +83,20 @@ const useConfig = (id: string, payload: ToolNodeType) => { useEffect(() => { if (!currTool) return - setToolSettingValue(addDefaultValue(tool_configurations, toolSettingSchema)) + 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: '', + } + }) + }) + setInputs(inputsWithDefaultValue) }, [currTool]) // setting when call - const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm') const setInputVar = useCallback((value: ToolVarInput[]) => { setInputs({ ...inputs,