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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user