362c37fb42
- Add hotQuestions and quickQuestions fields to agent model - Update admin form with textarea inputs for hot/quick questions - Make chat page display dynamic agent data (name, icon, questions) - Widen center chat area to 60% for better readability - Add enterprise service category and 3 new agents (jiaotou, promotion, group-policy) - Update Prisma schema formatting and seed data
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server"
|
|
import { prisma } from "@//app/lib/prisma"
|
|
|
|
// 创建智能体
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const data = await request.json()
|
|
const agent = await prisma.agent.create({
|
|
data: {
|
|
name: data.name,
|
|
slug: data.slug,
|
|
description: data.description,
|
|
icon: data.icon || null,
|
|
categoryId: data.categoryId ? parseInt(data.categoryId) : null,
|
|
features: data.features || "",
|
|
hotQuestions: data.hotQuestions || "[]",
|
|
quickQuestions: data.quickQuestions || "[]",
|
|
status: data.status || "active",
|
|
},
|
|
})
|
|
return NextResponse.json(agent)
|
|
} catch (error) {
|
|
return NextResponse.json({ error: "创建失败" }, { status: 500 })
|
|
}
|
|
}
|
|
|
|
// 获取所有智能体
|
|
export async function GET() {
|
|
try {
|
|
const agents = await prisma.agent.findMany({
|
|
include: { category: true },
|
|
})
|
|
return NextResponse.json(agents)
|
|
} catch (error) {
|
|
return NextResponse.json({ error: "获取失败" }, { status: 500 })
|
|
}
|
|
}
|