feat: add optional bot backchannels to prompt pipelines
Quality gate / backend (push) Waiting to run
Quality gate / frontend (push) Waiting to run

This commit is contained in:
Xin Wang
2026-10-30 14:39:22 +08:00
parent 1eda4190db
commit eb35caffcb
9 changed files with 429 additions and 0 deletions
@@ -935,6 +935,7 @@ export function PromptEditor({
description="设置实时视频对话时的交互体验"
>
{form.runtimeMode === "pipeline" ? (
<>
<TurnConfigEditor
enabled={form.enableInterrupt}
config={form.turnConfig}
@@ -945,6 +946,26 @@ export function PromptEditor({
updateForm("turnConfig", config)
}
/>
<div className="space-y-2 rounded-xl border border-hairline bg-canvas-soft p-3.5">
<label className="flex items-center justify-between gap-3 text-sm font-medium">
机器人附和
<input type="checkbox" checked={form.turnConfig.botBackchannel?.enabled ?? false}
onChange={event => updateForm("turnConfig", { ...form.turnConfig, botBackchannel: {
enabled: event.target.checked, delaySecs: form.turnConfig.botBackchannel?.delaySecs ?? 4,
} })} />
</label>
<p className="text-xs text-muted-foreground">用户持续讲话时轻声回应“嗯”,每轮最多一次,间隔至少 10 秒。不会触发模型回答,也不会改变用户打断策略。</p>
{form.turnConfig.botBackchannel?.enabled && <label className="flex items-center gap-3 text-xs">
连续讲话等待秒数
<input type="number" min={2} max={15} step={0.5}
className="w-20 rounded-md border border-input bg-background px-2 py-1"
value={form.turnConfig.botBackchannel.delaySecs}
onChange={event => { const value = Number(event.target.value); if (Number.isFinite(value) && value >= 2 && value <= 15) updateForm("turnConfig", {
...form.turnConfig, botBackchannel: { enabled: true, delaySecs: value },
}); }} />
</label>}
</div>
</>
) : (
<p className="text-sm text-muted-foreground">
高级抢话与轮次检测当前仅支持 Pipeline 模式。
+1
View File
@@ -268,6 +268,7 @@ export type AssistantType =
| "fastgpt";
export type RuntimeMode = "pipeline" | "realtime";
export type TurnConfig = {
botBackchannel?: { enabled: boolean; delaySecs: number };
bargeIn: {
strategy: "vad" | "transcription";
};
+3
View File
@@ -2,6 +2,7 @@ import type { TurnConfig } from "@/lib/api";
export function defaultTurnConfig(): TurnConfig {
return {
botBackchannel: { enabled: false, delaySecs: 4 },
bargeIn: { strategy: "vad" },
vad: {
confidence: 0.7,
@@ -32,11 +33,13 @@ function numberOr(value: unknown, fallback: number): number {
export function normalizeTurnConfig(value: unknown): TurnConfig {
const defaults = defaultTurnConfig();
const input = record(value);
const botBackchannel = record(input.botBackchannel);
const bargeIn = record(input.bargeIn);
const vad = record(input.vad);
const turnDetection = record(input.turnDetection);
return {
botBackchannel: { enabled: botBackchannel.enabled === true, delaySecs: numberOr(botBackchannel.delaySecs, 4) },
bargeIn: {
strategy:
bargeIn.strategy === "transcription" ? "transcription" : "vad",