diff --git a/web/app/components/workflow/nodes/_base/components/editor/base.tsx b/web/app/components/workflow/nodes/_base/components/editor/base.tsx index 38968b2e0d..c2b95cacf9 100644 --- a/web/app/components/workflow/nodes/_base/components/editor/base.tsx +++ b/web/app/components/workflow/nodes/_base/components/editor/base.tsx @@ -75,7 +75,7 @@ const Base: FC = ({ return ( -
+
{title}
{ diff --git a/web/app/components/workflow/nodes/_base/components/editor/code-editor/index.tsx b/web/app/components/workflow/nodes/_base/components/editor/code-editor/index.tsx index a185f16e2e..a7c0f1fc6d 100644 --- a/web/app/components/workflow/nodes/_base/components/editor/code-editor/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/editor/code-editor/index.tsx @@ -22,7 +22,7 @@ export type Props = { value?: string | object placeholder?: React.JSX.Element | string onChange?: (value: string) => void - title?: React.JSX.Element + title?: string | React.JSX.Element language: CodeLanguage headerRight?: React.JSX.Element readOnly?: boolean diff --git a/web/app/components/workflow/nodes/_base/components/form-input-item.tsx b/web/app/components/workflow/nodes/_base/components/form-input-item.tsx index a50c7c86ad..c4c3221d09 100644 --- a/web/app/components/workflow/nodes/_base/components/form-input-item.tsx +++ b/web/app/components/workflow/nodes/_base/components/form-input-item.tsx @@ -20,6 +20,8 @@ import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-select import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import cn from '@/utils/classnames' +import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' +import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' type Props = { readOnly: boolean @@ -54,12 +56,15 @@ const FormInputItem: FC = ({ const isNumber = type === FormTypeEnum.textNumber const isObject = type === FormTypeEnum.object const isArray = type === FormTypeEnum.array + const isShowJSONEditor = isObject || isArray const isBoolean = type === FormTypeEnum.boolean const isSelect = type === FormTypeEnum.select const isAppSelector = type === FormTypeEnum.appSelector const isModelSelector = type === FormTypeEnum.modelSelector const isFile = type === FormTypeEnum.file || type === FormTypeEnum.files const showTypeSwitch = isNumber || isObject || isArray + const isVariable = varInput?.type === VarKindType.variable + const isConstant = varInput?.type === VarKindType.constant const { availableVars, availableNodesWithParent } = useAvailableVarList(nodeId, { onlyLeafNodeVar: false, @@ -168,9 +173,9 @@ const FormInputItem: FC = ({ }, []) return ( -
+
{showTypeSwitch && !hideTypeSwitch && ( - + )} {isString && ( = ({ placeholderClassName='!leading-[21px]' /> )} - {isNumber && varInput?.type === VarKindType.constant && ( + {isNumber && isConstant && ( = ({ placeholder={placeholder?.[language] || placeholder?.en_US} /> )} + {isShowJSONEditor && isConstant && ( +
+ {placeholder?.[language] || placeholder?.en_US}
} + /> +
+ )} {isAppSelector && ( = ({ onSelect={handleValueChange} /> )} - {isModelSelector && ( + {isModelSelector && isConstant && ( = ({ scope={scope} /> )} - {varInput?.type === VarKindType.variable && ( + {isVariable && ( void + value: VarType + onChange: (value: VarType) => void } const FormInputTypeSwitch: FC = ({ @@ -20,7 +20,7 @@ const FormInputTypeSwitch: FC = ({ }) => { const { t } = useTranslation() return ( -
+
diff --git a/web/app/components/workflow/nodes/tool/use-config.ts b/web/app/components/workflow/nodes/tool/use-config.ts index 38c4454ec0..08e00edf87 100644 --- a/web/app/components/workflow/nodes/tool/use-config.ts +++ b/web/app/components/workflow/nodes/tool/use-config.ts @@ -178,8 +178,11 @@ const useConfig = (id: string, payload: ToolNodeType) => { const res = produce(inputVarValues, (draft) => { Object.keys(inputs.tool_parameters).forEach((key: string) => { const { type, value } = inputs.tool_parameters[key] - if (type === VarType.constant && (value === undefined || value === null)) + if (type === VarType.constant && (value === undefined || value === null)) { + if(!draft.tool_parameters || !draft.tool_parameters[key]) + return draft.tool_parameters[key].value = value + } }) }) return res