show outputs in workflow main page (#1982)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { getClient } from "@/api/AxiosClient";
|
import { getClient } from "@/api/AxiosClient";
|
||||||
import { ProxyLocation } from "@/api/types";
|
import { ProxyLocation, Status } from "@/api/types";
|
||||||
import { StatusBadge } from "@/components/StatusBadge";
|
import { StatusBadge } from "@/components/StatusBadge";
|
||||||
import { SwitchBarNavigation } from "@/components/SwitchBarNavigation";
|
import { SwitchBarNavigation } from "@/components/SwitchBarNavigation";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -21,6 +21,7 @@ import { copyText } from "@/util/copyText";
|
|||||||
import { apiBaseUrl } from "@/util/env";
|
import { apiBaseUrl } from "@/util/env";
|
||||||
import {
|
import {
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
|
FileIcon,
|
||||||
Pencil2Icon,
|
Pencil2Icon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
ReloadIcon,
|
ReloadIcon,
|
||||||
@@ -34,6 +35,9 @@ import { useWorkflowRunQuery } from "./hooks/useWorkflowRunQuery";
|
|||||||
import { WorkflowRunTimeline } from "./workflowRun/WorkflowRunTimeline";
|
import { WorkflowRunTimeline } from "./workflowRun/WorkflowRunTimeline";
|
||||||
import { useWorkflowRunTimelineQuery } from "./hooks/useWorkflowRunTimelineQuery";
|
import { useWorkflowRunTimelineQuery } from "./hooks/useWorkflowRunTimelineQuery";
|
||||||
import { findActiveItem } from "./workflowRun/workflowTimelineUtils";
|
import { findActiveItem } from "./workflowRun/workflowTimelineUtils";
|
||||||
|
import { getAggregatedExtractedInformation } from "./workflowRun/workflowRunUtils";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { CodeEditor } from "./components/CodeEditor";
|
||||||
|
|
||||||
function WorkflowRun() {
|
function WorkflowRun() {
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
@@ -128,6 +132,13 @@ function WorkflowRun() {
|
|||||||
|
|
||||||
const isTaskv2Run = workflowRun && workflowRun.task_v2 !== null;
|
const isTaskv2Run = workflowRun && workflowRun.task_v2 !== null;
|
||||||
|
|
||||||
|
const outputs = workflowRun?.outputs;
|
||||||
|
const aggregatedExtractedInformation = getAggregatedExtractedInformation(
|
||||||
|
outputs ?? {},
|
||||||
|
);
|
||||||
|
|
||||||
|
const fileUrls = workflowRun?.downloaded_file_urls ?? [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
<header className="flex justify-between">
|
<header className="flex justify-between">
|
||||||
@@ -229,6 +240,38 @@ function WorkflowRun() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
{workflowRunIsFinalized && workflowRun.status === Status.Completed && (
|
||||||
|
<div className="grid grid-cols-2 gap-4 rounded-lg bg-slate-elevation1 p-4">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Label>Extracted Information</Label>
|
||||||
|
<CodeEditor
|
||||||
|
language="json"
|
||||||
|
value={JSON.stringify(aggregatedExtractedInformation, null, 2)}
|
||||||
|
readOnly
|
||||||
|
maxHeight="250px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Label>Downloaded Files</Label>
|
||||||
|
<div className="space-y-2">
|
||||||
|
{fileUrls.length > 0 ? (
|
||||||
|
fileUrls.map((url, index) => {
|
||||||
|
return (
|
||||||
|
<div key={url} title={url} className="flex gap-2">
|
||||||
|
<FileIcon className="size-6" />
|
||||||
|
<a href={url} className="underline underline-offset-4">
|
||||||
|
<span>{`File ${index + 1}`}</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<div className="text-sm">No files downloaded</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{workflowFailureReason}
|
{workflowFailureReason}
|
||||||
<SwitchBarNavigation
|
<SwitchBarNavigation
|
||||||
options={[
|
options={[
|
||||||
|
|||||||
@@ -12,20 +12,7 @@ import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuer
|
|||||||
import { Status } from "@/api/types";
|
import { Status } from "@/api/types";
|
||||||
import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";
|
import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";
|
||||||
import { isTaskVariantBlock } from "../types/workflowTypes";
|
import { isTaskVariantBlock } from "../types/workflowTypes";
|
||||||
|
import { getAggregatedExtractedInformation } from "./workflowRunUtils";
|
||||||
function getAggregatedExtractedInformation(outputs: Record<string, unknown>) {
|
|
||||||
const extractedInformation: Record<string, unknown> = {};
|
|
||||||
Object.entries(outputs).forEach(([id, output]) => {
|
|
||||||
if (
|
|
||||||
typeof output === "object" &&
|
|
||||||
output !== null &&
|
|
||||||
"extracted_information" in output
|
|
||||||
) {
|
|
||||||
extractedInformation[id] = output.extracted_information;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return extractedInformation;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatExtractedInformation(outputs: Record<string, unknown>) {
|
function formatExtractedInformation(outputs: Record<string, unknown>) {
|
||||||
const aggregateExtractedInformation =
|
const aggregateExtractedInformation =
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
export function getAggregatedExtractedInformation(
|
||||||
|
outputs: Record<string, unknown>,
|
||||||
|
) {
|
||||||
|
const extractedInformation: Record<string, unknown> = {};
|
||||||
|
Object.entries(outputs).forEach(([id, output]) => {
|
||||||
|
if (
|
||||||
|
typeof output === "object" &&
|
||||||
|
output !== null &&
|
||||||
|
"extracted_information" in output
|
||||||
|
) {
|
||||||
|
extractedInformation[id] = output.extracted_information;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return extractedInformation;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user