diff --git a/app/admin/agents/AgentForm.tsx b/app/admin/agents/AgentForm.tsx
index d5cde01..e9e4222 100644
--- a/app/admin/agents/AgentForm.tsx
+++ b/app/admin/agents/AgentForm.tsx
@@ -16,6 +16,8 @@ export default function AgentForm({
icon?: string
categoryId?: number
features?: string
+ hotQuestions?: string
+ quickQuestions?: string
status?: string
}
}) {
@@ -27,6 +29,8 @@ export default function AgentForm({
icon: agent?.icon || "",
categoryId: agent?.categoryId || "",
features: agent?.features || "",
+ hotQuestions: agent?.hotQuestions ? JSON.parse(agent.hotQuestions).join('\n') : '',
+ quickQuestions: agent?.quickQuestions ? JSON.parse(agent.quickQuestions).join('\n') : '',
status: agent?.status || "active",
})
const [loading, setLoading] = useState(false)
@@ -44,10 +48,16 @@ export default function AgentForm({
const method = agent?.id ? "PUT" : "POST"
+ const body = {
+ ...formData,
+ hotQuestions: JSON.stringify(formData.hotQuestions.split('\n').filter(q => q.trim())),
+ quickQuestions: JSON.stringify(formData.quickQuestions.split('\n').filter(q => q.trim())),
+ }
+
const res = await fetch(url, {
method,
headers: { "Content-Type": "application/json" },
- body: JSON.stringify(formData),
+ body: JSON.stringify(body),
})
if (res.ok) {
@@ -175,6 +185,33 @@ export default function AgentForm({
/>
+
+
{/* 聊天头部 */}
-
+ {agent.icon || '🤖'}
-
智慧养老服务助手
+
{agent.name}
{sending ? '正在回复...' : '24小时为您服务'}
-
智能小养正在为您服务
{/* 消息区域 */}
@@ -508,7 +505,7 @@ export default function AgentChatPage() {
{/* 右侧服务区域 */}
-
+
{/* 自助服务 */}
@@ -549,7 +546,7 @@ export default function AgentChatPage() {
- {suggestedQuestions.map((question, index) => (
+ {hotQuestions.map((question: string, index: number) => (
-
- {/* 快捷提问 */}
-
-
-
- 快捷提问
-
-
-
-
-
-
-
-
-
- {['养老政策咨询', '养老机构推荐', '养老服务申请'].map((question, index) => (
- -
-
-
- ))}
-
-
+{/* 快捷提问 */}
+
+
+
+ 快捷提问
+
+
+ {quickQuestions.map((question: string, index: number) => (
+ -
+
+
+ ))}
+
+
diff --git a/app/api/admin/agents/[id]/route.ts b/app/api/admin/agents/[id]/route.ts
index 79a93d5..504865b 100644
--- a/app/api/admin/agents/[id]/route.ts
+++ b/app/api/admin/agents/[id]/route.ts
@@ -18,11 +18,14 @@ export async function PUT(
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) {
+ console.error('PUT /api/admin/agents error:', error)
return NextResponse.json({ error: "更新失败" }, { status: 500 })
}
}
diff --git a/app/api/admin/agents/route.ts b/app/api/admin/agents/route.ts
index 5ab94d6..be093ba 100644
--- a/app/api/admin/agents/route.ts
+++ b/app/api/admin/agents/route.ts
@@ -13,6 +13,8 @@ export async function POST(request: NextRequest) {
icon: data.icon || null,
categoryId: data.categoryId ? parseInt(data.categoryId) : null,
features: data.features || "",
+ hotQuestions: data.hotQuestions || "[]",
+ quickQuestions: data.quickQuestions || "[]",
status: data.status || "active",
},
})
diff --git a/prisma/dev.db b/prisma/dev.db
index 117ef9a..e3a3d6b 100644
Binary files a/prisma/dev.db and b/prisma/dev.db differ
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 7159820..e5858d8 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -1,6 +1,3 @@
-// This is your Prisma schema file,
-// learn more about it in the docs: https://pris.ly/d/prisma-schema
-
generator client {
provider = "prisma-client-js"
}
@@ -11,40 +8,42 @@ datasource db {
}
model User {
- id Int @id @default(autoincrement())
- email String @unique
- username String @unique
- password String
- name String?
- role String @default("admin")
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
+ id Int @id @default(autoincrement())
+ email String @unique
+ username String @unique
+ password String
+ name String?
+ role String @default("admin")
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
conversations Conversation[]
}
model Category {
- id Int @id @default(autoincrement())
- name String @unique
- icon String?
+ id Int @id @default(autoincrement())
+ name String @unique
+ icon String?
description String?
- agents Agent[]
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ agents Agent[]
}
model Agent {
- id Int @id @default(autoincrement())
- name String
- slug String @unique
- description String
- icon String?
- categoryId Int?
- category Category? @relation(fields: [categoryId], references: [id])
- features String @default("")
- usageCount Int @default(0)
- status String @default("active")
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
+ id Int @id @default(autoincrement())
+ name String
+ slug String @unique
+ description String
+ icon String?
+ categoryId Int?
+ features String @default("")
+ hotQuestions String @default("[]")
+ quickQuestions String @default("[]")
+ usageCount Int @default(0)
+ status String @default("active")
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ category Category? @relation(fields: [categoryId], references: [id])
conversations Conversation[]
}
@@ -53,30 +52,30 @@ model News {
title String
content String
type String @default("news")
- published Boolean @default(false)
+ published Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Conversation {
- id Int @id @default(autoincrement())
+ id Int @id @default(autoincrement())
agentId Int
- agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
userId Int?
- user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
- title String @default("新对话")
+ title String @default("新对话")
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ user User? @relation(fields: [userId], references: [id])
+ agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
messages Message[]
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
}
model Message {
- id Int @id @default(autoincrement())
+ id Int @id @default(autoincrement())
conversationId Int
- conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
- role String // 'user' 或 'assistant'
+ role String
content String
- timestamp DateTime @default(now())
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
+ timestamp DateTime @default(now())
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
}
diff --git a/prisma/seed.ts b/prisma/seed.ts
index 3daeab8..06a4999 100644
--- a/prisma/seed.ts
+++ b/prisma/seed.ts
@@ -76,6 +76,15 @@ async function main() {
description: "适用于虚拟主播、数字客服、形象代言等场景,提供逼真的数字人交互体验。",
},
}),
+ prisma.category.upsert({
+ where: { name: "企业服务" },
+ update: {},
+ create: {
+ name: "企业服务",
+ icon: "🏢",
+ description: "适用于企业专属AI助手、行业解决方案等场景,提供定制化智能服务。",
+ },
+ }),
])
console.log("Created categories:", categories.map(c => c.name).join(", "))
@@ -91,6 +100,17 @@ async function main() {
icon: "🤖",
categoryId: categories[0].id,
features: "智能问答, 知识库查询, 工单提交",
+ hotQuestions: JSON.stringify([
+ "养老政策有哪些最新变化?",
+ "如何申请养老服务补贴?",
+ "老年人健康管理需要注意什么?",
+ "养老机构如何选择?",
+ ]),
+ quickQuestions: JSON.stringify([
+ "养老政策咨询",
+ "养老机构推荐",
+ "养老服务申请",
+ ]),
usageCount: 1000,
status: "active",
},
@@ -137,6 +157,48 @@ async function main() {
status: "active",
},
}),
+ prisma.agent.upsert({
+ where: { slug: "jiaotou-ai-assistant" },
+ update: {},
+ create: {
+ name: "交投集团AI助手",
+ slug: "jiaotou-ai-assistant",
+ description: "专为交投集团打造的智能助手,提供交通投资政策解读、项目分析、数据分析等专业化服务,助力企业决策。",
+ icon: "🚇",
+ categoryId: categories[6].id,
+ features: "政策解读, 项目分析, 数据分析, 决策支持",
+ usageCount: 120,
+ status: "active",
+ },
+ }),
+ prisma.agent.upsert({
+ where: { slug: "promotion-content-ai" },
+ update: {},
+ create: {
+ name: "宣传文稿AI助手",
+ slug: "promotion-content-ai",
+ description: "智能生成各类宣传文稿,包括新闻稿、活动文案、品牌宣传、海报文案等,快速产出高质量宣传内容。",
+ icon: "📝",
+ categoryId: categories[1].id,
+ features: "新闻稿, 活动文案, 品牌宣传, 海报文案",
+ usageCount: 95,
+ status: "active",
+ },
+ }),
+ prisma.agent.upsert({
+ where: { slug: "group-policy-ai-assistant" },
+ update: {},
+ create: {
+ name: "集团制度AI助手",
+ slug: "group-policy-ai-assistant",
+ description: "专注于集团规章制度解读与咨询,快速查询、解读各类制度文件,助力合规管理与制度落地。",
+ icon: "📋",
+ categoryId: categories[6].id,
+ features: "制度解读, 合规咨询, 文件查询, 制度培训",
+ usageCount: 50,
+ status: "active",
+ },
+ }),
])
console.log("Created agents:", agents.map(a => a.name).join(", "))