Enhance credential management and testing functionality

- Introduce new fields for voice, speed, and language in the AssistantConfig and ProviderCredential models to support TTS and ASR configurations.
- Update the database schema and seeding script to accommodate the new fields, ensuring backward compatibility.
- Implement credential testing endpoints and logic to validate OpenAI-compatible credentials, enhancing user experience and reliability.
- Modify frontend components to include new fields in the credential forms and improve connection testing feedback.
- Refactor related services and API interactions to support the new credential testing feature.
This commit is contained in:
Xin Wang
2026-06-09 14:42:25 +08:00
parent 3661dab81c
commit c64b7dcf99
12 changed files with 443 additions and 28 deletions

View File

@@ -11,6 +11,17 @@ from models import AssistantConfig
from pipecat.services.openai.llm import OpenAILLMService
from pipecat.services.openai.stt import OpenAISTTService
from pipecat.services.openai.tts import OpenAITTSService
from pipecat.transcriptions.language import Language
def _language(value: str) -> Language | None:
if not value:
return None
try:
return Language(value)
except ValueError:
logger.warning(f"忽略不支持的 ASR language: {value}")
return None
def create_stt(cfg: AssistantConfig):
@@ -22,6 +33,7 @@ def create_stt(cfg: AssistantConfig):
api_key=cfg.stt_api_key or config.STT_API_KEY,
base_url=cfg.stt_base_url or config.STT_BASE_URL,
model=cfg.asr or config.STT_MODEL,
language=_language(cfg.stt_language),
)
@@ -41,6 +53,7 @@ def create_tts(cfg: AssistantConfig):
base_url=cfg.tts_base_url or config.TTS_BASE_URL,
model=config.TTS_MODEL,
voice=cfg.voice or config.TTS_VOICE,
speed=cfg.tts_speed,
)