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>
32 lines
860 B
TypeScript
32 lines
860 B
TypeScript
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 })
|
||
}
|
||
}
|