mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
refactor: remove unused WebSearchToolUI component and update onFetchChart to return a Promise
This commit is contained in:
@@ -14,7 +14,7 @@ import { ToolInvocation } from 'ai';
|
||||
|
||||
interface ChatPanelProps {
|
||||
onDisplayChart: (xml: string) => void;
|
||||
onFetchChart: () => string;
|
||||
onFetchChart: () => Promise<string>; // Change return type to Promise<string>
|
||||
}
|
||||
|
||||
export default function ChatPanel({ onDisplayChart, onFetchChart }: ChatPanelProps) {
|
||||
@@ -25,7 +25,7 @@ export default function ChatPanel({ onDisplayChart, onFetchChart }: ChatPanelPro
|
||||
const { xml } = toolCall.args as { xml: string };
|
||||
onDisplayChart(xml);
|
||||
} else if (toolCall.toolName === "fetch_flow_chart") {
|
||||
const currentXML = onFetchChart();
|
||||
const currentXML = await onFetchChart();
|
||||
console.log("Current XML:", currentXML);
|
||||
addToolResult({
|
||||
toolCallId: toolCall.toolCallId,
|
||||
@@ -95,7 +95,7 @@ export default function ChatPanel({ onDisplayChart, onFetchChart }: ChatPanelPro
|
||||
<CardFooter className="pt-2">
|
||||
<form onSubmit={onFormSubmit} className="w-full flex space-x-2">
|
||||
<Input
|
||||
value={"what you can see on the drawio panel?"}
|
||||
value={input}
|
||||
onChange={handleInputChange}
|
||||
placeholder="Describe what changes you want to make to the diagram..."
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { makeAssistantToolUI } from "@assistant-ui/react";
|
||||
|
||||
type WebSearchArgs = {
|
||||
query: string;
|
||||
};
|
||||
|
||||
type WebSearchResult = {
|
||||
title: string;
|
||||
description: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export const WebSearchToolUI = makeAssistantToolUI<
|
||||
WebSearchArgs,
|
||||
WebSearchResult
|
||||
>({
|
||||
toolName: "web_search",
|
||||
render: ({ args, status }) => {
|
||||
return <p>web_search({args.query}) </p>;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user