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
This commit is contained in:
@@ -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({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
热点问题(每行一个)
|
||||
</label>
|
||||
<textarea
|
||||
rows={5}
|
||||
value={formData.hotQuestions}
|
||||
onChange={(e) => setFormData({ ...formData, hotQuestions: e.target.value })}
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"
|
||||
placeholder="养老政策有哪些最新变化? 如何申请养老服务补贴? 老年人健康管理需要注意什么? 养老机构如何选择?"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
快捷提问(每行一个)
|
||||
</label>
|
||||
<textarea
|
||||
rows={5}
|
||||
value={formData.quickQuestions}
|
||||
onChange={(e) => setFormData({ ...formData, quickQuestions: e.target.value })}
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500"
|
||||
placeholder="养老政策咨询 养老机构推荐 养老服务申请"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-4">
|
||||
<button
|
||||
type="submit"
|
||||
|
||||
Reference in New Issue
Block a user