"use client"; import { Bot, Boxes, Brain, Check, Database, MessageSquareText, MoreHorizontal, Pencil, Plus, Rocket, Search, Sparkles, Trash2, Workflow, ChevronLeft, ChevronRight, Save, Mic, Volume2, Send, MessageCircle, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Switch } from "@/components/ui/switch"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { useState } from "react"; type RuntimeMode = "pipeline" | "realtime"; type AssistantForm = { name: string; greeting: string; prompt: string; runtimeMode: RuntimeMode; realtimeModel: string; model: string; asr: string; voice: string; knowledgeBase: string; enableInterrupt: boolean; }; type AssistantType = "提示词" | "工作流" | "Dify" | "FastGPT"; const assistantTypes: AssistantType[] = ["提示词", "工作流", "Dify", "FastGPT"]; type AssistantTypeOption = { type: AssistantType; label: string; description: string; icon: React.ReactNode; /** 提示词类型已落地,其余三种暂时显示占位页 */ available: boolean; }; const assistantTypeOptions: AssistantTypeOption[] = [ { type: "提示词", label: "使用提示词构建", description: "通过提示词、模型与语音快速搭建对话助手,适合大多数场景。", icon: , available: true, }, { type: "工作流", label: "使用工作流构建", description: "用可视化编排串联多个节点,适合多步骤、带分支的复杂流程。", icon: , available: false, }, { type: "Dify", label: "使用 Dify 构建", description: "对接 Dify 应用,复用其编排能力与知识库配置。", icon: , available: false, }, { type: "FastGPT", label: "使用 FastGPT 构建", description: "对接 FastGPT 应用,复用其知识库问答与工作流能力。", icon: , available: false, }, ]; type AssistantListItem = { id: string; name: string; type: AssistantType; updatedAt: string; }; const mockAssistants: AssistantListItem[] = [ { id: "asst_001", name: "政务视频咨询助手", type: "提示词", updatedAt: "2026-06-05 18:20", }, { id: "asst_002", name: "热线工单辅助助手", type: "工作流", updatedAt: "2026-06-04 15:12", }, { id: "asst_003", name: "Dify 知识库问答助手", type: "Dify", updatedAt: "2026-06-02 09:48", }, { id: "asst_004", name: "FastGPT 售后咨询助手", type: "FastGPT", updatedAt: "2026-05-29 11:06", }, { id: "asst_005", name: "医院挂号问询助手", type: "提示词", updatedAt: "2026-05-25 14:30", }, { id: "asst_006", name: "政务办事进度助手", type: "工作流", updatedAt: "2026-05-22 10:15", }, { id: "asst_007", name: "Dify 智能客服助手", type: "Dify", updatedAt: "2026-05-18 09:02", }, { id: "asst_008", name: "FastGPT 智能催收助手", type: "FastGPT", updatedAt: "2026-05-15 17:20", }, { id: "asst_009", name: "高校课程咨询助手", type: "提示词", updatedAt: "2026-05-10 12:48", }, { id: "asst_010", name: "企业入驻流程助手", type: "工作流", updatedAt: "2026-05-06 08:43", }, { id: "asst_011", name: "Dify 政策助手", type: "Dify", updatedAt: "2026-05-01 16:45", }, { id: "asst_012", name: "FastGPT 报修助手", type: "FastGPT", updatedAt: "2026-04-28 19:34", }, ]; type DebugMode = "text" | "voice"; type TypeFilter = "全部" | AssistantType; const typeFilters: TypeFilter[] = ["全部", ...assistantTypes]; export function AssistantPage() { const [form, setForm] = useState({ name: "政务视频咨询助手", greeting: "您好,我是 AI 视频助手,请问有什么可以帮您?", prompt: "你是一名专业的政务视频咨询助手,负责为市民提供政策解读、办事指南和常见问题解答。\n\n请遵循以下原则:\n1. 回答准确、简洁,使用通俗易懂的语言\n2. 不确定的信息应明确告知,不编造政策内容\n3. 涉及具体办事流程时,引导用户前往官方渠道核实", runtimeMode: "pipeline", realtimeModel: "gpt-realtime-2", model: "DeepSeek-V3", asr: "SenseVoice", voice: "晓宁", knowledgeBase: "无", enableInterrupt: true, }); const [view, setView] = useState<"list" | "choose" | "create" | "placeholder">( "list", ); const [searchQuery, setSearchQuery] = useState(""); const [typeFilter, setTypeFilter] = useState("全部"); const [currentPage, setCurrentPage] = useState(1); // 右侧调试 drawer 的当前模式 const [debugMode, setDebugMode] = useState("text"); // choose 步骤的草稿:名称与已选类型,确认后才决定进入哪个构建页 const [draftName, setDraftName] = useState(""); const [draftType, setDraftType] = useState(null); function startCreate() { setDraftName(""); setDraftType(null); setView("choose"); } function confirmType() { if (!draftName.trim() || !draftType) { return; } if (draftType === "提示词") { // 提示词类型:复用现有创建表单,并把已填的名称带过去 updateForm("name", draftName.trim()); setView("create"); } else { // 工作流 / Dify / FastGPT:暂时显示占位页 setView("placeholder"); } } const filteredAssistants = mockAssistants.filter((assistant) => { if (typeFilter !== "全部" && assistant.type !== typeFilter) { return false; } const keyword = searchQuery.trim().toLowerCase(); if (!keyword) { return true; } return [assistant.name, assistant.id, assistant.type, assistant.updatedAt] .join(" ") .toLowerCase() .includes(keyword); }); const pageSize = 5; const totalPages = Math.max(1, Math.ceil(filteredAssistants.length / pageSize)); const safeCurrentPage = Math.min(currentPage, totalPages); const pageStart = (safeCurrentPage - 1) * pageSize; const pageEnd = pageStart + pageSize; const paginatedAssistants = filteredAssistants.slice(pageStart, pageEnd); function handleSearchChange(value: string) { setSearchQuery(value); setCurrentPage(1); } function handleFilterChange(filter: TypeFilter) { setTypeFilter(filter); setCurrentPage(1); } function updateForm( key: K, value: AssistantForm[K], ) { setForm((prev) => ({ ...prev, [key]: value, })); } if (view === "list") { return (

助手列表

管理已有的视频助手,支持提示词、工作流、Dify 和 FastGPT 类型。

{typeFilters.map((filter) => ( ))}
handleSearchChange(event.target.value)} className="h-10 border-hairline-strong bg-background pl-9 text-sm text-foreground placeholder:text-muted-soft" placeholder="搜索助手名称、类型或 ID..." />
助手名称
助手类型
更新时间
操作
{paginatedAssistants.map((assistant) => (
{assistant.name}
{assistant.id}
{assistant.type}
{assistant.updatedAt}
删除
))} {filteredAssistants.length === 0 && (
未找到匹配的助手
请调整关键词或筛选条件后再试。
)}
{filteredAssistants.length === 0 ? "没有数据" : `显示 ${pageStart + 1}-${Math.min(pageEnd, filteredAssistants.length)} / 共 ${filteredAssistants.length} 个助手`}
{Array.from({ length: totalPages }, (_, index) => index + 1).map( (page) => ( ), )}
); } if (view === "choose") { const selectedOption = assistantTypeOptions.find( (option) => option.type === draftType, ); return (

创建助手

先为助手取个名字,再选择构建方式。不同方式将进入不同的构建流程。

构建方式
{assistantTypeOptions.map((option) => { const selected = draftType === option.type; return ( ); })}
); } if (view === "placeholder") { return (

{draftName.trim() || "创建助手"}

{draftType} 构建方式正在开发中,敬请期待。

建设中

{draftType} 构建页面正在编写中

页面骨架与设计语言已就绪,后续将填充具体构建流程与数据。

); } return (

创建助手

通过提示词、模型、语音和知识库快速创建 AI 视频助手

} title="基础信息" description="定义助手名称、开场白和提示词" > updateForm("name", value)} placeholder="请输入助手名称" /> updateForm("greeting", value)} placeholder="请输入助手开场白" /> updateForm("prompt", value)} placeholder="请输入提示词,描述助手的角色、能力和回答要求" rows={8} /> {form.runtimeMode === "realtime" && ( } title="Realtime 配置" description="当前模式下 ASR 与 TTS 由 Realtime 模型内置完成" > updateForm("realtimeModel", value)} options={["gpt-realtime-2", "gpt-realtime", "gpt-4o-realtime-preview"]} /> )} {form.runtimeMode === "pipeline" && ( <> } title="LLM 配置" description="选择驱动对话理解与生成的大语言模型" > updateForm("model", value)} options={["DeepSeek-V3", "Qwen-Max", "Kimi-K2", "Doubao-Pro", "GPT-4o"]} /> } title="ASR 配置" description="选择将用户语音转为文本的识别引擎" > updateForm("asr", value)} options={["SenseVoice", "Paraformer", "Whisper", "FunASR"]} /> } title="TTS 配置" description="选择助手播报回复时使用的合成音色" > updateForm("voice", value)} options={["晓宁", "晓美", "晓宇", "晓晨"]} /> )} } title="知识库配置" description="选择助手回答时可检索的业务知识来源" > updateForm("knowledgeBase", value)} options={["无", "政务政策知识库", "售后知识库", "教育课程知识库", "医疗问答知识库"]} /> } title="交互策略" description="设置实时视频对话时的交互体验" > updateForm("enableInterrupt", checked)} />
); } function DebugDrawer({ mode, onModeChange, }: { mode: DebugMode; onModeChange: (mode: DebugMode) => void; }) { const modeTabs: { key: DebugMode; label: string; icon: React.ReactNode }[] = [ { key: "text", label: "文字测试", icon: }, { key: "voice", label: "语音测试", icon: }, ]; return ( ); } function DebugTextPanel() { return (
您好,我是 AI 视频助手,请问有什么可以帮您?
助手
我想咨询一下社保卡的办理流程。
社保卡可通过线上或线下渠道办理。线上可在政务服务 App 提交申请,线下可前往社保经办网点……
助手