From c3c6a480594a843244672496f6b551760c481ad0 Mon Sep 17 00:00:00 2001 From: "suzuki.sh" Date: Mon, 9 Dec 2024 16:02:04 +0900 Subject: [PATCH] Fix the token count at the iteration node (#11235) Co-authored-by: -LAN- --- api/core/workflow/nodes/iteration/iteration_node.py | 5 ++++- web/app/(commonLayout)/apps/AppCard.tsx | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/core/workflow/nodes/iteration/iteration_node.py b/api/core/workflow/nodes/iteration/iteration_node.py index 74ec95deaaeb02..75a2fb78a2700b 100644 --- a/api/core/workflow/nodes/iteration/iteration_node.py +++ b/api/core/workflow/nodes/iteration/iteration_node.py @@ -242,7 +242,10 @@ def _run(self) -> Generator[NodeEvent | InNodeEvent, None, None]: run_result=NodeRunResult( status=WorkflowNodeExecutionStatus.SUCCEEDED, outputs={"output": outputs}, - metadata={NodeRunMetadataKey.ITERATION_DURATION_MAP: iter_run_map}, + metadata={ + NodeRunMetadataKey.ITERATION_DURATION_MAP: iter_run_map, + NodeRunMetadataKey.TOTAL_TOKENS: graph_engine.graph_runtime_state.total_tokens, + }, ) ) except IterationNodeError as e: diff --git a/web/app/(commonLayout)/apps/AppCard.tsx b/web/app/(commonLayout)/apps/AppCard.tsx index 4d1537d38dbccd..fa5bcb596a214a 100644 --- a/web/app/(commonLayout)/apps/AppCard.tsx +++ b/web/app/(commonLayout)/apps/AppCard.tsx @@ -9,8 +9,7 @@ import s from './style.module.css' import cn from '@/utils/classnames' import type { App } from '@/types/app' import Confirm from '@/app/components/base/confirm' -import Toast from '@/app/components/base/toast' -import { ToastContext } from '@/app/components/base/toast' +import Toast, { ToastContext } from '@/app/components/base/toast' import { copyApp, deleteApp, exportAppConfig, updateAppInfo } from '@/service/apps' import DuplicateAppModal from '@/app/components/app/duplicate-modal' import type { DuplicateAppModalProps } from '@/app/components/app/duplicate-modal'