mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
refactor: replace deprecated addToolResult with addToolOutput (#85)
Replaced the deprecated addToolResult API with the new addToolOutput API from ai to ensure compatibility with future versions.
This commit is contained in:
@@ -71,7 +71,7 @@ export default function ChatPanel({
|
|||||||
chartXMLRef.current = chartXML;
|
chartXMLRef.current = chartXML;
|
||||||
}, [chartXML]);
|
}, [chartXML]);
|
||||||
|
|
||||||
const { messages, sendMessage, addToolResult, status, error, setMessages } =
|
const { messages, sendMessage, addToolOutput, status, error, setMessages } =
|
||||||
useChat({
|
useChat({
|
||||||
transport: new DefaultChatTransport({
|
transport: new DefaultChatTransport({
|
||||||
api: "/api/chat",
|
api: "/api/chat",
|
||||||
@@ -83,13 +83,13 @@ export default function ChatPanel({
|
|||||||
const validationError = validateMxCellStructure(xml);
|
const validationError = validateMxCellStructure(xml);
|
||||||
|
|
||||||
if (validationError) {
|
if (validationError) {
|
||||||
addToolResult({
|
addToolOutput({
|
||||||
tool: "display_diagram",
|
tool: "display_diagram",
|
||||||
toolCallId: toolCall.toolCallId,
|
toolCallId: toolCall.toolCallId,
|
||||||
output: validationError,
|
output: validationError,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addToolResult({
|
addToolOutput({
|
||||||
tool: "display_diagram",
|
tool: "display_diagram",
|
||||||
toolCallId: toolCall.toolCallId,
|
toolCallId: toolCall.toolCallId,
|
||||||
output: "Successfully displayed the diagram.",
|
output: "Successfully displayed the diagram.",
|
||||||
@@ -122,7 +122,7 @@ export default function ChatPanel({
|
|||||||
|
|
||||||
onDisplayChart(editedXml);
|
onDisplayChart(editedXml);
|
||||||
|
|
||||||
addToolResult({
|
addToolOutput({
|
||||||
tool: "edit_diagram",
|
tool: "edit_diagram",
|
||||||
toolCallId: toolCall.toolCallId,
|
toolCallId: toolCall.toolCallId,
|
||||||
output: `Successfully applied ${edits.length} edit(s) to the diagram.`,
|
output: `Successfully applied ${edits.length} edit(s) to the diagram.`,
|
||||||
@@ -136,7 +136,7 @@ export default function ChatPanel({
|
|||||||
? error.message
|
? error.message
|
||||||
: String(error);
|
: String(error);
|
||||||
|
|
||||||
addToolResult({
|
addToolOutput({
|
||||||
tool: "edit_diagram",
|
tool: "edit_diagram",
|
||||||
toolCallId: toolCall.toolCallId,
|
toolCallId: toolCall.toolCallId,
|
||||||
output: `Edit failed: ${errorMessage}
|
output: `Edit failed: ${errorMessage}
|
||||||
|
|||||||
Reference in New Issue
Block a user