| @@ -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<WorkflowProps, 'nodes' | 'edges' | 'viewport'> | |||
| 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 ( | |||
| @@ -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]) | |||
| } | |||
| @@ -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, | |||
| } | |||
| } | |||
| @@ -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 { | |||
| @@ -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) | |||
| @@ -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) => { | |||
| @@ -1,4 +1,4 @@ | |||
| export enum FlowType { | |||
| appFlow = 'appFlow', | |||
| ragFlow = 'ragFlow', | |||
| ragPipeline = 'ragPipeline', | |||
| } | |||