mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
feat: enhance chat functionality with XML guide integration and improved tool descriptions
This commit is contained in:
@@ -21,16 +21,17 @@ export default function ChatPanel({ onDisplayChart, onFetchChart }: ChatPanelPro
|
||||
const { messages, input, handleInputChange, handleSubmit, isLoading, error, addToolResult } = useChat({
|
||||
async onToolCall({ toolCall }) {
|
||||
console.log("Tool call:", toolCall);
|
||||
console.log("Tool call name:", toolCall.toolName);
|
||||
console.log("Tool call arguments:", toolCall.args);
|
||||
|
||||
if (toolCall.toolName === "display_flow_chart") {
|
||||
const { xml } = toolCall.args as { xml: string };
|
||||
onDisplayChart(xml);
|
||||
return "Displaying the flowchart...";
|
||||
} else if (toolCall.toolName === "fetch_flow_chart") {
|
||||
const currentXML = await onFetchChart();
|
||||
console.log("Current XML:", currentXML);
|
||||
addToolResult({
|
||||
toolCallId: toolCall.toolCallId,
|
||||
result: currentXML
|
||||
});
|
||||
return currentXML;
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
|
||||
Reference in New Issue
Block a user