From e3ae529a55977a9590ce292cf8ec7048a0d42164 Mon Sep 17 00:00:00 2001 From: Yi Date: Fri, 30 Aug 2024 17:00:02 +0800 Subject: [PATCH] update the onNodeFinished method for nodes being passed through more than once --- web/app/components/workflow/hooks/use-workflow-run.ts | 7 ++++++- .../components/workflow/panel/debug-and-preview/hooks.ts | 7 ++++++- web/types/workflow.ts | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/web/app/components/workflow/hooks/use-workflow-run.ts b/web/app/components/workflow/hooks/use-workflow-run.ts index af08baeceb..e60a356cb2 100644 --- a/web/app/components/workflow/hooks/use-workflow-run.ts +++ b/web/app/components/workflow/hooks/use-workflow-run.ts @@ -329,7 +329,12 @@ export const useWorkflowRun = () => { else { const nodes = getNodes() setWorkflowRunningData(produce(workflowRunningData!, (draft) => { - const currentIndex = draft.tracing!.findIndex(trace => trace.node_id === data.node_id) + const currentIndex = draft.tracing!.findIndex((trace) => { + if (!trace.execution_metadata?.parallel_id) + return trace.node_id === data.node_id + + return trace.node_id === data.node_id && trace.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id + }) if (currentIndex > -1 && draft.tracing) { draft.tracing[currentIndex] = { diff --git a/web/app/components/workflow/panel/debug-and-preview/hooks.ts b/web/app/components/workflow/panel/debug-and-preview/hooks.ts index 155d2a84ac..b46711e37d 100644 --- a/web/app/components/workflow/panel/debug-and-preview/hooks.ts +++ b/web/app/components/workflow/panel/debug-and-preview/hooks.ts @@ -382,7 +382,12 @@ export const useChat = ( })) } else { - const currentIndex = responseItem.workflowProcess!.tracing!.findIndex(item => item.node_id === data.node_id) + const currentIndex = responseItem.workflowProcess!.tracing!.findIndex((item) => { + if (!item.execution_metadata?.parallel_id) + return item.node_id === data.node_id + + return item.node_id === data.node_id && item.execution_metadata?.parallel_id === data.execution_metadata?.parallel_id + }) responseItem.workflowProcess!.tracing[currentIndex] = { ...(responseItem.workflowProcess!.tracing[currentIndex].extras ? { extras: responseItem.workflowProcess!.tracing[currentIndex].extras } diff --git a/web/types/workflow.ts b/web/types/workflow.ts index 2550f77201..535595b9ad 100644 --- a/web/types/workflow.ts +++ b/web/types/workflow.ts @@ -144,6 +144,7 @@ export type NodeFinishedResponse = { total_tokens: number total_price: number currency: string + parallel_id?: string } created_at: number }