From 4c30d1c1eb859befa0272aefa361c58e60a391aa Mon Sep 17 00:00:00 2001 From: twwu Date: Tue, 13 May 2025 16:33:38 +0800 Subject: [PATCH] feat: Enhance InputFieldDialog and workflow hooks to handle ragPipelineVariables --- .../components/input-field/index.tsx | 18 +++++++++++------- .../rag-pipeline/hooks/use-nodes-sync-draft.ts | 2 ++ .../rag-pipeline/hooks/use-pipeline-init.ts | 2 ++ web/types/workflow.ts | 2 ++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/web/app/components/rag-pipeline/components/input-field/index.tsx b/web/app/components/rag-pipeline/components/input-field/index.tsx index f3fd87388b..bd8b0fbba7 100644 --- a/web/app/components/rag-pipeline/components/input-field/index.tsx +++ b/web/app/components/rag-pipeline/components/input-field/index.tsx @@ -95,6 +95,8 @@ const InputFieldDialog = ({ { datasourceKeys.map((key) => { const inputFields = inputFieldsMap[key] || [] + if (!inputFields.length) + return null return ( } @@ -107,13 +109,15 @@ const InputFieldDialog = ({ }) } {/* Shared Inputs */} - } - inputFields={inputFieldsMap.shared || []} - readonly={readonly} - labelClassName='pt-1 pb-2' - handleInputFieldsChange={updateInputFields.bind(null, '')} - /> + {inputFieldsMap.shared?.length > 0 && ( + } + inputFields={inputFieldsMap.shared} + readonly={readonly} + labelClassName='pt-1 pb-2' + handleInputFieldsChange={updateInputFields.bind(null, '')} + /> + )} diff --git a/web/app/components/rag-pipeline/hooks/use-nodes-sync-draft.ts b/web/app/components/rag-pipeline/hooks/use-nodes-sync-draft.ts index 30b0ced0ab..58ef594df4 100644 --- a/web/app/components/rag-pipeline/hooks/use-nodes-sync-draft.ts +++ b/web/app/components/rag-pipeline/hooks/use-nodes-sync-draft.ts @@ -24,6 +24,7 @@ export const useNodesSyncDraft = () => { pipelineId, environmentVariables, syncWorkflowDraftHash, + ragPipelineVariables, } = workflowStore.getState() if (pipelineId) { @@ -58,6 +59,7 @@ export const useNodesSyncDraft = () => { }, }, environment_variables: environmentVariables, + rag_pipeline_variables: ragPipelineVariables, hash: syncWorkflowDraftHash, }, } diff --git a/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts b/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts index ab1ee1ea59..327a9f6ce4 100644 --- a/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts +++ b/web/app/components/rag-pipeline/hooks/use-pipeline-init.ts @@ -38,6 +38,7 @@ export const usePipelineInit = () => { setSyncWorkflowDraftHash, setDraftUpdatedAt, setToolPublished, + setRagPipelineVariables, } = workflowStore.getState() try { const res = await fetchWorkflowDraft(`/rag/pipeline/${datasetId}/workflows/draft`) @@ -50,6 +51,7 @@ export const usePipelineInit = () => { }, {} as Record)) setEnvironmentVariables(res.environment_variables?.map(env => env.value_type === 'secret' ? { ...env, value: '[__HIDDEN__]' } : env) || []) setSyncWorkflowDraftHash(res.hash) + setRagPipelineVariables?.(res.rag_pipeline_variables || []) setIsLoading(false) } catch (error: any) { diff --git a/web/types/workflow.ts b/web/types/workflow.ts index d5b1226d03..53340f8cf1 100644 --- a/web/types/workflow.ts +++ b/web/types/workflow.ts @@ -2,6 +2,7 @@ import type { Viewport } from 'reactflow' import type { BlockEnum, ConversationVariable, Edge, EnvironmentVariable, Node } from '@/app/components/workflow/types' import type { TransferMethod } from '@/types/app' import type { ErrorHandleTypeEnum } from '@/app/components/workflow/nodes/_base/components/error-handle/types' +import type { RAGPipelineVariables } from '@/models/pipeline' export type AgentLogItem = { node_execution_id: string, @@ -120,6 +121,7 @@ export type FetchWorkflowDraftResponse = { tool_published: boolean environment_variables?: EnvironmentVariable[] conversation_variables?: ConversationVariable[] + rag_pipeline_variables?: RAGPipelineVariables version: string marked_name: string marked_comment: string