Add tts/text output schema
This commit is contained in:
@@ -21,6 +21,7 @@ def _resolve_runtime_metadata(db: Session, assistant: Assistant) -> dict:
|
||||
metadata = {
|
||||
"systemPrompt": assistant.prompt or "",
|
||||
"greeting": assistant.opener or "",
|
||||
"output": {"mode": "audio" if assistant.voice_output_enabled else "text"},
|
||||
"services": {},
|
||||
}
|
||||
warnings = []
|
||||
@@ -49,11 +50,14 @@ def _resolve_runtime_metadata(db: Session, assistant: Assistant) -> dict:
|
||||
else:
|
||||
warnings.append(f"ASR model not found: {assistant.asr_model_id}")
|
||||
|
||||
if assistant.voice:
|
||||
if not assistant.voice_output_enabled:
|
||||
metadata["services"]["tts"] = {"enabled": False}
|
||||
elif assistant.voice:
|
||||
voice = db.query(Voice).filter(Voice.id == assistant.voice).first()
|
||||
if voice:
|
||||
tts_provider = "siliconflow" if _is_siliconflow_vendor(voice.vendor) else "edge"
|
||||
metadata["services"]["tts"] = {
|
||||
"enabled": True,
|
||||
"provider": tts_provider,
|
||||
"model": voice.model,
|
||||
"apiKey": voice.api_key if tts_provider == "siliconflow" else None,
|
||||
@@ -63,6 +67,7 @@ def _resolve_runtime_metadata(db: Session, assistant: Assistant) -> dict:
|
||||
else:
|
||||
# Keep assistant.voice as direct voice identifier fallback
|
||||
metadata["services"]["tts"] = {
|
||||
"enabled": True,
|
||||
"voice": assistant.voice,
|
||||
"speed": assistant.speed or 1.0,
|
||||
}
|
||||
@@ -98,6 +103,7 @@ def assistant_to_dict(assistant: Assistant) -> dict:
|
||||
"prompt": assistant.prompt or "",
|
||||
"knowledgeBaseId": assistant.knowledge_base_id,
|
||||
"language": assistant.language,
|
||||
"voiceOutputEnabled": assistant.voice_output_enabled,
|
||||
"voice": assistant.voice,
|
||||
"speed": assistant.speed,
|
||||
"hotwords": assistant.hotwords or [],
|
||||
@@ -120,6 +126,7 @@ def _apply_assistant_update(assistant: Assistant, update_data: dict) -> None:
|
||||
"knowledgeBaseId": "knowledge_base_id",
|
||||
"interruptionSensitivity": "interruption_sensitivity",
|
||||
"configMode": "config_mode",
|
||||
"voiceOutputEnabled": "voice_output_enabled",
|
||||
"apiUrl": "api_url",
|
||||
"apiKey": "api_key",
|
||||
"llmModelId": "llm_model_id",
|
||||
@@ -180,6 +187,7 @@ def create_assistant(data: AssistantCreate, db: Session = Depends(get_db)):
|
||||
prompt=data.prompt,
|
||||
knowledge_base_id=data.knowledgeBaseId,
|
||||
language=data.language,
|
||||
voice_output_enabled=data.voiceOutputEnabled,
|
||||
voice=data.voice,
|
||||
speed=data.speed,
|
||||
hotwords=data.hotwords,
|
||||
|
||||
Reference in New Issue
Block a user