| 1234567891011121314151617181920212223242526272829 |
- import { streamText } from "ai";
- import { dashboardCatalog } from "@/lib/render/catalog";
- export const maxDuration = 30;
- // Use the new catalog.prompt() API
- const SYSTEM_PROMPT = dashboardCatalog.prompt();
- const DEFAULT_MODEL = "anthropic/claude-haiku-4.5";
- export async function POST(req: Request) {
- const { prompt, context } = await req.json();
- let fullPrompt = prompt;
- // Add data context
- if (context?.data) {
- fullPrompt += `\n\nAVAILABLE DATA:\n${JSON.stringify(context.data, null, 2)}`;
- }
- const result = streamText({
- model: process.env.AI_GATEWAY_MODEL || DEFAULT_MODEL,
- system: SYSTEM_PROMPT,
- prompt: fullPrompt,
- temperature: 0.7,
- });
- return result.toTextStreamResponse();
- }
|