fix: flash problem

This commit is contained in:
dayuan.jiang
2025-03-25 08:56:24 +00:00
parent 8882aa9ee1
commit 5d152c66d5
5 changed files with 148 additions and 57 deletions

View File

@@ -14,6 +14,7 @@ import { useChat } from "@ai-sdk/react";
import { ChatInput } from "@/components/chat-input";
import { ChatMessageDisplay } from "./chat-message-display";
interface ChatPanelProps {
chartXML: string;
onDisplayChart: (xml: string) => void;
onFetchChart: () => Promise<string>;
diagramHistory?: { svg: string; xml: string }[];
@@ -21,9 +22,9 @@ interface ChatPanelProps {
}
export default function ChatPanel({
chartXML,
onDisplayChart,
onFetchChart,
mergeXML,
diagramHistory = [],
onAddToHistory = () => {},
}: ChatPanelProps) {
@@ -49,7 +50,8 @@ export default function ChatPanel({
async onToolCall({ toolCall }) {
if (toolCall.toolName === "display_diagram") {
const { xml } = toolCall.args as { xml: string };
onDisplayChart(xml);
// do nothing because we will handle this streamingly in the ChatMessageDisplay component
// onDisplayChart(xml);
return "Successfully displayed the flowchart.";
}
},
@@ -105,6 +107,7 @@ export default function ChatPanel({
</CardHeader>
<CardContent className="flex-grow overflow-hidden px-2">
<ChatMessageDisplay
chartXML={chartXML}
messages={messages}
error={error}
setInput={setInput}