diff --git a/web/app/components/app/configuration/config-var/config-modal/index.tsx b/web/app/components/app/configuration/config-var/config-modal/index.tsx index 28eaa828be..2d107bd68b 100644 --- a/web/app/components/app/configuration/config-var/config-modal/index.tsx +++ b/web/app/components/app/configuration/config-var/config-modal/index.tsx @@ -97,8 +97,8 @@ const ConfigModal: FC = ({ value: InputVarType.number, }, { - name: t('appDebug.variableConfig.boolean'), - value: InputVarType.boolean, + name: t('appDebug.variableConfig.checkbox'), + value: InputVarType.checkbox, }, ...(supportFile ? [ { diff --git a/web/app/components/app/configuration/config-var/select-var-type.tsx b/web/app/components/app/configuration/config-var/select-var-type.tsx index 1a691a17c2..7b01ec8938 100644 --- a/web/app/components/app/configuration/config-var/select-var-type.tsx +++ b/web/app/components/app/configuration/config-var/select-var-type.tsx @@ -65,7 +65,7 @@ const SelectVarType: FC = ({ - +
diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx index dad5441a54..62bd57c5d1 100644 --- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx +++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx @@ -120,6 +120,8 @@ const SettingBuiltInTool: FC = ({ return t('tools.setBuiltInTools.number') if (type === 'text-input') return t('tools.setBuiltInTools.string') + if (type === 'checkbox') + return 'boolean' if (type === 'file') return t('tools.setBuiltInTools.file') return type diff --git a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx index 0899c46128..e856e6a88a 100644 --- a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx +++ b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx @@ -90,7 +90,7 @@ const ChatWrapper = () => { let hasEmptyInput = '' let fileIsUploading = false - const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) + const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox) if (requiredVars.length) { requiredVars.forEach(({ variable, label, type }) => { if (hasEmptyInput) diff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsx index 05d820c2bf..6c80368e51 100644 --- a/web/app/components/base/chat/chat-with-history/hooks.tsx +++ b/web/app/components/base/chat/chat-with-history/hooks.tsx @@ -208,11 +208,11 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { } } - if(item.boolean) { + if(item.checkbox) { return { - ...item.boolean, + ...item.checkbox, default: false, - type: 'boolean', + type: 'checkbox', } } if (item.select) { @@ -333,7 +333,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { let hasEmptyInput = '' let fileIsUploading = false - const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) + const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox) if (requiredVars.length) { requiredVars.forEach(({ variable, label, type }) => { if (hasEmptyInput) diff --git a/web/app/components/base/chat/chat-with-history/inputs-form/content.tsx b/web/app/components/base/chat/chat-with-history/inputs-form/content.tsx index aec128e90e..a2ae980977 100644 --- a/web/app/components/base/chat/chat-with-history/inputs-form/content.tsx +++ b/web/app/components/base/chat/chat-with-history/inputs-form/content.tsx @@ -43,7 +43,7 @@ const InputsFormContent = ({ showTip }: Props) => {
{visibleInputsForms.map(form => (
- {form.type !== InputVarType.boolean && ( + {form.type !== InputVarType.checkbox && (
{form.label}
{!form.required && ( @@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => { placeholder={form.label} /> )} - {form.type === InputVarType.boolean && ( + {form.type === InputVarType.checkbox && ( { const checkInputsForm = useCallback((inputs: Record, inputsForm: InputForm[]) => { let hasEmptyInput = '' let fileIsUploading = false - const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.boolean) // boolean can be not checked + const requiredVars = inputsForm.filter(({ required, type }) => required && type !== InputVarType.checkbox) // boolean can be not checked if (requiredVars?.length) { requiredVars.forEach(({ variable, label, type }) => { diff --git a/web/app/components/base/chat/chat/utils.ts b/web/app/components/base/chat/chat/utils.ts index 9e4957ce9d..199ccff578 100644 --- a/web/app/components/base/chat/chat/utils.ts +++ b/web/app/components/base/chat/chat/utils.ts @@ -32,7 +32,7 @@ export const getProcessedInputs = (inputs: Record, inputsForm: Inpu inputsForm.forEach((item) => { const inputValue = inputs[item.variable] // set boolean type default value - if(item.type === InputVarType.boolean) { + if(item.type === InputVarType.checkbox) { processedInputs[item.variable] = !!inputValue return } diff --git a/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx b/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx index 256616bcf3..14a291e9fd 100644 --- a/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx +++ b/web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx @@ -90,7 +90,7 @@ const ChatWrapper = () => { let hasEmptyInput = '' let fileIsUploading = false - const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) + const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox) // boolean can be not checked if (requiredVars.length) { requiredVars.forEach(({ variable, label, type }) => { if (hasEmptyInput) diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsx index 8a949b2cc9..7596f272f3 100644 --- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx +++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx @@ -195,6 +195,13 @@ export const useEmbeddedChatbot = () => { type: 'number', } } + if (item.checkbox) { + return { + ...item.checkbox, + default: false, + type: 'checkbox', + } + } if (item.select) { const isInputInOptions = item.select.options.includes(initInputs[item.select.variable]) return { @@ -312,7 +319,7 @@ export const useEmbeddedChatbot = () => { let hasEmptyInput = '' let fileIsUploading = false - const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.boolean) + const requiredVars = inputsForms.filter(({ required, type }) => required && type !== InputVarType.checkbox) if (requiredVars.length) { requiredVars.forEach(({ variable, label, type }) => { if (hasEmptyInput) diff --git a/web/app/components/base/chat/embedded-chatbot/inputs-form/content.tsx b/web/app/components/base/chat/embedded-chatbot/inputs-form/content.tsx index a8cb576de5..e35930881f 100644 --- a/web/app/components/base/chat/embedded-chatbot/inputs-form/content.tsx +++ b/web/app/components/base/chat/embedded-chatbot/inputs-form/content.tsx @@ -43,7 +43,7 @@ const InputsFormContent = ({ showTip }: Props) => {
{visibleInputsForms.map(form => (
- {form.type !== InputVarType.boolean && ( + {form.type !== InputVarType.checkbox && (
{form.label}
{!form.required && ( @@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => { placeholder={form.label} /> )} - {form.type === InputVarType.boolean && ( + {form.type === InputVarType.checkbox && ( = ({ return t('tools.setBuiltInTools.number') if (type === 'text-input') return t('tools.setBuiltInTools.string') + if (type === 'checkbox') + return 'boolean' if (type === 'file') return t('tools.setBuiltInTools.file') if (type === 'array[tools]') diff --git a/web/app/components/tools/utils/to-form-schema.ts b/web/app/components/tools/utils/to-form-schema.ts index ee7f3379ad..9596016691 100644 --- a/web/app/components/tools/utils/to-form-schema.ts +++ b/web/app/components/tools/utils/to-form-schema.ts @@ -8,6 +8,8 @@ export const toType = (type: string) => { return 'text-input' case 'number': return 'number-input' + case 'boolean': + return 'checkbox' default: return type } diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx index b3308b4145..825c46e9c0 100644 --- a/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/form-item.tsx @@ -93,7 +93,7 @@ const FormItem: FC = ({ return '' })() - const isBooleanType = type === InputVarType.boolean + const isBooleanType = type === InputVarType.checkbox const isArrayLikeType = [InputVarType.contexts, InputVarType.iterator].includes(type) const isContext = type === InputVarType.contexts const isIterator = type === InputVarType.iterator diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx index a7cbbf9ddf..44abbb67b5 100644 --- a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx @@ -32,7 +32,7 @@ export type BeforeRunFormProps = { } & Partial function formatValue(value: string | any, type: InputVarType) { - if(type === InputVarType.boolean) + if(type === InputVarType.checkbox) return !!value if(value === undefined || value === null) return value @@ -89,7 +89,7 @@ const BeforeRunForm: FC = ({ form.inputs.forEach((input) => { const value = form.values[input.variable] as any - if (!errMsg && input.required && (input.type !== InputVarType.boolean) && !(input.variable in existVarValuesInForm) && (value === '' || value === undefined || value === null || (input.type === InputVarType.files && value.length === 0))) + if (!errMsg && input.required && (input.type !== InputVarType.checkbox) && !(input.variable in existVarValuesInForm) && (value === '' || value === undefined || value === null || (input.type === InputVarType.files && value.length === 0))) errMsg = t('workflow.errorMsg.fieldRequired', { field: typeof input.label === 'object' ? input.label.variable : input.label }) if (!errMsg && (input.type === InputVarType.singleFile || input.type === InputVarType.multiFiles) && value) { diff --git a/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx b/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx index a0d89aecc2..c821cd5306 100644 --- a/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx +++ b/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx @@ -15,7 +15,7 @@ const getIcon = (type: InputVarType) => { [InputVarType.paragraph]: RiAlignLeft, [InputVarType.select]: RiCheckboxMultipleLine, [InputVarType.number]: RiHashtag, - [InputVarType.boolean]: RiCheckboxLine, + [InputVarType.checkbox]: RiCheckboxLine, [InputVarType.singleFile]: RiFileList2Line, [InputVarType.multiFiles]: RiFileCopy2Line, } as any)[type] || RiTextSnippet diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 95e6a1eafa..229f0a44e2 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -59,7 +59,7 @@ export const hasValidChildren = (children: any): boolean => { export const inputVarTypeToVarType = (type: InputVarType): VarType => { return ({ [InputVarType.number]: VarType.number, - [InputVarType.boolean]: VarType.boolean, + [InputVarType.checkbox]: VarType.boolean, [InputVarType.singleFile]: VarType.file, [InputVarType.multiFiles]: VarType.arrayFile, } as any)[type] || VarType.string diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts index 591368219e..b05f5aee34 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts @@ -95,7 +95,7 @@ const varTypeToInputVarType = (type: VarType, { if (type === VarType.number) return InputVarType.number if (type === VarType.boolean) - return InputVarType.boolean + return InputVarType.checkbox if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type)) return InputVarType.json if (type === VarType.file) diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index ab6f3fd194..dade28d6a5 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -178,7 +178,7 @@ export enum InputVarType { paragraph = 'paragraph', select = 'select', number = 'number', - boolean = 'boolean', + checkbox = 'checkbox', url = 'url', files = 'files', json = 'json', // obj, array @@ -449,6 +449,6 @@ export enum VersionHistoryContextMenuOptions { delete = 'delete', } -export interface ChildNodeTypeCount { +export type ChildNodeTypeCount = { [key: string]: number; } diff --git a/web/i18n/en-US/app-debug.ts b/web/i18n/en-US/app-debug.ts index 4bf5653c55..4c3334260e 100644 --- a/web/i18n/en-US/app-debug.ts +++ b/web/i18n/en-US/app-debug.ts @@ -359,7 +359,7 @@ const translation = { 'paragraph': 'Paragraph', 'select': 'Select', 'number': 'Number', - 'boolean': 'Checkbox', + 'checkbox': 'Checkbox', 'single-file': 'Single File', 'multi-files': 'File List', 'notSet': 'Not set, try typing {{input}} in the prefix prompt', diff --git a/web/i18n/zh-Hans/app-debug.ts b/web/i18n/zh-Hans/app-debug.ts index 8f0053905b..f397606023 100644 --- a/web/i18n/zh-Hans/app-debug.ts +++ b/web/i18n/zh-Hans/app-debug.ts @@ -355,7 +355,7 @@ const translation = { 'paragraph': '段落', 'select': '下拉选项', 'number': '数字', - 'boolean': '复选框', + 'checkbox': '复选框', 'single-file': '单文件', 'multi-files': '文件列表', 'notSet': '未设置,在 Prompt 中输入 {{input}} 试试', diff --git a/web/utils/model-config.ts b/web/utils/model-config.ts index e317454db1..3b4772f03d 100644 --- a/web/utils/model-config.ts +++ b/web/utils/model-config.ts @@ -18,6 +18,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] | if (item.number) return ['number', item.number] + if (item.checkbox) + return ['boolean', item.checkbox] + if (item.file) return ['file', item.file]