fix(chat): show only chart artifacts
This commit is contained in:
@@ -25,7 +25,6 @@ import {
|
||||
import type { Message, SpeechState } from "./GlobalChatbox.types";
|
||||
import { stripMarkdown } from "./GlobalChatbox.utils";
|
||||
import { AgentProgressTimeline } from "./AgentProgressTimeline";
|
||||
import { AgentArtifactPanel } from "./AgentArtifactPanel";
|
||||
import { ChatInlineChart } from "./ChatInlineChart";
|
||||
import { ChatToolCallBlock } from "./ChatToolCallBlock";
|
||||
import { MarkdownBlock, normalizeClipboardText } from "./AgentMarkdownBlock";
|
||||
@@ -99,11 +98,11 @@ export const AgentTurn = React.memo(
|
||||
(segment.toolCall.tool === "chart" ||
|
||||
segment.toolCall.tool === "show_chart"),
|
||||
);
|
||||
const visibleArtifacts = useMemo(
|
||||
const visibleChartArtifacts = useMemo(
|
||||
() =>
|
||||
hasInlineChart
|
||||
? message.artifacts?.filter((artifact) => artifact.kind !== "chart")
|
||||
: message.artifacts,
|
||||
? []
|
||||
: (message.artifacts?.filter((artifact) => artifact.kind === "chart") ?? []),
|
||||
[hasInlineChart, message.artifacts],
|
||||
);
|
||||
|
||||
@@ -290,9 +289,25 @@ export const AgentTurn = React.memo(
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
{visibleArtifacts?.length ? (
|
||||
<AgentArtifactPanel artifacts={visibleArtifacts} />
|
||||
) : null}
|
||||
{visibleChartArtifacts.map((artifact) => (
|
||||
<ChatInlineChart
|
||||
key={artifact.id}
|
||||
title={(artifact.params.title as string) ?? artifact.title}
|
||||
chart_type={
|
||||
(artifact.params.chart_type as "line" | "bar" | "pie") ??
|
||||
"line"
|
||||
}
|
||||
x_data={
|
||||
artifact.params.x_data ??
|
||||
artifact.params.xData ??
|
||||
artifact.params.labels ??
|
||||
artifact.params.categories
|
||||
}
|
||||
series={artifact.params.series}
|
||||
x_axis_name={(artifact.params.x_axis_name as string) ?? undefined}
|
||||
y_axis_name={(artifact.params.y_axis_name as string) ?? undefined}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
|
||||
<AnimatePresence>
|
||||
|
||||
Reference in New Issue
Block a user