From bb753c41400161035193bd25d2c043f6b8fcde0f Mon Sep 17 00:00:00 2001 From: "dayuan.jiang" Date: Wed, 19 Mar 2025 12:02:07 +0000 Subject: [PATCH] feat: update system message to reflect diagram terminology and integrate OpenAI model --- app/api/chat/route.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index a42cb50..1765e9a 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -1,4 +1,5 @@ import { google } from "@ai-sdk/google"; +import { openai } from "@ai-sdk/openai"; import { streamText } from "ai"; import { z } from "zod"; import { readFileSync } from 'fs'; @@ -17,7 +18,7 @@ export async function POST(req: Request) { // Read and escape the guide content const systemMessage = ` -You are a helpful assistant that can create, edit, and display flowcharts using draw.io through xml strings. +You are a helpful assistant that can create, edit, and display diagram using draw.io through xml strings. You can use the following tools: ---Tool1--- tool name: display_flow_chart @@ -27,15 +28,15 @@ parameters: { } ---Tool2--- tool name: fetch_flow_chart -description: Get the current flowchart XML from draw.io +description: Get the current diagram XML from draw.io parameters: {} ---End of tools--- -When you need to modify the flowchart, you need fetch the current flowchart XML from draw.io and then modify it and display it again. +When you need to modify the diagram, you need fetch the current diagram XML from draw.io and then modify it and display it again. here is a guide for the XML format: ${guide} -You can use the tools to create and manipulate flowcharts. +You can use the tools to create and manipulate diagram. You can also answer questions and provide explanations. -If user want you to draw something rather than flowchart, you can use the combination of the shape to draw it. +If user want you to draw something rather than diagram, you can use the combination of the shape to draw it. `; // Add system message if only user message is provided @@ -44,7 +45,8 @@ If user want you to draw something rather than flowchart, you can use the combin : messages; const result = streamText({ - model: google("gemini-2.0-flash"), + // model: google("gemini-2.0-flash"), + model: openai("gpt-4o"), messages: enhancedMessages, tools: { // Client-side tool that will be executed on the client