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:
@@ -16,6 +16,7 @@ from pydantic.alias_generators import to_camel
|
||||
RuntimeMode = Literal["pipeline", "realtime"]
|
||||
ModelType = Literal["LLM", "ASR", "TTS", "Realtime", "Embedding", "Agent"]
|
||||
AssistantType = Literal["prompt", "workflow", "dify", "fastgpt", "opencode"]
|
||||
TurnEndStrategy = Literal["silence", "smart_turn"]
|
||||
ToolType = Literal["end_call", "http"]
|
||||
ToolStatus = Literal["active", "archived", "draft"]
|
||||
ToolParameterType = Literal["string", "number", "integer", "boolean", "object", "array"]
|
||||
@@ -40,6 +41,27 @@ class CamelModel(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class BargeInConfig(CamelModel):
|
||||
strategy: Literal["vad", "transcription"] = "vad"
|
||||
|
||||
|
||||
class VadConfig(CamelModel):
|
||||
confidence: float = Field(default=0.7, ge=0.0, le=1.0)
|
||||
start_secs: float = Field(default=0.2, ge=0.05, le=2.0)
|
||||
stop_secs: float = Field(default=0.2, ge=0.05, le=3.0)
|
||||
min_volume: float = Field(default=0.6, ge=0.0, le=1.0)
|
||||
|
||||
class TurnDetectionConfig(CamelModel):
|
||||
strategy: TurnEndStrategy = "silence"
|
||||
silence_timeout_secs: float = Field(default=0.6, ge=0.2, le=5.0)
|
||||
|
||||
|
||||
class TurnConfig(CamelModel):
|
||||
barge_in: BargeInConfig = Field(default_factory=BargeInConfig)
|
||||
vad: VadConfig = Field(default_factory=VadConfig)
|
||||
turn_detection: TurnDetectionConfig = Field(default_factory=TurnDetectionConfig)
|
||||
|
||||
|
||||
# 各 type 允许的瘦字段(其余字段写入时清零,防止跨类型脏数据)
|
||||
ALLOWED_FIELDS: dict[str, set[str]] = {
|
||||
"prompt": {"prompt"},
|
||||
@@ -57,6 +79,7 @@ class AssistantUpsert(CamelModel):
|
||||
runtime_mode: RuntimeMode = "pipeline"
|
||||
greeting: str = ""
|
||||
enable_interrupt: bool = True
|
||||
turn_config: TurnConfig = Field(default_factory=TurnConfig)
|
||||
vision_enabled: bool = False
|
||||
vision_model_resource_id: str | None = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user