Fix extracted information bug (#2095)
Co-authored-by: Muhammed Salih Altun <muhammedsalihaltun@gmail.com>
This commit is contained in:
@@ -35,7 +35,6 @@ 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 { Label } from "@/components/ui/label";
|
||||||
import { CodeEditor } from "./components/CodeEditor";
|
import { CodeEditor } from "./components/CodeEditor";
|
||||||
import { cn } from "@/util/utils";
|
import { cn } from "@/util/utils";
|
||||||
@@ -138,13 +137,16 @@ function WorkflowRun() {
|
|||||||
const isTaskv2Run = workflowRun && workflowRun.task_v2 !== null;
|
const isTaskv2Run = workflowRun && workflowRun.task_v2 !== null;
|
||||||
|
|
||||||
const outputs = workflowRun?.outputs;
|
const outputs = workflowRun?.outputs;
|
||||||
const aggregatedExtractedInformation = getAggregatedExtractedInformation(
|
const extractedInformation =
|
||||||
outputs ?? {},
|
typeof outputs === "object" &&
|
||||||
);
|
outputs !== null &&
|
||||||
|
"extracted_information" in outputs
|
||||||
|
? (outputs.extracted_information as Record<string, unknown>)
|
||||||
|
: null;
|
||||||
|
|
||||||
const hasSomeExtractedInformation = Object.values(
|
const hasSomeExtractedInformation = extractedInformation
|
||||||
aggregatedExtractedInformation,
|
? Object.values(extractedInformation).some((value) => value !== null)
|
||||||
).some((value) => value !== null);
|
: false;
|
||||||
|
|
||||||
const hasTaskv2Output = Boolean(isTaskv2Run && workflowRun.task_v2?.output);
|
const hasTaskv2Output = Boolean(isTaskv2Run && workflowRun.task_v2?.output);
|
||||||
|
|
||||||
@@ -282,7 +284,7 @@ function WorkflowRun() {
|
|||||||
value={
|
value={
|
||||||
hasTaskv2Output
|
hasTaskv2Output
|
||||||
? JSON.stringify(workflowRun.task_v2?.output, null, 2)
|
? JSON.stringify(workflowRun.task_v2?.output, null, 2)
|
||||||
: JSON.stringify(aggregatedExtractedInformation, null, 2)
|
: JSON.stringify(extractedInformation, null, 2)
|
||||||
}
|
}
|
||||||
readOnly
|
readOnly
|
||||||
maxHeight="250px"
|
maxHeight="250px"
|
||||||
|
|||||||
@@ -12,16 +12,6 @@ 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 formatExtractedInformation(outputs: Record<string, unknown>) {
|
|
||||||
const aggregateExtractedInformation =
|
|
||||||
getAggregatedExtractedInformation(outputs);
|
|
||||||
return {
|
|
||||||
extracted_information: aggregateExtractedInformation,
|
|
||||||
...outputs,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function WorkflowRunOutput() {
|
function WorkflowRunOutput() {
|
||||||
const { data: workflowRunTimeline, isLoading: workflowRunTimelineIsLoading } =
|
const { data: workflowRunTimeline, isLoading: workflowRunTimelineIsLoading } =
|
||||||
@@ -60,9 +50,6 @@ function WorkflowRunOutput() {
|
|||||||
activeBlock.status === Status.Completed;
|
activeBlock.status === Status.Completed;
|
||||||
|
|
||||||
const outputs = workflowRun?.outputs;
|
const outputs = workflowRun?.outputs;
|
||||||
const formattedOutputs = outputs
|
|
||||||
? formatExtractedInformation(outputs)
|
|
||||||
: outputs;
|
|
||||||
const fileUrls = workflowRun?.downloaded_file_urls ?? [];
|
const fileUrls = workflowRun?.downloaded_file_urls ?? [];
|
||||||
const observerOutput = workflowRun?.task_v2?.output;
|
const observerOutput = workflowRun?.task_v2?.output;
|
||||||
|
|
||||||
@@ -140,9 +127,7 @@ function WorkflowRunOutput() {
|
|||||||
<h1 className="text-lg font-bold">Workflow Run Outputs</h1>
|
<h1 className="text-lg font-bold">Workflow Run Outputs</h1>
|
||||||
<CodeEditor
|
<CodeEditor
|
||||||
language="json"
|
language="json"
|
||||||
value={
|
value={outputs ? JSON.stringify(outputs, null, 2) : ""}
|
||||||
formattedOutputs ? JSON.stringify(formattedOutputs, null, 2) : ""
|
|
||||||
}
|
|
||||||
readOnly
|
readOnly
|
||||||
minHeight="96px"
|
minHeight="96px"
|
||||||
maxHeight="200px"
|
maxHeight="200px"
|
||||||
|
|||||||
Reference in New Issue
Block a user