27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import type { KamidsoArtifact } from '../../../contracts/run'
|
|
import { CodePreview } from './CodePreview'
|
|
import { TablePreview } from './TablePreview'
|
|
import { ChartPreview } from './ChartPreview'
|
|
import { JsonPreview } from './JsonPreview'
|
|
import { HtmlPreview } from '../components/HtmlPreview'
|
|
import { MarkdownAnswer } from '../components/MarkdownAnswer'
|
|
|
|
export function ArtifactRenderer({ artifact }: { artifact: KamidsoArtifact }) {
|
|
switch (artifact.type) {
|
|
case 'code':
|
|
return <CodePreview code={String(artifact.content)} language="python" />
|
|
case 'table':
|
|
return <TablePreview table={artifact.content as { columns?: string[]; rows?: unknown[][] }} />
|
|
case 'chart':
|
|
return <ChartPreview spec={artifact.content as Record<string, unknown>} />
|
|
case 'html':
|
|
return <HtmlPreview html={String(artifact.content)} />
|
|
case 'markdown':
|
|
return <MarkdownAnswer content={String(artifact.content)} />
|
|
case 'json':
|
|
return <JsonPreview data={artifact.content} />
|
|
default:
|
|
return <JsonPreview data={artifact.content} />
|
|
}
|
|
}
|