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 { useWorkflowRunTimelineQuery } from "./hooks/useWorkflowRunTimelineQuery";
|
||||
import { findActiveItem } from "./workflowRun/workflowTimelineUtils";
|
||||
import { getAggregatedExtractedInformation } from "./workflowRun/workflowRunUtils";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { CodeEditor } from "./components/CodeEditor";
|
||||
import { cn } from "@/util/utils";
|
||||
@@ -138,13 +137,16 @@ function WorkflowRun() {
|
||||
const isTaskv2Run = workflowRun && workflowRun.task_v2 !== null;
|
||||
|
||||
const outputs = workflowRun?.outputs;
|
||||
const aggregatedExtractedInformation = getAggregatedExtractedInformation(
|
||||
outputs ?? {},
|
||||
);
|
||||
const extractedInformation =
|
||||
typeof outputs === "object" &&
|
||||
outputs !== null &&
|
||||
"extracted_information" in outputs
|
||||
? (outputs.extracted_information as Record<string, unknown>)
|
||||
: null;
|
||||
|
||||
const hasSomeExtractedInformation = Object.values(
|
||||
aggregatedExtractedInformation,
|
||||
).some((value) => value !== null);
|
||||
const hasSomeExtractedInformation = extractedInformation
|
||||
? Object.values(extractedInformation).some((value) => value !== null)
|
||||
: false;
|
||||
|
||||
const hasTaskv2Output = Boolean(isTaskv2Run && workflowRun.task_v2?.output);
|
||||
|
||||
@@ -282,7 +284,7 @@ function WorkflowRun() {
|
||||
value={
|
||||
hasTaskv2Output
|
||||
? JSON.stringify(workflowRun.task_v2?.output, null, 2)
|
||||
: JSON.stringify(aggregatedExtractedInformation, null, 2)
|
||||
: JSON.stringify(extractedInformation, null, 2)
|
||||
}
|
||||
readOnly
|
||||
maxHeight="250px"
|
||||
|
||||
@@ -12,16 +12,6 @@ import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuer
|
||||
import { Status } from "@/api/types";
|
||||
import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";
|
||||
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() {
|
||||
const { data: workflowRunTimeline, isLoading: workflowRunTimelineIsLoading } =
|
||||
@@ -60,9 +50,6 @@ function WorkflowRunOutput() {
|
||||
activeBlock.status === Status.Completed;
|
||||
|
||||
const outputs = workflowRun?.outputs;
|
||||
const formattedOutputs = outputs
|
||||
? formatExtractedInformation(outputs)
|
||||
: outputs;
|
||||
const fileUrls = workflowRun?.downloaded_file_urls ?? [];
|
||||
const observerOutput = workflowRun?.task_v2?.output;
|
||||
|
||||
@@ -140,9 +127,7 @@ function WorkflowRunOutput() {
|
||||
<h1 className="text-lg font-bold">Workflow Run Outputs</h1>
|
||||
<CodeEditor
|
||||
language="json"
|
||||
value={
|
||||
formattedOutputs ? JSON.stringify(formattedOutputs, null, 2) : ""
|
||||
}
|
||||
value={outputs ? JSON.stringify(outputs, null, 2) : ""}
|
||||
readOnly
|
||||
minHeight="96px"
|
||||
maxHeight="200px"
|
||||
|
||||
Reference in New Issue
Block a user