Add workflow run cost (#1467)
This commit is contained in:
@@ -211,6 +211,8 @@ export type WorkflowRunStatusApiResponse = {
|
|||||||
outputs: Record<string, unknown> | null;
|
outputs: Record<string, unknown> | null;
|
||||||
failure_reason: string | null;
|
failure_reason: string | null;
|
||||||
downloaded_file_urls: Array<string> | null;
|
downloaded_file_urls: Array<string> | null;
|
||||||
|
total_steps: number | null;
|
||||||
|
total_cost: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TaskGenerationApiResponse = {
|
export type TaskGenerationApiResponse = {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
isActionItem,
|
isActionItem,
|
||||||
isBlockItem,
|
isBlockItem,
|
||||||
isObserverThought,
|
isObserverThought,
|
||||||
|
isTaskVariantBlockItem,
|
||||||
isThoughtItem,
|
isThoughtItem,
|
||||||
isWorkflowRunBlock,
|
isWorkflowRunBlock,
|
||||||
ObserverThought,
|
ObserverThought,
|
||||||
@@ -25,6 +26,11 @@ import { ObserverThoughtScreenshot } from "./ObserverThoughtScreenshot";
|
|||||||
import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollAreaViewport } from "@/components/ui/scroll-area";
|
||||||
import { WorkflowRunBlockScreenshot } from "./WorkflowRunBlockScreenshot";
|
import { WorkflowRunBlockScreenshot } from "./WorkflowRunBlockScreenshot";
|
||||||
|
|
||||||
|
const formatter = Intl.NumberFormat("en-US", {
|
||||||
|
style: "currency",
|
||||||
|
currency: "USD",
|
||||||
|
});
|
||||||
|
|
||||||
export type ActionItem = {
|
export type ActionItem = {
|
||||||
block: WorkflowRunBlock;
|
block: WorkflowRunBlock;
|
||||||
action: ActionsApiResponse;
|
action: ActionsApiResponse;
|
||||||
@@ -92,6 +98,13 @@ function WorkflowRunOverview() {
|
|||||||
|
|
||||||
const selection = getActiveSelection();
|
const selection = getActiveSelection();
|
||||||
|
|
||||||
|
const numberOfActions = workflowRunTimeline.reduce((total, current) => {
|
||||||
|
if (isTaskVariantBlockItem(current)) {
|
||||||
|
return total + current.block!.actions!.length;
|
||||||
|
}
|
||||||
|
return total + 0;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-[42rem] gap-6">
|
<div className="flex h-[42rem] gap-6">
|
||||||
<div className="w-2/3 space-y-4">
|
<div className="w-2/3 space-y-4">
|
||||||
@@ -117,11 +130,21 @@ function WorkflowRunOverview() {
|
|||||||
|
|
||||||
<WorkflowRunTimelineItemInfoSection activeItem={selection} />
|
<WorkflowRunTimelineItemInfoSection activeItem={selection} />
|
||||||
</div>
|
</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>
|
<ScrollArea>
|
||||||
<ScrollAreaViewport className="max-h-[40rem]">
|
<ScrollAreaViewport className="max-h-[37rem]">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="gap-2"></div>
|
|
||||||
{workflowRunIsNotFinalized && (
|
{workflowRunIsNotFinalized && (
|
||||||
<div
|
<div
|
||||||
key="stream"
|
key="stream"
|
||||||
|
|||||||
Reference in New Issue
Block a user