From 564692727b90bdb087e3c115f86c67bd68d98827 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Thu, 2 Jan 2025 09:33:50 -0800 Subject: [PATCH] Add workflow run cost (#1467) --- skyvern-frontend/src/api/types.ts | 2 ++ .../workflowRun/WorkflowRunOverview.tsx | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts index 74e7d745..c67bb49d 100644 --- a/skyvern-frontend/src/api/types.ts +++ b/skyvern-frontend/src/api/types.ts @@ -211,6 +211,8 @@ export type WorkflowRunStatusApiResponse = { outputs: Record | null; failure_reason: string | null; downloaded_file_urls: Array | null; + total_steps: number | null; + total_cost: number | null; }; export type TaskGenerationApiResponse = { diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx index 143c9838..36923f8f 100644 --- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx +++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOverview.tsx @@ -12,6 +12,7 @@ import { isActionItem, isBlockItem, isObserverThought, + isTaskVariantBlockItem, isThoughtItem, isWorkflowRunBlock, ObserverThought, @@ -25,6 +26,11 @@ import { ObserverThoughtScreenshot } from "./ObserverThoughtScreenshot"; import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area"; import { WorkflowRunBlockScreenshot } from "./WorkflowRunBlockScreenshot"; +const formatter = Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", +}); + export type ActionItem = { block: WorkflowRunBlock; action: ActionsApiResponse; @@ -92,6 +98,13 @@ function WorkflowRunOverview() { const selection = getActiveSelection(); + const numberOfActions = workflowRunTimeline.reduce((total, current) => { + if (isTaskVariantBlockItem(current)) { + return total + current.block!.actions!.length; + } + return total + 0; + }, 0); + return (
@@ -117,11 +130,21 @@ function WorkflowRunOverview() {
-
+
+
+
+ Actions: {numberOfActions} +
+
+ Steps: {workflowRun.total_steps ?? 0} +
+
+ Cost: {formatter.format(workflowRun.total_cost ?? 0)} +
+
- +
-
{workflowRunIsNotFinalized && (