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