diff --git a/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx b/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx index fabe45ba..aaaa2ab5 100644 --- a/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx +++ b/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx @@ -1,5 +1,5 @@ import { forwardRef, useImperativeHandle, useState } from 'react'; -import { Form, Input, Select, Checkbox, InputNumber } from 'antd'; +import { Form, Input, Select, InputNumber } from 'antd'; import { useTranslation } from 'react-i18next'; import type { ChatVariableModalRef } from './types' @@ -26,6 +26,7 @@ const ChatVariableModal = forwardRef(); const [loading, setLoading] = useState(false) const [editIndex, setEditIndex] = useState(undefined) + const type = Form.useWatch('type', form); // 封装取消方法,添加关闭弹窗逻辑 const handleClose = () => { @@ -38,7 +39,8 @@ const ChatVariableModal = forwardRef { setVisible(true); if (variable) { - form.setFieldsValue(variable) + const { default: _, ...rest } = variable + form.setFieldsValue({ ...rest }) setEditIndex(index) } else { form.resetFields(); @@ -48,7 +50,7 @@ const ChatVariableModal = forwardRef { form.validateFields().then((values) => { - refresh({ ...values }, editIndex) + refresh({ ...values, default: values.defaultValue }, editIndex) handleClose() }) } @@ -89,52 +91,36 @@ const ChatVariableModal = forwardRef - ); - } - return ; - }} - - - + {type === 'number' + ? + : type === 'boolean' + ? + } + - - - {t('workflow.config.parameter-extractor.required')} - ); diff --git a/web/src/views/Workflow/components/AddChatVariable/index.tsx b/web/src/views/Workflow/components/AddChatVariable/index.tsx index f765b5eb..7ebce7df 100644 --- a/web/src/views/Workflow/components/AddChatVariable/index.tsx +++ b/web/src/views/Workflow/components/AddChatVariable/index.tsx @@ -40,7 +40,7 @@ const AddChatVariable = forwardRef(({ } const handleSave = (value: ChatVariable, index?: number) => { const list = [...variables] - if (index && index > -1) { + if (typeof index === 'number' && index > -1) { list[index] = value } else { list.push(value) @@ -75,17 +75,15 @@ const AddChatVariable = forwardRef(({ dataSource={variables} renderItem={(item, index) => ( -
+
{item.name} ({t(`workflow.config.parameter-extractor.${item.type}`)})
- {item.required ? t('workflow.config.parameter-extractor.required') : ''} -
{item.description}
- +
handleEdit(index)} diff --git a/web/src/views/Workflow/components/AddChatVariable/types.ts b/web/src/views/Workflow/components/AddChatVariable/types.ts index ab00ae69..5d9aa7b0 100644 --- a/web/src/views/Workflow/components/AddChatVariable/types.ts +++ b/web/src/views/Workflow/components/AddChatVariable/types.ts @@ -11,8 +11,8 @@ export interface VariableFormData { name: string; type: ChatVariable['type']; description?: string; - required?: boolean; - defaultValue?: any; + defaultValue?: string; + default?: string; } export interface ChatVariableModalRef { diff --git a/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx b/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx index 2ac8397b..97f28668 100644 --- a/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx +++ b/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx @@ -114,6 +114,7 @@ const AssignmentList: FC = ({ ? form.setFieldValue([name, 'value'], value)} /> : operation === 'assign' ? <> diff --git a/web/src/views/Workflow/components/Properties/CaseList/index.tsx b/web/src/views/Workflow/components/Properties/CaseList/index.tsx index 22ac7490..96850911 100644 --- a/web/src/views/Workflow/components/Properties/CaseList/index.tsx +++ b/web/src/views/Workflow/components/Properties/CaseList/index.tsx @@ -348,8 +348,12 @@ const CaseList: FC = ({ popupMatchSelectWidth={false} variant="borderless" /> - : + : form.setFieldValue([name, caseIndex, 'expressions', conditionIndex, 'right'], value)} + /> } diff --git a/web/src/views/Workflow/components/Properties/ConditionList/index.tsx b/web/src/views/Workflow/components/Properties/ConditionList/index.tsx index 6d955647..8fbebeda 100644 --- a/web/src/views/Workflow/components/Properties/ConditionList/index.tsx +++ b/web/src/views/Workflow/components/Properties/ConditionList/index.tsx @@ -169,8 +169,12 @@ const ConditionList: FC = ({ variant="borderless" className="rb:w-full!" /> - : + : form.setFieldValue([parentName, 'expressions', index, 'right'], value)} + /> } diff --git a/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx b/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx index 4e704ca8..80584220 100644 --- a/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx +++ b/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx @@ -194,19 +194,31 @@ const HttpRequest: FC<{ options: Suggestion[]; selectedNode?: any; graphRef?: an name={['timeouts', 'connect_timeout']} label={t('workflow.config.http-request.connect_timeout')} > - + form.setFieldValue(['timeouts', 'connect_timeout'], value)} + /> - + form.setFieldValue(['timeouts', 'read_timeout'], value)} + /> - + form.setFieldValue(['timeouts', 'write_timeout'], value)} + /> @@ -219,13 +231,21 @@ const HttpRequest: FC<{ options: Suggestion[]; selectedNode?: any; graphRef?: an name={['retry', 'max_attempts']} label={t('workflow.config.http-request.max_attempts')} > - + form.setFieldValue(['retry', 'max_attempts'], value)} + /> {t('workflow.config.http-request.retry_interval')} (ms)} > - + form.setFieldValue(['retry', 'retry_interval'], value)} + /> } @@ -254,7 +274,11 @@ const HttpRequest: FC<{ options: Suggestion[]; selectedNode?: any; graphRef?: an name={['error_handle', 'status_code']} label={<>status_code number} > - + form.setFieldValue(['error_handle', 'status_code'], value)} + /> - + form.setFieldValue('top_k', value)} + /> {/* 语义相似度阈值 similarity_threshold */} {values?.retrieve_type === 'semantic' && ( diff --git a/web/src/views/Workflow/components/Properties/Knowledge/KnowledgeGlobalConfigModal.tsx b/web/src/views/Workflow/components/Properties/Knowledge/KnowledgeGlobalConfigModal.tsx index 773fb881..2f349487 100644 --- a/web/src/views/Workflow/components/Properties/Knowledge/KnowledgeGlobalConfigModal.tsx +++ b/web/src/views/Workflow/components/Properties/Knowledge/KnowledgeGlobalConfigModal.tsx @@ -110,7 +110,12 @@ const KnowledgeGlobalConfigModal = forwardRef - + form.setFieldValue('reranker_top_k', value)} + /> } diff --git a/web/src/views/Workflow/components/Properties/ToolConfig/index.tsx b/web/src/views/Workflow/components/Properties/ToolConfig/index.tsx index 0cba5596..2ee192f9 100644 --- a/web/src/views/Workflow/components/Properties/ToolConfig/index.tsx +++ b/web/src/views/Workflow/components/Properties/ToolConfig/index.tsx @@ -197,7 +197,14 @@ const ToolConfig: FC<{ options: Suggestion[]; }> = ({ : parameter.type === 'boolean' ? : parameter.type === 'integer' || parameter.type === 'number' - ? + ? form.setFieldValue(['tool_parameters', parameter.name], value)} + /> : - + form.setFieldValue('max_length', value)} + /> )} {/* 默认值 */} @@ -151,7 +155,13 @@ const VariableEditModal = forwardRef {['string'].includes(values.type) && } - {['number'].includes(values.type) && } + {['number'].includes(values.type) && ( + form.setFieldValue('default', value)} + /> + )} {['boolean'].includes(values.type) &&