Add turn configuration support for assistants

- Introduce a new `turnConfig` field in `AssistantConfig` and `Assistant` models to manage user interaction settings.
- Implement `TurnConfig`, `BargeInConfig`, `VadConfig`, and `TurnDetectionConfig` schemas to define turn management strategies.
- Update the backend to handle turn configuration in the database and during assistant operations.
- Enhance frontend components with a `TurnConfigEditor` for configuring turn settings, including VAD and barge-in strategies.
- Modify existing pages to integrate turn configuration, improving user experience and interaction capabilities.
This commit is contained in:
Xin Wang
2026-07-12 11:08:19 +08:00
parent 00270a5c01
commit 01c563a3e7
13 changed files with 453 additions and 168 deletions

View File

@@ -47,6 +47,8 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import type { TurnConfig } from "@/lib/api";
import { TurnConfigEditor } from "@/components/turn-config-editor";
import { Textarea } from "@/components/ui/textarea";
import { edgeTypes } from "./ConditionEdge";
@@ -73,6 +75,7 @@ export type WorkflowSettings = {
asr?: string;
tts?: string;
allowInterrupt: boolean;
turnConfig: TurnConfig;
};
export type ModelOption = { value: string; label: string };
@@ -528,22 +531,16 @@ function Canvas({
options={modelOptions.tts}
onChange={(v) => onSettingsChange({ ...settings, tts: v })}
/>
<label className="flex items-center justify-between gap-4 rounded-2xl border border-hairline bg-card p-4 shadow-sm">
<span>
<span className="block text-sm font-medium text-foreground">
</span>
<span className="mt-1 block text-xs leading-5 text-muted-foreground">
</span>
</span>
<Switch
checked={settings.allowInterrupt}
onCheckedChange={(checked) =>
onSettingsChange({ ...settings, allowInterrupt: checked })
}
/>
</label>
<TurnConfigEditor
enabled={settings.allowInterrupt}
config={settings.turnConfig}
onEnabledChange={(allowInterrupt) =>
onSettingsChange({ ...settings, allowInterrupt })
}
onConfigChange={(turnConfig) =>
onSettingsChange({ ...settings, turnConfig })
}
/>
</div>
<DialogFooter className="border-t border-hairline bg-card px-5 py-4">
<Button onClick={() => setSettingsOpen(false)}></Button>