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