From 9381c08c436555c8fc18399adffccf1336499818 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 13 Aug 2024 17:22:33 +0800 Subject: [PATCH] chore: not use step_boundary field (#7231) --- web/app/components/workflow/run/index.tsx | 49 ++++++----------------- web/app/components/workflow/run/node.tsx | 2 +- web/types/workflow.ts | 3 +- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/web/app/components/workflow/run/index.tsx b/web/app/components/workflow/run/index.tsx index 8b9981346..702ce06e1 100644 --- a/web/app/components/workflow/run/index.tsx +++ b/web/app/components/workflow/run/index.tsx @@ -63,30 +63,25 @@ const RunPanel: FC = ({ hideResult, activeTab = 'RESULT', runID, getRe const formatNodeList = useCallback((list: NodeTracing[]) => { const allItems = list.reverse() const result: NodeTracing[] = [] - let iterationIndexInfos: { - start: number - end: number - }[] = [] + let iterationIndex = 0 allItems.forEach((item) => { - const { node_type, index, execution_metadata } = item + const { node_type, execution_metadata } = item if (node_type !== BlockEnum.Iteration) { - let isInIteration = false - let isIterationFirstNode = false - iterationIndexInfos.forEach(({ start, end }) => { - if (index >= start && index < end) { - if (index === start) - isIterationFirstNode = true + const isInIteration = !!execution_metadata?.iteration_id - isInIteration = true - } - }) if (isInIteration) { const iterationDetails = result[result.length - 1].details! - if (isIterationFirstNode) - iterationDetails!.push([item]) + const currentIterationIndex = execution_metadata?.iteration_index + const isIterationFirstNode = iterationIndex !== currentIterationIndex || iterationDetails.length === 0 - else + if (isIterationFirstNode) { + iterationDetails!.push([item]) + iterationIndex = currentIterationIndex! + } + + else { iterationDetails[iterationDetails.length - 1].push(item) + } return } @@ -96,26 +91,6 @@ const RunPanel: FC = ({ hideResult, activeTab = 'RESULT', runID, getRe return } - const { steps_boundary } = execution_metadata - iterationIndexInfos = [] - steps_boundary.forEach((boundary, index) => { - if (index === 0) { - iterationIndexInfos.push({ - start: boundary, - end: 0, - }) - } - else if (index === steps_boundary.length - 1) { - iterationIndexInfos[iterationIndexInfos.length - 1].end = boundary - } - else { - iterationIndexInfos[iterationIndexInfos.length - 1].end = boundary - iterationIndexInfos.push({ - start: boundary, - end: 0, - }) - } - }) result.push({ ...item, details: [], diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx index f5df961d2..f0f7ec517 100644 --- a/web/app/components/workflow/run/node.tsx +++ b/web/app/components/workflow/run/node.tsx @@ -123,7 +123,7 @@ const NodePanel: FC = ({
-
{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length || (nodeInfo.execution_metadata?.steps_boundary?.length - 1) })}
+
{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length })}
{justShowIterationNavArrow ? ( diff --git a/web/types/workflow.ts b/web/types/workflow.ts index 72475ce55..f7991bc4e 100644 --- a/web/types/workflow.ts +++ b/web/types/workflow.ts @@ -24,7 +24,8 @@ export type NodeTracing = { total_tokens: number total_price: number currency: string - steps_boundary: number[] + iteration_id?: string + iteration_index?: number } metadata: { iterator_length: number