mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
feat: add system message for flowchart assistance and improve message handling in chat API
This commit is contained in:
@@ -15,7 +15,24 @@ interface ToolContext {
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const { messages } = await req.json();
|
||||
let { messages } = await req.json();
|
||||
const systemMessage = `
|
||||
You are a helpful assistant that can create, edit, and display flowcharts using draw.io.
|
||||
You can use the following tools:
|
||||
- display_flow_chart: Display a flowchart on draw.io.
|
||||
- fetch_flow_chart: Get the current flowchart XML from draw.io.
|
||||
You can use the tools to create and manipulate flowcharts.
|
||||
You can also answer questions and provide explanations.
|
||||
`;
|
||||
if (messages.length === 1) {
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": systemMessage,
|
||||
},
|
||||
...messages,
|
||||
];
|
||||
}
|
||||
const response = streamText({
|
||||
model: google("gemini-2.0-flash"),
|
||||
messages,
|
||||
|
||||
Reference in New Issue
Block a user