From 362c37fb423b377be2f2810f85e6ae1d3d7fe7d0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 7 May 2026 22:14:43 +0800 Subject: [PATCH] feat: enhance agent system with hot/quick questions, dynamic chat UI, and new enterprise agents - 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 --- app/admin/agents/AgentForm.tsx | 39 ++++++++++++- app/admin/agents/[id]/edit/page.tsx | 2 + app/admin/login/page.tsx | 2 +- app/agents/[slug]/chat/page.tsx | 72 ++++++++++-------------- app/api/admin/agents/[id]/route.ts | 3 + app/api/admin/agents/route.ts | 2 + prisma/dev.db | Bin 77824 -> 86016 bytes prisma/schema.prisma | 83 ++++++++++++++-------------- prisma/seed.ts | 62 +++++++++++++++++++++ 9 files changed, 177 insertions(+), 88 deletions(-) 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({ /> +
+
+ +