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 cf9b9744e9..82c80684b8 100644 --- a/web/app/components/rag-pipeline/components/rag-pipeline-main.tsx +++ b/web/app/components/rag-pipeline/components/rag-pipeline-main.tsx @@ -1,4 +1,5 @@ import { + useCallback, useMemo, } from 'react' import { WorkflowWithInnerContext } from '@/app/components/workflow' @@ -13,6 +14,7 @@ import { usePipelineRun, usePipelineStartRun, } from '../hooks' +import { useWorkflowStore } from '@/app/components/workflow/store' type RagPipelineMainProps = Pick const RagPipelineMain = ({ @@ -20,6 +22,23 @@ const RagPipelineMain = ({ edges, viewport, }: RagPipelineMainProps) => { + const workflowStore = useWorkflowStore() + + const handleWorkflowDataUpdate = useCallback((payload: any) => { + const { + rag_pipeline_variables, + environment_variables, + } = payload + if (rag_pipeline_variables) { + const { setRagPipelineVariables } = workflowStore.getState() + setRagPipelineVariables?.(rag_pipeline_variables) + } + if (environment_variables) { + const { setEnvironmentVariables } = workflowStore.getState() + setEnvironmentVariables(environment_variables) + } + }, [workflowStore]) + const { doSyncWorkflowDraft, syncWorkflowDraftWhenPageClose, @@ -83,6 +102,7 @@ const RagPipelineMain = ({ edges={edges} viewport={viewport} hooksStore={hooksStore as any} + onWorkflowDataUpdate={handleWorkflowDataUpdate} >