From 7b80852e03f58a18e1ffdcca7127c3c5b9244795 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Sun, 7 Jun 2026 11:39:37 +0800 Subject: [PATCH] Add runtime mode selection to AssistantPage and configure allowed development origins Introduced a new feature in AssistantPage allowing users to select between 'pipeline' and 'realtime' runtime modes, enhancing the flexibility of the assistant's functionality. Updated the configuration to include 'allowedDevOrigins' for local development. This change improves user experience by providing clear options for runtime configurations and streamlining the development process. --- next.config.ts | 1 + src/components/pages/AssistantPage.tsx | 189 ++++++++++++++++++------- 2 files changed, 139 insertions(+), 51 deletions(-) diff --git a/next.config.ts b/next.config.ts index e9ffa30..e704545 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + allowedDevOrigins: ["127.0.0.1"], }; export default nextConfig; diff --git a/src/components/pages/AssistantPage.tsx b/src/components/pages/AssistantPage.tsx index 40d528e..65b7475 100644 --- a/src/components/pages/AssistantPage.tsx +++ b/src/components/pages/AssistantPage.tsx @@ -7,10 +7,10 @@ import { Check, Database, MessageSquareText, - Mic, MoreHorizontal, Pencil, Plus, + Rocket, Search, Sparkles, Trash2, @@ -48,10 +48,14 @@ import { } 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; @@ -190,6 +194,8 @@ export function AssistantPage() { greeting: "您好,我是 AI 视频助手,请问有什么可以帮您?", prompt: "你是一名专业的政务视频咨询助手,负责为市民提供政策解读、办事指南和常见问题解答。\n\n请遵循以下原则:\n1. 回答准确、简洁,使用通俗易懂的语言\n2. 不确定的信息应明确告知,不编造政策内容\n3. 涉及具体办事流程时,引导用户前往官方渠道核实", + runtimeMode: "pipeline", + realtimeModel: "gpt-realtime-2", model: "DeepSeek-V3", asr: "SenseVoice", voice: "晓宁", @@ -686,6 +692,66 @@ export function AssistantPage() {
+ +
+ + + +
+
+ } title="基础信息" @@ -714,18 +780,51 @@ export function AssistantPage() { /> - } - title="模型配置" - description="选择大语言模型和知识库能力" - > - updateForm("model", value)} - options={["DeepSeek-V3", "Qwen-Max", "Kimi-K2", "Doubao-Pro", "GPT-4o"]} - /> - + {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="Pipeline 配置" + description="选择 ASR、LLM 和 TTS 组成级联语音管线" + > +
+ updateForm("model", value)} + options={["DeepSeek-V3", "Qwen-Max", "Kimi-K2", "Doubao-Pro", "GPT-4o"]} + /> + + updateForm("asr", value)} + options={["SenseVoice", "Paraformer", "Whisper", "FunASR"]} + /> + + updateForm("voice", value)} + options={["晓宁", "晓美", "晓宇", "晓晨"]} + /> +
+
+ )} } @@ -740,28 +839,6 @@ export function AssistantPage() { /> - } - title="语音配置" - description="配置语音识别模型和播报声音" - > -
- updateForm("asr", value)} - options={["SenseVoice", "Paraformer", "Whisper", "FunASR"]} - /> - - updateForm("voice", value)} - options={["晓宁", "晓美", "晓宇", "晓晨"]} - /> -
-
- } title="交互策略" @@ -785,29 +862,39 @@ function SectionCard({ description, children, }: { - icon: React.ReactNode; - title: string; - description: string; + icon?: React.ReactNode; + title?: string; + description?: string; children: React.ReactNode; }) { + const hasHeader = Boolean(title); + return ( - -
-
- {icon} -
+ {hasHeader && ( + +
+ {icon && ( +
+ {icon} +
+ )} -
- {title} - - {description} - +
+ {title} + {description && ( + + {description} + + )} +
-
-
+ + )} - {children} + + {children} + ); }