From 3431b19f9ad4adf1ae28e3875b2981715c4c3847 Mon Sep 17 00:00:00 2001 From: Yi Date: Tue, 3 Sep 2024 11:46:04 +0800 Subject: [PATCH] update styling and iteration log --- .../workflow/hooks/use-workflow-run.ts | 29 +++++++++---------- web/app/components/workflow/run/node.tsx | 4 +-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/web/app/components/workflow/hooks/use-workflow-run.ts b/web/app/components/workflow/hooks/use-workflow-run.ts index 83e2a262c5..57e49f92e0 100644 --- a/web/app/components/workflow/hooks/use-workflow-run.ts +++ b/web/app/components/workflow/hooks/use-workflow-run.ts @@ -255,7 +255,7 @@ export const useWorkflowRun = () => { setWorkflowRunningData(produce(workflowRunningData!, (draft) => { const tracing = draft.tracing! const iterations = tracing[tracing.length - 1] - const currIteration = iterations.details![iterations.details!.length - 1] + const currIteration = [iterations.details![iterations.details!.length - 1]] currIteration.push({ ...data, status: NodeRunningStatus.Running, @@ -320,10 +320,6 @@ export const useWorkflowRun = () => { if (iterations && iterations.details) { const iterationIndex = data.execution_metadata?.iteration_index || 0 - // console.log(`the current iteration index is ${iterationIndex}`) - - // console.log(JSON.parse(JSON.stringify(iterations.details))) - if (!iterations.details[iterationIndex]) iterations.details[iterationIndex] = [] @@ -331,17 +327,18 @@ export const useWorkflowRun = () => { const nodeIndex = currIteration.findIndex(node => node.node_id === data.node_id, ) - - if (nodeIndex !== -1) { - currIteration[nodeIndex] = { - ...(currIteration[nodeIndex].extras ? { extras: currIteration[nodeIndex].extras } : {}), - ...data, - } as any - } - else { - currIteration.push({ - ...data, - } as any) + if (data.status === NodeRunningStatus.Succeeded) { + if (nodeIndex !== -1) { + currIteration[nodeIndex] = { + ...currIteration[nodeIndex], + ...data, + } as any + } + else { + currIteration.push({ + ...data, + } as any) + } } } })) diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx index 2e1f9bb7e9..fdfc48bf5a 100644 --- a/web/app/components/workflow/run/node.tsx +++ b/web/app/components/workflow/run/node.tsx @@ -99,13 +99,13 @@ const NodePanel: FC = ({ hideInfo && '!text-xs', )} title={nodeInfo.title}>{nodeInfo.title} {nodeInfo.status !== 'running' && !hideInfo && ( -
{`${getTime(nodeInfo.elapsed_time || 0)} · ${getTokenCount(nodeInfo.execution_metadata?.total_tokens || 0)} tokens`}
+
{nodeInfo.execution_metadata?.total_tokens ? `${getTokenCount(nodeInfo.execution_metadata?.total_tokens || 0)} tokens · ` : ''}{`${getTime(nodeInfo.elapsed_time || 0)}`}
)} {nodeInfo.status === 'succeeded' && ( )} {nodeInfo.status === 'failed' && ( - + )} {nodeInfo.status === 'stopped' && (