From 4d9b15e519e3162a0b3860dafacd3d36020ca152 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 11 Jun 2025 17:11:28 +0800 Subject: [PATCH 1/2] fix --- .../plugins/component-picker-block/index.tsx | 4 +- .../components/base/prompt-editor/types.ts | 2 + .../components/input-field/dialog-wrapper.tsx | 2 +- .../input-field/editor/dialog-wrapper.tsx | 2 +- .../workflow/hooks/use-nodes-interactions.ts | 2 +- .../components/input-support-select-var.tsx | 6 +++ .../nodes/_base/components/prompt/editor.tsx | 2 +- .../variable/manage-input-field.tsx | 38 +++++++++++++++++++ .../variable/var-reference-picker.tsx | 1 + .../variable/var-reference-popup.tsx | 8 +++- .../variable/var-reference-vars.tsx | 12 ++++++ .../condition-list/condition-input.tsx | 4 ++ .../workflow/nodes/knowledge-base/default.ts | 2 +- .../condition-list/condition-input.tsx | 4 ++ web/i18n/en-US/pipeline.ts | 4 ++ web/i18n/zh-Hans/pipeline.ts | 4 ++ 16 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx diff --git a/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx b/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx index b43d2c8117..b7444be38c 100644 --- a/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx +++ b/web/app/components/base/prompt-editor/plugins/component-picker-block/index.tsx @@ -165,6 +165,8 @@ const ComponentPicker = ({ isSupportFileVar={isSupportFileVar} onClose={handleClose} onBlur={handleClose} + showManageInputField={workflowVariableBlock.showManageInputField} + onManageInputField={workflowVariableBlock.onManageInputField} /> ) @@ -205,7 +207,7 @@ const ComponentPicker = ({ } ) - }, [allFlattenOptions.length, workflowVariableBlock?.show, refs, isPositioned, floatingStyles, queryString, workflowVariableOptions, handleSelectWorkflowVariable, handleClose, isSupportFileVar]) + }, [allFlattenOptions.length, workflowVariableBlock?.show, refs, isPositioned, floatingStyles, queryString, workflowVariableOptions, handleSelectWorkflowVariable, handleClose, isSupportFileVar, workflowVariableBlock?.showManageInputField, workflowVariableBlock?.onManageInputField]) return ( void onDelete?: () => void getVarType?: GetVarType + showManageInputField?: boolean + onManageInputField?: () => void } export type MenuTextMatch = { diff --git a/web/app/components/rag-pipeline/components/input-field/dialog-wrapper.tsx b/web/app/components/rag-pipeline/components/input-field/dialog-wrapper.tsx index aa118f8840..b0273962b4 100644 --- a/web/app/components/rag-pipeline/components/input-field/dialog-wrapper.tsx +++ b/web/app/components/rag-pipeline/components/input-field/dialog-wrapper.tsx @@ -21,7 +21,7 @@ const DialogWrapper = ({ const close = useCallback(() => onClose?.(), [onClose]) return ( - +
onClose?.(), [onClose]) return ( - +
{ } else { // If no nodeId is provided, fall back to the current behavior - const bundledNodes = nodes.filter(node => node.data._isBundled && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.DataSource + const bundledNodes = nodes.filter(node => node.data._isBundled && node.data.type !== BlockEnum.Start && node.data.type !== BlockEnum.DataSource && node.data.type !== BlockEnum.KnowledgeBase && !node.data.isInIteration && !node.data.isInLoop) if (bundledNodes.length) { diff --git a/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx b/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx index a741629da8..e8e2645a46 100644 --- a/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx +++ b/web/app/components/workflow/nodes/_base/components/input-support-select-var.tsx @@ -13,6 +13,7 @@ import PromptEditor from '@/app/components/base/prompt-editor' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import Tooltip from '@/app/components/base/tooltip' import { noop } from 'lodash-es' +import { useStore } from '@/app/components/workflow/store' type Props = { instanceId?: string @@ -56,6 +57,9 @@ const Editor: FC = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [isFocus]) + const pipelineId = useStore(s => s.pipelineId) + const setShowInputFieldDialog = useStore(s => s.setShowInputFieldDialog) + return (
<> @@ -103,6 +107,8 @@ const Editor: FC = ({ } return acc }, {} as any), + showManageInputField: !!pipelineId, + onManageInputField: () => setShowInputFieldDialog?.(true), }} onChange={onChange} editable={!readOnly} diff --git a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx index 0a7ebc2a09..51993d0397 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -254,7 +254,7 @@ const Editor: FC = ({ workflowVariableBlock={{ show: true, variables: nodesOutputVars || [], - getVarType, + getVarType: getVarType as any, workflowNodesMap: availableNodes.reduce((acc, node) => { acc[node.id] = { title: node.data.title, diff --git a/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx b/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx new file mode 100644 index 0000000000..929e585157 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/variable/manage-input-field.tsx @@ -0,0 +1,38 @@ +import { useTranslation } from 'react-i18next' +import { RiAddLine } from '@remixicon/react' + +type ManageInputFieldProps = { + onManage: () => void +} + +const ManageInputField = ({ + onManage, +}: ManageInputFieldProps) => { + const { t } = useTranslation() + + return ( +
+
+ +
+ {t('pipeline.inputField.create')} +
+
+
+
+ {t('pipeline.inputField.manage')} +
+
+ ) +} + +export default ManageInputField diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx index f0b2b6c572..18ee82d865 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx @@ -319,6 +319,7 @@ const VarReferencePicker: FC = ({ return null }, [isValidVar, isShowAPart, hasValue, t, outputVarNode?.title, outputVarNode?.type, value, type]) + return (
= ({ }) => { const { t } = useTranslation() const { locale } = useContext(I18n) + const pipelineId = useStore(s => s.pipelineId) + const showManageRagInputFields = useMemo(() => !!pipelineId, [pipelineId]) + const setShowInputFieldDialog = useStore(s => s.setShowInputFieldDialog) // max-h-[300px] overflow-y-auto todo: use portal to handle long list return (
= ({ onChange={onChange} itemWidth={itemWidth} isSupportFileVar={isSupportFileVar} + showManageInputField={showManageRagInputFields} + onManageInputField={() => setShowInputFieldDialog?.(true)} /> }
diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx index b77c9f005b..329b14b9f2 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx @@ -24,6 +24,7 @@ import { FILE_STRUCT } from '@/app/components/workflow/constants' import { Loop } from '@/app/components/base/icons/src/vender/workflow' import { noop } from 'lodash-es' import { InputField } from '@/app/components/base/icons/src/vender/pipeline' +import ManageInputField from './manage-input-field' type ObjectChildrenProps = { nodeId: string @@ -266,6 +267,8 @@ type Props = { maxHeightClass?: string onClose?: () => void onBlur?: () => void + showManageInputField?: boolean + onManageInputField?: () => void } const VarReferenceVars: FC = ({ hideSearch, @@ -277,6 +280,8 @@ const VarReferenceVars: FC = ({ maxHeightClass, onClose, onBlur, + showManageInputField, + onManageInputField, }) => { const { t } = useTranslation() const [searchText, setSearchText] = useState('') @@ -367,6 +372,13 @@ const VarReferenceVars: FC = ({ }
:
{t('workflow.common.noVar')}
} + { + showManageInputField && ( + + ) + } ) } diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx index e6f08184c8..ea8f6a5b5d 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx @@ -23,6 +23,8 @@ const ConditionInput = ({ }: ConditionInputProps) => { const { t } = useTranslation() const controlPromptEditorRerenderKey = useStore(s => s.controlPromptEditorRerenderKey) + const pipelineId = useStore(s => s.pipelineId) + const setShowInputFieldDialog = useStore(s => s.setShowInputFieldDialog) return ( setShowInputFieldDialog?.(true), }} onChange={onChange} editable={!disabled} diff --git a/web/app/components/workflow/nodes/knowledge-base/default.ts b/web/app/components/workflow/nodes/knowledge-base/default.ts index a7132df364..e43c08778f 100644 --- a/web/app/components/workflow/nodes/knowledge-base/default.ts +++ b/web/app/components/workflow/nodes/knowledge-base/default.ts @@ -13,7 +13,7 @@ const nodeDefault: NodeDefault = { index_chunk_variable_selector: [], keyword_number: 10, retrieval_model: { - top_k: 2, + top_k: 3, score_threshold_enabled: false, score_threshold: 0.5, }, diff --git a/web/app/components/workflow/nodes/loop/components/condition-list/condition-input.tsx b/web/app/components/workflow/nodes/loop/components/condition-list/condition-input.tsx index 5c02f140dc..4df537ee43 100644 --- a/web/app/components/workflow/nodes/loop/components/condition-list/condition-input.tsx +++ b/web/app/components/workflow/nodes/loop/components/condition-list/condition-input.tsx @@ -20,6 +20,8 @@ const ConditionInput = ({ }: ConditionInputProps) => { const { t } = useTranslation() const controlPromptEditorRerenderKey = useStore(s => s.controlPromptEditorRerenderKey) + const pipelineId = useStore(s => s.pipelineId) + const setShowInputFieldDialog = useStore(s => s.setShowInputFieldDialog) return ( setShowInputFieldDialog?.(true), }} onChange={onChange} editable={!disabled} diff --git a/web/i18n/en-US/pipeline.ts b/web/i18n/en-US/pipeline.ts index 7a3d24b5ca..5f895eb250 100644 --- a/web/i18n/en-US/pipeline.ts +++ b/web/i18n/en-US/pipeline.ts @@ -11,6 +11,10 @@ const translation = { descriptionPlaceholder: 'Please enter the description of this Knowledge Pipeline. (Optional) ', }, }, + inputField: { + create: 'Create user input field', + manage: 'Manage', + }, } export default translation diff --git a/web/i18n/zh-Hans/pipeline.ts b/web/i18n/zh-Hans/pipeline.ts index b02fc001a1..3197e66170 100644 --- a/web/i18n/zh-Hans/pipeline.ts +++ b/web/i18n/zh-Hans/pipeline.ts @@ -11,6 +11,10 @@ const translation = { descriptionPlaceholder: '请输入此 Pipeline 的描述。 (可选)', }, }, + inputField: { + create: '创建用户输入字段', + manage: '管理', + }, } export default translation From 92e6c52c0e1eb3bfadc577c746752ac7f69952bf Mon Sep 17 00:00:00 2001 From: twwu Date: Wed, 11 Jun 2025 17:17:09 +0800 Subject: [PATCH 2/2] refactor: update handleUseTemplate to use callback for dataset creation and improve error handling; change HTTP method for dependency check --- .../list/template-card/index.tsx | 47 ++++++++++--------- web/service/use-pipeline.ts | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx index 74bbdded9d..a8d4081993 100644 --- a/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx +++ b/web/app/components/datasets/create-from-pipeline/list/template-card/index.tsx @@ -52,34 +52,35 @@ const TemplateCard = ({ }, []) const handleUseTemplate = useCallback(async (payload: Omit) => { - try { - const { data: pipelineTemplateInfo } = await getPipelineTemplateInfo() - if (!pipelineTemplateInfo) { - Toast.notify({ - type: 'error', - message: t('datasetPipeline.creation.errorTip'), - }) - return - } - const request = { - ...payload, - yaml_content: pipelineTemplateInfo.export_data, - } - const newDataset = await createEmptyDataset(request) - Toast.notify({ - type: 'success', - message: t('app.newApp.appCreated'), - }) - if (newDataset.pipeline_id) - await handleCheckPluginDependencies(newDataset.pipeline_id, true) - push(`dataset/${newDataset.id}/pipeline`) - } - catch { + const { data: pipelineTemplateInfo } = await getPipelineTemplateInfo() + if (!pipelineTemplateInfo) { Toast.notify({ type: 'error', message: t('datasetPipeline.creation.errorTip'), }) + return } + const request = { + ...payload, + yaml_content: pipelineTemplateInfo.export_data, + } + await createEmptyDataset(request, { + onSuccess: async (newDataset) => { + Toast.notify({ + type: 'success', + message: t('app.newApp.appCreated'), + }) + if (newDataset.pipeline_id) + await handleCheckPluginDependencies(newDataset.pipeline_id, true) + push(`/datasets/${newDataset.id}/pipeline`) + }, + onError: () => { + Toast.notify({ + type: 'error', + message: t('datasetPipeline.creation.errorTip'), + }) + }, + }) }, [getPipelineTemplateInfo, createEmptyDataset, t, handleCheckPluginDependencies, push]) const handleShowTemplateDetails = useCallback(() => { diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts index a141a04ca9..e45d705e4c 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -127,7 +127,7 @@ export const useCheckPipelineDependencies = ( return useMutation({ mutationKey: [NAME_SPACE, 'check-dependencies'], mutationFn: (pipelineId: string) => { - return post(`/rag/pipelines/imports/${pipelineId}/check-dependencies`) + return get(`/rag/pipelines/imports/${pipelineId}/check-dependencies`) }, ...mutationOptions, })