diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-main.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-main.tsx index 82c80684b8..5daf1f2ceb 100644 --- a/web/app/components/rag-pipeline/components/rag-pipeline-main.tsx +++ b/web/app/components/rag-pipeline/components/rag-pipeline-main.tsx @@ -15,6 +15,9 @@ import { usePipelineStartRun, } from '../hooks' import { useWorkflowStore } from '@/app/components/workflow/store' +import { useConfigsMap } from '../hooks/use-configs-map' +import { useSetWorkflowVarsWithValue } from '@/app/components/workflow/hooks/use-fetch-workflow-inspect-vars' +import { useInspectVarsCrud } from '../hooks/use-inspect-vars-crud' type RagPipelineMainProps = Pick const RagPipelineMain = ({ @@ -62,6 +65,27 @@ const RagPipelineMain = ({ handleExportDSL, } = useDSL() + const configsMap = useConfigsMap() + const { fetchInspectVars } = useSetWorkflowVarsWithValue({ + ...configsMap, + }) + const { + hasNodeInspectVars, + hasSetInspectVar, + fetchInspectVarValue, + editInspectVarValue, + renameInspectVarName, + appendNodeInspectVars, + deleteInspectVar, + deleteNodeInspectorVars, + deleteAllInspectorVars, + isInspectVarEdited, + resetToLastRunVar, + invalidateSysVarValues, + resetConversationVar, + invalidateConversationVarValues, + } = useInspectVarsCrud() + const hooksStore = useMemo(() => { return { availableNodesMetaData, @@ -78,6 +102,22 @@ const RagPipelineMain = ({ getWorkflowRunAndTraceUrl, exportCheck, handleExportDSL, + fetchInspectVars, + hasNodeInspectVars, + hasSetInspectVar, + fetchInspectVarValue, + editInspectVarValue, + renameInspectVarName, + appendNodeInspectVars, + deleteInspectVar, + deleteNodeInspectorVars, + deleteAllInspectorVars, + isInspectVarEdited, + resetToLastRunVar, + invalidateSysVarValues, + resetConversationVar, + invalidateConversationVarValues, + configsMap, } }, [ availableNodesMetaData, @@ -94,6 +134,22 @@ const RagPipelineMain = ({ getWorkflowRunAndTraceUrl, exportCheck, handleExportDSL, + fetchInspectVars, + hasNodeInspectVars, + hasSetInspectVar, + fetchInspectVarValue, + editInspectVarValue, + renameInspectVarName, + appendNodeInspectVars, + deleteInspectVar, + deleteNodeInspectorVars, + deleteAllInspectorVars, + isInspectVarEdited, + resetToLastRunVar, + invalidateSysVarValues, + resetConversationVar, + invalidateConversationVarValues, + configsMap, ]) return ( diff --git a/web/app/components/rag-pipeline/hooks/use-configs-map.ts b/web/app/components/rag-pipeline/hooks/use-configs-map.ts new file mode 100644 index 0000000000..537d6f253a --- /dev/null +++ b/web/app/components/rag-pipeline/hooks/use-configs-map.ts @@ -0,0 +1,13 @@ +import { useMemo } from 'react' +import { useStore } from '@/app/components/workflow/store' +import { FlowType } from '@/types/common' + +export const useConfigsMap = () => { + const pipelineId = useStore(s => s.pipelineId) + return useMemo(() => { + return { + flowId: pipelineId!, + flowType: FlowType.ragPipeline, + } + }, [pipelineId]) +} diff --git a/web/app/components/rag-pipeline/hooks/use-inspect-vars-crud.ts b/web/app/components/rag-pipeline/hooks/use-inspect-vars-crud.ts new file mode 100644 index 0000000000..48c65e6b30 --- /dev/null +++ b/web/app/components/rag-pipeline/hooks/use-inspect-vars-crud.ts @@ -0,0 +1,13 @@ +import { useInspectVarsCrudCommon } from '../../workflow/hooks/use-inspect-vars-crud-common' +import { useConfigsMap } from './use-configs-map' + +export const useInspectVarsCrud = () => { + const configsMap = useConfigsMap() + const apis = useInspectVarsCrudCommon({ + ...configsMap, + }) + + return { + ...apis, + } +} diff --git a/web/app/components/workflow-app/components/workflow-main.tsx b/web/app/components/workflow-app/components/workflow-main.tsx index af8488e640..f979a12f26 100644 --- a/web/app/components/workflow-app/components/workflow-main.tsx +++ b/web/app/components/workflow-app/components/workflow-main.tsx @@ -73,8 +73,10 @@ const WorkflowMain = ({ exportCheck, handleExportDSL, } = useDSL() + + const configsMap = useConfigsMap() const { fetchInspectVars } = useSetWorkflowVarsWithValue({ - ...useConfigsMap(), + ...configsMap, }) const { hasNodeInspectVars, @@ -92,7 +94,6 @@ const WorkflowMain = ({ resetConversationVar, invalidateConversationVarValues, } = useInspectVarsCrud() - const configsMap = useConfigsMap() const hooksStore = useMemo(() => { return { diff --git a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts index ab38bf0446..c922192267 100644 --- a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts +++ b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts @@ -4,12 +4,14 @@ import { useConversationVarValues, useSysVarValues, } from '@/service/use-workflow' +import { FlowType } from '@/types/common' const useInspectVarsCrud = () => { const nodesWithInspectVars = useStore(s => s.nodesWithInspectVars) const configsMap = useHooksStore(s => s.configsMap) - const { data: conversationVars } = useConversationVarValues(configsMap?.flowType, configsMap?.flowId) - const { data: systemVars } = useSysVarValues(configsMap?.flowType, configsMap?.flowId) + const isRagPipeline = configsMap?.flowType === FlowType.ragPipeline + const { data: conversationVars } = useConversationVarValues(configsMap?.flowType, !isRagPipeline ? configsMap?.flowId : '') + const { data: systemVars } = useSysVarValues(configsMap?.flowType, !isRagPipeline ? configsMap?.flowId : '') const hasNodeInspectVars = useHooksStore(s => s.hasNodeInspectVars) const hasSetInspectVar = useHooksStore(s => s.hasSetInspectVar) const fetchInspectVarValue = useHooksStore(s => s.fetchInspectVarValue) diff --git a/web/service/utils.ts b/web/service/utils.ts index 7700f62582..6d0c3ca88e 100644 --- a/web/service/utils.ts +++ b/web/service/utils.ts @@ -2,7 +2,7 @@ import { FlowType } from '@/types/common' export const flowPrefixMap = { [FlowType.appFlow]: 'apps', - [FlowType.ragFlow]: 'rag/pipelines', + [FlowType.ragPipeline]: 'rag/pipelines', } export const getFlowPrefix = (type?: FlowType) => { diff --git a/web/types/common.ts b/web/types/common.ts index 9f55b740a8..19bc8acc8d 100644 --- a/web/types/common.ts +++ b/web/types/common.ts @@ -1,4 +1,4 @@ export enum FlowType { appFlow = 'appFlow', - ragFlow = 'ragFlow', + ragPipeline = 'ragPipeline', }