From 7080c9f279011df6d866959a81f3c0bf920db609 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 4 Jun 2025 16:29:36 +0800 Subject: [PATCH 1/6] fix: show rag vars names --- .../_base/components/variable/var-reference-picker.tsx | 10 +++++++--- .../_base/components/variable/var-reference-vars.tsx | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) 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 e9825cd44a..24de113e0d 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 @@ -13,7 +13,7 @@ import { useReactFlow, useStoreApi } from 'reactflow' import RemoveButton from '../remove-button' import useAvailableVarList from '../../hooks/use-available-var-list' import VarReferencePopup from './var-reference-popup' -import { getNodeInfoById, isConversationVar, isENV, isSystemVar, varTypeToStructType } from './utils' +import { getNodeInfoById, isConversationVar, isENV, isRagVariableVar, isSystemVar, varTypeToStructType } from './utils' import ConstantField from './constant-field' import cn from '@/utils/classnames' import type { Node, NodeOutPutVar, ValueSelector, Var } from '@/app/components/workflow/types' @@ -40,6 +40,7 @@ import Tooltip from '@/app/components/base/tooltip' import { isExceptionVariable } from '@/app/components/workflow/utils' import VarFullPathPanel from './var-full-path-panel' import { noop } from 'lodash-es' +import { InputField } from '@/app/components/base/icons/src/vender/pipeline' const TRIGGER_DEFAULT_WIDTH = 227 @@ -274,14 +275,16 @@ const VarReferencePicker: FC = ({ isConstant: !!isConstant, }) - const { isEnv, isChatVar, isValidVar, isException } = useMemo(() => { + const { isEnv, isChatVar, isRagVar, isValidVar, isException } = useMemo(() => { const isEnv = isENV(value as ValueSelector) const isChatVar = isConversationVar(value as ValueSelector) + const isRagVar = isRagVariableVar(value as ValueSelector) const isValidVar = Boolean(outputVarNode) || isEnv || isChatVar const isException = isExceptionVariable(varName, outputVarNode?.type) return { isEnv, isChatVar, + isRagVar, isValidVar, isException, } @@ -385,7 +388,7 @@ const VarReferencePicker: FC = ({ {hasValue ? ( <> - {isShowNodeName && !isEnv && !isChatVar && ( + {isShowNodeName && !isEnv && !isChatVar && !isRagVar && (
{ if (e.metaKey || e.ctrlKey) { e.stopPropagation() @@ -414,6 +417,7 @@ const VarReferencePicker: FC = ({ {!hasValue && } {isEnv && } {isChatVar && } + {isRagVar && }
{varName}
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 7ca334bb05..1f72d57da7 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 @@ -125,7 +125,7 @@ const Item: FC = ({ if (!isSupportFileVar && isFile) return - if (isSys || isEnv || isChatVar) { // system variable | environment variable | conversation variable + if (isSys || isEnv || isChatVar || isRagVariable) { // system variable | environment variable | conversation variable onChange([...objPath, ...itemData.variable.split('.')], itemData) } else { @@ -155,7 +155,7 @@ const Item: FC = ({ {isChatVar && } {isLoopVar && } {isRagVariable && } - {!isEnv && !isChatVar && ( + {!isEnv && !isChatVar && !isRagVariable && (
{itemData.variable}
)} {isEnv && ( @@ -164,6 +164,9 @@ const Item: FC = ({ {isChatVar && (
{itemData.variable.replace('conversation.', '')}
)} + {isRagVariable && ( +
{itemData.variable.replace('rag.', '')}
+ )}
{itemData.type}
{ From c155afac2997f091e443b6c3060af2e6592b7132 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 4 Jun 2025 16:43:24 +0800 Subject: [PATCH 2/6] chore: rename rag var spell errro --- .../workflow/nodes/_base/components/variable/utils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 a899c22161..d29459a161 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -496,11 +496,11 @@ const formatItem = ( } case 'rag': { - res.vars = data.ragVariables.map((ragVarialbe: RAGPipelineVariable) => { + res.vars = data.ragVariables.map((ragVar: RAGPipelineVariable) => { return { - variable: `rag.${ragVarialbe.variable}`, - type: inputVarTypeToVarType(ragVarialbe.type as any), - des: ragVarialbe.label, + variable: `rag.${ragVar.variable}`, + type: inputVarTypeToVarType(ragVar.type as any), + des: ragVar.label, isRagVariable: true, } }) as Var[] From 9934eac15c8190fe45c68700f52c88f568efd5e6 Mon Sep 17 00:00:00 2001 From: twwu Date: Wed, 4 Jun 2025 16:50:27 +0800 Subject: [PATCH 3/6] refactor: refactor data source handling and add form for document processing --- .../documents/create-from-pipeline/hooks.ts | 1 - .../documents/create-from-pipeline/index.tsx | 2 +- .../input-field/preview/data-source.tsx | 20 ++++++++- .../components/input-field/preview/form.tsx | 41 +++++++++++++++++++ .../components/input-field/preview/index.tsx | 14 +++++++ .../input-field/preview/process-documents.tsx | 31 ++++++++++++++ .../components/panel/test-run/hooks.ts | 1 - .../components/panel/test-run/index.tsx | 2 +- .../components/panel/test-run/types.ts | 3 +- web/service/use-pipeline.ts | 1 + 10 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 web/app/components/rag-pipeline/components/input-field/preview/form.tsx create mode 100644 web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks.ts index 49f9dc359b..c8315f565c 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/hooks.ts +++ b/web/app/components/datasets/documents/create-from-pipeline/hooks.ts @@ -51,7 +51,6 @@ export const useDatasourceOptions = (pipelineNodes: Node[]) return { nodeId: node.id, type: node.data.provider_type as DatasourceType, - variables: node.data.variables || [], description: node.data.desc || '', docTitle: '', // todo: Add docTitle and docLink if needed, or remove these properties if not used docLink: '', diff --git a/web/app/components/datasets/documents/create-from-pipeline/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/index.tsx index 8de9a436db..3eb2f0445d 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/index.tsx @@ -274,7 +274,7 @@ const CreateFormPipeline = () => { {datasource?.type === DatasourceType.websiteCrawl && ( { +type DatasourceProps = { + onSelect: (dataSource: Datasource) => void + datasourceNodeId: string +} + +const DataSource = ({ + onSelect: setDatasource, + datasourceNodeId, +}: DatasourceProps) => { const { t } = useTranslation() return ( @@ -9,6 +20,13 @@ const DataSource = () => {
{t('datasetPipeline.inputFieldPanel.preview.stepOneTitle')}
+
+ +
+
) } diff --git a/web/app/components/rag-pipeline/components/input-field/preview/form.tsx b/web/app/components/rag-pipeline/components/input-field/preview/form.tsx new file mode 100644 index 0000000000..0e67b084df --- /dev/null +++ b/web/app/components/rag-pipeline/components/input-field/preview/form.tsx @@ -0,0 +1,41 @@ +import { useAppForm } from '@/app/components/base/form' +import BaseField from '@/app/components/base/form/form-scenarios/base/field' +import type { RAGPipelineVariables } from '@/models/pipeline' +import { useConfigurations, useInitialData } from '../../panel/test-run/data-source/website-crawl/base/options/hooks' + +type FormProps = { + variables: RAGPipelineVariables +} + +const Form = ({ + variables, +}: FormProps) => { + const initialData = useInitialData(variables) + const configurations = useConfigurations(variables) + + const form = useAppForm({ + defaultValues: initialData, + }) + + return ( + { + e.preventDefault() + e.stopPropagation() + }} + > +
+ {configurations.map((config, index) => { + const FieldComponent = BaseField({ + initialData, + config, + }) + return + })} +
+
+ ) +} + +export default Form diff --git a/web/app/components/rag-pipeline/components/input-field/preview/index.tsx b/web/app/components/rag-pipeline/components/input-field/preview/index.tsx index 534a219bb5..692306a642 100644 --- a/web/app/components/rag-pipeline/components/input-field/preview/index.tsx +++ b/web/app/components/rag-pipeline/components/input-field/preview/index.tsx @@ -1,7 +1,12 @@ +import { useState } from 'react' import { RiCloseLine } from '@remixicon/react' import DialogWrapper from './dialog-wrapper' import { useTranslation } from 'react-i18next' import Badge from '@/app/components/base/badge' +import DataSource from './data-source' +import Divider from '@/app/components/base/divider' +import ProcessDocuments from './process-documents' +import type { Datasource } from '../../panel/test-run/types' type PreviewPanelProps = { show: boolean @@ -13,6 +18,7 @@ const PreviewPanel = ({ onClose, }: PreviewPanelProps) => { const { t } = useTranslation() + const [datasource, setDatasource] = useState() return ( + +
+ +
+
) } diff --git a/web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx b/web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx new file mode 100644 index 0000000000..2d93f66b75 --- /dev/null +++ b/web/app/components/rag-pipeline/components/input-field/preview/process-documents.tsx @@ -0,0 +1,31 @@ +import React from 'react' +import { useTranslation } from 'react-i18next' +import { useStore } from '@/app/components/workflow/store' +import { useDraftPipelineProcessingParams } from '@/service/use-pipeline' +import Form from './form' + +type ProcessDocumentsProps = { + dataSourceNodeId: string +} + +const ProcessDocuments = ({ + dataSourceNodeId, +}: ProcessDocumentsProps) => { + const { t } = useTranslation() + const pipelineId = useStore(state => state.pipelineId) + const { data: paramsConfig } = useDraftPipelineProcessingParams({ + pipeline_id: pipelineId!, + node_id: dataSourceNodeId, + }) + + return ( +
+
+ {t('datasetPipeline.inputFieldPanel.preview.stepTwoTitle')} +
+
+
+ ) +} + +export default React.memo(ProcessDocuments) diff --git a/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts b/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts index 661a021a6a..3fbb1a07aa 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts +++ b/web/app/components/rag-pipeline/components/panel/test-run/hooks.ts @@ -49,7 +49,6 @@ export const useDatasourceOptions = () => { return { nodeId: node.id, type: node.data.provider_type as DatasourceType, - variables: node.data.variables || [], description: '', // todo: Add description docTitle: '', // todo: Add docTitle and docLink docLink: '', diff --git a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx index 5c718bb3da..84b48c3653 100644 --- a/web/app/components/rag-pipeline/components/panel/test-run/index.tsx +++ b/web/app/components/rag-pipeline/components/panel/test-run/index.tsx @@ -139,7 +139,7 @@ const TestRunPanel = () => { {datasource?.type === DatasourceType.websiteCrawl && ( Date: Wed, 4 Jun 2025 16:58:08 +0800 Subject: [PATCH 4/6] fix: update input type from 'number-input' to 'number' for consistency --- .../base/form/components/field/input-type-select/hooks.tsx | 2 +- .../base/form/components/field/input-type-select/types.tsx | 2 +- web/models/pipeline.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/components/base/form/components/field/input-type-select/hooks.tsx b/web/app/components/base/form/components/field/input-type-select/hooks.tsx index b77ddad4ca..cc1192414d 100644 --- a/web/app/components/base/form/components/field/input-type-select/hooks.tsx +++ b/web/app/components/base/form/components/field/input-type-select/hooks.tsx @@ -12,7 +12,7 @@ import { } from '@remixicon/react' const i18nFileTypeMap: Record = { - 'number-input': 'number', + 'number': 'number', 'file': 'single-file', 'file-list': 'multi-files', } diff --git a/web/app/components/base/form/components/field/input-type-select/types.tsx b/web/app/components/base/form/components/field/input-type-select/types.tsx index 99cbae4d23..abf4bbd2a7 100644 --- a/web/app/components/base/form/components/field/input-type-select/types.tsx +++ b/web/app/components/base/form/components/field/input-type-select/types.tsx @@ -4,7 +4,7 @@ import { z } from 'zod' export const InputTypeEnum = z.enum([ 'text-input', 'paragraph', - 'number-input', + 'number', 'select', 'checkbox', 'file', diff --git a/web/models/pipeline.ts b/web/models/pipeline.ts index fb1f29438b..ac0f5f544b 100644 --- a/web/models/pipeline.ts +++ b/web/models/pipeline.ts @@ -107,7 +107,7 @@ export enum PipelineInputVarType { textInput = 'text-input', paragraph = 'paragraph', select = 'select', - number = 'number-input', + number = 'number', singleFile = 'file', multiFiles = 'file-list', checkbox = 'checkbox', From 0bf0c7dbe865512a01a4e3038cb3d369c920d750 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 4 Jun 2025 17:34:12 +0800 Subject: [PATCH 5/6] feat: var type to inner --- .../workflow/nodes/assigner/node.tsx | 17 +++--------- .../nodes/document-extractor/node.tsx | 9 ++----- .../workflow/nodes/list-operator/node.tsx | 9 ++----- .../components/node-group-item.tsx | 9 ++----- .../components/node-variable-item.tsx | 26 +++++++++++++------ 5 files changed, 27 insertions(+), 43 deletions(-) diff --git a/web/app/components/workflow/nodes/assigner/node.tsx b/web/app/components/workflow/nodes/assigner/node.tsx index 2dd1ead4f8..ae42065e2d 100644 --- a/web/app/components/workflow/nodes/assigner/node.tsx +++ b/web/app/components/workflow/nodes/assigner/node.tsx @@ -4,7 +4,7 @@ import { useNodes } from 'reactflow' import { useTranslation } from 'react-i18next' import NodeVariableItem from '../variable-assigner/components/node-variable-item' import type { AssignerNodeType } from './types' -import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types' const i18nPrefix = 'workflow.nodes.assigner' @@ -38,18 +38,13 @@ const NodeComponent: FC> = ({ if (!variable || variable.length === 0) return null const isSystem = isSystemVar(variable) - const isEnv = isENV(variable) - const isChatVar = isConversationVar(variable) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) - const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') return ( ) @@ -63,19 +58,13 @@ const NodeComponent: FC> = ({ if (!variable || variable.length === 0) return null const isSystem = isSystemVar(variable) - const isEnv = isENV(variable) - const isChatVar = isConversationVar(variable) - const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) - const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') return (
diff --git a/web/app/components/workflow/nodes/document-extractor/node.tsx b/web/app/components/workflow/nodes/document-extractor/node.tsx index 6b1d4343be..660e2ebb18 100644 --- a/web/app/components/workflow/nodes/document-extractor/node.tsx +++ b/web/app/components/workflow/nodes/document-extractor/node.tsx @@ -4,7 +4,7 @@ import { useNodes } from 'reactflow' import { useTranslation } from 'react-i18next' import NodeVariableItem from '../variable-assigner/components/node-variable-item' import type { DocExtractorNodeType } from './types' -import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types' const i18nPrefix = 'workflow.nodes.docExtractor' @@ -21,18 +21,13 @@ const NodeComponent: FC> = ({ return null const isSystem = isSystemVar(variable) - const isEnv = isENV(variable) - const isChatVar = isConversationVar(variable) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) - const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') return (
{t(`${i18nPrefix}.inputVar`)}
diff --git a/web/app/components/workflow/nodes/list-operator/node.tsx b/web/app/components/workflow/nodes/list-operator/node.tsx index 4c3596fd3b..8120c8e402 100644 --- a/web/app/components/workflow/nodes/list-operator/node.tsx +++ b/web/app/components/workflow/nodes/list-operator/node.tsx @@ -4,7 +4,7 @@ import { useNodes } from 'reactflow' import { useTranslation } from 'react-i18next' import NodeVariableItem from '../variable-assigner/components/node-variable-item' import type { ListFilterNodeType } from './types' -import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types' const i18nPrefix = 'workflow.nodes.listFilter' @@ -21,18 +21,13 @@ const NodeComponent: FC> = ({ return null const isSystem = isSystemVar(variable) - const isEnv = isENV(variable) - const isChatVar = isConversationVar(variable) const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) - const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') return (
{t(`${i18nPrefix}.inputVar`)}
diff --git a/web/app/components/workflow/nodes/variable-assigner/components/node-group-item.tsx b/web/app/components/workflow/nodes/variable-assigner/components/node-group-item.tsx index e6984b98e0..c5bc9399b0 100644 --- a/web/app/components/workflow/nodes/variable-assigner/components/node-group-item.tsx +++ b/web/app/components/workflow/nodes/variable-assigner/components/node-group-item.tsx @@ -19,7 +19,7 @@ import { import { filterVar } from '../utils' import AddVariable from './add-variable' import NodeVariableItem from './node-variable-item' -import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import cn from '@/utils/classnames' import { isExceptionVariable } from '@/app/components/workflow/utils' @@ -124,9 +124,6 @@ const NodeGroupItem = ({ { !!item.variables.length && item.variables.map((variable = [], index) => { const isSystem = isSystemVar(variable) - const isEnv = isENV(variable) - const isChatVar = isConversationVar(variable) - const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0]) const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') const isException = isExceptionVariable(varName, node?.data.type) @@ -134,11 +131,9 @@ const NodeGroupItem = ({ return ( ) diff --git a/web/app/components/workflow/nodes/variable-assigner/components/node-variable-item.tsx b/web/app/components/workflow/nodes/variable-assigner/components/node-variable-item.tsx index f5d05aae26..81286e21f8 100644 --- a/web/app/components/workflow/nodes/variable-assigner/components/node-variable-item.tsx +++ b/web/app/components/workflow/nodes/variable-assigner/components/node-variable-item.tsx @@ -9,13 +9,13 @@ import { Line3 } from '@/app/components/base/icons/src/public/common' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' import Badge from '@/app/components/base/badge' -import type { Node } from '@/app/components/workflow/types' +import type { Node, ValueSelector } from '@/app/components/workflow/types' +import { isConversationVar, isENV, isRagVariableVar, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { InputField } from '@/app/components/base/icons/src/vender/pipeline' type NodeVariableItemProps = { - isEnv: boolean - isChatVar: boolean node: Node - varName: string + variable: ValueSelector writeMode?: string showBorder?: boolean className?: string @@ -25,10 +25,8 @@ type NodeVariableItemProps = { const i18nPrefix = 'workflow.nodes.assigner' const NodeVariableItem = ({ - isEnv, - isChatVar, node, - varName, + variable, writeMode, showBorder, className, @@ -36,6 +34,12 @@ const NodeVariableItem = ({ }: NodeVariableItemProps) => { const { t } = useTranslation() + const isSystem = isSystemVar(variable) + const isEnv = isENV(variable) + const isChatVar = isConversationVar(variable) + const isRagVar = isRagVariableVar(variable) + const varName = isSystem ? `sys.${variable[variable.length - 1]}` : variable.slice(1).join('.') + const VariableIcon = useMemo(() => { if (isEnv) { return ( @@ -49,6 +53,12 @@ const NodeVariableItem = ({ ) } + if(isRagVar) { + return ( + + ) + } + return ( ) - }, [isEnv, isChatVar, isException]) + }, [isEnv, isChatVar, isRagVar, isException]) const VariableName = useMemo(() => { return ( From a7fa5044e34b4643c085d48d2b6635166132dc5d Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 4 Jun 2025 18:09:03 +0800 Subject: [PATCH 6/6] datasource --- web/app/components/tools/types.ts | 1 + web/app/components/workflow/nodes/data-source/panel.tsx | 6 +++--- web/service/use-pipeline.ts | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/web/app/components/tools/types.ts b/web/app/components/tools/types.ts index 94718b3469..0828506ccd 100644 --- a/web/app/components/tools/types.ts +++ b/web/app/components/tools/types.ts @@ -52,6 +52,7 @@ export type Collection = { plugin_id?: string letter?: string is_authorized?: boolean + provider?: string } export type ToolParameter = { diff --git a/web/app/components/workflow/nodes/data-source/panel.tsx b/web/app/components/workflow/nodes/data-source/panel.tsx index b9c5348bb7..f28e19d919 100644 --- a/web/app/components/workflow/nodes/data-source/panel.tsx +++ b/web/app/components/workflow/nodes/data-source/panel.tsx @@ -71,8 +71,8 @@ const Panel: FC> = ({ id, data }) => { const { mutateAsync } = useUpdateDataSourceCredentials() const handleAuth = useCallback(async (value: any) => { await mutateAsync({ - provider: currentDataSourceItem?.provider, - pluginId: currentDataSourceItem?.plugin_id, + provider: currentDataSource?.provider || '', + pluginId: currentDataSource?.plugin_id || '', credentials: value, }) @@ -81,7 +81,7 @@ const Panel: FC> = ({ id, data }) => { message: t('common.api.actionSuccess'), }) hideAuthModal() - }, [currentDataSourceItem, mutateAsync, notify, t, hideAuthModal]) + }, [currentDataSource, mutateAsync, notify, t, hideAuthModal]) return (
diff --git a/web/service/use-pipeline.ts b/web/service/use-pipeline.ts index 98bb21e19c..f864bd844b 100644 --- a/web/service/use-pipeline.ts +++ b/web/service/use-pipeline.ts @@ -212,12 +212,12 @@ export const useRunPublishedPipeline = ( } export const useDataSourceCredentials = (provider: string, pluginId: string, onSuccess: (value: ToolCredential[]) => void) => { - return useQuery({ + return useQuery({ queryKey: [NAME_SPACE, 'datasource-credentials', provider, pluginId], queryFn: async () => { - const result = await get(`/auth/plugin/datasource?provider=${provider}&plugin_id=${pluginId}`) - onSuccess(result) - return result + const result = await get<{ result: ToolCredential[] }>(`/auth/plugin/datasource?provider=${provider}&plugin_id=${pluginId}`) + onSuccess(result.result) + return result.result }, enabled: !!provider && !!pluginId, retry: 2,