import React from 'react'; import { CodeBlock } from './ui/CodeBlock'; import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, } from './ui/Dialog'; import { Button } from './ui/Button'; import { IconLog, IconTerminalWindow } from './ui/Icons'; import { Separator } from './ui/Separator'; import Img from './ui/Img'; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from './ui/carousel'; export interface CodeResultDisplayProps {} const CodeResultDisplay: React.FC<{ codeResult: PrismaJson.FinalCodeBody['payload']; }> = ({ codeResult }) => { const { code, test, result } = codeResult; const getDetail = () => { if (!result) return {}; try { // IMPORTANT: This is for backwards compatibility with old chat that save result as JSON string // updated in https://github.com/landing-ai/vision-agent-ui/pull/86 const detail = typeof result === 'object' ? result : (JSON.parse(result) as PrismaJson.StructuredResult); return { results: detail.results, stderr: detail.logs.stderr, stdout: detail.logs.stdout, error: detail.error, }; } catch { return {}; } }; const { results = [], stderr, stdout, error } = getDetail(); const imageResults = results?.filter(_ => !!_.png).map(_ => _.png); const videoResults = results?.filter(_ => !!_.mp4).map(_ => _.mp4); const finalResult = results?.find(_ => _.is_main_result)?.text; return (
image output
video output