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