Skip to content

Automate browser based workflows with AI

Add workflow run cost (#1467)

Shuchang Zheng564692727b90
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index 74e7d7459..c67bb49de 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -211,6 +211,8 @@ export type WorkflowRunStatusApiResponse = {
outputs: Record<string, unknown> | null;
failure_reason: string | null;
downloaded_file_urls: Array<string> | 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 143c98382..36923f8ff 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 (
<div className="flex h-[42rem] gap-6">
<div className="w-2/3 space-y-4">
@@ -117,11 +130,21 @@ function WorkflowRunOverview() {
<WorkflowRunTimelineItemInfoSection activeItem={selection} />
</div>
- <div className="w-1/3 min-w-0 rounded bg-slate-elevation1 p-4">
+ <div className="w-1/3 min-w-0 space-y-4 rounded bg-slate-elevation1 p-4">
+ <div className="grid grid-cols-3 gap-2">
+ <div className="flex items-center justify-center rounded bg-slate-elevation3 px-4 py-3 text-xs">
+ Actions: {numberOfActions}
+ </div>
+ <div className="flex items-center justify-center rounded bg-slate-elevation3 px-4 py-3 text-xs">
+ Steps: {workflowRun.total_steps ?? 0}
+ </div>
+ <div className="flex items-center justify-center rounded bg-slate-elevation3 px-4 py-3 text-xs">
+ Cost: {formatter.format(workflowRun.total_cost ?? 0)}
+ </div>
+ </div>
<ScrollArea>
- <ScrollAreaViewport className="max-h-[40rem]">
+ <ScrollAreaViewport className="max-h-[37rem]">
<div className="space-y-4">
- <div className="gap-2"></div>
{workflowRunIsNotFinalized && (
<div
key="stream"