feat: enhance chat functionality with XML guide integration and improved tool descriptions

This commit is contained in:
dayuan.jiang
2025-03-19 11:03:37 +00:00
parent ec80a6c578
commit 7caaa358e4
4 changed files with 557 additions and 38 deletions

View File

@@ -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) => {