diff --git a/src/pipecat/services/anthropic/llm.py b/src/pipecat/services/anthropic/llm.py index 6bf7bf180..0c6d436e1 100644 --- a/src/pipecat/services/anthropic/llm.py +++ b/src/pipecat/services/anthropic/llm.py @@ -160,7 +160,7 @@ class AnthropicLLMService(LLMService): """ Settings = AnthropicLLMSettings - _settings: AnthropicLLMSettings + _settings: Settings # Overriding the default adapter to use the Anthropic one. adapter_class = AnthropicLLMAdapter @@ -172,7 +172,7 @@ class AnthropicLLMService(LLMService): """Input parameters for Anthropic model inference. .. deprecated:: 0.0.105 - Use ``AnthropicLLMSettings`` instead. Pass settings directly via the + Use ``AnthropicLLMService.Settings`` instead. Pass settings directly via the ``settings`` parameter of :class:`AnthropicLLMService`. Parameters: @@ -220,7 +220,7 @@ class AnthropicLLMService(LLMService): api_key: str, model: Optional[str] = None, params: Optional[InputParams] = None, - settings: Optional[AnthropicLLMSettings] = None, + settings: Optional[Settings] = None, client=None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, @@ -233,12 +233,12 @@ class AnthropicLLMService(LLMService): model: Model name to use. .. deprecated:: 0.0.105 - Use ``settings=AnthropicLLMSettings(model=...)`` instead. + Use ``settings=AnthropicLLMService.Settings(model=...)`` instead. params: Optional model parameters for inference. .. deprecated:: 0.0.105 - Use ``settings=AnthropicLLMSettings(...)`` instead. + Use ``settings=AnthropicLLMService.Settings(...)`` instead. settings: Runtime-updatable settings for this service. When both deprecated parameters and *settings* are provided, *settings* @@ -249,7 +249,7 @@ class AnthropicLLMService(LLMService): **kwargs: Additional arguments passed to parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AnthropicLLMSettings( + default_settings = self.Settings( model="claude-sonnet-4-6", system_instruction=None, max_tokens=4096, @@ -268,12 +268,12 @@ class AnthropicLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", AnthropicLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AnthropicLLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.max_tokens = params.max_tokens default_settings.temperature = params.temperature diff --git a/src/pipecat/services/assemblyai/models.py b/src/pipecat/services/assemblyai/models.py index efc13d482..cffebcf06 100644 --- a/src/pipecat/services/assemblyai/models.py +++ b/src/pipecat/services/assemblyai/models.py @@ -125,7 +125,7 @@ class AssemblyAIConnectionParams(BaseModel): """Configuration parameters for AssemblyAI WebSocket connection. .. deprecated:: 0.0.105 - Use ``settings=AssemblyAISTTSettings(foo=...)`` instead. + Use ``settings=AssemblyAISTTService.Settings(foo=...)`` instead. Parameters: sample_rate: Audio sample rate in Hz. Defaults to 16000. diff --git a/src/pipecat/services/assemblyai/stt.py b/src/pipecat/services/assemblyai/stt.py index ddfcb4a47..e7a2854b0 100644 --- a/src/pipecat/services/assemblyai/stt.py +++ b/src/pipecat/services/assemblyai/stt.py @@ -129,7 +129,7 @@ class AssemblyAISTTService(WebsocketSTTService): """ Settings = AssemblyAISTTSettings - _settings: AssemblyAISTTSettings + _settings: Settings def __init__( self, @@ -143,7 +143,7 @@ class AssemblyAISTTService(WebsocketSTTService): vad_force_turn_endpoint: bool = True, should_interrupt: bool = True, speaker_format: Optional[str] = None, - settings: Optional[AssemblyAISTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = ASSEMBLYAI_TTFS_P99, **kwargs, ): @@ -154,7 +154,7 @@ class AssemblyAISTTService(WebsocketSTTService): language: Language code for transcription. Defaults to English (Language.EN). .. deprecated:: 0.0.105 - Use ``settings=AssemblyAISTTSettings(language=...)`` instead. + Use ``settings=AssemblyAISTTService.Settings(language=...)`` instead. api_endpoint_base_url: WebSocket endpoint URL. Defaults to AssemblyAI's streaming endpoint. sample_rate: Audio sample rate in Hz. Defaults to 16000. @@ -162,7 +162,7 @@ class AssemblyAISTTService(WebsocketSTTService): connection_params: Connection configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=AssemblyAISTTSettings(...)`` instead. + Use ``settings=AssemblyAISTTService.Settings(...)`` instead. vad_force_turn_endpoint: Controls turn detection mode. When True (Pipecat mode, default): Forces AssemblyAI to return finals ASAP @@ -190,7 +190,7 @@ class AssemblyAISTTService(WebsocketSTTService): **kwargs: Additional arguments passed to parent STTService class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AssemblyAISTTSettings( + default_settings = self.Settings( model="u3-rt-pro", language=Language.EN, formatted_finals=True, @@ -208,12 +208,12 @@ class AssemblyAISTTService(WebsocketSTTService): # 2. Apply direct init arg overrides (deprecated) if language is not None: - _warn_deprecated_param("language", AssemblyAISTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = language # 3. Apply connection_params overrides (deprecated) — only if settings not provided if connection_params is not None: - _warn_deprecated_param("connection_params", AssemblyAISTTSettings) + _warn_deprecated_param("connection_params", self.Settings) if not settings: sample_rate = connection_params.sample_rate encoding = connection_params.encoding @@ -299,7 +299,7 @@ class AssemblyAISTTService(WebsocketSTTService): self._user_speaking = False - def _configure_pipecat_turn_mode(self, settings: AssemblyAISTTSettings, is_u3_pro: bool): + def _configure_pipecat_turn_mode(self, settings: Settings, is_u3_pro: bool): """Configure settings for Pipecat turn detection mode. When vad_force_turn_endpoint is enabled, force AssemblyAI to return @@ -353,7 +353,7 @@ class AssemblyAISTTService(WebsocketSTTService): """ return True - async def _update_settings(self, delta: AssemblyAISTTSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply a settings delta and reconnect to apply changes. Args: diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index 67f79dbfd..2cecb2d5b 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -86,13 +86,13 @@ class AsyncAITTSService(WebsocketTTSService): """ Settings = AsyncAITTSSettings - _settings: AsyncAITTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Async TTS configuration. .. deprecated:: 0.0.105 - Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. + Use ``AsyncAITTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language to use for synthesis. @@ -112,7 +112,7 @@ class AsyncAITTSService(WebsocketTTSService): encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, - settings: Optional[AsyncAITTSSettings] = None, + settings: Optional[Settings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -125,14 +125,14 @@ class AsyncAITTSService(WebsocketTTSService): https://docs.async.com/list-voices-16699698e0 .. deprecated:: 0.0.105 - Use ``settings=AsyncAITTSSettings(voice=...)`` instead. + Use ``settings=AsyncAITTSService.Settings(voice=...)`` instead. version: Async API version. url: WebSocket URL for Async TTS API. model: TTS model to use (e.g., "async_flash_v1.0"). .. deprecated:: 0.0.105 - Use ``settings=AsyncAITTSSettings(model=...)`` instead. + Use ``settings=AsyncAITTSService.Settings(model=...)`` instead. sample_rate: Audio sample rate. encoding: Audio encoding format. @@ -140,7 +140,7 @@ class AsyncAITTSService(WebsocketTTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=AsyncAITTSSettings(...)`` instead. + Use ``settings=AsyncAITTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -153,7 +153,7 @@ class AsyncAITTSService(WebsocketTTSService): **kwargs: Additional arguments passed to the parent service. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AsyncAITTSSettings( + default_settings = self.Settings( model="async_flash_v1.0", voice=None, language=None, @@ -161,15 +161,15 @@ class AsyncAITTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", AsyncAITTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", AsyncAITTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AsyncAITTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = ( self.language_to_service_language(params.language) if params.language else None @@ -487,13 +487,13 @@ class AsyncAIHttpTTSService(TTSService): """ Settings = AsyncAITTSSettings - _settings: AsyncAITTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Async API. .. deprecated:: 0.0.105 - Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. + Use ``AsyncAIHttpTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language to use for synthesis. @@ -514,7 +514,7 @@ class AsyncAIHttpTTSService(TTSService): encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, - settings: Optional[AsyncAITTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Async TTS service. @@ -524,13 +524,13 @@ class AsyncAIHttpTTSService(TTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=AsyncAITTSSettings(voice=...)`` instead. + Use ``settings=AsyncAIHttpTTSService.Settings(voice=...)`` instead. aiohttp_session: An aiohttp session for making HTTP requests. model: TTS model to use (e.g., "async_flash_v1.0"). .. deprecated:: 0.0.105 - Use ``settings=AsyncAITTSSettings(model=...)`` instead. + Use ``settings=AsyncAIHttpTTSService.Settings(model=...)`` instead. url: Base URL for Async API. version: API version string for Async API. @@ -540,14 +540,14 @@ class AsyncAIHttpTTSService(TTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=AsyncAITTSSettings(...)`` instead. + Use ``settings=AsyncAIHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AsyncAITTSSettings( + default_settings = self.Settings( model="async_flash_v1.0", voice=None, language=None, @@ -555,15 +555,15 @@ class AsyncAIHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", AsyncAITTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", AsyncAITTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AsyncAITTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = ( self.language_to_service_language(params.language) if params.language else None diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index c77321ead..9a2ebfdcf 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -747,7 +747,7 @@ class AWSBedrockLLMService(LLMService): """ Settings = AWSBedrockLLMSettings - _settings: AWSBedrockLLMSettings + _settings: Settings # Overriding the default adapter to use the Anthropic one. adapter_class = AWSBedrockLLMAdapter @@ -756,7 +756,7 @@ class AWSBedrockLLMService(LLMService): """Input parameters for AWS Bedrock LLM service. .. deprecated:: 0.0.105 - Use ``AWSBedrockLLMSettings`` instead. Pass settings directly via the + Use ``AWSBedrockLLMService.Settings`` instead. Pass settings directly via the ``settings`` parameter of :class:`AWSBedrockLLMService`. Parameters: @@ -784,7 +784,7 @@ class AWSBedrockLLMService(LLMService): aws_session_token: Optional[str] = None, aws_region: Optional[str] = None, params: Optional[InputParams] = None, - settings: Optional[AWSBedrockLLMSettings] = None, + settings: Optional[Settings] = None, stop_sequences: Optional[List[str]] = None, client_config: Optional[Config] = None, retry_timeout_secs: Optional[float] = 5.0, @@ -797,7 +797,7 @@ class AWSBedrockLLMService(LLMService): model: The AWS Bedrock model identifier to use. .. deprecated:: 0.0.105 - Use ``settings=AWSBedrockLLMSettings(model=...)`` instead. + Use ``settings=AWSBedrockLLMService.Settings(model=...)`` instead. aws_access_key: AWS access key ID. If None, uses default credentials. aws_secret_key: AWS secret access key. If None, uses default credentials. @@ -806,7 +806,7 @@ class AWSBedrockLLMService(LLMService): params: Model parameters and configuration. .. deprecated:: 0.0.105 - Use ``settings=AWSBedrockLLMSettings(...)`` instead. + Use ``settings=AWSBedrockLLMService.Settings(...)`` instead. settings: Runtime-updatable settings for this service. When both deprecated parameters and *settings* are provided, *settings* @@ -814,7 +814,7 @@ class AWSBedrockLLMService(LLMService): stop_sequences: List of strings that stop generation. .. deprecated:: 0.0.105 - Use ``settings=AWSBedrockLLMSettings(stop_sequences=...)`` instead. + Use ``settings=AWSBedrockLLMService.Settings(stop_sequences=...)`` instead. client_config: Custom boto3 client configuration. retry_timeout_secs: Request timeout in seconds for retry logic. @@ -822,7 +822,7 @@ class AWSBedrockLLMService(LLMService): **kwargs: Additional arguments passed to parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AWSBedrockLLMSettings( + default_settings = self.Settings( model="us.amazon.nova-lite-v1:0", system_instruction=None, max_tokens=None, @@ -841,15 +841,15 @@ class AWSBedrockLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", AWSBedrockLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if stop_sequences is not None: - _warn_deprecated_param("stop_sequences", AWSBedrockLLMSettings, "stop_sequences") + _warn_deprecated_param("stop_sequences", self.Settings, "stop_sequences") default_settings.stop_sequences = stop_sequences # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AWSBedrockLLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.max_tokens = params.max_tokens default_settings.temperature = params.temperature diff --git a/src/pipecat/services/aws/nova_sonic/llm.py b/src/pipecat/services/aws/nova_sonic/llm.py index 8e4633544..0309c0fad 100644 --- a/src/pipecat/services/aws/nova_sonic/llm.py +++ b/src/pipecat/services/aws/nova_sonic/llm.py @@ -150,7 +150,7 @@ class Params(BaseModel): """Configuration parameters for AWS Nova Sonic. .. deprecated:: 0.0.105 - Use ``settings=AWSNovaSonicLLMSettings(...)`` for inference settings + Use ``settings=AWSNovaSonicLLMService.Settings(...)`` for inference settings and ``audio_config=AudioConfig(...)`` for audio configuration. Parameters: @@ -247,7 +247,7 @@ class AWSNovaSonicLLMService(LLMService): """ Settings = AWSNovaSonicLLMSettings - _settings: AWSNovaSonicLLMSettings + _settings: Settings # Override the default adapter to use the AWSNovaSonicLLMAdapter one adapter_class = AWSNovaSonicLLMAdapter @@ -263,7 +263,7 @@ class AWSNovaSonicLLMService(LLMService): voice_id: str = "matthew", params: Optional[Params] = None, audio_config: Optional[AudioConfig] = None, - settings: Optional[AWSNovaSonicLLMSettings] = None, + settings: Optional[Settings] = None, system_instruction: Optional[str] = None, tools: Optional[ToolsSchema] = None, send_transcription_frames: bool = True, @@ -282,7 +282,7 @@ class AWSNovaSonicLLMService(LLMService): model: Model identifier. Defaults to "amazon.nova-2-sonic-v1:0". .. deprecated:: 0.0.105 - Use ``settings=AWSNovaSonicLLMSettings(model=...)`` instead. + Use ``settings=AWSNovaSonicLLMService.Settings(model=...)`` instead. voice_id: Voice ID for speech synthesis. Note that some voices are designed for use with a specific language. @@ -291,12 +291,12 @@ class AWSNovaSonicLLMService(LLMService): - Nova Sonic (the older model): see https://docs.aws.amazon.com/nova/latest/userguide/available-voices.html. .. deprecated:: 0.0.105 - Use ``settings=AWSNovaSonicLLMSettings(voice=...)`` instead. + Use ``settings=AWSNovaSonicLLMService.Settings(voice=...)`` instead. params: Model parameters for audio configuration and inference. .. deprecated:: 0.0.105 - Use ``settings=AWSNovaSonicLLMSettings(...)`` for inference + Use ``settings=AWSNovaSonicLLMService.Settings(...)`` for inference settings and ``audio_config=AudioConfig(...)`` for audio configuration. @@ -308,7 +308,7 @@ class AWSNovaSonicLLMService(LLMService): system_instruction: System-level instruction for the model. .. deprecated:: 0.0.105 - Use ``settings=AWSNovaSonicLLMSettings(system_instruction=...)`` instead. + Use ``settings=AWSNovaSonicLLMService.Settings(system_instruction=...)`` instead. tools: Available tools/functions for the model to use. send_transcription_frames: Whether to emit transcription frames. @@ -319,7 +319,7 @@ class AWSNovaSonicLLMService(LLMService): **kwargs: Additional arguments passed to the parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AWSNovaSonicLLMSettings( + default_settings = self.Settings( model="amazon.nova-2-sonic-v1:0", system_instruction=None, voice="matthew", @@ -337,15 +337,13 @@ class AWSNovaSonicLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model != "amazon.nova-2-sonic-v1:0": - _warn_deprecated_param("model", AWSNovaSonicLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id != "matthew": - _warn_deprecated_param("voice_id", AWSNovaSonicLLMSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if system_instruction is not None: - _warn_deprecated_param( - "system_instruction", AWSNovaSonicLLMSettings, "system_instruction" - ) + _warn_deprecated_param("system_instruction", self.Settings, "system_instruction") default_settings.system_instruction = system_instruction # 3. Apply params overrides — only if settings not provided @@ -356,7 +354,7 @@ class AWSNovaSonicLLMService(LLMService): warnings.simplefilter("always") warnings.warn( "The `params` parameter is deprecated. " - "Use `settings=AWSNovaSonicLLMSettings(...)` for inference settings " + "Use `settings=self.Settings(...)` for inference settings " "(temperature, max_tokens, top_p, endpointing_sensitivity) " "and `audio_config=AudioConfig(...)` for audio configuration " "(sample rates, sample sizes, channel counts).", @@ -447,7 +445,7 @@ class AWSNovaSonicLLMService(LLMService): # settings # - async def _update_settings(self, delta: AWSNovaSonicLLMSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply a settings delta. Settings are stored but not applied to the active connection. diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index 8b28c006a..0a648759c 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -61,7 +61,7 @@ class AWSTranscribeSTTService(WebsocketSTTService): """ Settings = AWSTranscribeSTTSettings - _settings: AWSTranscribeSTTSettings + _settings: Settings def __init__( self, @@ -72,7 +72,7 @@ class AWSTranscribeSTTService(WebsocketSTTService): region: Optional[str] = None, sample_rate: Optional[int] = None, language: Optional[Language] = None, - settings: Optional[AWSTranscribeSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = AWS_TRANSCRIBE_TTFS_P99, **kwargs, ): @@ -89,7 +89,7 @@ class AWSTranscribeSTTService(WebsocketSTTService): language: Language for transcription. .. deprecated:: 0.0.105 - Use ``settings=AWSTranscribeSTTSettings(language=...)`` instead. + Use ``settings=AWSTranscribeSTTService.Settings(language=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -98,14 +98,14 @@ class AWSTranscribeSTTService(WebsocketSTTService): **kwargs: Additional arguments passed to parent STTService class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AWSTranscribeSTTSettings( + default_settings = self.Settings( model=None, language=self.language_to_service_language(Language.EN), ) # 2. Apply direct init arg overrides (deprecated) if language is not None: - _warn_deprecated_param("language", AWSTranscribeSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = self.language_to_service_language(language) # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/aws/tts.py b/src/pipecat/services/aws/tts.py index 47b12429a..1e16958fe 100644 --- a/src/pipecat/services/aws/tts.py +++ b/src/pipecat/services/aws/tts.py @@ -149,13 +149,13 @@ class AWSPollyTTSService(TTSService): """ Settings = AWSPollyTTSSettings - _settings: AWSPollyTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for AWS Polly TTS configuration. .. deprecated:: 0.0.105 - Use ``AWSPollyTTSSettings`` directly via the ``settings`` parameter instead. + Use ``AWSPollyTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: engine: TTS engine to use ('standard', 'neural', etc.). @@ -183,7 +183,7 @@ class AWSPollyTTSService(TTSService): voice_id: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[AWSPollyTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initializes the AWS Polly TTS service. @@ -196,20 +196,20 @@ class AWSPollyTTSService(TTSService): voice_id: Voice ID to use for synthesis. Defaults to 'Joanna'. .. deprecated:: 0.0.105 - Use ``settings=AWSPollyTTSSettings(voice=...)`` instead. + Use ``settings=AWSPollyTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses service default. params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=AWSPollyTTSSettings(...)`` instead. + Use ``settings=AWSPollyTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AWSPollyTTSSettings( + default_settings = self.Settings( model=None, voice="Joanna", language="en-US", @@ -222,12 +222,12 @@ class AWSPollyTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", AWSPollyTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AWSPollyTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.engine = params.engine default_settings.language = ( diff --git a/src/pipecat/services/azure/image.py b/src/pipecat/services/azure/image.py index 1b62fbfe4..a80496599 100644 --- a/src/pipecat/services/azure/image.py +++ b/src/pipecat/services/azure/image.py @@ -44,7 +44,7 @@ class AzureImageGenServiceREST(ImageGenService): """ Settings = AzureImageGenSettings - _settings: AzureImageGenSettings + _settings: Settings def __init__( self, @@ -55,7 +55,7 @@ class AzureImageGenServiceREST(ImageGenService): model: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, api_version="2023-06-01-preview", - settings: Optional[AzureImageGenSettings] = None, + settings: Optional[Settings] = None, ): """Initialize the AzureImageGenServiceREST. @@ -63,14 +63,14 @@ class AzureImageGenServiceREST(ImageGenService): image_size: Size specification for generated images (e.g., "1024x1024"). .. deprecated:: 0.0.105 - Use ``settings=AzureImageGenSettings(image_size=...)`` instead. + Use ``settings=AzureImageGenServiceREST.Settings(image_size=...)`` instead. api_key: Azure OpenAI API key for authentication. endpoint: Azure OpenAI endpoint URL. model: The image generation model to use. .. deprecated:: 0.0.105 - Use ``settings=AzureImageGenSettings(model=...)`` instead. + Use ``settings=AzureImageGenServiceREST.Settings(model=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. api_version: Azure API version string. Defaults to "2023-06-01-preview". @@ -78,18 +78,18 @@ class AzureImageGenServiceREST(ImageGenService): parameters, ``settings`` values take precedence. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AzureImageGenSettings( + default_settings = self.Settings( model=None, image_size=None, ) # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", AzureImageGenSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if image_size is not None: - _warn_deprecated_param("image_size", AzureImageGenSettings, "image_size") + _warn_deprecated_param("image_size", self.Settings, "image_size") default_settings.image_size = image_size # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/azure/llm.py b/src/pipecat/services/azure/llm.py index 322ff0b3e..b4f2de5dc 100644 --- a/src/pipecat/services/azure/llm.py +++ b/src/pipecat/services/azure/llm.py @@ -12,13 +12,13 @@ from typing import Optional from loguru import logger from openai import AsyncAzureOpenAI -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class AzureLLMSettings(OpenAILLMSettings): +class AzureLLMSettings(BaseOpenAILLMService.Settings): """Settings for AzureLLMService.""" pass @@ -40,7 +40,7 @@ class AzureLLMService(OpenAILLMService): endpoint: str, model: Optional[str] = None, api_version: str = "2024-09-01-preview", - settings: Optional[AzureLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Azure LLM service. @@ -51,7 +51,7 @@ class AzureLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "gpt-4o". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=AzureLLMService.Settings(model=...)`` instead. api_version: Azure API version. Defaults to "2024-09-01-preview". settings: Runtime-updatable settings. When provided alongside deprecated @@ -59,11 +59,11 @@ class AzureLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AzureLLMSettings(model="gpt-4o") + default_settings = self.Settings(model="gpt-4o") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", AzureLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/azure/realtime/llm.py b/src/pipecat/services/azure/realtime/llm.py index c791af94d..e6bc05478 100644 --- a/src/pipecat/services/azure/realtime/llm.py +++ b/src/pipecat/services/azure/realtime/llm.py @@ -10,7 +10,7 @@ from dataclasses import dataclass from loguru import logger -from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService, OpenAIRealtimeLLMSettings +from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService try: from websockets.asyncio.client import connect as websocket_connect @@ -21,7 +21,7 @@ except ModuleNotFoundError as e: @dataclass -class AzureRealtimeLLMSettings(OpenAIRealtimeLLMSettings): +class AzureRealtimeLLMSettings(OpenAIRealtimeLLMService.Settings): """Settings for AzureRealtimeLLMService.""" pass @@ -36,7 +36,7 @@ class AzureRealtimeLLMService(OpenAIRealtimeLLMService): """ Settings = AzureRealtimeLLMSettings - _settings: AzureRealtimeLLMSettings + _settings: Settings def __init__( self, diff --git a/src/pipecat/services/azure/stt.py b/src/pipecat/services/azure/stt.py index 6abe52db1..7309a4a4e 100644 --- a/src/pipecat/services/azure/stt.py +++ b/src/pipecat/services/azure/stt.py @@ -67,7 +67,7 @@ class AzureSTTService(STTService): """ Settings = AzureSTTSettings - _settings: AzureSTTSettings + _settings: Settings def __init__( self, @@ -78,7 +78,7 @@ class AzureSTTService(STTService): sample_rate: Optional[int] = None, private_endpoint: Optional[str] = None, endpoint_id: Optional[str] = None, - settings: Optional[AzureSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = AZURE_TTFS_P99, **kwargs, ): @@ -91,7 +91,7 @@ class AzureSTTService(STTService): language: Language for speech recognition. Defaults to English (US). .. deprecated:: 0.0.105 - Use ``settings=AzureSTTSettings(language=...)`` instead. + Use ``settings=AzureSTTService.Settings(language=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. private_endpoint: Private endpoint for STT behind firewall. @@ -104,14 +104,14 @@ class AzureSTTService(STTService): **kwargs: Additional arguments passed to parent STTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AzureSTTSettings( + default_settings = self.Settings( model=None, language=language_to_azure_language(Language.EN_US), ) # 2. Apply direct init arg overrides (deprecated) if language is not None and language != Language.EN_US: - _warn_deprecated_param("language", AzureSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = language_to_azure_language(language) # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index 1c74c7655..d33937d52 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -97,7 +97,8 @@ class AzureBaseTTSService: This is a mixin class and should be used alongside TTSService or its subclasses. """ - _settings: AzureTTSSettings + Settings = AzureTTSSettings + _settings: Settings # Define SSML escape mappings based on SSML reserved characters # See - https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-structure @@ -113,7 +114,7 @@ class AzureBaseTTSService: """Input parameters for Azure TTS voice configuration. .. deprecated:: 0.0.105 - Use ``settings=AzureTTSSettings(...)`` instead. + Use ``settings=AzureBaseTTSService.Settings(...)`` instead. Parameters: emphasis: Emphasis level for speech ("strong", "moderate", "reduced"). @@ -256,7 +257,7 @@ class AzureTTSService(TTSService, AzureBaseTTSService): voice: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[AzureBaseTTSService.InputParams] = None, - settings: Optional[AzureTTSSettings] = None, + settings: Optional[Settings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -269,13 +270,13 @@ class AzureTTSService(TTSService, AzureBaseTTSService): voice: Voice name to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=AzureTTSSettings(voice=...)`` instead. + Use ``settings=AzureTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. .. deprecated:: 0.0.105 - Use ``settings=AzureTTSSettings(...)`` instead. + Use ``settings=AzureTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -288,7 +289,7 @@ class AzureTTSService(TTSService, AzureBaseTTSService): **kwargs: Additional arguments passed to parent WordTTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AzureTTSSettings( + default_settings = self.Settings( model=None, voice="en-US-SaraNeural", language="en-US", @@ -303,12 +304,12 @@ class AzureTTSService(TTSService, AzureBaseTTSService): # 2. Apply direct init arg overrides (deprecated) if voice is not None: - _warn_deprecated_param("voice", AzureTTSSettings, "voice") + _warn_deprecated_param("voice", self.Settings, "voice") default_settings.voice = voice # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AzureTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.emphasis = params.emphasis default_settings.language = ( @@ -761,7 +762,7 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): voice: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[AzureBaseTTSService.InputParams] = None, - settings: Optional[AzureTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Azure HTTP TTS service. @@ -772,20 +773,20 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): voice: Voice name to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=AzureTTSSettings(voice=...)`` instead. + Use ``settings=AzureHttpTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. .. deprecated:: 0.0.105 - Use ``settings=AzureTTSSettings(...)`` instead. + Use ``settings=AzureHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = AzureTTSSettings( + default_settings = self.Settings( model=None, voice="en-US-SaraNeural", language="en-US", @@ -800,12 +801,12 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): # 2. Apply direct init arg overrides (deprecated) if voice is not None: - _warn_deprecated_param("voice", AzureTTSSettings, "voice") + _warn_deprecated_param("voice", self.Settings, "voice") default_settings.voice = voice # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", AzureTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.emphasis = params.emphasis default_settings.language = ( diff --git a/src/pipecat/services/camb/tts.py b/src/pipecat/services/camb/tts.py index f458fa2e4..7586644ce 100644 --- a/src/pipecat/services/camb/tts.py +++ b/src/pipecat/services/camb/tts.py @@ -176,13 +176,13 @@ class CambTTSService(TTSService): """ Settings = CambTTSSettings - _settings: CambTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Camb.ai TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=CambTTSSettings(...)`` instead. + Use ``settings=CambTTSService.Settings(...)`` instead. Parameters: language: Language for synthesis (BCP-47 format). Defaults to English. @@ -207,7 +207,7 @@ class CambTTSService(TTSService): timeout: float = 60.0, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[CambTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Camb.ai TTS service. @@ -217,12 +217,12 @@ class CambTTSService(TTSService): voice_id: Voice ID to use. .. deprecated:: 0.0.105 - Use ``settings=CambTTSSettings(voice=...)`` instead. + Use ``settings=CambTTSService.Settings(voice=...)`` instead. model: TTS model to use. Options: "mars-flash" (fast), "mars-pro" (high quality). .. deprecated:: 0.0.105 - Use ``settings=CambTTSSettings(model=...)`` instead. + Use ``settings=CambTTSService.Settings(model=...)`` instead. timeout: Request timeout in seconds. Defaults to 60.0 (minimum recommended by Camb.ai). @@ -230,14 +230,14 @@ class CambTTSService(TTSService): params: Additional voice parameters. If None, uses defaults. .. deprecated:: 0.0.105 - Use ``settings=CambTTSSettings(...)`` instead. + Use ``settings=CambTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = CambTTSSettings( + default_settings = self.Settings( model="mars-flash", voice=147320, language="en-us", @@ -246,15 +246,15 @@ class CambTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", CambTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id is not None: - _warn_deprecated_param("voice_id", CambTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", CambTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = ( diff --git a/src/pipecat/services/cartesia/stt.py b/src/pipecat/services/cartesia/stt.py index 9c0924827..e094ef044 100644 --- a/src/pipecat/services/cartesia/stt.py +++ b/src/pipecat/services/cartesia/stt.py @@ -55,7 +55,7 @@ class CartesiaLiveOptions: """Configuration options for Cartesia Live STT service. .. deprecated:: 0.0.105 - Use ``settings=CartesiaSTTSettings(...)`` for model/language and + Use ``settings=CartesiaSTTService.Settings(...)`` for model/language and direct ``__init__`` parameters for encoding/sample_rate instead. """ @@ -147,7 +147,7 @@ class CartesiaSTTService(WebsocketSTTService): """ Settings = CartesiaSTTSettings - _settings: CartesiaSTTSettings + _settings: Settings def __init__( self, @@ -157,7 +157,7 @@ class CartesiaSTTService(WebsocketSTTService): encoding: str = "pcm_s16le", sample_rate: Optional[int] = None, live_options: Optional[CartesiaLiveOptions] = None, - settings: Optional[CartesiaSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = CARTESIA_TTFS_P99, **kwargs, ): @@ -172,7 +172,7 @@ class CartesiaSTTService(WebsocketSTTService): live_options: Configuration options for transcription service. .. deprecated:: 0.0.105 - Use ``settings=CartesiaSTTSettings(...)`` for model/language + Use ``settings=CartesiaSTTService.Settings(...)`` for model/language and direct init parameters for encoding/sample_rate instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -182,14 +182,14 @@ class CartesiaSTTService(WebsocketSTTService): **kwargs: Additional arguments passed to parent STTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = CartesiaSTTSettings( + default_settings = self.Settings( model="ink-whisper", language=Language.EN.value, ) # 2. Apply live_options overrides — only if settings not provided if live_options is not None: - _warn_deprecated_param("live_options", CartesiaSTTSettings) + _warn_deprecated_param("live_options", self.Settings) if not settings: if live_options.sample_rate and sample_rate is None: sample_rate = live_options.sample_rate @@ -313,7 +313,7 @@ class CartesiaSTTService(WebsocketSTTService): """Apply a settings delta. Args: - delta: A :class:`STTSettings` (or ``CartesiaSTTSettings``) delta. + delta: A :class:`STTSettings` (or ``CartesiaSTTService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index d41f341ca..90497eb1d 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -211,7 +211,7 @@ class CartesiaTTSService(WebsocketTTSService): """ Settings = CartesiaTTSSettings - _settings: CartesiaTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Cartesia TTS configuration. @@ -239,7 +239,7 @@ class CartesiaTTSService(WebsocketTTSService): encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, - settings: Optional[CartesiaTTSSettings] = None, + settings: Optional[Settings] = None, text_aggregator: Optional[BaseTextAggregator] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, @@ -252,14 +252,14 @@ class CartesiaTTSService(WebsocketTTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=CartesiaTTSSettings(voice=...)`` instead. + Use ``settings=CartesiaTTSService.Settings(voice=...)`` instead. cartesia_version: API version string for Cartesia service. url: WebSocket URL for Cartesia TTS API. model: TTS model to use (e.g., "sonic-3"). .. deprecated:: 0.0.105 - Use ``settings=CartesiaTTSSettings(model=...)`` instead. + Use ``settings=CartesiaTTSService.Settings(model=...)`` instead. sample_rate: Audio sample rate. If None, uses default. encoding: Audio encoding format. @@ -267,7 +267,7 @@ class CartesiaTTSService(WebsocketTTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=CartesiaTTSSettings(...)`` instead. + Use ``settings=CartesiaTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -299,7 +299,7 @@ class CartesiaTTSService(WebsocketTTSService): # playout timing of the audio! # 1. Initialize default_settings with hardcoded defaults - default_settings = CartesiaTTSSettings( + default_settings = self.Settings( model="sonic-3", voice=None, language=language_to_cartesia_language(Language.EN), @@ -309,15 +309,15 @@ class CartesiaTTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", CartesiaTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", CartesiaTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", CartesiaTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) @@ -683,7 +683,7 @@ class CartesiaHttpTTSService(TTSService): """ Settings = CartesiaTTSSettings - _settings: CartesiaTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Cartesia HTTP TTS configuration. @@ -712,7 +712,7 @@ class CartesiaHttpTTSService(TTSService): encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, - settings: Optional[CartesiaTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Cartesia HTTP TTS service. @@ -722,12 +722,12 @@ class CartesiaHttpTTSService(TTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=CartesiaTTSSettings(voice=...)`` instead. + Use ``settings=CartesiaHttpTTSService.Settings(voice=...)`` instead. model: TTS model to use (e.g., "sonic-3"). .. deprecated:: 0.0.105 - Use ``settings=CartesiaTTSSettings(model=...)`` instead. + Use ``settings=CartesiaHttpTTSService.Settings(model=...)`` instead. base_url: Base URL for Cartesia HTTP API. cartesia_version: API version string for Cartesia service. @@ -739,14 +739,14 @@ class CartesiaHttpTTSService(TTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=CartesiaTTSSettings(...)`` instead. + Use ``settings=CartesiaHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = CartesiaTTSSettings( + default_settings = self.Settings( model="sonic-3", voice=None, language=language_to_cartesia_language(Language.EN), @@ -756,15 +756,15 @@ class CartesiaHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", CartesiaTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", CartesiaTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", CartesiaTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index 5d4bc2d14..e2a15f4e5 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -12,13 +12,13 @@ from typing import Optional from loguru import logger from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class CerebrasLLMSettings(OpenAILLMSettings): +class CerebrasLLMSettings(BaseOpenAILLMService.Settings): """Settings for CerebrasLLMService.""" pass @@ -32,7 +32,7 @@ class CerebrasLLMService(OpenAILLMService): """ Settings = CerebrasLLMSettings - _settings: CerebrasLLMSettings + _settings: Settings def __init__( self, @@ -40,7 +40,7 @@ class CerebrasLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.cerebras.ai/v1", model: Optional[str] = None, - settings: Optional[CerebrasLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Cerebras LLM service. @@ -51,18 +51,18 @@ class CerebrasLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "gpt-oss-120b". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=CerebrasLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = CerebrasLLMSettings(model="gpt-oss-120b") + default_settings = self.Settings(model="gpt-oss-120b") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", CerebrasLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index 3227bd0a6..085d1ed2c 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -116,14 +116,14 @@ class DeepgramFluxSTTService(WebsocketSTTService): """ Settings = DeepgramFluxSTTSettings - _settings: DeepgramFluxSTTSettings + _settings: Settings _CONFIGURE_FIELDS = {"keyterm", "eot_threshold", "eager_eot_threshold", "eot_timeout_ms"} class InputParams(BaseModel): """Configuration parameters for Deepgram Flux API. .. deprecated:: 0.0.105 - Use ``settings=DeepgramFluxSTTSettings(...)`` instead. + Use ``settings=DeepgramFluxSTTService.Settings(...)`` instead. Parameters: eager_eot_threshold: Optional. EagerEndOfTurn/TurnResumed are off by default. @@ -162,7 +162,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): tag: Optional[list] = None, params: Optional[InputParams] = None, should_interrupt: bool = True, - settings: Optional[DeepgramFluxSTTSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Deepgram Flux STT service. @@ -176,7 +176,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): model: Deepgram Flux model to use for transcription. .. deprecated:: 0.0.105 - Use ``settings=DeepgramFluxSTTSettings(model=...)`` instead. + Use ``settings=DeepgramFluxSTTService.Settings(model=...)`` instead. flux_encoding: Audio encoding format required by Flux API. Must be "linear16". Raw signed little-endian 16-bit PCM encoding. @@ -184,7 +184,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): params: InputParams instance containing detailed API configuration options. .. deprecated:: 0.0.105 - Use ``settings=DeepgramFluxSTTSettings(...)`` instead. + Use ``settings=DeepgramFluxSTTService.Settings(...)`` instead. should_interrupt: Determine whether the bot should be interrupted when Flux detects that the user is speaking. settings: Runtime-updatable settings. When provided alongside deprecated @@ -200,7 +200,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): stt = DeepgramFluxSTTService( api_key="your-api-key", - settings=DeepgramFluxSTTSettings( + settings=DeepgramFluxSTTService.Settings( model="flux-general-en", eager_eot_threshold=0.5, eot_threshold=0.8, @@ -221,7 +221,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): # already try to reconnect if needed. # 1. Initialize default_settings with hardcoded defaults - default_settings = DeepgramFluxSTTSettings( + default_settings = self.Settings( model="flux-general-en", language=Language.EN, eager_eot_threshold=None, @@ -233,12 +233,12 @@ class DeepgramFluxSTTService(WebsocketSTTService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", DeepgramFluxSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", DeepgramFluxSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.eager_eot_threshold = params.eager_eot_threshold default_settings.eot_threshold = params.eot_threshold @@ -448,7 +448,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): """ return True - async def _update_settings(self, delta: DeepgramFluxSTTSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply a settings delta. Configure-able fields (keyterm, eot_threshold, eager_eot_threshold, diff --git a/src/pipecat/services/deepgram/sagemaker/stt.py b/src/pipecat/services/deepgram/sagemaker/stt.py index f6093a630..98b3556cc 100644 --- a/src/pipecat/services/deepgram/sagemaker/stt.py +++ b/src/pipecat/services/deepgram/sagemaker/stt.py @@ -32,7 +32,7 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.aws.sagemaker.bidi_client import SageMakerBidiClient -from pipecat.services.deepgram.stt import DeepgramSTTSettings, LiveOptions +from pipecat.services.deepgram.stt import DeepgramSTTService, LiveOptions from pipecat.services.settings import STTSettings, _warn_deprecated_param, is_given from pipecat.services.stt_latency import DEEPGRAM_SAGEMAKER_TTFS_P99 from pipecat.services.stt_service import STTService @@ -42,10 +42,10 @@ from pipecat.utils.tracing.service_decorators import traced_stt @dataclass -class DeepgramSageMakerSTTSettings(DeepgramSTTSettings): +class DeepgramSageMakerSTTSettings(DeepgramSTTService.Settings): """Settings for the Deepgram SageMaker STT service. - Inherits all fields from :class:`DeepgramSTTSettings`. + Inherits all fields from :class:`DeepgramSTTService.Settings`. """ pass @@ -79,7 +79,7 @@ class DeepgramSageMakerSTTService(STTService): """ Settings = DeepgramSageMakerSTTSettings - _settings: DeepgramSageMakerSTTSettings + _settings: Settings def __init__( self, @@ -92,7 +92,7 @@ class DeepgramSageMakerSTTService(STTService): sample_rate: Optional[int] = None, mip_opt_out: Optional[bool] = None, live_options: Optional[LiveOptions] = None, - settings: Optional[DeepgramSageMakerSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = DEEPGRAM_SAGEMAKER_TTFS_P99, **kwargs, ): @@ -112,7 +112,7 @@ class DeepgramSageMakerSTTService(STTService): live_options: Legacy configuration options. .. deprecated:: 0.0.105 - Use ``settings=DeepgramSageMakerSTTSettings(...)`` for + Use ``settings=DeepgramSageMakerSTTService.Settings(...)`` for runtime-updatable fields and direct init parameters for connection-level config. @@ -124,7 +124,7 @@ class DeepgramSageMakerSTTService(STTService): **kwargs: Additional arguments passed to the parent STTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = DeepgramSageMakerSTTSettings( + default_settings = self.Settings( model="nova-3", language=Language.EN, detect_entities=False, @@ -147,7 +147,7 @@ class DeepgramSageMakerSTTService(STTService): # 2. Apply live_options overrides — only if settings not provided if live_options is not None: - _warn_deprecated_param("live_options", DeepgramSageMakerSTTSettings) + _warn_deprecated_param("live_options", self.Settings) if not settings: # Extract init-only fields from live_options if live_options.sample_rate is not None and sample_rate is None: @@ -170,7 +170,7 @@ class DeepgramSageMakerSTTService(STTService): "mip_opt_out", } lo_dict = {k: v for k, v in live_options.to_dict().items() if k not in init_only} - delta = DeepgramSageMakerSTTSettings.from_mapping(lo_dict) + delta = self.Settings.from_mapping(lo_dict) default_settings.apply_update(delta) # 3. Apply settings delta (canonical API, always wins) @@ -216,7 +216,7 @@ class DeepgramSageMakerSTTService(STTService): return changed # Sync extra to fields after the update so self._settings stays unambiguous - if isinstance(self._settings, DeepgramSTTSettings): + if isinstance(self._settings, self.Settings): self._settings._sync_extra_to_fields() # TODO: someday we could reconnect here to apply updated settings. diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index d315b9e01..f2c55c882 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -70,7 +70,7 @@ class DeepgramSageMakerTTSService(TTSService): """ Settings = DeepgramSageMakerTTSSettings - _settings: DeepgramSageMakerTTSSettings + _settings: Settings def __init__( self, @@ -80,7 +80,7 @@ class DeepgramSageMakerTTSService(TTSService): voice: Optional[str] = None, sample_rate: Optional[int] = None, encoding: str = "linear16", - settings: Optional[DeepgramSageMakerTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Deepgram SageMaker TTS service. @@ -92,7 +92,7 @@ class DeepgramSageMakerTTSService(TTSService): voice: Voice model to use for synthesis. Defaults to "aura-2-helena-en". .. deprecated:: 0.0.105 - Use ``settings=DeepgramSageMakerTTSSettings(voice=...)`` instead. + Use ``settings=DeepgramSageMakerTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses the value from StartFrame. encoding: Audio encoding format. Defaults to "linear16". @@ -101,11 +101,11 @@ class DeepgramSageMakerTTSService(TTSService): **kwargs: Additional arguments passed to the parent TTSService. """ if voice is not None: - _warn_deprecated_param("voice", DeepgramSageMakerTTSSettings, "voice") + _warn_deprecated_param("voice", self.Settings, "voice") voice = voice or "aura-2-helena-en" - default_settings = DeepgramSageMakerTTSSettings( + default_settings = self.Settings( model=None, voice=voice, language=None, diff --git a/src/pipecat/services/deepgram/stt.py b/src/pipecat/services/deepgram/stt.py index d8f782f5d..e84964dce 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -59,7 +59,7 @@ class LiveOptions: deepgram-sdk v6. .. deprecated:: 0.0.105 - Use ``settings=DeepgramSTTSettings(...)`` for runtime-updatable fields + Use ``settings=DeepgramSTTService.Settings(...)`` for runtime-updatable fields and direct ``__init__`` parameters for connection-level config instead. """ @@ -267,7 +267,7 @@ class DeepgramSTTService(STTService): """ Settings = DeepgramSTTSettings - _settings: DeepgramSTTSettings + _settings: Settings def __init__( self, @@ -286,7 +286,7 @@ class DeepgramSTTService(STTService): live_options: Optional[LiveOptions] = None, addons: Optional[dict] = None, should_interrupt: bool = True, - settings: Optional[DeepgramSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = DEEPGRAM_TTFS_P99, **kwargs, ): @@ -313,7 +313,7 @@ class DeepgramSTTService(STTService): live_options: Legacy configuration options. .. deprecated:: 0.0.105 - Use ``settings=DeepgramSTTSettings(...)`` for runtime-updatable + Use ``settings=DeepgramSTTService.Settings(...)`` for runtime-updatable fields and direct init parameters for connection-level config. addons: Additional Deepgram features to enable. @@ -345,7 +345,7 @@ class DeepgramSTTService(STTService): base_url = url # 1. Initialize default_settings with hardcoded defaults - default_settings = DeepgramSTTSettings( + default_settings = self.Settings( model="nova-3-general", language=Language.EN, detect_entities=False, @@ -370,7 +370,7 @@ class DeepgramSTTService(STTService): # 3. Apply live_options overrides — only if settings not provided if live_options is not None: - _warn_deprecated_param("live_options", DeepgramSTTSettings) + _warn_deprecated_param("live_options", self.Settings) if not settings: # Extract init-only fields from live_options if live_options.sample_rate is not None and sample_rate is None: @@ -402,7 +402,7 @@ class DeepgramSTTService(STTService): "mip_opt_out", } lo_dict = {k: v for k, v in live_options.to_dict().items() if k not in init_only} - delta = DeepgramSTTSettings.from_mapping(lo_dict) + delta = self.Settings.from_mapping(lo_dict) default_settings.apply_update(delta) # 4. Apply settings delta (canonical API, always wins) @@ -494,7 +494,7 @@ class DeepgramSTTService(STTService): return changed # Sync extra to fields after the update so self._settings stays unambiguous - if isinstance(self._settings, DeepgramSTTSettings): + if isinstance(self._settings, self.Settings): self._settings._sync_extra_to_fields() if self._connection: diff --git a/src/pipecat/services/deepgram/tts.py b/src/pipecat/services/deepgram/tts.py index 791462a91..5fdbeb700 100644 --- a/src/pipecat/services/deepgram/tts.py +++ b/src/pipecat/services/deepgram/tts.py @@ -57,7 +57,7 @@ class DeepgramTTSService(WebsocketTTSService): """ Settings = DeepgramTTSSettings - _settings: DeepgramTTSSettings + _settings: Settings SUPPORTED_ENCODINGS = ("linear16", "mulaw", "alaw") @@ -69,7 +69,7 @@ class DeepgramTTSService(WebsocketTTSService): base_url: str = "wss://api.deepgram.com", sample_rate: Optional[int] = None, encoding: str = "linear16", - settings: Optional[DeepgramTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Deepgram WebSocket TTS service. @@ -79,7 +79,7 @@ class DeepgramTTSService(WebsocketTTSService): voice: Voice model to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=DeepgramTTSSettings(voice=...)`` instead. + Use ``settings=DeepgramTTSService.Settings(voice=...)`` instead. base_url: WebSocket base URL for Deepgram API. Defaults to "wss://api.deepgram.com". sample_rate: Audio sample rate in Hz. If None, uses service default. @@ -97,7 +97,7 @@ class DeepgramTTSService(WebsocketTTSService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = DeepgramTTSSettings( + default_settings = self.Settings( model=None, voice="aura-2-helena-en", language=None, @@ -105,7 +105,7 @@ class DeepgramTTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice is not None: - _warn_deprecated_param("voice", DeepgramTTSSettings, "voice") + _warn_deprecated_param("voice", self.Settings, "voice") default_settings.model = voice default_settings.voice = voice @@ -189,7 +189,7 @@ class DeepgramTTSService(WebsocketTTSService): """Apply a settings delta. Args: - delta: A :class:`TTSSettings` (or ``DeepgramTTSSettings``) delta. + delta: A :class:`TTSSettings` (or ``DeepgramTTSService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. @@ -367,7 +367,7 @@ class DeepgramHttpTTSService(TTSService): """ Settings = DeepgramTTSSettings - _settings: DeepgramTTSSettings + _settings: Settings def __init__( self, @@ -378,7 +378,7 @@ class DeepgramHttpTTSService(TTSService): base_url: str = "https://api.deepgram.com", sample_rate: Optional[int] = None, encoding: str = "linear16", - settings: Optional[DeepgramTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Deepgram TTS service. @@ -388,7 +388,7 @@ class DeepgramHttpTTSService(TTSService): voice: Voice model to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=DeepgramTTSSettings(voice=...)`` instead. + Use ``settings=DeepgramHttpTTSService.Settings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests with connection pooling. base_url: Custom base URL for Deepgram API. Defaults to "https://api.deepgram.com". @@ -399,7 +399,7 @@ class DeepgramHttpTTSService(TTSService): **kwargs: Additional arguments passed to parent TTSService class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = DeepgramTTSSettings( + default_settings = self.Settings( model=None, voice="aura-2-helena-en", language=None, @@ -407,7 +407,7 @@ class DeepgramHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice is not None: - _warn_deprecated_param("voice", DeepgramTTSSettings, "voice") + _warn_deprecated_param("voice", self.Settings, "voice") default_settings.model = voice default_settings.voice = voice diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index 8fc4b5db8..abb0d56bb 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -12,13 +12,13 @@ from typing import Optional from loguru import logger from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class DeepSeekLLMSettings(OpenAILLMSettings): +class DeepSeekLLMSettings(BaseOpenAILLMService.Settings): """Settings for DeepSeekLLMService.""" pass @@ -32,7 +32,7 @@ class DeepSeekLLMService(OpenAILLMService): """ Settings = DeepSeekLLMSettings - _settings: DeepSeekLLMSettings + _settings: Settings def __init__( self, @@ -40,7 +40,7 @@ class DeepSeekLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.deepseek.com/v1", model: Optional[str] = None, - settings: Optional[DeepSeekLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the DeepSeek LLM service. @@ -51,18 +51,18 @@ class DeepSeekLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "deepseek-chat". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=DeepSeekLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = DeepSeekLLMSettings(model="deepseek-chat") + default_settings = self.Settings(model="deepseek-chat") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", DeepSeekLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/elevenlabs/stt.py b/src/pipecat/services/elevenlabs/stt.py index 76e854ade..7247241d3 100644 --- a/src/pipecat/services/elevenlabs/stt.py +++ b/src/pipecat/services/elevenlabs/stt.py @@ -217,13 +217,13 @@ class ElevenLabsSTTService(SegmentedSTTService): """ Settings = ElevenLabsSTTSettings - _settings: ElevenLabsSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for ElevenLabs STT API. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsSTTSettings(...)`` instead. + Use ``settings=ElevenLabsSTTService.Settings(...)`` instead. Parameters: language: Target language for transcription. @@ -242,7 +242,7 @@ class ElevenLabsSTTService(SegmentedSTTService): model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[ElevenLabsSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = ELEVENLABS_TTFS_P99, **kwargs, ): @@ -255,13 +255,13 @@ class ElevenLabsSTTService(SegmentedSTTService): model: Model ID for transcription. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsSTTSettings(model=...)`` instead. + Use ``settings=ElevenLabsSTTService.Settings(model=...)`` instead. sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate. params: Configuration parameters for the STT service. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsSTTSettings(...)`` instead. + Use ``settings=ElevenLabsSTTService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -270,7 +270,7 @@ class ElevenLabsSTTService(SegmentedSTTService): **kwargs: Additional arguments passed to SegmentedSTTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = ElevenLabsSTTSettings( + default_settings = self.Settings( model="scribe_v2", language=language_to_elevenlabs_language(Language.EN), tag_audio_events=None, @@ -278,12 +278,12 @@ class ElevenLabsSTTService(SegmentedSTTService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", ElevenLabsSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", ElevenLabsSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = language_to_elevenlabs_language(params.language) @@ -450,13 +450,13 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): """ Settings = ElevenLabsRealtimeSTTSettings - _settings: ElevenLabsRealtimeSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for ElevenLabs Realtime STT API. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. + Use ``settings=ElevenLabsRealtimeSTTService.Settings(...)`` instead. Parameters: language_code: ISO-639-1 or ISO-639-3 language code. Leave None for auto-detection. @@ -496,7 +496,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): enable_logging: bool = False, include_language_detection: bool = False, params: Optional[InputParams] = None, - settings: Optional[ElevenLabsRealtimeSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = ELEVENLABS_REALTIME_TTFS_P99, **kwargs, ): @@ -511,7 +511,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): model: Model ID for transcription. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsRealtimeSTTSettings(model=...)`` instead. + Use ``settings=ElevenLabsRealtimeSTTService.Settings(model=...)`` instead. sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate. include_timestamps: Whether to include word-level timestamps in transcripts. @@ -520,7 +520,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): params: Configuration parameters for the STT service. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. + Use ``settings=ElevenLabsRealtimeSTTService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -529,7 +529,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): **kwargs: Additional arguments passed to WebsocketSTTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = ElevenLabsRealtimeSTTSettings( + default_settings = self.Settings( model="scribe_v2_realtime", language=None, vad_silence_threshold_secs=None, @@ -540,12 +540,12 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", ElevenLabsRealtimeSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", ElevenLabsRealtimeSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = params.language_code if params.commit_strategy != CommitStrategy.MANUAL: @@ -597,7 +597,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): """Apply a settings delta and reconnect if anything changed. Args: - delta: A :class:`STTSettings` (or ``ElevenLabsRealtimeSTTSettings``) delta. + delta: A :class:`STTSettings` (or ``ElevenLabsRealtimeSTTService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 01f3cd516..46acc2f1c 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -317,13 +317,13 @@ class ElevenLabsTTSService(WebsocketTTSService): """ Settings = ElevenLabsTTSSettings - _settings: ElevenLabsTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for ElevenLabs TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsTTSSettings(...)`` instead. + Use ``settings=ElevenLabsTTSService.Settings(...)`` instead. Parameters: language: Language to use for synthesis. @@ -364,7 +364,7 @@ class ElevenLabsTTSService(WebsocketTTSService): enable_logging: Optional[bool] = None, pronunciation_dictionary_locators: Optional[List[PronunciationDictionaryLocator]] = None, params: Optional[InputParams] = None, - settings: Optional[ElevenLabsTTSSettings] = None, + settings: Optional[Settings] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, **kwargs, @@ -376,12 +376,12 @@ class ElevenLabsTTSService(WebsocketTTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsTTSSettings(voice=...)`` instead. + Use ``settings=ElevenLabsTTSService.Settings(voice=...)`` instead. model: TTS model to use (e.g., "eleven_turbo_v2_5"). .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsTTSSettings(model=...)`` instead. + Use ``settings=ElevenLabsTTSService.Settings(model=...)`` instead. url: WebSocket URL for ElevenLabs TTS API. sample_rate: Audio sample rate. If None, uses default. @@ -393,7 +393,7 @@ class ElevenLabsTTSService(WebsocketTTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsTTSSettings(...)`` instead. + Use ``settings=ElevenLabsTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -423,7 +423,7 @@ class ElevenLabsTTSService(WebsocketTTSService): # after a short period not receiving any audio. # 1. Initialize default_settings with hardcoded defaults - default_settings = ElevenLabsTTSSettings( + default_settings = self.Settings( model="eleven_turbo_v2_5", voice=None, language=None, @@ -437,16 +437,16 @@ class ElevenLabsTTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", ElevenLabsTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", ElevenLabsTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided _pronunciation_dictionary_locators = pronunciation_dictionary_locators if params is not None: - _warn_deprecated_param("params", ElevenLabsTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) @@ -533,11 +533,11 @@ class ElevenLabsTTSService(WebsocketTTSService): """Apply a settings delta, reconnecting as needed. Uses the declarative ``URL_FIELDS`` and ``VOICE_SETTINGS_FIELDS`` - sets on :class:`ElevenLabsTTSSettings` to decide whether to + sets on :class:`ElevenLabsTTSService.Settings` to decide whether to reconnect the WebSocket or close the current audio context. Args: - delta: A :class:`TTSSettings` (or ``ElevenLabsTTSSettings``) delta. + delta: A :class:`TTSSettings` (or ``ElevenLabsTTSService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. @@ -550,19 +550,19 @@ class ElevenLabsTTSService(WebsocketTTSService): # Rebuild voice settings for next context self._voice_settings = self._set_voice_settings() - url_changed = bool(changed.keys() & ElevenLabsTTSSettings.URL_FIELDS) - voice_settings_changed = bool(changed.keys() & ElevenLabsTTSSettings.VOICE_SETTINGS_FIELDS) + url_changed = bool(changed.keys() & self.Settings.URL_FIELDS) + voice_settings_changed = bool(changed.keys() & self.Settings.VOICE_SETTINGS_FIELDS) if url_changed: logger.debug( - f"URL-level setting changed ({changed.keys() & ElevenLabsTTSSettings.URL_FIELDS}), " + f"URL-level setting changed ({changed.keys() & self.Settings.URL_FIELDS}), " f"reconnecting WebSocket" ) await self._disconnect() await self._connect() elif voice_settings_changed: logger.debug( - f"Voice settings changed ({changed.keys() & ElevenLabsTTSSettings.VOICE_SETTINGS_FIELDS}), " + f"Voice settings changed ({changed.keys() & self.Settings.VOICE_SETTINGS_FIELDS}), " f"closing current context to apply changes" ) audio_contexts = self.get_audio_contexts() @@ -573,7 +573,7 @@ class ElevenLabsTTSService(WebsocketTTSService): if not url_changed: # Reconnect applies all settings; only warn about fields not handled # by voice settings or URL changes. - handled = ElevenLabsTTSSettings.URL_FIELDS | ElevenLabsTTSSettings.VOICE_SETTINGS_FIELDS + handled = self.Settings.URL_FIELDS | self.Settings.VOICE_SETTINGS_FIELDS self._warn_unhandled_updated_settings(changed.keys() - handled) return changed @@ -906,13 +906,13 @@ class ElevenLabsHttpTTSService(TTSService): """ Settings = ElevenLabsHttpTTSSettings - _settings: ElevenLabsHttpTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for ElevenLabs HTTP TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. + Use ``settings=ElevenLabsHttpTTSService.Settings(...)`` instead. Parameters: language: Language to use for synthesis. @@ -947,7 +947,7 @@ class ElevenLabsHttpTTSService(TTSService): sample_rate: Optional[int] = None, pronunciation_dictionary_locators: Optional[List[PronunciationDictionaryLocator]] = None, params: Optional[InputParams] = None, - settings: Optional[ElevenLabsHttpTTSSettings] = None, + settings: Optional[Settings] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, **kwargs, @@ -959,13 +959,13 @@ class ElevenLabsHttpTTSService(TTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsHttpTTSSettings(voice=...)`` instead. + Use ``settings=ElevenLabsHttpTTSService.Settings(voice=...)`` instead. aiohttp_session: aiohttp ClientSession for HTTP requests. model: TTS model to use (e.g., "eleven_turbo_v2_5"). .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsHttpTTSSettings(model=...)`` instead. + Use ``settings=ElevenLabsHttpTTSService.Settings(model=...)`` instead. base_url: Base URL for ElevenLabs HTTP API. sample_rate: Audio sample rate. If None, uses default. @@ -974,7 +974,7 @@ class ElevenLabsHttpTTSService(TTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. + Use ``settings=ElevenLabsHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -987,7 +987,7 @@ class ElevenLabsHttpTTSService(TTSService): **kwargs: Additional arguments passed to the parent service. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = ElevenLabsHttpTTSSettings( + default_settings = self.Settings( model="eleven_turbo_v2_5", voice=None, language=None, @@ -1002,16 +1002,16 @@ class ElevenLabsHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", ElevenLabsHttpTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", ElevenLabsHttpTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided _pronunciation_dictionary_locators = pronunciation_dictionary_locators if params is not None: - _warn_deprecated_param("params", ElevenLabsHttpTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) @@ -1091,7 +1091,7 @@ class ElevenLabsHttpTTSService(TTSService): """Apply a settings delta and rebuild voice settings. Args: - delta: A :class:`TTSSettings` (or ``ElevenLabsHttpTTSSettings``) delta. + delta: A :class:`TTSSettings` (or ``ElevenLabsHttpTTSService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/fal/image.py b/src/pipecat/services/fal/image.py index cb4d646ba..3c15a918a 100644 --- a/src/pipecat/services/fal/image.py +++ b/src/pipecat/services/fal/image.py @@ -71,13 +71,13 @@ class FalImageGenService(ImageGenService): """ Settings = FalImageGenSettings - _settings: FalImageGenSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Fal.ai image generation. .. deprecated:: 0.0.105 - Use ``settings=FalImageGenSettings(...)`` instead. + Use ``settings=FalImageGenService.Settings(...)`` instead. Parameters: seed: Random seed for reproducible generation. If None, uses random seed. @@ -97,7 +97,7 @@ class FalImageGenService(ImageGenService): enable_safety_checker: bool = True format: str = "png" - _settings: FalImageGenSettings + _settings: Settings def __init__( self, @@ -106,7 +106,7 @@ class FalImageGenService(ImageGenService): aiohttp_session: aiohttp.ClientSession, model: Optional[str] = None, key: Optional[str] = None, - settings: Optional[FalImageGenSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the FalImageGenService. @@ -115,13 +115,13 @@ class FalImageGenService(ImageGenService): params: Input parameters for image generation configuration. .. deprecated:: 0.0.105 - Use ``settings=FalImageGenSettings(...)`` instead. + Use ``settings=FalImageGenService.Settings(...)`` instead. aiohttp_session: HTTP client session for downloading generated images. model: The Fal.ai model to use for generation. Defaults to "fal-ai/fast-sdxl". .. deprecated:: 0.0.105 - Use ``settings=FalImageGenSettings(model=...)`` instead. + Use ``settings=FalImageGenService.Settings(model=...)`` instead. key: Optional API key for Fal.ai. If provided, sets FAL_KEY environment variable. settings: Runtime-updatable settings. When provided alongside deprecated @@ -129,7 +129,7 @@ class FalImageGenService(ImageGenService): **kwargs: Additional arguments passed to parent ImageGenService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = FalImageGenSettings( + default_settings = self.Settings( model="fal-ai/fast-sdxl", seed=None, num_inference_steps=8, @@ -142,11 +142,11 @@ class FalImageGenService(ImageGenService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", FalImageGenSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if params is not None: - _warn_deprecated_param("params", FalImageGenSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.seed = params.seed default_settings.num_inference_steps = params.num_inference_steps diff --git a/src/pipecat/services/fal/stt.py b/src/pipecat/services/fal/stt.py index 692878bf6..c1aae24b7 100644 --- a/src/pipecat/services/fal/stt.py +++ b/src/pipecat/services/fal/stt.py @@ -156,13 +156,13 @@ class FalSTTService(SegmentedSTTService): """ Settings = FalSTTSettings - _settings: FalSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Fal's Wizper API. .. deprecated:: 0.0.105 - Use ``settings=FalSTTSettings(...)`` instead. + Use ``settings=FalSTTService.Settings(...)`` instead. Parameters: language: Language of the audio input. Defaults to English. @@ -186,7 +186,7 @@ class FalSTTService(SegmentedSTTService): version: str = "3", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[FalSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = FAL_TTFS_P99, **kwargs, ): @@ -204,7 +204,7 @@ class FalSTTService(SegmentedSTTService): params: Configuration parameters for the Wizper API. .. deprecated:: 0.0.105 - Use ``settings=FalSTTSettings(...)`` for model/language and + Use ``settings=FalSTTService.Settings(...)`` for model/language and direct init parameters for task/chunk_level/version instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -214,7 +214,7 @@ class FalSTTService(SegmentedSTTService): **kwargs: Additional arguments passed to SegmentedSTTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = FalSTTSettings( + default_settings = self.Settings( model=None, language=language_to_fal_language(Language.EN), ) @@ -223,7 +223,7 @@ class FalSTTService(SegmentedSTTService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", FalSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = language_to_fal_language(params.language) diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index 118090be9..fdd688149 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -12,13 +12,13 @@ from typing import Optional from loguru import logger from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class FireworksLLMSettings(OpenAILLMSettings): +class FireworksLLMSettings(BaseOpenAILLMService.Settings): """Settings for FireworksLLMService.""" pass @@ -32,7 +32,7 @@ class FireworksLLMService(OpenAILLMService): """ Settings = FireworksLLMSettings - _settings: FireworksLLMSettings + _settings: Settings def __init__( self, @@ -40,7 +40,7 @@ class FireworksLLMService(OpenAILLMService): api_key: str, model: Optional[str] = None, base_url: str = "https://api.fireworks.ai/inference/v1", - settings: Optional[FireworksLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Fireworks LLM service. @@ -50,7 +50,7 @@ class FireworksLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "accounts/fireworks/models/firefunction-v2". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=FireworksLLMService.Settings(model=...)`` instead. base_url: The base URL for Fireworks API. Defaults to "https://api.fireworks.ai/inference/v1". settings: Runtime-updatable settings. When provided alongside deprecated @@ -58,11 +58,11 @@ class FireworksLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = FireworksLLMSettings(model="accounts/fireworks/models/firefunction-v2") + default_settings = self.Settings(model="accounts/fireworks/models/firefunction-v2") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", FireworksLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index f21b42b97..39669574a 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -85,13 +85,13 @@ class FishAudioTTSService(InterruptibleTTSService): """ Settings = FishAudioTTSSettings - _settings: FishAudioTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Fish Audio TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=FishAudioTTSSettings(...)`` instead. + Use ``settings=FishAudioTTSService.Settings(...)`` instead. Parameters: language: Language for synthesis. Defaults to English. @@ -117,7 +117,7 @@ class FishAudioTTSService(InterruptibleTTSService): output_format: FishAudioOutputFormat = "pcm", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[FishAudioTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Fish Audio TTS service. @@ -127,7 +127,7 @@ class FishAudioTTSService(InterruptibleTTSService): reference_id: Reference ID of the voice model to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=FishAudioTTSSettings(voice=...)`` instead. + Use ``settings=FishAudioTTSService.Settings(voice=...)`` instead. model: Deprecated. Reference ID of the voice model to use for synthesis. @@ -138,14 +138,14 @@ class FishAudioTTSService(InterruptibleTTSService): model_id: Specify which Fish Audio TTS model to use (e.g. "s1"). .. deprecated:: 0.0.105 - Use ``settings=FishAudioTTSSettings(model=...)`` instead. + Use ``settings=FishAudioTTSService.Settings(model=...)`` instead. output_format: Audio output format. Defaults to "pcm". sample_rate: Audio sample rate. If None, uses default. params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=FishAudioTTSSettings(...)`` instead. + Use ``settings=FishAudioTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -171,7 +171,7 @@ class FishAudioTTSService(InterruptibleTTSService): reference_id = model # 1. Initialize default_settings with hardcoded defaults - default_settings = FishAudioTTSSettings( + default_settings = self.Settings( model="s2-pro", voice=None, language=None, @@ -185,15 +185,15 @@ class FishAudioTTSService(InterruptibleTTSService): # 2. Apply direct init arg overrides (deprecated) if reference_id is not None: - _warn_deprecated_param("reference_id", FishAudioTTSSettings, "voice") + _warn_deprecated_param("reference_id", self.Settings, "voice") default_settings.voice = reference_id if model_id is not None: - _warn_deprecated_param("model_id", FishAudioTTSSettings, "model") + _warn_deprecated_param("model_id", self.Settings, "model") default_settings.model = model_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", FishAudioTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.latency is not None: default_settings.latency = params.latency @@ -240,7 +240,7 @@ class FishAudioTTSService(InterruptibleTTSService): Any change to voice or model triggers a WebSocket reconnect. Args: - delta: A :class:`TTSSettings` (or ``FishAudioTTSSettings``) delta. + delta: A :class:`TTSSettings` (or ``FishAudioTTSService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/gladia/config.py b/src/pipecat/services/gladia/config.py index ec8997d7c..c492a04a1 100644 --- a/src/pipecat/services/gladia/config.py +++ b/src/pipecat/services/gladia/config.py @@ -153,7 +153,7 @@ class GladiaInputParams(BaseModel): """Configuration parameters for the Gladia STT service. .. deprecated:: 0.0.105 - Use ``settings=GladiaSTTSettings(...)`` for runtime-updatable + Use ``settings=GladiaSTTService.Settings(...)`` for runtime-updatable fields and direct init parameters for encoding/bit_depth/channels. Parameters: diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index fc09d94fc..a68bf78b3 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -231,7 +231,7 @@ class GladiaSTTService(WebsocketSTTService): """ Settings = GladiaSTTSettings - _settings: GladiaSTTSettings + _settings: Settings # Maintain backward compatibility InputParams = _InputParamsDescriptor() @@ -251,7 +251,7 @@ class GladiaSTTService(WebsocketSTTService): params: Optional[GladiaInputParams] = None, max_buffer_size: int = 1024 * 1024 * 20, # 20MB default buffer should_interrupt: bool = True, - settings: Optional[GladiaSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = GLADIA_TTFS_P99, **kwargs, ): @@ -274,12 +274,12 @@ class GladiaSTTService(WebsocketSTTService): model: Model to use for transcription. .. deprecated:: 0.0.105 - Use ``settings=GladiaSTTSettings(model=...)`` instead. + Use ``settings=GladiaSTTService.Settings(model=...)`` instead. params: Additional configuration parameters for Gladia service. .. deprecated:: 0.0.105 - Use ``settings=GladiaSTTSettings(...)`` for runtime-updatable + Use ``settings=GladiaSTTService.Settings(...)`` for runtime-updatable fields and direct init parameters for encoding/bit_depth/channels. max_buffer_size: Maximum size of audio buffer in bytes. Defaults to 20MB. @@ -302,7 +302,7 @@ class GladiaSTTService(WebsocketSTTService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = GladiaSTTSettings( + default_settings = self.Settings( model="solaria-1", language=None, language_config=None, @@ -317,12 +317,12 @@ class GladiaSTTService(WebsocketSTTService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GladiaSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GladiaSTTSettings) + _warn_deprecated_param("params", self.Settings) if params.language is not None: with warnings.catch_warnings(): warnings.simplefilter("always") @@ -469,7 +469,7 @@ class GladiaSTTService(WebsocketSTTService): await super().start(frame) await self._connect() - async def _update_settings(self, delta: GladiaSTTSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply settings delta. Settings are stored but not applied to the active session. diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index 07f185f99..167abb938 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -553,7 +553,7 @@ class InputParams(BaseModel): """Input parameters for Gemini Live generation. .. deprecated:: 0.0.105 - Use ``GeminiLiveLLMSettings`` instead. + Use ``GeminiLiveLLMService.Settings`` instead. Parameters: frequency_penalty: Frequency penalty for generation (0.0-2.0). Defaults to None. @@ -643,7 +643,7 @@ class GeminiLiveLLMService(LLMService): """ Settings = GeminiLiveLLMSettings - _settings: GeminiLiveLLMSettings + _settings: Settings # Overriding the default adapter to use the Gemini one. adapter_class = GeminiLLMAdapter @@ -660,7 +660,7 @@ class GeminiLiveLLMService(LLMService): system_instruction: Optional[str] = None, tools: Optional[Union[List[dict], ToolsSchema]] = None, params: Optional[InputParams] = None, - settings: Optional[GeminiLiveLLMSettings] = None, + settings: Optional[Settings] = None, inference_on_context_initialization: bool = True, file_api_base_url: str = "https://generativelanguage.googleapis.com/v1beta/files", http_options: Optional[HttpOptions] = None, @@ -680,12 +680,12 @@ class GeminiLiveLLMService(LLMService): model: Model identifier to use. .. deprecated:: 0.0.105 - Use ``settings=GeminiLiveLLMSettings(model=...)`` instead. + Use ``settings=GeminiLiveLLMService.Settings(model=...)`` instead. voice_id: TTS voice identifier. Defaults to "Charon". .. deprecated:: 0.0.105 - Use ``settings=GeminiLiveLLMSettings(voice=...)`` instead. + Use ``settings=GeminiLiveLLMService.Settings(voice=...)`` instead. start_audio_paused: Whether to start with audio input paused. Defaults to False. start_video_paused: Whether to start with video input paused. Defaults to False. system_instruction: System prompt for the model. Defaults to None. @@ -693,7 +693,7 @@ class GeminiLiveLLMService(LLMService): params: Configuration parameters for the model. .. deprecated:: 0.0.105 - Use ``settings=GeminiLiveLLMSettings(...)`` instead. + Use ``settings=GeminiLiveLLMService.Settings(...)`` instead. settings: Gemini Live LLM settings. If provided together with deprecated top-level parameters, the ``settings`` values take precedence. @@ -716,7 +716,7 @@ class GeminiLiveLLMService(LLMService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = GeminiLiveLLMSettings( + default_settings = self.Settings( model="models/gemini-2.5-flash-native-audio-preview-12-2025", system_instruction=system_instruction, voice="Charon", @@ -742,15 +742,15 @@ class GeminiLiveLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GeminiLiveLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id != "Charon": - _warn_deprecated_param("voice_id", GeminiLiveLLMSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GeminiLiveLLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.frequency_penalty = params.frequency_penalty default_settings.max_tokens = params.max_tokens diff --git a/src/pipecat/services/google/gemini_live/vertex/llm.py b/src/pipecat/services/google/gemini_live/vertex/llm.py index cdfde1660..c610b4cdb 100644 --- a/src/pipecat/services/google/gemini_live/vertex/llm.py +++ b/src/pipecat/services/google/gemini_live/vertex/llm.py @@ -20,7 +20,6 @@ from loguru import logger from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.services.google.gemini_live.llm import ( GeminiLiveLLMService, - GeminiLiveLLMSettings, GeminiMediaResolution, GeminiModalities, HttpOptions, @@ -43,7 +42,7 @@ except ModuleNotFoundError as e: @dataclass -class GeminiLiveVertexLLMSettings(GeminiLiveLLMSettings): +class GeminiLiveVertexLLMSettings(GeminiLiveLLMService.Settings): """Settings for GeminiLiveVertexLLMService.""" pass @@ -58,7 +57,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): """ Settings = GeminiLiveVertexLLMSettings - _settings: GeminiLiveVertexLLMSettings + _settings: Settings def __init__( self, @@ -74,7 +73,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): system_instruction: Optional[str] = None, tools: Optional[Union[List[dict], ToolsSchema]] = None, params: Optional[InputParams] = None, - settings: Optional[GeminiLiveVertexLLMSettings] = None, + settings: Optional[Settings] = None, inference_on_context_initialization: bool = True, file_api_base_url: str = "https://generativelanguage.googleapis.com/v1beta/files", http_options: Optional[HttpOptions] = None, @@ -90,12 +89,12 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): model: Model identifier to use. .. deprecated:: 0.0.105 - Use ``settings=GeminiLiveLLMSettings(model=...)`` instead. + Use ``settings=GeminiLiveVertexLLMService.Settings(model=...)`` instead. voice_id: TTS voice identifier. Defaults to "Charon". .. deprecated:: 0.0.105 - Use ``settings=GeminiLiveVertexLLMSettings(voice=...)`` instead. + Use ``settings=GeminiLiveVertexLLMService.Settings(voice=...)`` instead. start_audio_paused: Whether to start with audio input paused. Defaults to False. start_video_paused: Whether to start with video input paused. Defaults to False. system_instruction: System prompt for the model. Defaults to None. @@ -104,7 +103,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): location and project ID. .. deprecated:: 0.0.105 - Use ``settings=GeminiLiveLLMSettings(...)`` instead. + Use ``settings=GeminiLiveVertexLLMService.Settings(...)`` instead. settings: Gemini Live LLM settings. If provided together with deprecated top-level parameters, the ``settings`` values take precedence. @@ -136,7 +135,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # double deprecation warnings from the parent. # 1. Initialize default_settings with hardcoded defaults - default_settings = GeminiLiveVertexLLMSettings( + default_settings = self.Settings( model="google/gemini-live-2.5-flash-native-audio", voice="Charon", frequency_penalty=None, @@ -161,15 +160,15 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GeminiLiveVertexLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id != "Charon": - _warn_deprecated_param("voice_id", GeminiLiveVertexLLMSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GeminiLiveVertexLLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.frequency_penalty = params.frequency_penalty default_settings.max_tokens = params.max_tokens diff --git a/src/pipecat/services/google/image.py b/src/pipecat/services/google/image.py index 5cf37aa4e..40706ad50 100644 --- a/src/pipecat/services/google/image.py +++ b/src/pipecat/services/google/image.py @@ -60,13 +60,13 @@ class GoogleImageGenService(ImageGenService): """ Settings = GoogleImageGenSettings - _settings: GoogleImageGenSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Google image generation. .. deprecated:: 0.0.105 - Use ``settings=GoogleImageGenSettings(...)`` instead. + Use ``settings=GoogleImageGenService.Settings(...)`` instead. Parameters: number_of_images: Number of images to generate (1-8). Defaults to 1. @@ -84,7 +84,7 @@ class GoogleImageGenService(ImageGenService): api_key: str, params: Optional[InputParams] = None, http_options: Optional[Any] = None, - settings: Optional[GoogleImageGenSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the GoogleImageGenService with API key and parameters. @@ -94,7 +94,7 @@ class GoogleImageGenService(ImageGenService): params: Configuration parameters for image generation. .. deprecated:: 0.0.105 - Use ``settings=GoogleImageGenSettings(...)`` instead. + Use ``settings=GoogleImageGenService.Settings(...)`` instead. http_options: HTTP options for the client. settings: Runtime-updatable settings. When provided alongside deprecated @@ -102,7 +102,7 @@ class GoogleImageGenService(ImageGenService): **kwargs: Additional arguments passed to the parent ImageGenService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleImageGenSettings( + default_settings = self.Settings( model="imagen-3.0-generate-002", number_of_images=1, negative_prompt=None, @@ -110,7 +110,7 @@ class GoogleImageGenService(ImageGenService): # 2. Apply params overrides (deprecated) if params is not None: - _warn_deprecated_param("params", GoogleImageGenSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.model = params.model default_settings.number_of_images = params.number_of_images diff --git a/src/pipecat/services/google/llm.py b/src/pipecat/services/google/llm.py index cf9e91b53..2ade23906 100644 --- a/src/pipecat/services/google/llm.py +++ b/src/pipecat/services/google/llm.py @@ -743,7 +743,7 @@ class GoogleLLMService(LLMService): """ Settings = GoogleLLMSettings - _settings: GoogleLLMSettings + _settings: Settings # Overriding the default adapter to use the Gemini one. adapter_class = GeminiLLMAdapter @@ -755,7 +755,7 @@ class GoogleLLMService(LLMService): """Input parameters for Google AI models. .. deprecated:: 0.0.105 - Use ``settings=GoogleLLMSettings(...)`` instead. + Use ``settings=GoogleLLMService.Settings(...)`` instead. Parameters: max_tokens: Maximum number of tokens to generate. @@ -784,7 +784,7 @@ class GoogleLLMService(LLMService): api_key: str, model: Optional[str] = None, params: Optional[InputParams] = None, - settings: Optional[GoogleLLMSettings] = None, + settings: Optional[Settings] = None, system_instruction: Optional[str] = None, tools: Optional[List[Dict[str, Any]]] = None, tool_config: Optional[Dict[str, Any]] = None, @@ -798,12 +798,12 @@ class GoogleLLMService(LLMService): model: Model name to use. .. deprecated:: 0.0.105 - Use ``settings=GoogleLLMSettings(model=...)`` instead. + Use ``settings=GoogleLLMService.Settings(model=...)`` instead. params: Optional model parameters for inference. .. deprecated:: 0.0.105 - Use ``settings=GoogleLLMSettings(...)`` instead. + Use ``settings=GoogleLLMService.Settings(...)`` instead. settings: Runtime-updatable settings for this service. When both deprecated parameters and *settings* are provided, *settings* @@ -811,14 +811,14 @@ class GoogleLLMService(LLMService): system_instruction: System instruction/prompt for the model. .. deprecated:: 0.0.105 - Use ``settings=GoogleLLMSettings(system_instruction=...)`` instead. + Use ``settings=GoogleLLMService.Settings(system_instruction=...)`` instead. tools: List of available tools/functions. tool_config: Configuration for tool usage. http_options: HTTP options for the client. **kwargs: Additional arguments passed to parent class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleLLMSettings( + default_settings = self.Settings( model="gemini-2.5-flash", system_instruction=None, max_tokens=4096, @@ -836,15 +836,15 @@ class GoogleLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GoogleLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if system_instruction is not None: - _warn_deprecated_param("system_instruction", GoogleLLMSettings, "system_instruction") + _warn_deprecated_param("system_instruction", self.Settings, "system_instruction") default_settings.system_instruction = system_instruction # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GoogleLLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.max_tokens = params.max_tokens default_settings.temperature = params.temperature diff --git a/src/pipecat/services/google/openai/llm.py b/src/pipecat/services/google/openai/llm.py index cd5e0f060..717c1e379 100644 --- a/src/pipecat/services/google/openai/llm.py +++ b/src/pipecat/services/google/openai/llm.py @@ -28,13 +28,13 @@ from loguru import logger from pipecat.frames.frames import LLMTextFrame from pipecat.metrics.metrics import LLMTokenUsage from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class GoogleOpenAILLMSettings(OpenAILLMSettings): +class GoogleOpenAILLMSettings(BaseOpenAILLMService.Settings): """Settings for GoogleLLMOpenAIBetaService.""" pass @@ -59,7 +59,7 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): """ Settings = GoogleOpenAILLMSettings - _settings: GoogleOpenAILLMSettings + _settings: Settings def __init__( self, @@ -67,7 +67,7 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): api_key: str, base_url: str = "https://generativelanguage.googleapis.com/v1beta/openai/", model: Optional[str] = None, - settings: Optional[GoogleOpenAILLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Google LLM service. @@ -78,7 +78,7 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): model: Google model name to use (e.g., "gemini-2.0-flash"). .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=GoogleLLMOpenAIBetaService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -96,11 +96,11 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleOpenAILLMSettings(model="gemini-2.0-flash") + default_settings = self.Settings(model="gemini-2.0-flash") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GoogleOpenAILLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/google/stt.py b/src/pipecat/services/google/stt.py index 70e51ac3c..cab176668 100644 --- a/src/pipecat/services/google/stt.py +++ b/src/pipecat/services/google/stt.py @@ -415,7 +415,7 @@ class GoogleSTTService(STTService): """ Settings = GoogleSTTSettings - _settings: GoogleSTTSettings + _settings: Settings # Google Cloud's STT service has a connection time limit of 5 minutes per stream. # They've shared an "endless streaming" example that guided this implementation: @@ -427,7 +427,7 @@ class GoogleSTTService(STTService): """Configuration parameters for Google Speech-to-Text. .. deprecated:: 0.0.105 - Use ``settings=GoogleSTTSettings(...)`` instead. + Use ``settings=GoogleSTTService.Settings(...)`` instead. Parameters: languages: Single language or list of recognition languages. First language is primary. @@ -488,7 +488,7 @@ class GoogleSTTService(STTService): location: str = "global", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[GoogleSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = GOOGLE_TTFS_P99, **kwargs, ): @@ -502,7 +502,7 @@ class GoogleSTTService(STTService): params: Configuration parameters for the service. .. deprecated:: 0.0.105 - Use ``settings=GoogleSTTSettings(...)`` instead. + Use ``settings=GoogleSTTService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated ``params``, ``settings`` values take precedence. @@ -511,7 +511,7 @@ class GoogleSTTService(STTService): **kwargs: Additional arguments passed to STTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleSTTSettings( + default_settings = self.Settings( language=None, languages=[Language.EN_US], language_codes=None, @@ -531,7 +531,7 @@ class GoogleSTTService(STTService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GoogleSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.languages = list(params.language_list) default_settings.model = params.model @@ -655,7 +655,7 @@ class GoogleSTTService(STTService): """Update the service's recognition languages. .. deprecated:: 0.0.104 - Use ``STTUpdateSettingsFrame`` with ``GoogleSTTSettings(languages=...)`` + Use ``STTUpdateSettingsFrame`` with ``GoogleSTTService.Settings(languages=...)`` instead. Args: @@ -665,13 +665,13 @@ class GoogleSTTService(STTService): warnings.simplefilter("always") warnings.warn( "set_languages() is deprecated. Use STTUpdateSettingsFrame with " - "GoogleSTTSettings(languages=...) instead.", + "self.Settings(languages=...) instead.", DeprecationWarning, ) logger.debug(f"Switching STT languages to: {languages}") - await self._update_settings(GoogleSTTSettings(languages=list(languages))) + await self._update_settings(self.Settings(languages=list(languages))) - async def _update_settings(self, delta: GoogleSTTSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply settings delta and reconnect if anything changed. Handles ``language`` from base ``set_language`` by converting it to @@ -698,8 +698,8 @@ class GoogleSTTService(STTService): with warnings.catch_warnings(): warnings.simplefilter("always") warnings.warn( - "GoogleSTTSettings.language_codes is deprecated. " - "Use GoogleSTTSettings.languages (List[Language]) instead.", + "self.Settings.language_codes is deprecated. " + "Use self.Settings.languages (List[Language]) instead.", DeprecationWarning, stacklevel=2, ) @@ -756,7 +756,7 @@ class GoogleSTTService(STTService): """Update service options dynamically. .. deprecated:: - Use ``STTUpdateSettingsFrame`` with ``GoogleSTTSettings(...)`` + Use ``STTUpdateSettingsFrame`` with ``GoogleSTTService.Settings(...)`` instead. Args: @@ -780,11 +780,11 @@ class GoogleSTTService(STTService): warnings.simplefilter("always") warnings.warn( "update_options() is deprecated. Use STTUpdateSettingsFrame with " - "GoogleSTTSettings(...) instead.", + "self.Settings(...) instead.", DeprecationWarning, ) # Build a settings delta from the provided options - delta = GoogleSTTSettings() + delta = self.Settings() if languages is not None: delta.languages = list(languages) diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index 9d92c91ea..c2e32ad3c 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -523,7 +523,7 @@ class GoogleTTSSettings(TTSSettings): #: .. deprecated:: 0.0.105 -#: Use ``GoogleTTSSettings`` instead. +#: Use ``GoogleTTSService.Settings`` instead. GoogleStreamTTSSettings = GoogleTTSSettings @@ -559,13 +559,13 @@ class GoogleHttpTTSService(TTSService): """ Settings = GoogleHttpTTSSettings - _settings: GoogleHttpTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Google HTTP TTS voice customization. .. deprecated:: 0.0.105 - Use ``GoogleHttpTTSSettings`` directly via the ``settings`` parameter instead. + Use ``GoogleHttpTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: pitch: Voice pitch adjustment (e.g., "+2st", "-50%"). @@ -596,7 +596,7 @@ class GoogleHttpTTSService(TTSService): voice_id: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[GoogleHttpTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initializes the Google HTTP TTS service. @@ -608,20 +608,20 @@ class GoogleHttpTTSService(TTSService): voice_id: Google TTS voice identifier (e.g., "en-US-Standard-A"). .. deprecated:: 0.0.105 - Use ``settings=GoogleHttpTTSSettings(voice=...)`` instead. + Use ``settings=GoogleHttpTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses default. params: Voice customization parameters including pitch, rate, volume, etc. .. deprecated:: 0.0.105 - Use ``settings=GoogleHttpTTSSettings(...)`` instead. + Use ``settings=GoogleHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleHttpTTSSettings( + default_settings = self.Settings( model=None, voice="en-US-Chirp3-HD-Charon", language="en-US", @@ -636,12 +636,12 @@ class GoogleHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", GoogleHttpTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GoogleHttpTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.pitch is not None: default_settings.pitch = params.pitch @@ -747,7 +747,7 @@ class GoogleHttpTTSService(TTSService): Args: delta: Settings delta. Can include 'speaking_rate' (float). """ - if isinstance(delta, GoogleHttpTTSSettings) and is_given(delta.speaking_rate): + if isinstance(delta, self.Settings) and is_given(delta.speaking_rate): rate_value = float(delta.speaking_rate) if not (0.25 <= rate_value <= 2.0): logger.warning( @@ -1022,13 +1022,13 @@ class GoogleTTSService(GoogleBaseTTSService): """ Settings = GoogleTTSSettings - _settings: GoogleTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Google streaming TTS configuration. .. deprecated:: 0.0.105 - Use ``GoogleTTSSettings`` directly via the ``settings`` parameter instead. + Use ``GoogleTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language for synthesis. Defaults to English. @@ -1048,7 +1048,7 @@ class GoogleTTSService(GoogleBaseTTSService): voice_cloning_key: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[GoogleTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initializes the Google streaming TTS service. @@ -1060,21 +1060,21 @@ class GoogleTTSService(GoogleBaseTTSService): voice_id: Google TTS voice identifier (e.g., "en-US-Chirp3-HD-Charon"). .. deprecated:: 0.0.105 - Use ``settings=GoogleTTSSettings(voice=...)`` instead. + Use ``settings=GoogleTTSService.Settings(voice=...)`` instead. voice_cloning_key: The voice cloning key for Chirp 3 custom voices. sample_rate: Audio sample rate in Hz. If None, uses default. params: Language configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=GoogleTTSSettings(...)`` instead. + Use ``settings=GoogleTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleTTSSettings( + default_settings = self.Settings( model=None, voice="en-US-Chirp3-HD-Charon", language="en-US", @@ -1083,12 +1083,12 @@ class GoogleTTSService(GoogleBaseTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", GoogleTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GoogleTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) @@ -1119,7 +1119,7 @@ class GoogleTTSService(GoogleBaseTTSService): Args: delta: Settings delta. Can include 'speaking_rate' (float). """ - if isinstance(delta, GoogleTTSSettings) and is_given(delta.speaking_rate): + if isinstance(delta, self.Settings) and is_given(delta.speaking_rate): rate_value = float(delta.speaking_rate) if not (0.25 <= rate_value <= 2.0): logger.warning( @@ -1201,7 +1201,7 @@ class GeminiTTSService(GoogleBaseTTSService): """ Settings = GeminiTTSSettings - _settings: GeminiTTSSettings + _settings: Settings GOOGLE_SAMPLE_RATE = 24000 # Google TTS always outputs at 24kHz @@ -1243,7 +1243,7 @@ class GeminiTTSService(GoogleBaseTTSService): """Input parameters for Gemini TTS configuration. .. deprecated:: 0.0.105 - Use ``GeminiTTSSettings`` directly via the ``settings`` parameter instead. + Use ``GeminiTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language for synthesis. Defaults to English. @@ -1268,7 +1268,7 @@ class GeminiTTSService(GoogleBaseTTSService): voice_id: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[GeminiTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initializes the Gemini TTS service. @@ -1284,7 +1284,7 @@ class GeminiTTSService(GoogleBaseTTSService): "gemini-2.5-flash-tts" or "gemini-2.5-pro-tts". .. deprecated:: 0.0.105 - Use ``settings=GeminiTTSSettings(model=...)`` instead. + Use ``settings=GeminiTTSService.Settings(model=...)`` instead. credentials: JSON string containing Google Cloud service account credentials. credentials_path: Path to Google Cloud service account JSON file. @@ -1292,13 +1292,13 @@ class GeminiTTSService(GoogleBaseTTSService): voice_id: Voice name from the available Gemini voices. .. deprecated:: 0.0.105 - Use ``settings=GeminiTTSSettings(voice=...)`` instead. + Use ``settings=GeminiTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses Google's default 24kHz. params: TTS configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=GeminiTTSSettings(...)`` instead. + Use ``settings=GeminiTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -1320,7 +1320,7 @@ class GeminiTTSService(GoogleBaseTTSService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = GeminiTTSSettings( + default_settings = self.Settings( model="gemini-2.5-flash-tts", voice="Kore", language="en-US", @@ -1331,10 +1331,10 @@ class GeminiTTSService(GoogleBaseTTSService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GeminiTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id is not None: - _warn_deprecated_param("voice_id", GeminiTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if default_settings.voice not in self.AVAILABLE_VOICES: @@ -1344,7 +1344,7 @@ class GeminiTTSService(GoogleBaseTTSService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GeminiTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) diff --git a/src/pipecat/services/google/vertex/llm.py b/src/pipecat/services/google/vertex/llm.py index 3901b5d50..014dea405 100644 --- a/src/pipecat/services/google/vertex/llm.py +++ b/src/pipecat/services/google/vertex/llm.py @@ -21,7 +21,7 @@ from typing import Optional from loguru import logger -from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.llm import GoogleLLMService from pipecat.services.settings import _warn_deprecated_param try: @@ -41,7 +41,7 @@ except ModuleNotFoundError as e: @dataclass -class GoogleVertexLLMSettings(GoogleLLMSettings): +class GoogleVertexLLMSettings(GoogleLLMService.Settings): """Settings for GoogleVertexLLMService.""" pass @@ -60,7 +60,7 @@ class GoogleVertexLLMService(GoogleLLMService): """ Settings = GoogleVertexLLMSettings - _settings: GoogleVertexLLMSettings + _settings: Settings class InputParams(GoogleLLMService.InputParams): """Input parameters specific to Vertex AI. @@ -115,7 +115,7 @@ class GoogleVertexLLMService(GoogleLLMService): location: Optional[str] = None, project_id: Optional[str] = None, params: Optional[GoogleLLMService.InputParams] = None, - settings: Optional[GoogleVertexLLMSettings] = None, + settings: Optional[Settings] = None, system_instruction: Optional[str] = None, tools: Optional[list] = None, tool_config: Optional[dict] = None, @@ -130,14 +130,14 @@ class GoogleVertexLLMService(GoogleLLMService): model: Model identifier (e.g., "gemini-2.5-flash"). .. deprecated:: 0.0.105 - Use ``settings=GoogleLLMSettings(model=...)`` instead. + Use ``settings=GoogleVertexLLMService.Settings(model=...)`` instead. location: GCP region for Vertex AI endpoint (e.g., "us-east4"). project_id: Google Cloud project ID. params: Input parameters for the model. .. deprecated:: 0.0.105 - Use ``settings=GoogleLLMSettings(...)`` instead. + Use ``settings=GoogleVertexLLMService.Settings(...)`` instead. settings: Runtime-updatable settings for this service. When both deprecated parameters and *settings* are provided, *settings* @@ -145,7 +145,7 @@ class GoogleVertexLLMService(GoogleLLMService): system_instruction: System instruction/prompt for the model. .. deprecated:: 0.0.105 - Use ``settings=GoogleVertexLLMSettings(system_instruction=...)`` instead. + Use ``settings=GoogleVertexLLMService.Settings(system_instruction=...)`` instead. tools: List of available tools/functions. tool_config: Configuration for tool usage. http_options: HTTP options for the client. @@ -197,7 +197,7 @@ class GoogleVertexLLMService(GoogleLLMService): self._location = location # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleVertexLLMSettings( + default_settings = self.Settings( model="gemini-2.5-flash", system_instruction=None, max_tokens=4096, @@ -215,17 +215,15 @@ class GoogleVertexLLMService(GoogleLLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GoogleVertexLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if system_instruction is not None: - _warn_deprecated_param( - "system_instruction", GoogleVertexLLMSettings, "system_instruction" - ) + _warn_deprecated_param("system_instruction", self.Settings, "system_instruction") default_settings.system_instruction = system_instruction # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GoogleVertexLLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.max_tokens = params.max_tokens default_settings.temperature = params.temperature diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index 3fddf0470..90d1e800f 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -89,13 +89,13 @@ class GradiumSTTService(WebsocketSTTService): """ Settings = GradiumSTTSettings - _settings: GradiumSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Gradium STT API. .. deprecated:: 0.0.105 - Use ``settings=GradiumSTTSettings(...)`` instead. + Use ``settings=GradiumSTTService.Settings(...)`` instead. Parameters: language: Expected language of the audio (e.g., "en", "es", "fr"). @@ -117,7 +117,7 @@ class GradiumSTTService(WebsocketSTTService): api_endpoint_base_url: str = "wss://eu.api.gradium.ai/api/speech/asr", params: Optional[InputParams] = None, json_config: Optional[str] = None, - settings: Optional[GradiumSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = GRADIUM_TTFS_P99, **kwargs, ): @@ -129,7 +129,7 @@ class GradiumSTTService(WebsocketSTTService): params: Configuration parameters for language and delay settings. .. deprecated:: 0.0.105 - Use ``settings=GradiumSTTSettings(...)`` instead. + Use ``settings=GradiumSTTService.Settings(...)`` instead. json_config: Optional JSON configuration string for additional model settings. @@ -152,7 +152,7 @@ class GradiumSTTService(WebsocketSTTService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = GradiumSTTSettings( + default_settings = self.Settings( model=None, language=None, delay_in_frames=None, @@ -162,7 +162,7 @@ class GradiumSTTService(WebsocketSTTService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GradiumSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = params.language if params.delay_in_frames is not None: @@ -207,7 +207,7 @@ class GradiumSTTService(WebsocketSTTService): """Apply a settings delta, sync params, and reconnect. Args: - delta: A :class:`STTSettings` (or ``GradiumSTTSettings``) delta. + delta: A :class:`STTSettings` (or ``GradiumSTTService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/gradium/tts.py b/src/pipecat/services/gradium/tts.py index 03b4d7008..43114b193 100644 --- a/src/pipecat/services/gradium/tts.py +++ b/src/pipecat/services/gradium/tts.py @@ -48,13 +48,13 @@ class GradiumTTSService(WebsocketTTSService): """Text-to-Speech service using Gradium's websocket API.""" Settings = GradiumTTSSettings - _settings: GradiumTTSSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Gradium TTS service. .. deprecated:: 0.0.105 - Use ``GradiumTTSSettings`` directly via the ``settings`` parameter instead. + Use ``GradiumTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: temp: Temperature to be used for generation, defaults to 0.6. @@ -71,7 +71,7 @@ class GradiumTTSService(WebsocketTTSService): model: Optional[str] = None, json_config: Optional[str] = None, params: Optional[InputParams] = None, - settings: Optional[GradiumTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Gradium TTS service. @@ -81,26 +81,26 @@ class GradiumTTSService(WebsocketTTSService): voice_id: the voice identifier. .. deprecated:: 0.0.105 - Use ``settings=GradiumTTSSettings(voice=...)`` instead. + Use ``settings=GradiumTTSService.Settings(voice=...)`` instead. url: Gradium websocket API endpoint. model: Model ID to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=GradiumTTSSettings(model=...)`` instead. + Use ``settings=GradiumTTSService.Settings(model=...)`` instead. json_config: Optional JSON configuration string for additional model settings. params: Additional configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=GradiumTTSSettings(...)`` instead. + Use ``settings=GradiumTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GradiumTTSSettings( + default_settings = self.Settings( model="default", voice="YTpq7expH9539ERJ", language=None, @@ -108,15 +108,15 @@ class GradiumTTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GradiumTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id is not None: - _warn_deprecated_param("voice_id", GradiumTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GradiumTTSSettings) + _warn_deprecated_param("params", self.Settings) # Note: params.temp has no corresponding settings field # 4. Apply settings delta (canonical API, always wins) @@ -153,7 +153,7 @@ class GradiumTTSService(WebsocketTTSService): """Apply a settings delta and reconnect if voice changed. Args: - delta: A :class:`TTSSettings` (or ``GradiumTTSSettings``) delta. + delta: A :class:`TTSSettings` (or ``GradiumTTSService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index 255ee2cf5..3eaf0646a 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response import ( LLMUserAggregatorParams, ) from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import ( OpenAIAssistantContextAggregator, OpenAILLMService, @@ -71,7 +71,7 @@ class GrokContextAggregatorPair: @dataclass -class GrokLLMSettings(OpenAILLMSettings): +class GrokLLMSettings(BaseOpenAILLMService.Settings): """Settings for GrokLLMService.""" pass @@ -87,7 +87,7 @@ class GrokLLMService(OpenAILLMService): """ Settings = GrokLLMSettings - _settings: GrokLLMSettings + _settings: Settings def __init__( self, @@ -95,7 +95,7 @@ class GrokLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.x.ai/v1", model: Optional[str] = None, - settings: Optional[GrokLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the GrokLLMService with API key and model. @@ -106,18 +106,18 @@ class GrokLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "grok-3-beta". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=GrokLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GrokLLMSettings(model="grok-3-beta") + default_settings = self.Settings(model="grok-3-beta") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GrokLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/grok/realtime/llm.py b/src/pipecat/services/grok/realtime/llm.py index 9063ac22c..dcd7ac59e 100644 --- a/src/pipecat/services/grok/realtime/llm.py +++ b/src/pipecat/services/grok/realtime/llm.py @@ -109,7 +109,7 @@ class GrokRealtimeLLMSettings(LLMSettings): # -- Bidirectional sync helpers ------------------------------------------ @staticmethod - def _sync_top_level_to_sp(settings: "GrokRealtimeLLMSettings"): + def _sync_top_level_to_sp(settings: "GrokRealtimeLLMService.Settings"): """Push top-level ``system_instruction`` into ``session_properties``.""" if not is_given(settings.session_properties): return @@ -119,7 +119,7 @@ class GrokRealtimeLLMSettings(LLMSettings): # -- apply_update override ----------------------------------------------- - def apply_update(self, delta: "GrokRealtimeLLMSettings") -> Dict[str, Any]: + def apply_update(self, delta: "GrokRealtimeLLMService.Settings") -> Dict[str, Any]: """Merge a delta, keeping ``system_instruction`` in sync with SP. When the delta contains ``session_properties``, it **replaces** the @@ -151,8 +151,8 @@ class GrokRealtimeLLMSettings(LLMSettings): @classmethod def from_mapping( - cls: Type["GrokRealtimeLLMSettings"], settings: Mapping[str, Any] - ) -> "GrokRealtimeLLMSettings": + cls: Type["GrokRealtimeLLMService.Settings"], settings: Mapping[str, Any] + ) -> "GrokRealtimeLLMService.Settings": """Build a delta from a plain dict, routing SP keys into ``session_properties``. Keys that correspond to ``SessionProperties`` fields are collected into @@ -203,7 +203,7 @@ class GrokRealtimeLLMService(LLMService): """ Settings = GrokRealtimeLLMSettings - _settings: GrokRealtimeLLMSettings + _settings: Settings # Use the Grok-specific adapter adapter_class = GrokRealtimeLLMAdapter @@ -214,7 +214,7 @@ class GrokRealtimeLLMService(LLMService): api_key: str, base_url: str = "wss://api.x.ai/v1/realtime", session_properties: Optional[events.SessionProperties] = None, - settings: Optional[GrokRealtimeLLMSettings] = None, + settings: Optional[Settings] = None, start_audio_paused: bool = False, **kwargs, ): @@ -228,7 +228,7 @@ class GrokRealtimeLLMService(LLMService): If None, uses default SessionProperties with voice "Ara". .. deprecated:: 0.0.105 - Use ``settings=GrokRealtimeLLMSettings(session_properties=...)`` + Use ``settings=GrokRealtimeLLMService.Settings(session_properties=...)`` instead. To set a different voice, configure it in session_properties: @@ -241,7 +241,7 @@ class GrokRealtimeLLMService(LLMService): **kwargs: Additional arguments passed to parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GrokRealtimeLLMSettings( + default_settings = self.Settings( model=None, system_instruction=None, temperature=None, @@ -260,7 +260,7 @@ class GrokRealtimeLLMService(LLMService): if session_properties is not None: _warn_deprecated_param( "session_properties", - GrokRealtimeLLMSettings, + self.Settings, "session_properties", ) default_settings.session_properties = session_properties @@ -269,7 +269,7 @@ class GrokRealtimeLLMService(LLMService): default_settings.system_instruction = session_properties.instructions # Sync top-level system_instruction back into session_properties - GrokRealtimeLLMSettings._sync_top_level_to_sp(default_settings) + self.Settings._sync_top_level_to_sp(default_settings) # 3. Apply settings delta (canonical API, always wins) if settings is not None: diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index 6669c385a..8b6bdc3bc 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -11,13 +11,13 @@ from typing import Optional from loguru import logger -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class GroqLLMSettings(OpenAILLMSettings): +class GroqLLMSettings(BaseOpenAILLMService.Settings): """Settings for GroqLLMService.""" pass @@ -31,7 +31,7 @@ class GroqLLMService(OpenAILLMService): """ Settings = GroqLLMSettings - _settings: GroqLLMSettings + _settings: Settings def __init__( self, @@ -39,7 +39,7 @@ class GroqLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.groq.com/openai/v1", model: Optional[str] = None, - settings: Optional[GroqLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize Groq LLM service. @@ -50,18 +50,18 @@ class GroqLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "llama-3.3-70b-versatile". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=GroqLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GroqLLMSettings(model="llama-3.3-70b-versatile") + default_settings = self.Settings(model="llama-3.3-70b-versatile") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GroqLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/groq/stt.py b/src/pipecat/services/groq/stt.py index b5d59181a..6a234cc27 100644 --- a/src/pipecat/services/groq/stt.py +++ b/src/pipecat/services/groq/stt.py @@ -13,14 +13,13 @@ from pipecat.services.settings import _warn_deprecated_param from pipecat.services.stt_latency import GROQ_TTFS_P99 from pipecat.services.whisper.base_stt import ( BaseWhisperSTTService, - BaseWhisperSTTSettings, Transcription, ) from pipecat.transcriptions.language import Language @dataclass -class GroqSTTSettings(BaseWhisperSTTSettings): +class GroqSTTSettings(BaseWhisperSTTService.Settings): """Settings for the Groq STT service. Parameters: @@ -38,7 +37,7 @@ class GroqSTTService(BaseWhisperSTTService): """ Settings = GroqSTTSettings - _settings: GroqSTTSettings + _settings: Settings def __init__( self, @@ -49,7 +48,7 @@ class GroqSTTService(BaseWhisperSTTService): language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, - settings: Optional[GroqSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = GROQ_TTFS_P99, **kwargs, ): @@ -59,24 +58,24 @@ class GroqSTTService(BaseWhisperSTTService): model: Whisper model to use. .. deprecated:: 0.0.105 - Use ``settings=GroqSTTSettings(model=...)`` instead. + Use ``settings=GroqSTTService.Settings(model=...)`` instead. api_key: Groq API key. Defaults to None. base_url: API base URL. Defaults to "https://api.groq.com/openai/v1". language: Language of the audio input. .. deprecated:: 0.0.105 - Use ``settings=GroqSTTSettings(language=...)`` instead. + Use ``settings=GroqSTTService.Settings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. .. deprecated:: 0.0.105 - Use ``settings=GroqSTTSettings(prompt=...)`` instead. + Use ``settings=GroqSTTService.Settings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. .. deprecated:: 0.0.105 - Use ``settings=GroqSTTSettings(temperature=...)`` instead. + Use ``settings=GroqSTTService.Settings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -85,7 +84,7 @@ class GroqSTTService(BaseWhisperSTTService): **kwargs: Additional arguments passed to BaseWhisperSTTService. """ # --- 1. Hardcoded defaults --- - default_settings = GroqSTTSettings( + default_settings = self.Settings( model="whisper-large-v3-turbo", language=self.language_to_service_language(Language.EN), prompt=None, @@ -94,16 +93,16 @@ class GroqSTTService(BaseWhisperSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", GroqSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if language is not None: - _warn_deprecated_param("language", GroqSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = self.language_to_service_language(language) if prompt is not None: - _warn_deprecated_param("prompt", GroqSTTSettings, "prompt") + _warn_deprecated_param("prompt", self.Settings, "prompt") default_settings.prompt = prompt if temperature is not None: - _warn_deprecated_param("temperature", GroqSTTSettings, "temperature") + _warn_deprecated_param("temperature", self.Settings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- diff --git a/src/pipecat/services/groq/tts.py b/src/pipecat/services/groq/tts.py index bb39a9067..714ecdeb1 100644 --- a/src/pipecat/services/groq/tts.py +++ b/src/pipecat/services/groq/tts.py @@ -52,13 +52,13 @@ class GroqTTSService(TTSService): """ Settings = GroqTTSSettings - _settings: GroqTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Groq TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=GroqTTSSettings(...)`` instead. + Use ``settings=GroqTTSService.Settings(...)`` instead. Parameters: language: Language for speech synthesis. Defaults to English. @@ -79,7 +79,7 @@ class GroqTTSService(TTSService): model_name: Optional[str] = None, voice_id: Optional[str] = None, sample_rate: Optional[int] = GROQ_SAMPLE_RATE, - settings: Optional[GroqTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize Groq TTS service. @@ -90,17 +90,17 @@ class GroqTTSService(TTSService): params: Additional input parameters for voice customization. .. deprecated:: 0.0.105 - Use ``settings=GroqTTSSettings(...)`` instead. + Use ``settings=GroqTTSService.Settings(...)`` instead. model_name: TTS model to use. .. deprecated:: 0.0.105 - Use ``settings=GroqTTSSettings(model=...)`` instead. + Use ``settings=GroqTTSService.Settings(model=...)`` instead. voice_id: Voice identifier to use. .. deprecated:: 0.0.105 - Use ``settings=GroqTTSSettings(voice=...)`` instead. + Use ``settings=GroqTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate. Must be 48000 Hz for Groq TTS. settings: Runtime-updatable settings. When provided alongside deprecated @@ -111,7 +111,7 @@ class GroqTTSService(TTSService): logger.warning(f"Groq TTS only supports {self.GROQ_SAMPLE_RATE}Hz sample rate. ") # 1. Initialize default_settings with hardcoded defaults - default_settings = GroqTTSSettings( + default_settings = self.Settings( model="canopylabs/orpheus-v1-english", voice="autumn", language="en", @@ -120,15 +120,15 @@ class GroqTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if model_name is not None: - _warn_deprecated_param("model_name", GroqTTSSettings, "model") + _warn_deprecated_param("model_name", self.Settings, "model") default_settings.model = model_name if voice_id is not None: - _warn_deprecated_param("voice_id", GroqTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GroqTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = str(params.language) if params.language else "en" default_settings.speed = params.speed diff --git a/src/pipecat/services/heygen/video.py b/src/pipecat/services/heygen/video.py index 2c42dfc6b..9a20f35ef 100644 --- a/src/pipecat/services/heygen/video.py +++ b/src/pipecat/services/heygen/video.py @@ -83,7 +83,7 @@ class HeyGenVideoService(AIService): """ Settings = HeyGenVideoSettings - _settings: HeyGenVideoSettings + _settings: Settings def __init__( self, @@ -92,7 +92,7 @@ class HeyGenVideoService(AIService): session: aiohttp.ClientSession, session_request: Optional[Union[LiveAvatarNewSessionRequest, NewSessionRequest]] = None, service_type: Optional[ServiceType] = None, - settings: Optional[HeyGenVideoSettings] = None, + settings: Optional[Settings] = None, **kwargs, ) -> None: """Initialize the HeyGen video service. diff --git a/src/pipecat/services/hume/tts.py b/src/pipecat/services/hume/tts.py index 5eb2db646..9fa1cd46c 100644 --- a/src/pipecat/services/hume/tts.py +++ b/src/pipecat/services/hume/tts.py @@ -79,13 +79,13 @@ class HumeTTSService(TTSService): """ Settings = HumeTTSSettings - _settings: HumeTTSSettings + _settings: Settings class InputParams(BaseModel): """Optional synthesis parameters for Hume TTS. .. deprecated:: 0.0.105 - Use ``settings=HumeTTSSettings(...)`` instead. + Use ``settings=HumeTTSService.Settings(...)`` instead. Parameters: description: Natural-language acting directions (up to 100 characters). @@ -104,7 +104,7 @@ class HumeTTSService(TTSService): voice_id: Optional[str] = None, params: Optional[InputParams] = None, sample_rate: Optional[int] = HUME_SAMPLE_RATE, - settings: Optional[HumeTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ) -> None: """Initialize the HumeTTSService. @@ -114,12 +114,12 @@ class HumeTTSService(TTSService): voice_id: ID of the voice to use. Only voice IDs are supported; voice names are not. .. deprecated:: 0.0.105 - Use ``settings=HumeTTSSettings(voice=...)`` instead. + Use ``settings=HumeTTSService.Settings(voice=...)`` instead. params: Optional synthesis controls (acting instructions, speed, trailing silence). .. deprecated:: 0.0.105 - Use ``settings=HumeTTSSettings(...)`` instead. + Use ``settings=HumeTTSService.Settings(...)`` instead. sample_rate: Output sample rate for emitted PCM frames. Defaults to 48_000 (Hume). settings: Runtime-updatable settings. When provided alongside deprecated @@ -136,7 +136,7 @@ class HumeTTSService(TTSService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = HumeTTSSettings( + default_settings = self.Settings( model=None, voice=None, language=None, # Not applicable here @@ -147,12 +147,12 @@ class HumeTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", HumeTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", HumeTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.description = params.description default_settings.speed = params.speed @@ -242,7 +242,7 @@ class HumeTTSService(TTSService): """Runtime updates via key/value pair. .. deprecated:: 0.0.104 - Use ``TTSUpdateSettingsFrame(delta=HumeTTSSettings(...))`` instead. + Use ``TTSUpdateSettingsFrame(delta=HumeTTSService.Settings(...))`` instead. Args: key: The name of the setting to update. Recognized keys are: @@ -256,7 +256,7 @@ class HumeTTSService(TTSService): warnings.simplefilter("always") warnings.warn( "'update_setting' is deprecated, use " - "'TTSUpdateSettingsFrame(delta=HumeTTSSettings(...))' instead.", + "'TTSUpdateSettingsFrame(delta=self.Settings(...))' instead.", DeprecationWarning, stacklevel=2, ) @@ -274,7 +274,7 @@ class HumeTTSService(TTSService): kwargs["speed"] = None if value is None else float(value) elif key_l == "trailing_silence": kwargs["trailing_silence"] = None if value is None else float(value) - await self._update_settings(HumeTTSSettings(**kwargs)) + await self._update_settings(self.Settings(**kwargs)) @traced_tts async def run_tts(self, text: str, context_id: str) -> AsyncGenerator[Frame, None]: diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index dc09c0481..f24e9dcf6 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -101,13 +101,13 @@ class InworldHttpTTSService(TTSService): """ Settings = InworldTTSSettings - _settings: InworldTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Inworld TTS configuration. .. deprecated:: 0.0.105 - Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. + Use ``InworldHttpTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: temperature: Temperature for speech synthesis. @@ -131,7 +131,7 @@ class InworldHttpTTSService(TTSService): encoding: str = "LINEAR16", timestamp_transport_strategy: Optional[Literal["ASYNC", "SYNC"]] = "ASYNC", params: Optional[InputParams] = None, - settings: Optional[InworldTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Inworld TTS service. @@ -142,12 +142,12 @@ class InworldHttpTTSService(TTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=InworldTTSSettings(voice=...)`` instead. + Use ``settings=InworldHttpTTSService.Settings(voice=...)`` instead. model: ID of the model to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=InworldTTSSettings(model=...)`` instead. + Use ``settings=InworldHttpTTSService.Settings(model=...)`` instead. streaming: Whether to use streaming mode. sample_rate: Audio sample rate in Hz. @@ -157,14 +157,14 @@ class InworldHttpTTSService(TTSService): params: Input parameters for Inworld TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=InworldTTSSettings(...)`` instead. + Use ``settings=InworldHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = InworldTTSSettings( + default_settings = self.Settings( model="inworld-tts-1.5-max", voice="Ashley", language=None, @@ -174,15 +174,15 @@ class InworldHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", InworldTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", InworldTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", InworldTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.speaking_rate is not None: default_settings.speaking_rate = params.speaking_rate @@ -489,13 +489,13 @@ class InworldTTSService(WebsocketTTSService): """ Settings = InworldTTSSettings - _settings: InworldTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Inworld WebSocket TTS configuration. .. deprecated:: 0.0.105 - Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. + Use ``InworldTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: temperature: Temperature for speech synthesis. @@ -532,7 +532,7 @@ class InworldTTSService(WebsocketTTSService): apply_text_normalization: Optional[str] = None, timestamp_transport_strategy: Optional[Literal["ASYNC", "SYNC"]] = "ASYNC", params: Optional[InputParams] = None, - settings: Optional[InworldTTSSettings] = None, + settings: Optional[Settings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, append_trailing_space: bool = True, @@ -545,12 +545,12 @@ class InworldTTSService(WebsocketTTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=InworldTTSSettings(voice=...)`` instead. + Use ``settings=InworldTTSService.Settings(voice=...)`` instead. model: ID of the model to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=InworldTTSSettings(model=...)`` instead. + Use ``settings=InworldTTSService.Settings(model=...)`` instead. url: URL of the Inworld WebSocket API. sample_rate: Audio sample rate in Hz. @@ -564,7 +564,7 @@ class InworldTTSService(WebsocketTTSService): params: Input parameters for Inworld WebSocket TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=InworldTTSSettings(...)`` instead. + Use ``settings=InworldTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -582,7 +582,7 @@ class InworldTTSService(WebsocketTTSService): auto_mode = True if aggregate_sentences is None else aggregate_sentences # 1. Initialize default_settings with hardcoded defaults - default_settings = InworldTTSSettings( + default_settings = self.Settings( model="inworld-tts-1.5-max", voice="Ashley", language=None, @@ -592,17 +592,17 @@ class InworldTTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", InworldTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", InworldTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided _buffer_max_delay_ms = None _buffer_char_threshold = None if params is not None: - _warn_deprecated_param("params", InworldTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.speaking_rate is not None: default_settings.speaking_rate = params.speaking_rate diff --git a/src/pipecat/services/kokoro/tts.py b/src/pipecat/services/kokoro/tts.py index 98f181c6f..fd7f15c27 100644 --- a/src/pipecat/services/kokoro/tts.py +++ b/src/pipecat/services/kokoro/tts.py @@ -102,13 +102,13 @@ class KokoroTTSService(TTSService): """ Settings = KokoroTTSSettings - _settings: KokoroTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Kokoro TTS configuration. .. deprecated:: 0.0.105 - Use ``KokoroTTSSettings`` directly via the ``settings`` parameter instead. + Use ``KokoroTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language to use for synthesis. @@ -123,7 +123,7 @@ class KokoroTTSService(TTSService): model_path: Optional[str] = None, voices_path: Optional[str] = None, params: Optional[InputParams] = None, - settings: Optional[KokoroTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Kokoro TTS service. @@ -132,14 +132,14 @@ class KokoroTTSService(TTSService): voice_id: Voice identifier to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=KokoroTTSSettings(voice=...)`` instead. + Use ``settings=KokoroTTSService.Settings(voice=...)`` instead. model_path: Path to the kokoro ONNX model file. Defaults to auto-downloaded file. voices_path: Path to the voices binary file. Defaults to auto-downloaded file. params: Configuration parameters for synthesis. .. deprecated:: 0.0.105 - Use ``settings=KokoroTTSSettings(...)`` instead. + Use ``settings=KokoroTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -147,7 +147,7 @@ class KokoroTTSService(TTSService): """ # 1. Initialize default_settings with hardcoded defaults - default_settings = KokoroTTSSettings( + default_settings = self.Settings( model=None, voice=None, language=language_to_kokoro_language(Language.EN), @@ -155,12 +155,12 @@ class KokoroTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", KokoroTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", KokoroTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = language_to_kokoro_language(params.language) diff --git a/src/pipecat/services/lmnt/tts.py b/src/pipecat/services/lmnt/tts.py index 46e5e4697..ea5986ffc 100644 --- a/src/pipecat/services/lmnt/tts.py +++ b/src/pipecat/services/lmnt/tts.py @@ -89,7 +89,7 @@ class LmntTTSService(InterruptibleTTSService): """ Settings = LmntTTSSettings - _settings: LmntTTSSettings + _settings: Settings def __init__( self, @@ -100,7 +100,7 @@ class LmntTTSService(InterruptibleTTSService): language: Language = Language.EN, output_format: str = "pcm_s16le", model: Optional[str] = None, - settings: Optional[LmntTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the LMNT TTS service. @@ -110,7 +110,7 @@ class LmntTTSService(InterruptibleTTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=LmntTTSSettings(voice=...)`` instead. + Use ``settings=LmntTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses default. language: Language for synthesis. Defaults to English. @@ -119,14 +119,14 @@ class LmntTTSService(InterruptibleTTSService): model: TTS model to use. .. deprecated:: 0.0.105 - Use ``settings=LmntTTSSettings(model=...)`` instead. + Use ``settings=LmntTTSService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent InterruptibleTTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = LmntTTSSettings( + default_settings = self.Settings( model="aurora", voice=None, language=self.language_to_service_language(language), @@ -134,10 +134,10 @@ class LmntTTSService(InterruptibleTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", LmntTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", LmntTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) @@ -237,7 +237,7 @@ class LmntTTSService(InterruptibleTTSService): """Apply a settings delta. Args: - delta: A :class:`TTSSettings` (or ``LmntTTSSettings``) delta. + delta: A :class:`TTSSettings` (or ``LmntTTSService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/minimax/tts.py b/src/pipecat/services/minimax/tts.py index f62e8d46b..173c1ea05 100644 --- a/src/pipecat/services/minimax/tts.py +++ b/src/pipecat/services/minimax/tts.py @@ -141,13 +141,13 @@ class MiniMaxHttpTTSService(TTSService): """ Settings = MiniMaxTTSSettings - _settings: MiniMaxTTSSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for MiniMax TTS. .. deprecated:: 0.0.105 - Use ``MiniMaxTTSSettings`` directly via the ``settings`` parameter instead. + Use ``MiniMaxHttpTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language for TTS generation. Supports 40 languages. @@ -190,7 +190,7 @@ class MiniMaxHttpTTSService(TTSService): sample_rate: Optional[int] = None, stream: bool = True, params: Optional[InputParams] = None, - settings: Optional[MiniMaxTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the MiniMax TTS service. @@ -208,12 +208,12 @@ class MiniMaxHttpTTSService(TTSService): "speech-01-hd", "speech-01-turbo". .. deprecated:: 0.0.105 - Use ``settings=MiniMaxTTSSettings(model=...)`` instead. + Use ``settings=MiniMaxHttpTTSService.Settings(model=...)`` instead. voice_id: Voice identifier. Defaults to "Calm_Woman". .. deprecated:: 0.0.105 - Use ``settings=MiniMaxTTSSettings(voice=...)`` instead. + Use ``settings=MiniMaxHttpTTSService.Settings(voice=...)`` instead. aiohttp_session: aiohttp.ClientSession for API communication. sample_rate: Output audio sample rate in Hz. If None, uses pipeline default. @@ -221,14 +221,14 @@ class MiniMaxHttpTTSService(TTSService): params: Additional configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=MiniMaxTTSSettings(...)`` instead. + Use ``settings=MiniMaxHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = MiniMaxTTSSettings( + default_settings = self.Settings( model="speech-02-turbo", voice="Calm_Woman", language=None, @@ -243,15 +243,15 @@ class MiniMaxHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", MiniMaxTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id is not None: - _warn_deprecated_param("voice_id", MiniMaxTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", MiniMaxTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.speed = params.speed default_settings.volume = params.volume diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index 9e01a76b5..4b74695ef 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -14,13 +14,13 @@ from openai.types.chat import ChatCompletionMessageParam from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams from pipecat.frames.frames import FunctionCallFromLLM -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class MistralLLMSettings(OpenAILLMSettings): +class MistralLLMSettings(BaseOpenAILLMService.Settings): """Settings for MistralLLMService.""" pass @@ -34,7 +34,7 @@ class MistralLLMService(OpenAILLMService): """ Settings = MistralLLMSettings - _settings: MistralLLMSettings + _settings: Settings def __init__( self, @@ -42,7 +42,7 @@ class MistralLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.mistral.ai/v1", model: Optional[str] = None, - settings: Optional[MistralLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Mistral LLM service. @@ -53,18 +53,18 @@ class MistralLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "mistral-small-latest". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=MistralLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = MistralLLMSettings(model="mistral-small-latest") + default_settings = self.Settings(model="mistral-small-latest") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", MistralLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/moondream/vision.py b/src/pipecat/services/moondream/vision.py index abc344fc5..b8ab5a270 100644 --- a/src/pipecat/services/moondream/vision.py +++ b/src/pipecat/services/moondream/vision.py @@ -80,7 +80,7 @@ class MoondreamService(VisionService): """ Settings = MoondreamSettings - _settings: MoondreamSettings + _settings: Settings def __init__( self, @@ -88,7 +88,7 @@ class MoondreamService(VisionService): model: Optional[str] = None, revision="2025-01-09", use_cpu=False, - settings: Optional[MoondreamSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Moondream service. @@ -97,7 +97,7 @@ class MoondreamService(VisionService): model: Hugging Face model identifier for the Moondream model. .. deprecated:: 0.0.105 - Use ``settings=MoondreamSettings(model=...)`` instead. + Use ``settings=MoondreamService.Settings(model=...)`` instead. revision: Specific model revision to use. use_cpu: Whether to force CPU usage instead of hardware acceleration. @@ -106,11 +106,11 @@ class MoondreamService(VisionService): **kwargs: Additional arguments passed to the parent VisionService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = MoondreamSettings(model="vikhyatk/moondream2") + default_settings = self.Settings(model="vikhyatk/moondream2") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", MoondreamSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/neuphonic/tts.py b/src/pipecat/services/neuphonic/tts.py index abc33c37e..5c0605293 100644 --- a/src/pipecat/services/neuphonic/tts.py +++ b/src/pipecat/services/neuphonic/tts.py @@ -92,13 +92,13 @@ class NeuphonicTTSService(InterruptibleTTSService): """ Settings = NeuphonicTTSSettings - _settings: NeuphonicTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Neuphonic TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=NeuphonicTTSSettings(...)`` instead. + Use ``settings=NeuphonicTTSService.Settings(...)`` instead. Parameters: language: Language for synthesis. Defaults to English. @@ -117,7 +117,7 @@ class NeuphonicTTSService(InterruptibleTTSService): sample_rate: Optional[int] = 22050, encoding: str = "pcm_linear", params: Optional[InputParams] = None, - settings: Optional[NeuphonicTTSSettings] = None, + settings: Optional[Settings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -129,7 +129,7 @@ class NeuphonicTTSService(InterruptibleTTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. + Use ``settings=NeuphonicTTSService.Settings(voice=...)`` instead. url: WebSocket URL for the Neuphonic API. sample_rate: Audio sample rate in Hz. Defaults to 22050. @@ -137,7 +137,7 @@ class NeuphonicTTSService(InterruptibleTTSService): params: Additional input parameters for TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=NeuphonicTTSSettings(...)`` instead. + Use ``settings=NeuphonicTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -150,7 +150,7 @@ class NeuphonicTTSService(InterruptibleTTSService): **kwargs: Additional arguments passed to parent InterruptibleTTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = NeuphonicTTSSettings( + default_settings = self.Settings( model=None, voice=None, language=self.language_to_service_language(Language.EN), @@ -159,12 +159,12 @@ class NeuphonicTTSService(InterruptibleTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", NeuphonicTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", NeuphonicTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) @@ -432,13 +432,13 @@ class NeuphonicHttpTTSService(TTSService): """ Settings = NeuphonicTTSSettings - _settings: NeuphonicTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Neuphonic HTTP TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=NeuphonicTTSSettings(...)`` instead. + Use ``settings=NeuphonicHttpTTSService.Settings(...)`` instead. Parameters: language: Language for synthesis. Defaults to English. @@ -458,7 +458,7 @@ class NeuphonicHttpTTSService(TTSService): sample_rate: Optional[int] = 22050, encoding: Optional[str] = "pcm_linear", params: Optional[InputParams] = None, - settings: Optional[NeuphonicTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Neuphonic HTTP TTS service. @@ -468,7 +468,7 @@ class NeuphonicHttpTTSService(TTSService): voice_id: ID of the voice to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. + Use ``settings=NeuphonicHttpTTSService.Settings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. url: Base URL for the Neuphonic HTTP API. @@ -477,14 +477,14 @@ class NeuphonicHttpTTSService(TTSService): params: Additional input parameters for TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=NeuphonicTTSSettings(...)`` instead. + Use ``settings=NeuphonicHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = NeuphonicTTSSettings( + default_settings = self.Settings( model=None, voice=None, language=self.language_to_service_language(Language.EN), @@ -493,12 +493,12 @@ class NeuphonicHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", NeuphonicTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", NeuphonicTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index 17490f513..b40190bec 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -16,13 +16,13 @@ from typing import Optional from pipecat.metrics.metrics import LLMTokenUsage from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class NvidiaLLMSettings(OpenAILLMSettings): +class NvidiaLLMSettings(BaseOpenAILLMService.Settings): """Settings for NvidiaLLMService.""" pass @@ -37,7 +37,7 @@ class NvidiaLLMService(OpenAILLMService): """ Settings = NvidiaLLMSettings - _settings: NvidiaLLMSettings + _settings: Settings def __init__( self, @@ -45,7 +45,7 @@ class NvidiaLLMService(OpenAILLMService): api_key: str, base_url: str = "https://integrate.api.nvidia.com/v1", model: Optional[str] = None, - settings: Optional[NvidiaLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the NvidiaLLMService. @@ -57,18 +57,18 @@ class NvidiaLLMService(OpenAILLMService): "nvidia/llama-3.1-nemotron-70b-instruct". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=NvidiaLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = NvidiaLLMSettings(model="nvidia/llama-3.1-nemotron-70b-instruct") + default_settings = self.Settings(model="nvidia/llama-3.1-nemotron-70b-instruct") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", NvidiaLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index 5935e7846..3c8004baa 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -126,13 +126,13 @@ class NvidiaSTTService(STTService): """ Settings = NvidiaSTTSettings - _settings: NvidiaSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva STT service. .. deprecated:: 0.0.105 - Use ``settings=NvidiaSTTSettings(...)`` instead. + Use ``settings=NvidiaSTTService.Settings(...)`` instead. Parameters: language: Target language for transcription. Defaults to EN_US. @@ -152,7 +152,7 @@ class NvidiaSTTService(STTService): sample_rate: Optional[int] = None, params: Optional[InputParams] = None, use_ssl: bool = True, - settings: Optional[NvidiaSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = NVIDIA_TTFS_P99, **kwargs, ): @@ -166,7 +166,7 @@ class NvidiaSTTService(STTService): params: Additional configuration parameters for NVIDIA Riva. .. deprecated:: 0.0.105 - Use ``settings=NvidiaSTTSettings(...)`` instead. + Use ``settings=NvidiaSTTService.Settings(...)`` instead. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. settings: Runtime-updatable settings. When provided alongside deprecated @@ -176,7 +176,7 @@ class NvidiaSTTService(STTService): **kwargs: Additional arguments passed to STTService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = NvidiaSTTSettings( + default_settings = self.Settings( model=model_function_map.get("model_name"), language=Language.EN_US, ) @@ -185,7 +185,7 @@ class NvidiaSTTService(STTService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", NvidiaSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = params.language @@ -441,13 +441,13 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): """ Settings = NvidiaSegmentedSTTSettings - _settings: NvidiaSegmentedSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva segmented STT service. .. deprecated:: 0.0.105 - Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. + Use ``settings=NvidiaSegmentedSTTService.Settings(...)`` instead. Parameters: language: Target language for transcription. Defaults to EN_US. @@ -477,7 +477,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): sample_rate: Optional[int] = None, params: Optional[InputParams] = None, use_ssl: bool = True, - settings: Optional[NvidiaSegmentedSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = NVIDIA_TTFS_P99, **kwargs, ): @@ -491,7 +491,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): params: Additional configuration parameters for NVIDIA Riva .. deprecated:: 0.0.105 - Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. + Use ``settings=NvidiaSegmentedSTTService.Settings(...)`` instead. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. settings: Runtime-updatable settings. When provided alongside deprecated @@ -501,7 +501,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): **kwargs: Additional arguments passed to SegmentedSTTService """ # 1. Initialize default_settings with hardcoded defaults - default_settings = NvidiaSegmentedSTTSettings( + default_settings = self.Settings( model=model_function_map.get("model_name"), language=language_to_nvidia_riva_language(Language.EN_US) or "en-US", profanity_filter=False, @@ -515,7 +515,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", NvidiaSegmentedSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = ( language_to_nvidia_riva_language(params.language or Language.EN_US) or "en-US" @@ -641,7 +641,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): """Apply a settings delta and sync internal state. Args: - delta: A :class:`STTSettings` (or ``NvidiaSegmentedSTTSettings``) delta. + delta: A :class:`STTSettings` (or ``NvidiaSegmentedSTTService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/nvidia/tts.py b/src/pipecat/services/nvidia/tts.py index ad39d505b..b41de8b47 100644 --- a/src/pipecat/services/nvidia/tts.py +++ b/src/pipecat/services/nvidia/tts.py @@ -62,13 +62,13 @@ class NvidiaTTSService(TTSService): """ Settings = NvidiaTTSSettings - _settings: NvidiaTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Riva TTS configuration. .. deprecated:: 0.0.105 - Use ``NvidiaTTSSettings`` directly via the ``settings`` parameter instead. + Use ``NvidiaTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language code for synthesis. Defaults to US English. @@ -90,7 +90,7 @@ class NvidiaTTSService(TTSService): "model_name": "magpie-tts-multilingual", }, params: Optional[InputParams] = None, - settings: Optional[NvidiaTTSSettings] = None, + settings: Optional[Settings] = None, use_ssl: bool = True, **kwargs, ): @@ -102,14 +102,14 @@ class NvidiaTTSService(TTSService): voice_id: Voice model identifier. Defaults to multilingual Aria voice. .. deprecated:: 0.0.105 - Use ``settings=NvidiaTTSSettings(voice=...)`` instead. + Use ``settings=NvidiaTTSService.Settings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses service default. model_function_map: Dictionary containing function_id and model_name for the TTS model. params: Additional configuration parameters for TTS synthesis. .. deprecated:: 0.0.105 - Use ``settings=NvidiaTTSSettings(...)`` instead. + Use ``settings=NvidiaTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -117,7 +117,7 @@ class NvidiaTTSService(TTSService): **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = NvidiaTTSSettings( + default_settings = self.Settings( model=model_function_map.get("model_name"), voice="Magpie-Multilingual.EN-US.Aria", language=Language.EN_US, @@ -126,12 +126,12 @@ class NvidiaTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", NvidiaTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", NvidiaTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = params.language @@ -186,7 +186,7 @@ class NvidiaTTSService(TTSService): stacklevel=2, ) - async def _update_settings(self, delta: NvidiaTTSSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply a settings delta. Settings are stored but not applied to the active connection. diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index f4d138d78..3b15049a4 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -11,13 +11,13 @@ from typing import Optional from loguru import logger -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class OllamaLLMSettings(OpenAILLMSettings): +class OllamaLLMSettings(BaseOpenAILLMService.Settings): """Settings for OLLamaLLMService.""" pass @@ -31,14 +31,14 @@ class OLLamaLLMService(OpenAILLMService): """ Settings = OllamaLLMSettings - _settings: OllamaLLMSettings + _settings: Settings def __init__( self, *, model: Optional[str] = None, base_url: str = "http://localhost:11434/v1", - settings: Optional[OllamaLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize OLLama LLM service. @@ -47,7 +47,7 @@ class OLLamaLLMService(OpenAILLMService): model: The OLLama model to use. Defaults to "llama2". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=OLLamaLLMService.Settings(model=...)`` instead. base_url: The base URL for the OLLama API endpoint. Defaults to "http://localhost:11434/v1". @@ -56,11 +56,11 @@ class OLLamaLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OllamaLLMSettings(model="llama2") + default_settings = self.Settings(model="llama2") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OllamaLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 9e3b6a282..d1d695ef6 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -69,13 +69,13 @@ class BaseOpenAILLMService(LLMService): """ Settings = OpenAILLMSettings - _settings: OpenAILLMSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for OpenAI model configuration. .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(...)`` instead of + Use ``settings=BaseOpenAILLMService.Settings(...)`` instead of ``params=InputParams(...)``. Parameters: @@ -119,7 +119,7 @@ class BaseOpenAILLMService(LLMService): default_headers: Optional[Mapping[str, str]] = None, service_tier: Optional[str] = None, params: Optional[InputParams] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[Settings] = None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, **kwargs, @@ -130,7 +130,7 @@ class BaseOpenAILLMService(LLMService): model: The OpenAI model name to use (e.g., "gpt-4.1", "gpt-4o"). .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=BaseOpenAILLMService.Settings(model=...)`` instead. api_key: OpenAI API key. If None, uses environment variable. base_url: Custom base URL for OpenAI API. If None, uses default. @@ -141,7 +141,7 @@ class BaseOpenAILLMService(LLMService): params: Input parameters for model configuration and behavior. .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(...)`` instead. + Use ``settings=BaseOpenAILLMService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -150,7 +150,7 @@ class BaseOpenAILLMService(LLMService): **kwargs: Additional arguments passed to the parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings( + default_settings = self.Settings( model="gpt-4o", system_instruction=None, frequency_penalty=NOT_GIVEN, diff --git a/src/pipecat/services/openai/image.py b/src/pipecat/services/openai/image.py index 6091863f3..31f9949b8 100644 --- a/src/pipecat/services/openai/image.py +++ b/src/pipecat/services/openai/image.py @@ -49,7 +49,7 @@ class OpenAIImageGenService(ImageGenService): """ Settings = OpenAIImageGenSettings - _settings: OpenAIImageGenSettings + _settings: Settings def __init__( self, @@ -61,7 +61,7 @@ class OpenAIImageGenService(ImageGenService): Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"] ] = None, model: Optional[str] = None, - settings: Optional[OpenAIImageGenSettings] = None, + settings: Optional[Settings] = None, ): """Initialize the OpenAI image generation service. @@ -72,29 +72,29 @@ class OpenAIImageGenService(ImageGenService): image_size: Target size for generated images. Defaults to "1024x1024". .. deprecated:: 0.0.105 - Use ``settings=OpenAIImageGenSettings(image_size=...)`` instead. + Use ``settings=OpenAIImageGenService.Settings(image_size=...)`` instead. model: DALL-E model to use for generation. Defaults to "dall-e-3". .. deprecated:: 0.0.105 - Use ``settings=OpenAIImageGenSettings(model=...)`` instead. + Use ``settings=OpenAIImageGenService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAIImageGenSettings( + default_settings = self.Settings( model="dall-e-3", image_size=None, ) # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAIImageGenSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if image_size is not None: - _warn_deprecated_param("image_size", OpenAIImageGenSettings, "image_size") + _warn_deprecated_param("image_size", self.Settings, "image_size") default_settings.image_size = image_size # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index ab1384a4c..032d4dfa4 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response import ( LLMUserContextAggregator, ) from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext -from pipecat.services.openai.base_llm import BaseOpenAILLMService, OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.settings import _warn_deprecated_param @@ -72,13 +72,15 @@ class OpenAILLMService(BaseOpenAILLMService): context aggregator creation. """ + Settings = BaseOpenAILLMService.Settings + def __init__( self, *, model: Optional[str] = None, service_tier: Optional[str] = None, params: Optional[BaseOpenAILLMService.InputParams] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize OpenAI LLM service. @@ -87,20 +89,20 @@ class OpenAILLMService(BaseOpenAILLMService): model: The OpenAI model name to use. Defaults to "gpt-4.1". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=OpenAILLMService.Settings(model=...)`` instead. service_tier: Service tier to use (e.g., "auto", "flex", "priority"). params: Input parameters for model configuration. .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(...)`` instead. + Use ``settings=OpenAILLMService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent BaseOpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings( + default_settings = self.Settings( model="gpt-4.1", system_instruction=None, frequency_penalty=NOT_GIVEN, @@ -118,7 +120,7 @@ class OpenAILLMService(BaseOpenAILLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # Handle service_tier from deprecated params @@ -127,7 +129,7 @@ class OpenAILLMService(BaseOpenAILLMService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", OpenAILLMSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.frequency_penalty = params.frequency_penalty default_settings.presence_penalty = params.presence_penalty diff --git a/src/pipecat/services/openai/realtime/llm.py b/src/pipecat/services/openai/realtime/llm.py index 23d044c5f..300792cbd 100644 --- a/src/pipecat/services/openai/realtime/llm.py +++ b/src/pipecat/services/openai/realtime/llm.py @@ -115,7 +115,7 @@ class OpenAIRealtimeLLMSettings(LLMSettings): # -- Bidirectional sync helpers ------------------------------------------ @staticmethod - def _sync_top_level_to_sp(settings: "OpenAIRealtimeLLMSettings"): + def _sync_top_level_to_sp(settings: "OpenAIRealtimeLLMService.Settings"): """Push top-level ``model``/``system_instruction`` into ``session_properties``.""" if not is_given(settings.session_properties): return @@ -127,7 +127,7 @@ class OpenAIRealtimeLLMSettings(LLMSettings): # -- apply_update override ----------------------------------------------- - def apply_update(self, delta: "OpenAIRealtimeLLMSettings") -> Dict[str, Any]: + def apply_update(self, delta: "OpenAIRealtimeLLMService.Settings") -> Dict[str, Any]: """Merge a delta, keeping ``model``/``system_instruction`` in sync with SP. When the delta contains ``session_properties``, it **replaces** the @@ -165,8 +165,8 @@ class OpenAIRealtimeLLMSettings(LLMSettings): @classmethod def from_mapping( - cls: Type["OpenAIRealtimeLLMSettings"], settings: Mapping[str, Any] - ) -> "OpenAIRealtimeLLMSettings": + cls: Type["OpenAIRealtimeLLMService.Settings"], settings: Mapping[str, Any] + ) -> "OpenAIRealtimeLLMService.Settings": """Build a delta from a plain dict, routing SP keys into ``session_properties``. Keys that correspond to ``SessionProperties`` fields (except ``model``) @@ -211,7 +211,7 @@ class OpenAIRealtimeLLMService(LLMService): """ Settings = OpenAIRealtimeLLMSettings - _settings: OpenAIRealtimeLLMSettings + _settings: Settings # Overriding the default adapter to use the OpenAIRealtimeLLMAdapter one. adapter_class = OpenAIRealtimeLLMAdapter @@ -223,7 +223,7 @@ class OpenAIRealtimeLLMService(LLMService): model: Optional[str] = None, base_url: str = "wss://api.openai.com/v1/realtime", session_properties: Optional[events.SessionProperties] = None, - settings: Optional[OpenAIRealtimeLLMSettings] = None, + settings: Optional[Settings] = None, start_audio_paused: bool = False, start_video_paused: bool = False, video_frame_detail: str = "auto", @@ -237,7 +237,7 @@ class OpenAIRealtimeLLMService(LLMService): model: OpenAI model name. .. deprecated:: 0.0.105 - Use ``settings=OpenAIRealtimeLLMSettings(model=...)`` instead. + Use ``settings=OpenAIRealtimeLLMService.Settings(model=...)`` instead. This is a connection-level parameter set via the WebSocket URL query parameter and cannot be changed during the session. @@ -247,7 +247,7 @@ class OpenAIRealtimeLLMService(LLMService): If None, uses default SessionProperties. .. deprecated:: 0.0.105 - Use ``settings=OpenAIRealtimeLLMSettings(session_properties=...)`` + Use ``settings=OpenAIRealtimeLLMService.Settings(session_properties=...)`` instead. settings: Runtime-updatable settings for this service. start_audio_paused: Whether to start with audio input paused. Defaults to False. @@ -277,7 +277,7 @@ class OpenAIRealtimeLLMService(LLMService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAIRealtimeLLMSettings( + default_settings = self.Settings( model="gpt-realtime-1.5", system_instruction=None, temperature=None, @@ -294,13 +294,13 @@ class OpenAIRealtimeLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAIRealtimeLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if session_properties is not None: _warn_deprecated_param( "session_properties", - OpenAIRealtimeLLMSettings, + self.Settings, "session_properties", ) default_settings.session_properties = session_properties @@ -312,7 +312,7 @@ class OpenAIRealtimeLLMService(LLMService): default_settings.system_instruction = session_properties.instructions # Sync top-level model back into session_properties - OpenAIRealtimeLLMSettings._sync_top_level_to_sp(default_settings) + self.Settings._sync_top_level_to_sp(default_settings) # 3. Apply settings delta (canonical API, always wins) if settings is not None: diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index 473b23637..943be17de 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -40,7 +40,6 @@ from pipecat.services.stt_latency import OPENAI_REALTIME_TTFS_P99, OPENAI_TTFS_P from pipecat.services.stt_service import WebsocketSTTService from pipecat.services.whisper.base_stt import ( BaseWhisperSTTService, - BaseWhisperSTTSettings, Transcription, ) from pipecat.transcriptions.language import Language @@ -56,7 +55,7 @@ except ModuleNotFoundError: @dataclass -class OpenAISTTSettings(BaseWhisperSTTSettings): +class OpenAISTTSettings(BaseWhisperSTTService.Settings): """Settings for the OpenAI STT service.""" pass @@ -70,7 +69,7 @@ class OpenAISTTService(BaseWhisperSTTService): """ Settings = OpenAISTTSettings - _settings: OpenAISTTSettings + _settings: Settings def __init__( self, @@ -81,7 +80,7 @@ class OpenAISTTService(BaseWhisperSTTService): language: Optional[Language] = Language.EN, prompt: Optional[str] = None, temperature: Optional[float] = None, - settings: Optional[OpenAISTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = OPENAI_TTFS_P99, **kwargs, ): @@ -91,24 +90,24 @@ class OpenAISTTService(BaseWhisperSTTService): model: Model to use — either gpt-4o or Whisper. .. deprecated:: 0.0.105 - Use ``settings=OpenAISTTSettings(model=...)`` instead. + Use ``settings=OpenAISTTService.Settings(model=...)`` instead. api_key: OpenAI API key. Defaults to None. base_url: API base URL. Defaults to None. language: Language of the audio input. Defaults to English. .. deprecated:: 0.0.105 - Use ``settings=OpenAISTTSettings(language=...)`` instead. + Use ``settings=OpenAISTTService.Settings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. .. deprecated:: 0.0.105 - Use ``settings=OpenAISTTSettings(prompt=...)`` instead. + Use ``settings=OpenAISTTService.Settings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. Defaults to 0.0. .. deprecated:: 0.0.105 - Use ``settings=OpenAISTTSettings(temperature=...)`` instead. + Use ``settings=OpenAISTTService.Settings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -118,7 +117,7 @@ class OpenAISTTService(BaseWhisperSTTService): """ # --- 1. Hardcoded defaults --- _language = language or Language.EN - default_settings = OpenAISTTSettings( + default_settings = self.Settings( model="gpt-4o-transcribe", language=self.language_to_service_language(_language), prompt=None, @@ -127,13 +126,13 @@ class OpenAISTTService(BaseWhisperSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", OpenAISTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if prompt is not None: - _warn_deprecated_param("prompt", OpenAISTTSettings, "prompt") + _warn_deprecated_param("prompt", self.Settings, "prompt") default_settings.prompt = prompt if temperature is not None: - _warn_deprecated_param("temperature", OpenAISTTSettings, "temperature") + _warn_deprecated_param("temperature", self.Settings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- @@ -234,7 +233,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): """ Settings = OpenAIRealtimeSTTSettings - _settings: OpenAIRealtimeSTTSettings + _settings: Settings def __init__( self, @@ -247,7 +246,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): turn_detection: Optional[Union[dict, Literal[False]]] = False, noise_reduction: Optional[Literal["near_field", "far_field"]] = None, should_interrupt: bool = True, - settings: Optional[OpenAIRealtimeSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = OPENAI_REALTIME_TTFS_P99, **kwargs, ): @@ -259,20 +258,20 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): ``"gpt-4o-transcribe"`` and ``"gpt-4o-mini-transcribe"``. .. deprecated:: 0.0.105 - Use ``settings=OpenAIRealtimeSTTSettings(model=...)`` instead. + Use ``settings=OpenAIRealtimeSTTService.Settings(model=...)`` instead. base_url: WebSocket base URL for the Realtime API. Defaults to ``"wss://api.openai.com/v1/realtime"``. language: Language of the audio input. Defaults to English. .. deprecated:: 0.0.105 - Use ``settings=OpenAIRealtimeSTTSettings(language=...)`` instead. + Use ``settings=OpenAIRealtimeSTTService.Settings(language=...)`` instead. prompt: Optional prompt text to guide transcription style or provide keyword hints. .. deprecated:: 0.0.105 - Use ``settings=OpenAIRealtimeSTTSettings(prompt=...)`` instead. + Use ``settings=OpenAIRealtimeSTTService.Settings(prompt=...)`` instead. turn_detection: Server-side VAD configuration. Defaults to ``False`` (disabled), which relies on a local VAD @@ -284,7 +283,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): microphones, or ``None`` to disable. .. deprecated:: 0.0.106 - Use ``settings=OpenAIRealtimeSTTSettings(noise_reduction=...)`` instead. + Use ``settings=OpenAIRealtimeSTTService.Settings(noise_reduction=...)`` instead. should_interrupt: Whether to interrupt bot output when speech is detected by server-side VAD. Only applies when turn detection is enabled. Defaults to True. @@ -302,7 +301,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): ) # --- 1. Hardcoded defaults --- - default_settings = OpenAIRealtimeSTTSettings( + default_settings = self.Settings( model="gpt-4o-transcribe", language=Language.EN, prompt=None, @@ -311,16 +310,16 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", OpenAIRealtimeSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if language is not None and language != Language.EN: - _warn_deprecated_param("language", OpenAIRealtimeSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = language if prompt is not None: - _warn_deprecated_param("prompt", OpenAIRealtimeSTTSettings, "prompt") + _warn_deprecated_param("prompt", self.Settings, "prompt") default_settings.prompt = prompt if noise_reduction is not None: - _warn_deprecated_param("noise_reduction", OpenAIRealtimeSTTSettings, "noise_reduction") + _warn_deprecated_param("noise_reduction", self.Settings, "noise_reduction") default_settings.noise_reduction = noise_reduction # --- 3. (no params object for this service) --- @@ -376,7 +375,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): Sends a ``session.update`` to the server when the session is active. Args: - delta: A :class:`STTSettings` (or ``OpenAIRealtimeSTTSettings``) delta. + delta: A :class:`STTSettings` (or ``OpenAIRealtimeSTTService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index 264475113..7eb80cd1e 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -82,7 +82,7 @@ class OpenAITTSService(TTSService): """ Settings = OpenAITTSSettings - _settings: OpenAITTSSettings + _settings: Settings OPENAI_SAMPLE_RATE = 24000 # OpenAI TTS always outputs at 24kHz @@ -90,7 +90,7 @@ class OpenAITTSService(TTSService): """Input parameters for OpenAI TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=OpenAITTSSettings(...)`` instead. + Use ``settings=OpenAITTSService.Settings(...)`` instead. Parameters: instructions: Instructions to guide voice synthesis behavior. @@ -111,7 +111,7 @@ class OpenAITTSService(TTSService): instructions: Optional[str] = None, speed: Optional[float] = None, params: Optional[InputParams] = None, - settings: Optional[OpenAITTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize OpenAI TTS service. @@ -122,28 +122,28 @@ class OpenAITTSService(TTSService): voice: Voice ID to use for synthesis. Defaults to "alloy". .. deprecated:: 0.0.105 - Use ``settings=OpenAITTSSettings(voice=...)`` instead. + Use ``settings=OpenAITTSService.Settings(voice=...)`` instead. model: TTS model to use. Defaults to "gpt-4o-mini-tts". .. deprecated:: 0.0.105 - Use ``settings=OpenAITTSSettings(model=...)`` instead. + Use ``settings=OpenAITTSService.Settings(model=...)`` instead. sample_rate: Output audio sample rate in Hz. If None, uses OpenAI's default 24kHz. instructions: Optional instructions to guide voice synthesis behavior. .. deprecated:: 0.0.105 - Use ``settings=OpenAITTSSettings(instructions=...)`` instead. + Use ``settings=OpenAITTSService.Settings(instructions=...)`` instead. speed: Voice speed control (0.25 to 4.0, default 1.0). .. deprecated:: 0.0.105 - Use ``settings=OpenAITTSSettings(speed=...)`` instead. + Use ``settings=OpenAITTSService.Settings(speed=...)`` instead. params: Optional synthesis controls (acting instructions, speed, ...). .. deprecated:: 0.0.105 - Use ``settings=OpenAITTSSettings(...)`` instead. + Use ``settings=OpenAITTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -156,7 +156,7 @@ class OpenAITTSService(TTSService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAITTSSettings( + default_settings = self.Settings( model="gpt-4o-mini-tts", voice="alloy", language=None, @@ -166,21 +166,21 @@ class OpenAITTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice is not None: - _warn_deprecated_param("voice", OpenAITTSSettings, "voice") + _warn_deprecated_param("voice", self.Settings, "voice") default_settings.voice = voice if model is not None: - _warn_deprecated_param("model", OpenAITTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if instructions is not None: - _warn_deprecated_param("instructions", OpenAITTSSettings, "instructions") + _warn_deprecated_param("instructions", self.Settings, "instructions") default_settings.instructions = instructions if speed is not None: - _warn_deprecated_param("speed", OpenAITTSSettings, "speed") + _warn_deprecated_param("speed", self.Settings, "speed") default_settings.speed = speed # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", OpenAITTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.instructions is not None: default_settings.instructions = params.instructions diff --git a/src/pipecat/services/openai_realtime_beta/azure.py b/src/pipecat/services/openai_realtime_beta/azure.py index 6497e1266..b590f2c29 100644 --- a/src/pipecat/services/openai_realtime_beta/azure.py +++ b/src/pipecat/services/openai_realtime_beta/azure.py @@ -11,7 +11,7 @@ from dataclasses import dataclass from loguru import logger -from .openai import OpenAIRealtimeBetaLLMService, OpenAIRealtimeBetaLLMSettings +from .openai import OpenAIRealtimeBetaLLMService try: from websockets.asyncio.client import connect as websocket_connect @@ -24,7 +24,7 @@ except ModuleNotFoundError as e: @dataclass -class AzureRealtimeBetaLLMSettings(OpenAIRealtimeBetaLLMSettings): +class AzureRealtimeBetaLLMSettings(OpenAIRealtimeBetaLLMService.Settings): """Settings for AzureRealtimeBetaLLMService.""" pass @@ -43,7 +43,7 @@ class AzureRealtimeBetaLLMService(OpenAIRealtimeBetaLLMService): """ Settings = AzureRealtimeBetaLLMSettings - _settings: AzureRealtimeBetaLLMSettings + _settings: Settings def __init__( self, diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index d8f817ffc..209ff3122 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -112,7 +112,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): """ Settings = OpenAIRealtimeBetaLLMSettings - _settings: OpenAIRealtimeBetaLLMSettings + _settings: Settings # Overriding the default adapter to use the OpenAIRealtimeLLMAdapter one. adapter_class = OpenAIRealtimeLLMAdapter @@ -124,7 +124,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): model: Optional[str] = None, base_url: str = "wss://api.openai.com/v1/realtime", session_properties: Optional[events.SessionProperties] = None, - settings: Optional[OpenAIRealtimeBetaLLMSettings] = None, + settings: Optional[Settings] = None, start_audio_paused: bool = False, send_transcription_frames: bool = True, **kwargs, @@ -136,7 +136,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): model: OpenAI model name. .. deprecated:: 0.0.105 - Use ``settings=OpenAIRealtimeBetaLLMSettings(model=...)`` instead. + Use ``settings=OpenAIRealtimeBetaLLMService.Settings(model=...)`` instead. base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.openai.com/v1/realtime". @@ -157,7 +157,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAIRealtimeBetaLLMSettings( + default_settings = self.Settings( model="gpt-4o-realtime-preview-2025-06-03", system_instruction=None, temperature=None, @@ -173,7 +173,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAIRealtimeBetaLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply settings delta (canonical API, always wins) if settings is not None: diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index 3fef1e3af..a2198eb74 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -16,7 +16,7 @@ from typing import Dict, Optional from loguru import logger from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @@ -29,7 +29,7 @@ except ModuleNotFoundError as e: @dataclass -class OpenPipeLLMSettings(OpenAILLMSettings): +class OpenPipeLLMSettings(BaseOpenAILLMService.Settings): """Settings for OpenPipeLLMService.""" pass @@ -44,7 +44,7 @@ class OpenPipeLLMService(OpenAILLMService): """ Settings = OpenPipeLLMSettings - _settings: OpenPipeLLMSettings + _settings: Settings def __init__( self, @@ -55,7 +55,7 @@ class OpenPipeLLMService(OpenAILLMService): openpipe_api_key: Optional[str] = None, openpipe_base_url: str = "https://app.openpipe.ai/api/v1", tags: Optional[Dict[str, str]] = None, - settings: Optional[OpenPipeLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize OpenPipe LLM service. @@ -64,7 +64,7 @@ class OpenPipeLLMService(OpenAILLMService): model: The model name to use. Defaults to "gpt-4.1". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=OpenPipeLLMService.Settings(model=...)`` instead. api_key: OpenAI API key for authentication. If None, reads from environment. base_url: Custom OpenAI API endpoint URL. Uses default if None. @@ -76,11 +76,11 @@ class OpenPipeLLMService(OpenAILLMService): **kwargs: Additional arguments passed to parent OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenPipeLLMSettings(model="gpt-4.1") + default_settings = self.Settings(model="gpt-4.1") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenPipeLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index d57c5cf24..84647890f 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -15,13 +15,13 @@ from typing import Any, Dict, Optional from loguru import logger -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class OpenRouterLLMSettings(OpenAILLMSettings): +class OpenRouterLLMSettings(BaseOpenAILLMService.Settings): """Settings for OpenRouterLLMService.""" pass @@ -35,7 +35,7 @@ class OpenRouterLLMService(OpenAILLMService): """ Settings = OpenRouterLLMSettings - _settings: OpenRouterLLMSettings + _settings: Settings def __init__( self, @@ -43,7 +43,7 @@ class OpenRouterLLMService(OpenAILLMService): api_key: Optional[str] = None, model: Optional[str] = None, base_url: str = "https://openrouter.ai/api/v1", - settings: Optional[OpenRouterLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the OpenRouter LLM service. @@ -54,7 +54,7 @@ class OpenRouterLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "openai/gpt-4o-2024-11-20". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=OpenRouterLLMService.Settings(model=...)`` instead. base_url: The base URL for OpenRouter API. Defaults to "https://openrouter.ai/api/v1". settings: Runtime-updatable settings. When provided alongside deprecated @@ -62,11 +62,11 @@ class OpenRouterLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenRouterLLMSettings(model="openai/gpt-4o-2024-11-20") + default_settings = self.Settings(model="openai/gpt-4o-2024-11-20") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenRouterLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index b13fb20f0..c93a77c16 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -18,13 +18,13 @@ from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams from pipecat.metrics.metrics import LLMTokenUsage from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class PerplexityLLMSettings(OpenAILLMSettings): +class PerplexityLLMSettings(BaseOpenAILLMService.Settings): """Settings for PerplexityLLMService.""" pass @@ -39,7 +39,7 @@ class PerplexityLLMService(OpenAILLMService): """ Settings = PerplexityLLMSettings - _settings: PerplexityLLMSettings + _settings: Settings def __init__( self, @@ -47,7 +47,7 @@ class PerplexityLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.perplexity.ai", model: Optional[str] = None, - settings: Optional[PerplexityLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Perplexity LLM service. @@ -58,18 +58,18 @@ class PerplexityLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "sonar". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=PerplexityLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = PerplexityLLMSettings(model="sonar") + default_settings = self.Settings(model="sonar") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", PerplexityLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/piper/tts.py b/src/pipecat/services/piper/tts.py index 3cafd2dcd..0d56d377e 100644 --- a/src/pipecat/services/piper/tts.py +++ b/src/pipecat/services/piper/tts.py @@ -48,7 +48,7 @@ class PiperTTSService(TTSService): """ Settings = PiperTTSSettings - _settings: PiperTTSSettings + _settings: Settings def __init__( self, @@ -57,7 +57,7 @@ class PiperTTSService(TTSService): download_dir: Optional[Path] = None, force_redownload: bool = False, use_cuda: bool = False, - settings: Optional[PiperTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Piper TTS service. @@ -66,7 +66,7 @@ class PiperTTSService(TTSService): voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). .. deprecated:: 0.0.105 - Use ``settings=PiperTTSSettings(voice=...)`` instead. + Use ``settings=PiperTTSService.Settings(voice=...)`` instead. download_dir: Directory for storing voice model files. Defaults to the current working directory. @@ -77,11 +77,11 @@ class PiperTTSService(TTSService): **kwargs: Additional arguments passed to the parent `TTSService`. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = PiperTTSSettings(model=None, voice=None, language=None) + default_settings = self.Settings(model=None, voice=None, language=None) # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", PiperTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. (No step 3, as there's no params object to apply) @@ -121,7 +121,7 @@ class PiperTTSService(TTSService): """ return True - async def _update_settings(self, delta: PiperTTSSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply a settings delta. Settings are stored but not applied to the active connection. @@ -202,7 +202,7 @@ class PiperHttpTTSService(TTSService): """ Settings = PiperHttpTTSSettings - _settings: PiperHttpTTSSettings + _settings: Settings def __init__( self, @@ -210,7 +210,7 @@ class PiperHttpTTSService(TTSService): base_url: str, aiohttp_session: aiohttp.ClientSession, voice_id: Optional[str] = None, - settings: Optional[PiperHttpTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Piper TTS service. @@ -221,18 +221,18 @@ class PiperHttpTTSService(TTSService): voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). .. deprecated:: 0.0.105 - Use ``settings=PiperHttpTTSSettings(voice=...)`` instead. + Use ``settings=PiperHttpTTSService.Settings(voice=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = PiperHttpTTSSettings(model=None, voice=None, language=None) + default_settings = self.Settings(model=None, voice=None, language=None) # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", PiperHttpTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index d145f8339..4c3d7015c 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -11,13 +11,13 @@ from typing import Optional from loguru import logger -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class QwenLLMSettings(OpenAILLMSettings): +class QwenLLMSettings(BaseOpenAILLMService.Settings): """Settings for QwenLLMService.""" pass @@ -31,7 +31,7 @@ class QwenLLMService(OpenAILLMService): """ Settings = QwenLLMSettings - _settings: QwenLLMSettings + _settings: Settings def __init__( self, @@ -39,7 +39,7 @@ class QwenLLMService(OpenAILLMService): api_key: str, base_url: str = "https://dashscope-intl.aliyuncs.com/compatible-mode/v1", model: Optional[str] = None, - settings: Optional[QwenLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Qwen LLM service. @@ -50,18 +50,18 @@ class QwenLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "qwen-plus". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=QwenLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = QwenLLMSettings(model="qwen-plus") + default_settings = self.Settings(model="qwen-plus") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", QwenLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/resembleai/tts.py b/src/pipecat/services/resembleai/tts.py index 31977ca0b..7375b9a1b 100644 --- a/src/pipecat/services/resembleai/tts.py +++ b/src/pipecat/services/resembleai/tts.py @@ -52,7 +52,7 @@ class ResembleAITTSService(WebsocketTTSService): """ Settings = ResembleAITTSSettings - _settings: ResembleAITTSSettings + _settings: Settings def __init__( self, @@ -63,7 +63,7 @@ class ResembleAITTSService(WebsocketTTSService): precision: Optional[str] = "PCM_16", output_format: Optional[str] = "wav", sample_rate: Optional[int] = 22050, - settings: Optional[ResembleAITTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Resemble AI TTS service. @@ -73,7 +73,7 @@ class ResembleAITTSService(WebsocketTTSService): voice_id: Voice UUID to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=ResembleAITTSSettings(voice=...)`` instead. + Use ``settings=ResembleAITTSService.Settings(voice=...)`` instead. url: WebSocket URL for Resemble AI TTS API. precision: PCM bit depth (PCM_32, PCM_24, PCM_16, or MULAW). @@ -84,7 +84,7 @@ class ResembleAITTSService(WebsocketTTSService): **kwargs: Additional arguments passed to the parent service. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = ResembleAITTSSettings( + default_settings = self.Settings( model=None, voice=None, language=None, @@ -92,7 +92,7 @@ class ResembleAITTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", ResembleAITTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index 15cc8b88a..df1b269cd 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -132,13 +132,13 @@ class RimeTTSService(WebsocketTTSService): """ Settings = RimeTTSSettings - _settings: RimeTTSSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Rime TTS service. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(...)`` instead. + Use ``settings=RimeTTSService.Settings(...)`` instead. Parameters: language: Language for synthesis. Defaults to English. @@ -177,7 +177,7 @@ class RimeTTSService(WebsocketTTSService): model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[RimeTTSSettings] = None, + settings: Optional[Settings] = None, text_aggregator: Optional[BaseTextAggregator] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, @@ -190,19 +190,19 @@ class RimeTTSService(WebsocketTTSService): voice_id: ID of the voice to use. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(voice=...)`` instead. + Use ``settings=RimeTTSService.Settings(voice=...)`` instead. url: Rime websocket API endpoint. model: Model ID to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(model=...)`` instead. + Use ``settings=RimeTTSService.Settings(model=...)`` instead. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(...)`` instead. + Use ``settings=RimeTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -220,7 +220,7 @@ class RimeTTSService(WebsocketTTSService): **kwargs: Additional arguments passed to parent class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = RimeTTSSettings( + default_settings = self.Settings( model="arcana", voice=None, language=None, @@ -241,15 +241,15 @@ class RimeTTSService(WebsocketTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", RimeTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", RimeTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", RimeTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = ( self.language_to_service_language(params.language) if params.language else None @@ -663,13 +663,13 @@ class RimeHttpTTSService(TTSService): """ Settings = RimeTTSSettings - _settings: RimeTTSSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Rime HTTP TTS service. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(...)`` instead. + Use ``settings=RimeHttpTTSService.Settings(...)`` instead. Parameters: language: Language for synthesis. Defaults to English. @@ -696,7 +696,7 @@ class RimeHttpTTSService(TTSService): model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[RimeTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize Rime HTTP TTS service. @@ -706,26 +706,26 @@ class RimeHttpTTSService(TTSService): voice_id: ID of the voice to use. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(voice=...)`` instead. + Use ``settings=RimeHttpTTSService.Settings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. model: Model ID to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(model=...)`` instead. + Use ``settings=RimeHttpTTSService.Settings(model=...)`` instead. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=RimeTTSSettings(...)`` instead. + Use ``settings=RimeHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = RimeTTSSettings( + default_settings = self.Settings( model="mistv2", voice=None, language="eng", @@ -744,15 +744,15 @@ class RimeHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", RimeTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", RimeTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", RimeTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = ( self.language_to_service_language(params.language) if params.language else "eng" @@ -888,13 +888,13 @@ class RimeNonJsonTTSService(InterruptibleTTSService): """ Settings = RimeNonJsonTTSSettings - _settings: RimeNonJsonTTSSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Rime Non-JSON WebSocket TTS service. .. deprecated:: 0.0.105 - Use ``settings=RimeNonJsonTTSSettings(...)`` instead. + Use ``settings=RimeNonJsonTTSService.Settings(...)`` instead. Args: language: Language for synthesis. Defaults to English. @@ -922,7 +922,7 @@ class RimeNonJsonTTSService(InterruptibleTTSService): audio_format: str = "pcm", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[RimeNonJsonTTSSettings] = None, + settings: Optional[Settings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -934,20 +934,20 @@ class RimeNonJsonTTSService(InterruptibleTTSService): voice_id: ID of the voice to use. .. deprecated:: 0.0.105 - Use ``settings=RimeNonJsonTTSSettings(voice=...)`` instead. + Use ``settings=RimeNonJsonTTSService.Settings(voice=...)`` instead. url: Rime websocket API endpoint. model: Model ID to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=RimeNonJsonTTSSettings(model=...)`` instead. + Use ``settings=RimeNonJsonTTSService.Settings(model=...)`` instead. audio_format: Audio format to use. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. .. deprecated:: 0.0.105 - Use ``settings=RimeNonJsonTTSSettings(...)`` instead. + Use ``settings=RimeNonJsonTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -962,7 +962,7 @@ class RimeNonJsonTTSService(InterruptibleTTSService): **kwargs: Additional arguments passed to parent class. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = RimeNonJsonTTSSettings( + default_settings = self.Settings( voice=None, model="arcana", language=None, @@ -974,15 +974,15 @@ class RimeNonJsonTTSService(InterruptibleTTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", RimeNonJsonTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id if model is not None: - _warn_deprecated_param("model", RimeNonJsonTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", RimeNonJsonTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = ( self.language_to_service_language(params.language) if params.language else None diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index 629c3d4c5..a77252ff8 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -22,14 +22,14 @@ from pipecat.metrics.metrics import LLMTokenUsage from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.services.llm_service import FunctionCallFromLLM -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param from pipecat.utils.tracing.service_decorators import traced_llm @dataclass -class SambaNovaLLMSettings(OpenAILLMSettings): +class SambaNovaLLMSettings(BaseOpenAILLMService.Settings): """Settings for SambaNovaLLMService.""" pass @@ -43,7 +43,7 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore """ Settings = SambaNovaLLMSettings - _settings: SambaNovaLLMSettings + _settings: Settings def __init__( self, @@ -51,7 +51,7 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore api_key: str, model: Optional[str] = None, base_url: str = "https://api.sambanova.ai/v1", - settings: Optional[SambaNovaLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs: Dict[Any, Any], ) -> None: """Initialize SambaNova LLM service. @@ -61,7 +61,7 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore model: The model identifier to use. Defaults to "Llama-4-Maverick-17B-128E-Instruct". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=SambaNovaLLMService.Settings(model=...)`` instead. base_url: The base URL for SambaNova API. Defaults to "https://api.sambanova.ai/v1". settings: Runtime-updatable settings. When provided alongside deprecated @@ -69,11 +69,11 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = SambaNovaLLMSettings(model="Llama-4-Maverick-17B-128E-Instruct") + default_settings = self.Settings(model="Llama-4-Maverick-17B-128E-Instruct") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", SambaNovaLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/sambanova/stt.py b/src/pipecat/services/sambanova/stt.py index c273b67eb..c42a491e1 100644 --- a/src/pipecat/services/sambanova/stt.py +++ b/src/pipecat/services/sambanova/stt.py @@ -15,14 +15,13 @@ from pipecat.services.settings import _warn_deprecated_param from pipecat.services.stt_latency import SAMBANOVA_TTFS_P99 from pipecat.services.whisper.base_stt import ( BaseWhisperSTTService, - BaseWhisperSTTSettings, Transcription, ) from pipecat.transcriptions.language import Language @dataclass -class SambaNovaSTTSettings(BaseWhisperSTTSettings): +class SambaNovaSTTSettings(BaseWhisperSTTService.Settings): """Settings for the SambaNova STT service.""" pass @@ -46,7 +45,7 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, - settings: Optional[SambaNovaSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = SAMBANOVA_TTFS_P99, **kwargs: Any, ) -> None: @@ -56,24 +55,24 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore model: Whisper model to use. .. deprecated:: 0.0.105 - Use ``settings=SambaNovaSTTSettings(model=...)`` instead. + Use ``settings=SambaNovaSTTService.Settings(model=...)`` instead. api_key: SambaNova API key. Defaults to None. base_url: API base URL. Defaults to "https://api.sambanova.ai/v1". language: Language of the audio input. .. deprecated:: 0.0.105 - Use ``settings=SambaNovaSTTSettings(language=...)`` instead. + Use ``settings=SambaNovaSTTService.Settings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. .. deprecated:: 0.0.105 - Use ``settings=SambaNovaSTTSettings(prompt=...)`` instead. + Use ``settings=SambaNovaSTTService.Settings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. .. deprecated:: 0.0.105 - Use ``settings=SambaNovaSTTSettings(temperature=...)`` instead. + Use ``settings=SambaNovaSTTService.Settings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -82,7 +81,7 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore **kwargs: Additional arguments passed to `pipecat.services.whisper.base_stt.BaseWhisperSTTService`. """ # --- 1. Hardcoded defaults --- - default_settings = SambaNovaSTTSettings( + default_settings = self.Settings( model="Whisper-Large-v3", language=self.language_to_service_language(Language.EN), prompt=None, @@ -91,16 +90,16 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", SambaNovaSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if language is not None: - _warn_deprecated_param("language", SambaNovaSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = self.language_to_service_language(language) if prompt is not None: - _warn_deprecated_param("prompt", SambaNovaSTTSettings, "prompt") + _warn_deprecated_param("prompt", self.Settings, "prompt") default_settings.prompt = prompt if temperature is not None: - _warn_deprecated_param("temperature", SambaNovaSTTSettings, "temperature") + _warn_deprecated_param("temperature", self.Settings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- diff --git a/src/pipecat/services/sarvam/stt.py b/src/pipecat/services/sarvam/stt.py index 429973838..b2c02f7cd 100644 --- a/src/pipecat/services/sarvam/stt.py +++ b/src/pipecat/services/sarvam/stt.py @@ -172,13 +172,13 @@ class SarvamSTTService(STTService): """ Settings = SarvamSTTSettings - _settings: SarvamSTTSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Sarvam STT service. .. deprecated:: 0.0.105 - Use ``settings=SarvamSTTSettings(...)`` instead. + Use ``settings=SarvamSTTService.Settings(...)`` instead. Parameters: language: Target language for transcription. @@ -210,7 +210,7 @@ class SarvamSTTService(STTService): sample_rate: Optional[int] = None, input_audio_codec: str = "wav", params: Optional[InputParams] = None, - settings: Optional[SarvamSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = SARVAM_TTFS_P99, keepalive_timeout: Optional[float] = None, keepalive_interval: float = 5.0, @@ -223,7 +223,7 @@ class SarvamSTTService(STTService): model: Sarvam model to use for transcription. .. deprecated:: 0.0.105 - Use ``settings=SarvamSTTSettings(model=...)`` instead. + Use ``settings=SarvamSTTService.Settings(model=...)`` instead. mode: Mode of operation. Options: transcribe, translate, verbatim, translit, codemix. Only applicable to models that support it @@ -233,7 +233,7 @@ class SarvamSTTService(STTService): params: Configuration parameters for Sarvam STT service. .. deprecated:: 0.0.105 - Use ``settings=SarvamSTTSettings(...)`` instead. + Use ``settings=SarvamSTTService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -245,7 +245,7 @@ class SarvamSTTService(STTService): **kwargs: Additional arguments passed to the parent STTService. """ # --- 1. Hardcoded defaults --- - default_settings = SarvamSTTSettings( + default_settings = self.Settings( model="saarika:v2.5", language=None, prompt=None, @@ -255,12 +255,12 @@ class SarvamSTTService(STTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", SarvamSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # --- 3. Deprecated params overrides --- if params is not None: - _warn_deprecated_param("params", SarvamSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = params.language default_settings.prompt = params.prompt @@ -374,7 +374,7 @@ class SarvamSTTService(STTService): """Apply a settings delta, validate, sync state, and reconnect. Args: - delta: A :class:`STTSettings` (or ``SarvamSTTSettings``) delta. + delta: A :class:`STTSettings` (or ``SarvamSTTService.Settings``) delta. Returns: Dict mapping changed field names to their previous values. @@ -389,11 +389,7 @@ class SarvamSTTService(STTService): f"Model '{self._settings.model}' does not support language parameter " "(auto-detects language)." ) - if ( - isinstance(delta, SarvamSTTSettings) - and is_given(delta.prompt) - and delta.prompt is not None - ): + if isinstance(delta, self.Settings) and is_given(delta.prompt) and delta.prompt is not None: if not self._config.supports_prompt: raise ValueError( f"Model '{self._settings.model}' does not support prompt parameter." @@ -417,7 +413,7 @@ class SarvamSTTService(STTService): """Set the transcription/translation prompt and reconnect. .. deprecated:: 0.0.104 - Use ``STTUpdateSettingsFrame(SarvamSTTSettings(prompt=...))`` instead. + Use ``STTUpdateSettingsFrame(SarvamSTTService.Settings(prompt=...))`` instead. Args: prompt: Prompt text to guide transcription/translation style/context. @@ -430,7 +426,7 @@ class SarvamSTTService(STTService): warnings.simplefilter("always") warnings.warn( f"{self.__class__.__name__}.set_prompt() is deprecated. " - "Use STTUpdateSettingsFrame(SarvamSTTSettings(prompt=...)) instead.", + "Use STTUpdateSettingsFrame(self.Settings(prompt=...)) instead.", DeprecationWarning, stacklevel=2, ) diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 0d6a872eb..a469dbf33 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -284,7 +284,7 @@ class SarvamHttpTTSSettings(TTSSettings): class SarvamTTSSettings(SarvamHttpTTSSettings): """Settings for SarvamTTSService. - Extends :class:`SarvamHttpTTSSettings` with WebSocket-specific buffering parameters. + Extends :class:`SarvamHttpTTSService.Settings` with WebSocket-specific buffering parameters. Parameters: min_buffer_size: Minimum characters to buffer before generating audio. @@ -352,13 +352,13 @@ class SarvamHttpTTSService(TTSService): """ Settings = SarvamHttpTTSSettings - _settings: SarvamHttpTTSSettings + _settings: Settings class InputParams(BaseModel): """Input parameters for Sarvam TTS configuration. .. deprecated:: 0.0.105 - Use ``SarvamHttpTTSSettings`` directly via the ``settings`` parameter instead. + Use ``SarvamHttpTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: language: Language for synthesis. Defaults to English (India). @@ -416,7 +416,7 @@ class SarvamHttpTTSService(TTSService): base_url: str = "https://api.sarvam.ai", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[SarvamHttpTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Sarvam TTS service. @@ -427,14 +427,14 @@ class SarvamHttpTTSService(TTSService): voice_id: Speaker voice ID. If None, uses model-appropriate default. .. deprecated:: 0.0.105 - Use ``settings=SarvamHttpTTSSettings(voice=...)`` instead. + Use ``settings=SarvamHttpTTSService.Settings(voice=...)`` instead. model: TTS model to use. Options: - "bulbul:v2" (default): Standard model with pitch/loudness support - "bulbul:v3-beta": Advanced model with temperature control .. deprecated:: 0.0.105 - Use ``settings=SarvamHttpTTSSettings(model=...)`` instead. + Use ``settings=SarvamHttpTTSService.Settings(model=...)`` instead. base_url: Sarvam AI API base URL. Defaults to "https://api.sarvam.ai". sample_rate: Audio sample rate in Hz (8000, 16000, 22050, 24000). @@ -442,14 +442,14 @@ class SarvamHttpTTSService(TTSService): params: Additional voice and preprocessing parameters. If None, uses defaults. .. deprecated:: 0.0.105 - Use ``settings=SarvamHttpTTSSettings(...)`` instead. + Use ``settings=SarvamHttpTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = SarvamHttpTTSSettings( + default_settings = self.Settings( model="bulbul:v2", voice="anushka", language="en-IN", @@ -462,15 +462,15 @@ class SarvamHttpTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", SarvamHttpTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id is not None: - _warn_deprecated_param("voice_id", SarvamHttpTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", SarvamHttpTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = ( @@ -719,13 +719,13 @@ class SarvamTTSService(InterruptibleTTSService): """ Settings = SarvamTTSSettings - _settings: SarvamTTSSettings + _settings: Settings class InputParams(BaseModel): """Configuration parameters for Sarvam TTS WebSocket service. .. deprecated:: 0.0.105 - Use ``SarvamTTSSettings`` directly via the ``settings`` parameter instead. + Use ``SarvamTTSService.Settings`` directly via the ``settings`` parameter instead. Parameters: pitch: Voice pitch adjustment (-0.75 to 0.75). Defaults to 0.0. @@ -819,7 +819,7 @@ class SarvamTTSService(InterruptibleTTSService): text_aggregation_mode: Optional[TextAggregationMode] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, - settings: Optional[SarvamTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Sarvam TTS service with voice and transport configuration. @@ -831,12 +831,12 @@ class SarvamTTSService(InterruptibleTTSService): - "bulbul:v3-beta": Advanced model with temperature control .. deprecated:: 0.0.105 - Use ``settings=SarvamTTSSettings(model=...)`` instead. + Use ``settings=SarvamTTSService.Settings(model=...)`` instead. voice_id: Speaker voice ID. If None, uses model-appropriate default. .. deprecated:: 0.0.105 - Use ``settings=SarvamTTSSettings(voice=...)`` instead. + Use ``settings=SarvamTTSService.Settings(voice=...)`` instead. url: WebSocket URL for the TTS backend (default production URL). aggregate_sentences: Deprecated. Use text_aggregation_mode instead. @@ -850,7 +850,7 @@ class SarvamTTSService(InterruptibleTTSService): params: Optional input parameters to override defaults. .. deprecated:: 0.0.105 - Use ``settings=SarvamTTSSettings(...)`` instead. + Use ``settings=SarvamTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -859,7 +859,7 @@ class SarvamTTSService(InterruptibleTTSService): See https://docs.sarvam.ai/api-reference-docs/text-to-speech/stream """ # 1. Initialize default_settings with hardcoded defaults - default_settings = SarvamTTSSettings( + default_settings = self.Settings( model="bulbul:v2", voice="anushka", language="en-IN", @@ -874,10 +874,10 @@ class SarvamTTSService(InterruptibleTTSService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", SarvamTTSSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if voice_id is not None: - _warn_deprecated_param("voice_id", SarvamTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # Init-only audio format fields (not runtime-updatable) @@ -886,7 +886,7 @@ class SarvamTTSService(InterruptibleTTSService): # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", SarvamTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: if params.language is not None: default_settings.language = ( diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index 6e5a8f62c..abf42dcdc 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -80,7 +80,7 @@ class SonioxInputParams(BaseModel): """Real-time transcription settings. .. deprecated:: 0.0.105 - Use ``settings=SonioxSTTSettings(...)`` instead. + Use ``settings=SonioxSTTService.Settings(...)`` instead. See Soniox WebSocket API documentation for more details: https://soniox.com/docs/speech-to-text/api-reference/websocket-api#configuration-parameters @@ -175,7 +175,7 @@ class SonioxSTTService(WebsocketSTTService): """ Settings = SonioxSTTSettings - _settings: SonioxSTTSettings + _settings: Settings def __init__( self, @@ -188,7 +188,7 @@ class SonioxSTTService(WebsocketSTTService): num_channels: int = 1, params: Optional[SonioxInputParams] = None, vad_force_turn_endpoint: bool = True, - settings: Optional[SonioxSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = SONIOX_TTFS_P99, **kwargs, ): @@ -201,7 +201,7 @@ class SonioxSTTService(WebsocketSTTService): model: Soniox model to use for transcription. .. deprecated:: 0.0.105 - Use ``settings=SonioxSTTSettings(model=...)`` instead. + Use ``settings=SonioxSTTService.Settings(model=...)`` instead. audio_format: Audio format for transcription. Defaults to ``"pcm_s16le"``. num_channels: Number of audio channels. Defaults to 1. @@ -209,7 +209,7 @@ class SonioxSTTService(WebsocketSTTService): speaker diarization. .. deprecated:: 0.0.105 - Use ``settings=SonioxSTTSettings(...)`` instead. + Use ``settings=SonioxSTTService.Settings(...)`` instead. vad_force_turn_endpoint: Listen to `VADUserStoppedSpeakingFrame` to send finalize message to Soniox. If disabled, Soniox will detect the end of the speech. Defaults to True. @@ -220,7 +220,7 @@ class SonioxSTTService(WebsocketSTTService): **kwargs: Additional arguments passed to the STTService. """ # --- 1. Hardcoded defaults --- - default_settings = SonioxSTTSettings( + default_settings = self.Settings( model="stt-rt-v4", language=None, language_hints=None, @@ -233,12 +233,12 @@ class SonioxSTTService(WebsocketSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", SonioxSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # --- 3. Deprecated params overrides --- if params is not None: - _warn_deprecated_param("params", SonioxSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.model = params.model if params.audio_format is not None: @@ -297,7 +297,7 @@ class SonioxSTTService(WebsocketSTTService): await super().start(frame) await self._connect() - async def _update_settings(self, delta: SonioxSTTSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply settings delta and reconnect if anything changed. Args: diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index aaff90900..2a54b2b08 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -176,7 +176,7 @@ class SpeechmaticsSTTService(STTService): """ Settings = SpeechmaticsSTTSettings - _settings: SpeechmaticsSTTSettings + _settings: Settings # Export related classes as class attributes TurnDetectionMode = TurnDetectionMode @@ -343,7 +343,7 @@ class SpeechmaticsSTTService(STTService): """Update parameters for Speechmatics STT service. .. deprecated:: 0.0.104 - Use ``SpeechmaticsSTTSettings`` with ``STTUpdateSettingsFrame`` instead. + Use ``SpeechmaticsSTTService.Settings`` with ``STTUpdateSettingsFrame`` instead. Parameters: focus_speakers: List of speaker IDs to focus on. When enabled, only these speakers are @@ -380,7 +380,7 @@ class SpeechmaticsSTTService(STTService): encoding: AudioEncoding = AudioEncoding.PCM_S16LE, params: InputParams | None = None, should_interrupt: bool = True, - settings: SpeechmaticsSTTSettings | None = None, + settings: Settings | None = None, ttfs_p99_latency: float | None = SPEECHMATICS_TTFS_P99, **kwargs, ): @@ -396,7 +396,7 @@ class SpeechmaticsSTTService(STTService): params: Input parameters for the service. .. deprecated:: 0.0.105 - Use ``settings=SpeechmaticsSTTSettings(...)`` instead. + Use ``settings=SpeechmaticsSTTService.Settings(...)`` instead. should_interrupt: Determine whether the bot should be interrupted when Speechmatics turn_detection_mode is configured to detect user speech. settings: Runtime-updatable settings. When provided alongside deprecated @@ -424,7 +424,7 @@ class SpeechmaticsSTTService(STTService): self._check_deprecated_args(kwargs, _params) # --- 1. Hardcoded defaults --- - default_settings = SpeechmaticsSTTSettings( + default_settings = self.Settings( model=None, # Will be resolved from operating_point after config is built language=Language.EN, domain=None, @@ -454,7 +454,7 @@ class SpeechmaticsSTTService(STTService): # --- 3. Deprecated params overrides --- if params is not None: - _warn_deprecated_param("params", SpeechmaticsSTTSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.language = _params.language default_settings.domain = _params.domain @@ -537,11 +537,11 @@ class SpeechmaticsSTTService(STTService): await super().start(frame) await self._connect() - async def _update_settings(self, delta: SpeechmaticsSTTSettings) -> dict[str, Any]: + async def _update_settings(self, delta: Settings) -> dict[str, Any]: """Apply settings delta, reconnecting only when necessary. Fields are classified into three categories (see - ``SpeechmaticsSTTSettings``): + ``SpeechmaticsSTTService.Settings``): * **HOT_FIELDS** – diarization speaker settings that can be pushed to a live Speechmatics connection without reconnecting. @@ -561,7 +561,7 @@ class SpeechmaticsSTTService(STTService): if not changed: return changed - no_reconnect = SpeechmaticsSTTSettings.HOT_FIELDS | SpeechmaticsSTTSettings.LOCAL_FIELDS + no_reconnect = self.Settings.HOT_FIELDS | self.Settings.LOCAL_FIELDS needs_reconnect = bool(changed.keys() - no_reconnect) if needs_reconnect: @@ -571,7 +571,7 @@ class SpeechmaticsSTTService(STTService): self._config = self._build_config(self._settings) await self._disconnect() await self._connect() - elif changed.keys() & SpeechmaticsSTTSettings.HOT_FIELDS: + elif changed.keys() & self.Settings.HOT_FIELDS: logger.debug(f"{self} applying hot settings update: {changed.keys()}") if self._config.enable_diarization: # Only hot-updatable fields changed — push to the live session. @@ -586,7 +586,7 @@ class SpeechmaticsSTTService(STTService): ) # Diarization not enabled — the new settings will take effect # if/when diarization is enabled, which does require a reconnect. - elif changed.keys() & SpeechmaticsSTTSettings.LOCAL_FIELDS: + elif changed.keys() & self.Settings.LOCAL_FIELDS: logger.debug( f"{self} local settings update, no special action required: {changed.keys()}" ) @@ -705,7 +705,7 @@ class SpeechmaticsSTTService(STTService): # CONFIGURATION # ============================================================================ - def _build_config(self, settings: SpeechmaticsSTTSettings) -> VoiceAgentConfig: + def _build_config(self, settings: Settings) -> VoiceAgentConfig: """Build a ``VoiceAgentConfig`` from the given settings. Used both at init time (with explicit settings, before @@ -778,7 +778,7 @@ class SpeechmaticsSTTService(STTService): .. deprecated:: 0.0.104 Use ``STTUpdateSettingsFrame`` with - ``SpeechmaticsSTTSettings(...)`` instead. + ``SpeechmaticsSTTService.Settings(...)`` instead. This can update the speakers to listen to or ignore during an in-flight transcription. Only available if diarization is enabled. @@ -790,7 +790,7 @@ class SpeechmaticsSTTService(STTService): warnings.simplefilter("always") warnings.warn( "update_params() is deprecated. Use STTUpdateSettingsFrame with " - "SpeechmaticsSTTSettings(...) instead.", + "self.Settings(...) instead.", DeprecationWarning, ) # Check possible diff --git a/src/pipecat/services/speechmatics/tts.py b/src/pipecat/services/speechmatics/tts.py index 20a3212ff..243437cb3 100644 --- a/src/pipecat/services/speechmatics/tts.py +++ b/src/pipecat/services/speechmatics/tts.py @@ -54,7 +54,7 @@ class SpeechmaticsTTSService(TTSService): """ Settings = SpeechmaticsTTSSettings - _settings: SpeechmaticsTTSSettings + _settings: Settings SPEECHMATICS_SAMPLE_RATE = 16000 @@ -62,7 +62,7 @@ class SpeechmaticsTTSService(TTSService): """Optional input parameters for Speechmatics TTS configuration. .. deprecated:: 0.0.105 - Use ``settings=SpeechmaticsTTSSettings(...)`` instead. + Use ``settings=SpeechmaticsTTSService.Settings(...)`` instead. Parameters: max_retries: Maximum number of retries for TTS requests. Defaults to 5. @@ -79,7 +79,7 @@ class SpeechmaticsTTSService(TTSService): aiohttp_session: aiohttp.ClientSession, sample_rate: Optional[int] = SPEECHMATICS_SAMPLE_RATE, params: Optional[InputParams] = None, - settings: Optional[SpeechmaticsTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Speechmatics TTS service. @@ -90,14 +90,14 @@ class SpeechmaticsTTSService(TTSService): voice_id: Voice model to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=SpeechmaticsTTSSettings(voice=...)`` instead. + Use ``settings=SpeechmaticsTTSService.Settings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. sample_rate: Audio sample rate in Hz. params: Input parameters for the service. .. deprecated:: 0.0.105 - Use ``settings=SpeechmaticsTTSSettings(...)`` instead. + Use ``settings=SpeechmaticsTTSService.Settings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -110,7 +110,7 @@ class SpeechmaticsTTSService(TTSService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = SpeechmaticsTTSSettings( + default_settings = self.Settings( model=None, voice="sarah", language=None, @@ -119,12 +119,12 @@ class SpeechmaticsTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", SpeechmaticsTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", SpeechmaticsTTSSettings) + _warn_deprecated_param("params", self.Settings) if not settings: default_settings.max_retries = params.max_retries diff --git a/src/pipecat/services/tavus/video.py b/src/pipecat/services/tavus/video.py index 3d5946e54..9043710c8 100644 --- a/src/pipecat/services/tavus/video.py +++ b/src/pipecat/services/tavus/video.py @@ -60,7 +60,7 @@ class TavusVideoService(AIService): """ Settings = TavusVideoSettings - _settings: TavusVideoSettings + _settings: Settings def __init__( self, @@ -69,7 +69,7 @@ class TavusVideoService(AIService): replica_id: str, persona_id: str = "pipecat-stream", session: aiohttp.ClientSession, - settings: Optional[TavusVideoSettings] = None, + settings: Optional[Settings] = None, **kwargs, ) -> None: """Initialize the Tavus video service. diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index 21663206e..b1eb83d26 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -11,13 +11,13 @@ from typing import Optional from loguru import logger -from pipecat.services.openai.base_llm import OpenAILLMSettings +from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param @dataclass -class TogetherLLMSettings(OpenAILLMSettings): +class TogetherLLMSettings(BaseOpenAILLMService.Settings): """Settings for TogetherLLMService.""" pass @@ -31,7 +31,7 @@ class TogetherLLMService(OpenAILLMService): """ Settings = TogetherLLMSettings - _settings: TogetherLLMSettings + _settings: Settings def __init__( self, @@ -39,7 +39,7 @@ class TogetherLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.together.xyz/v1", model: Optional[str] = None, - settings: Optional[TogetherLLMSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize Together.ai LLM service. @@ -50,18 +50,18 @@ class TogetherLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo". .. deprecated:: 0.0.105 - Use ``settings=OpenAILLMSettings(model=...)`` instead. + Use ``settings=TogetherLLMService.Settings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = TogetherLLMSettings(model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo") + default_settings = self.Settings(model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", TogetherLLMSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model # 3. (No step 3, as there's no params object to apply) diff --git a/src/pipecat/services/ultravox/llm.py b/src/pipecat/services/ultravox/llm.py index bfd34ceae..fe8a97549 100644 --- a/src/pipecat/services/ultravox/llm.py +++ b/src/pipecat/services/ultravox/llm.py @@ -167,13 +167,13 @@ class UltravoxRealtimeLLMService(LLMService): """ Settings = UltravoxRealtimeLLMSettings - _settings: UltravoxRealtimeLLMSettings + _settings: Settings def __init__( self, *, params: Union[AgentInputParams, OneShotInputParams, JoinUrlInputParams], - settings: Optional[UltravoxRealtimeLLMSettings] = None, + settings: Optional[Settings] = None, one_shot_selected_tools: Optional[ToolsSchema] = None, **kwargs, ): @@ -188,7 +188,7 @@ class UltravoxRealtimeLLMService(LLMService): **kwargs: Additional arguments passed to parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = UltravoxRealtimeLLMSettings( + default_settings = self.Settings( model=None, system_instruction=None, temperature=None, @@ -383,7 +383,7 @@ class UltravoxRealtimeLLMService(LLMService): await self.cancel_task(self._receive_task, timeout=1.0) self._receive_task = None - async def _update_settings(self, delta: UltravoxRealtimeLLMSettings): + async def _update_settings(self, delta: Settings): changed = await super()._update_settings(delta) if "output_medium" in changed: await self._update_output_medium(self._settings.output_medium) diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index 869f92a55..d045eafc7 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -123,7 +123,7 @@ class BaseWhisperSTTService(SegmentedSTTService): """ Settings = BaseWhisperSTTSettings - _settings: BaseWhisperSTTSettings + _settings: Settings def __init__( self, @@ -136,7 +136,7 @@ class BaseWhisperSTTService(SegmentedSTTService): temperature: Optional[float] = None, include_prob_metrics: bool = False, push_empty_transcripts: bool = False, - settings: Optional[BaseWhisperSTTSettings] = None, + settings: Optional[Settings] = None, ttfs_p99_latency: Optional[float] = WHISPER_TTFS_P99, **kwargs, ): @@ -146,24 +146,24 @@ class BaseWhisperSTTService(SegmentedSTTService): model: Name of the Whisper model to use. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(model=...)`` instead. + Use ``settings=BaseWhisperSTTService.Settings(model=...)`` instead. api_key: Service API key. Defaults to None. base_url: Service API base URL. Defaults to None. language: Language of the audio input. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. + Use ``settings=BaseWhisperSTTService.Settings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. + Use ``settings=BaseWhisperSTTService.Settings(prompt=...)`` instead. temperature: Sampling temperature between 0 and 1. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. + Use ``settings=BaseWhisperSTTService.Settings(temperature=...)`` instead. include_prob_metrics: If True, enables probability metrics in API response. Each service implements this differently (see child classes). @@ -181,7 +181,7 @@ class BaseWhisperSTTService(SegmentedSTTService): **kwargs: Additional arguments passed to SegmentedSTTService. """ # --- 1. Hardcoded defaults --- - default_settings = BaseWhisperSTTSettings( + default_settings = self.Settings( model=None, language=None, prompt=None, @@ -190,16 +190,16 @@ class BaseWhisperSTTService(SegmentedSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if language is not None: - _warn_deprecated_param("language", BaseWhisperSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = self.language_to_service_language(language) if prompt is not None: - _warn_deprecated_param("prompt", BaseWhisperSTTSettings, "prompt") + _warn_deprecated_param("prompt", self.Settings, "prompt") default_settings.prompt = prompt if temperature is not None: - _warn_deprecated_param("temperature", BaseWhisperSTTSettings, "temperature") + _warn_deprecated_param("temperature", self.Settings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- diff --git a/src/pipecat/services/whisper/stt.py b/src/pipecat/services/whisper/stt.py index b5971ce9a..29574007a 100644 --- a/src/pipecat/services/whisper/stt.py +++ b/src/pipecat/services/whisper/stt.py @@ -208,7 +208,7 @@ class WhisperSTTService(SegmentedSTTService): """ Settings = WhisperSTTSettings - _settings: WhisperSTTSettings + _settings: Settings def __init__( self, @@ -218,7 +218,7 @@ class WhisperSTTService(SegmentedSTTService): compute_type: str = "default", no_speech_prob: Optional[float] = None, language: Optional[Language] = None, - settings: Optional[WhisperSTTSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the Whisper STT service. @@ -227,7 +227,7 @@ class WhisperSTTService(SegmentedSTTService): model: The Whisper model to use for transcription. Can be a Model enum or string. .. deprecated:: 0.0.105 - Use ``settings=WhisperSTTSettings(model=...)`` instead. + Use ``settings=WhisperSTTService.Settings(model=...)`` instead. device: The device to run inference on ('cpu', 'cuda', or 'auto'). Defaults to ``"auto"``. @@ -236,19 +236,19 @@ class WhisperSTTService(SegmentedSTTService): no_speech_prob: Probability threshold for filtering out non-speech segments. .. deprecated:: 0.0.105 - Use ``settings=WhisperSTTSettings(no_speech_prob=...)`` instead. + Use ``settings=WhisperSTTService.Settings(no_speech_prob=...)`` instead. language: The default language for transcription. .. deprecated:: 0.0.105 - Use ``settings=WhisperSTTSettings(language=...)`` instead. + Use ``settings=WhisperSTTService.Settings(language=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to SegmentedSTTService. """ # --- 1. Hardcoded defaults --- - default_settings = WhisperSTTSettings( + default_settings = self.Settings( model=Model.DISTIL_MEDIUM_EN.value, language=Language.EN, no_speech_prob=0.4, @@ -256,13 +256,13 @@ class WhisperSTTService(SegmentedSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", WhisperSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if isinstance(model, str) else model.value if no_speech_prob is not None: - _warn_deprecated_param("no_speech_prob", WhisperSTTSettings, "no_speech_prob") + _warn_deprecated_param("no_speech_prob", self.Settings, "no_speech_prob") default_settings.no_speech_prob = no_speech_prob if language is not None: - _warn_deprecated_param("language", WhisperSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = language # --- 3. (no params object for this service) --- @@ -382,7 +382,7 @@ class WhisperSTTServiceMLX(WhisperSTTService): """ Settings = WhisperMLXSTTSettings - _settings: WhisperMLXSTTSettings + _settings: Settings def __init__( self, @@ -391,7 +391,7 @@ class WhisperSTTServiceMLX(WhisperSTTService): no_speech_prob: Optional[float] = None, language: Optional[Language] = None, temperature: Optional[float] = None, - settings: Optional[WhisperMLXSTTSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the MLX Whisper STT service. @@ -400,29 +400,29 @@ class WhisperSTTServiceMLX(WhisperSTTService): model: The MLX Whisper model to use for transcription. Can be an MLXModel enum or string. .. deprecated:: 0.0.105 - Use ``settings=WhisperMLXSTTSettings(model=...)`` instead. + Use ``settings=WhisperSTTServiceMLX.Settings(model=...)`` instead. no_speech_prob: Probability threshold for filtering out non-speech segments. .. deprecated:: 0.0.105 - Use ``settings=WhisperMLXSTTSettings(no_speech_prob=...)`` instead. + Use ``settings=WhisperSTTServiceMLX.Settings(no_speech_prob=...)`` instead. language: The default language for transcription. .. deprecated:: 0.0.105 - Use ``settings=WhisperMLXSTTSettings(language=...)`` instead. + Use ``settings=WhisperSTTServiceMLX.Settings(language=...)`` instead. temperature: Temperature for sampling. Can be a float or tuple of floats. .. deprecated:: 0.0.105 - Use ``settings=WhisperMLXSTTSettings(temperature=...)`` instead. + Use ``settings=WhisperSTTServiceMLX.Settings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to SegmentedSTTService. """ # --- 1. Hardcoded defaults --- - default_settings = WhisperMLXSTTSettings( + default_settings = self.Settings( model=MLXModel.TINY.value, language=Language.EN, no_speech_prob=0.6, @@ -432,16 +432,16 @@ class WhisperSTTServiceMLX(WhisperSTTService): # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", WhisperMLXSTTSettings, "model") + _warn_deprecated_param("model", self.Settings, "model") default_settings.model = model if isinstance(model, str) else model.value if no_speech_prob is not None: - _warn_deprecated_param("no_speech_prob", WhisperMLXSTTSettings, "no_speech_prob") + _warn_deprecated_param("no_speech_prob", self.Settings, "no_speech_prob") default_settings.no_speech_prob = no_speech_prob if language is not None: - _warn_deprecated_param("language", WhisperMLXSTTSettings, "language") + _warn_deprecated_param("language", self.Settings, "language") default_settings.language = language if temperature is not None: - _warn_deprecated_param("temperature", WhisperMLXSTTSettings, "temperature") + _warn_deprecated_param("temperature", self.Settings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- diff --git a/src/pipecat/services/xtts/tts.py b/src/pipecat/services/xtts/tts.py index 32c2781f2..b769742f3 100644 --- a/src/pipecat/services/xtts/tts.py +++ b/src/pipecat/services/xtts/tts.py @@ -84,7 +84,7 @@ class XTTSService(TTSService): """ Settings = XTTSTTSSettings - _settings: XTTSTTSSettings + _settings: Settings def __init__( self, @@ -94,7 +94,7 @@ class XTTSService(TTSService): aiohttp_session: aiohttp.ClientSession, language: Language = Language.EN, sample_rate: Optional[int] = None, - settings: Optional[XTTSTTSSettings] = None, + settings: Optional[Settings] = None, **kwargs, ): """Initialize the XTTS service. @@ -103,7 +103,7 @@ class XTTSService(TTSService): voice_id: ID of the voice/speaker to use for synthesis. .. deprecated:: 0.0.105 - Use ``settings=XTTSTTSSettings(voice=...)`` instead. + Use ``settings=XTTSService.Settings(voice=...)`` instead. base_url: Base URL of the XTTS streaming server. aiohttp_session: HTTP session for making requests to the server. @@ -114,7 +114,7 @@ class XTTSService(TTSService): **kwargs: Additional arguments passed to parent TTSService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = XTTSTTSSettings( + default_settings = self.Settings( model=None, voice=None, language=self.language_to_service_language(language), @@ -122,7 +122,7 @@ class XTTSService(TTSService): # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: - _warn_deprecated_param("voice_id", XTTSTTSSettings, "voice") + _warn_deprecated_param("voice_id", self.Settings, "voice") default_settings.voice = voice_id # 3. (No step 3, as there's no params object to apply)