Files
users/app/api/ai-query/route.ts
v0 4eed69520c feat: refactor data asset center for enhanced search and analytics
Refactor homepage for focused search and data display; streamline data platform; enhance user and tag management; focus AI assistant on data analysis and report generation.

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
2025-07-25 06:42:34 +00:00

32 lines
860 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { type NextRequest, NextResponse } from "next/server"
import { getMindsDBConnector } from "@/lib/mindsdb-connector"
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { query, model = "gpt4", parameters = {}, useCache = true } = body
if (!query || !query.trim()) {
return NextResponse.json({ error: "AI查询不能为空" }, { status: 400 })
}
const mindsDB = getMindsDBConnector()
const result = await mindsDB.aiQuery({
query,
model,
parameters,
useCache,
})
return NextResponse.json({
success: true,
result,
timestamp: new Date().toISOString(),
})
} catch (error) {
console.error("AI查询API错误:", error)
return NextResponse.json({ error: "AI查询失败请稍后重试" }, { status: 500 })
}
}