From 5dc312ce0c76f503716f05dcdf845a6183a4a917 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Fri, 27 Feb 2026 21:46:03 -0500 Subject: [PATCH 01/17] Add `settings` as canonical init arg for all AIService descendants, deprecate redundant `model`/`voice`/`params` args ServiceSettings types were introduced for runtime updates via ServiceUpdateSettingsFrame, but there was tension between init-time and runtime APIs: overlapping-but-different InputParams vs ServiceSettings classes, and runtime-updatable fields like `model` and `voice` scattered as direct init args rather than living in a settings object. This unifies them so developers use the same settings type at both init and runtime, improving ergonomics and consistency. Every concrete AIService subclass (LLM, TTS, STT, ImageGen, Vision, Video) now accepts a `settings` parameter for runtime-updatable config. Old init args (`model`, `voice_id`, `params`/`InputParams`) still work but emit DeprecationWarnings pointing to the new API. When both are provided, `settings` takes precedence. Leaf classes emit warnings; base classes do not, avoiding double warnings in inheritance chains. --- src/pipecat/services/anthropic/llm.py | 87 ++++--- src/pipecat/services/assemblyai/stt.py | 17 +- src/pipecat/services/asyncai/tts.py | 112 ++++++--- src/pipecat/services/aws/llm.py | 72 ++++-- src/pipecat/services/aws/nova_sonic/llm.py | 74 ++++-- src/pipecat/services/aws/stt.py | 53 +++-- src/pipecat/services/aws/tts.py | 53 +++-- src/pipecat/services/azure/image.py | 22 +- src/pipecat/services/azure/llm.py | 24 +- src/pipecat/services/azure/stt.py | 33 ++- src/pipecat/services/azure/tts.py | 117 ++++++--- src/pipecat/services/camb/tts.py | 63 +++-- src/pipecat/services/cartesia/stt.py | 17 +- src/pipecat/services/cartesia/tts.py | 122 +++++++--- src/pipecat/services/cerebras/llm.py | 22 +- src/pipecat/services/deepgram/flux/stt.py | 72 +++--- .../services/deepgram/sagemaker/stt.py | 42 ++-- .../services/deepgram/sagemaker/tts.py | 32 ++- src/pipecat/services/deepgram/stt.py | 15 +- src/pipecat/services/deepgram/tts.py | 62 +++-- src/pipecat/services/deepseek/llm.py | 22 +- src/pipecat/services/elevenlabs/stt.py | 98 ++++++-- src/pipecat/services/elevenlabs/tts.py | 150 +++++++++--- src/pipecat/services/fal/image.py | 20 +- src/pipecat/services/fal/stt.py | 39 ++- src/pipecat/services/fireworks/llm.py | 24 +- src/pipecat/services/fish/tts.py | 68 ++++-- src/pipecat/services/gladia/stt.py | 56 +++-- .../services/google/gemini_live/llm.py | 88 ++++--- .../services/google/gemini_live/llm_vertex.py | 59 ++++- src/pipecat/services/google/image.py | 21 +- src/pipecat/services/google/llm.py | 69 ++++-- src/pipecat/services/google/llm_openai.py | 21 +- src/pipecat/services/google/llm_vertex.py | 44 +++- src/pipecat/services/google/stt.py | 51 ++-- src/pipecat/services/google/tts.py | 163 +++++++++---- src/pipecat/services/gradium/stt.py | 31 ++- src/pipecat/services/gradium/tts.py | 47 +++- src/pipecat/services/grok/llm.py | 21 +- src/pipecat/services/grok/realtime/llm.py | 45 ++-- src/pipecat/services/groq/llm.py | 22 +- src/pipecat/services/groq/stt.py | 63 ++++- src/pipecat/services/groq/tts.py | 57 +++-- src/pipecat/services/heygen/video.py | 10 +- src/pipecat/services/hume/tts.py | 45 +++- src/pipecat/services/inworld/tts.py | 128 +++++++--- src/pipecat/services/kokoro/tts.py | 43 +++- src/pipecat/services/lmnt/tts.py | 40 +++- src/pipecat/services/minimax/tts.py | 123 ++++++---- src/pipecat/services/mistral/llm.py | 22 +- src/pipecat/services/moondream/vision.py | 27 ++- src/pipecat/services/neuphonic/tts.py | 84 +++++-- src/pipecat/services/nvidia/llm.py | 27 ++- src/pipecat/services/nvidia/stt.py | 68 ++++-- src/pipecat/services/nvidia/tts.py | 43 +++- src/pipecat/services/ollama/llm.py | 26 +- src/pipecat/services/openai/base_llm.py | 54 +++-- src/pipecat/services/openai/image.py | 20 +- src/pipecat/services/openai/llm.py | 42 +++- src/pipecat/services/openai/realtime/llm.py | 56 +++-- src/pipecat/services/openai/stt.py | 54 ++++- src/pipecat/services/openai/tts.py | 79 +++++-- .../services/openai_realtime_beta/openai.py | 57 +++-- src/pipecat/services/openpipe/llm.py | 20 +- src/pipecat/services/openrouter/llm.py | 20 +- src/pipecat/services/perplexity/llm.py | 22 +- src/pipecat/services/piper/tts.py | 47 +++- src/pipecat/services/qwen/llm.py | 24 +- src/pipecat/services/resembleai/tts.py | 34 ++- src/pipecat/services/rime/tts.py | 222 ++++++++++++------ src/pipecat/services/sambanova/llm.py | 20 +- src/pipecat/services/sambanova/stt.py | 63 ++++- src/pipecat/services/sarvam/stt.py | 67 ++++-- src/pipecat/services/sarvam/tts.py | 174 +++++++++----- src/pipecat/services/settings.py | 40 ++++ src/pipecat/services/soniox/stt.py | 53 +++-- src/pipecat/services/speechmatics/stt.py | 25 +- src/pipecat/services/speechmatics/tts.py | 43 +++- src/pipecat/services/tavus/video.py | 10 +- src/pipecat/services/together/llm.py | 24 +- src/pipecat/services/ultravox/llm.py | 34 +-- src/pipecat/services/whisper/base_stt.py | 64 +++-- src/pipecat/services/whisper/stt.py | 139 ++++++++--- src/pipecat/services/xtts/tts.py | 30 ++- 84 files changed, 3431 insertions(+), 1182 deletions(-) diff --git a/src/pipecat/services/anthropic/llm.py b/src/pipecat/services/anthropic/llm.py index 5981d3e50..d2a4c300d 100644 --- a/src/pipecat/services/anthropic/llm.py +++ b/src/pipecat/services/anthropic/llm.py @@ -58,7 +58,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService from pipecat.services.settings import NOT_GIVEN as _NOT_GIVEN -from pipecat.services.settings import LLMSettings, _NotGiven, is_given +from pipecat.services.settings import LLMSettings, _NotGiven, _warn_deprecated_param, is_given from pipecat.utils.tracing.service_decorators import traced_llm try: @@ -170,6 +170,10 @@ class AnthropicLLMService(LLMService): class InputParams(BaseModel): """Input parameters for Anthropic model inference. + .. deprecated:: + Use ``AnthropicLLMSettings`` instead. Pass settings directly via the + ``settings`` parameter of :class:`AnthropicLLMService`. + Parameters: enable_prompt_caching: Whether to enable the prompt caching feature. enable_prompt_caching_beta (deprecated): Whether to enable the beta prompt caching feature. @@ -213,8 +217,9 @@ class AnthropicLLMService(LLMService): self, *, api_key: str, - model: str = "claude-sonnet-4-6", + model: Optional[str] = None, params: Optional[InputParams] = None, + settings: Optional[AnthropicLLMSettings] = None, client=None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, @@ -225,42 +230,66 @@ class AnthropicLLMService(LLMService): Args: api_key: Anthropic API key for authentication. - model: Model name to use. Defaults to "claude-sonnet-4-6". + model: Model name to use. + + .. deprecated:: + Use ``settings=AnthropicLLMSettings(model=...)`` instead. + params: Optional model parameters for inference. + + .. deprecated:: + Use ``settings=AnthropicLLMSettings(...)`` instead. + + settings: Runtime-updatable settings for this service. When both + deprecated parameters and *settings* are provided, *settings* + values take precedence. client: Optional custom Anthropic client instance. retry_timeout_secs: Request timeout in seconds for retry logic. retry_on_timeout: Whether to retry the request once if it times out. system_instruction: Optional system instruction to use as the system prompt. **kwargs: Additional arguments passed to parent LLMService. """ - params = params or AnthropicLLMService.InputParams() + if model is not None: + _warn_deprecated_param("model", "AnthropicLLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "AnthropicLLMSettings") - super().__init__( - settings=AnthropicLLMSettings( - model=model, - max_tokens=params.max_tokens, - enable_prompt_caching=( - params.enable_prompt_caching - if params.enable_prompt_caching is not None - else ( - params.enable_prompt_caching_beta - if params.enable_prompt_caching_beta is not None - else False - ) - ), - temperature=params.temperature, - top_k=params.top_k, - top_p=params.top_p, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - thinking=params.thinking, - extra=params.extra if isinstance(params.extra, dict) else {}, - ), - **kwargs, + _params = params or AnthropicLLMService.InputParams() + + # Handle existing enable_prompt_caching_beta deprecation + enable_prompt_caching = _params.enable_prompt_caching + if _params.enable_prompt_caching_beta is not None: + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "enable_prompt_caching_beta is deprecated. Use enable_prompt_caching instead.", + DeprecationWarning, + stacklevel=2, + ) + if enable_prompt_caching is None: + enable_prompt_caching = _params.enable_prompt_caching_beta + + default_settings = AnthropicLLMSettings( + model=model or "claude-sonnet-4-6", + max_tokens=_params.max_tokens, + enable_prompt_caching=enable_prompt_caching or False, + temperature=_params.temperature, + top_k=_params.top_k, + top_p=_params.top_p, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + thinking=_params.thinking, + extra=_params.extra if isinstance(_params.extra, dict) else {}, ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) self._client = client or AsyncAnthropic( api_key=api_key ) # if the client is provided, use it and remove it, otherwise create a new one diff --git a/src/pipecat/services/assemblyai/stt.py b/src/pipecat/services/assemblyai/stt.py index c62ae959b..85d4029b7 100644 --- a/src/pipecat/services/assemblyai/stt.py +++ b/src/pipecat/services/assemblyai/stt.py @@ -114,6 +114,7 @@ class AssemblyAISTTService(WebsocketSTTService): vad_force_turn_endpoint: bool = True, should_interrupt: bool = True, speaker_format: Optional[str] = None, + settings: Optional[AssemblyAISTTSettings] = None, ttfs_p99_latency: Optional[float] = ASSEMBLYAI_TTFS_P99, **kwargs, ): @@ -144,6 +145,8 @@ class AssemblyAISTTService(WebsocketSTTService): Use {speaker} for speaker label and {text} for transcript text. Example: "<{speaker}>{text}" or "{speaker}: {text}" If None, transcript text is not modified. Defaults to None. + settings: Runtime-updatable settings. When provided alongside other + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService class. @@ -185,14 +188,18 @@ class AssemblyAISTTService(WebsocketSTTService): if vad_force_turn_endpoint: connection_params = self._configure_pipecat_turn_mode(connection_params, is_u3_pro) + default_settings = AssemblyAISTTSettings( + model=None, + language=language, + connection_params=connection_params, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=connection_params.sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=AssemblyAISTTSettings( - model=None, - language=language, - connection_params=connection_params, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index 4f1fd5a58..245253ac8 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -27,7 +27,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService, TextAggregationMode, TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -110,6 +110,9 @@ class AsyncAITTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for Async TTS configuration. + .. deprecated:: 1.0 + Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language to use for synthesis. """ @@ -120,14 +123,15 @@ class AsyncAITTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, version: str = "v1", url: str = "wss://api.async.com/text_to_speech/websocket/ws", - model: str = "async_flash_v1.0", + model: Optional[str] = None, sample_rate: Optional[int] = None, encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, + settings: Optional[AsyncAITTSSettings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -138,13 +142,27 @@ class AsyncAITTSService(AudioContextTTSService): api_key: Async API key. voice_id: UUID of the voice to use for synthesis. See docs for a full list: https://docs.async.com/list-voices-16699698e0 + + .. deprecated:: 1.0 + Use ``settings=AsyncAITTSSettings(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:: 1.0 + Use ``settings=AsyncAITTSSettings(model=...)`` instead. + sample_rate: Audio sample rate. encoding: Audio encoding format. container: Audio container format. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=AsyncAITTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. aggregate_sentences: Deprecated. Use text_aggregation_mode instead. .. deprecated:: 0.0.104 @@ -153,7 +171,27 @@ class AsyncAITTSService(AudioContextTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to the parent service. """ - params = params or AsyncAITTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "AsyncAITTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "AsyncAITTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "AsyncAITTSSettings") + + _params = params or AsyncAITTSService.InputParams() + + default_settings = AsyncAITTSSettings( + model=model or "async_flash_v1.0", + voice=voice_id, + output_container=container, + output_encoding=encoding, + output_sample_rate=0, + language=self.language_to_service_language(_params.language) + if _params.language + else None, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( aggregate_sentences=aggregate_sentences, @@ -161,16 +199,7 @@ class AsyncAITTSService(AudioContextTTSService): pause_frame_processing=True, push_stop_frames=True, sample_rate=sample_rate, - settings=AsyncAITTSSettings( - model=model, - voice=voice_id, - output_container=container, - output_encoding=encoding, - output_sample_rate=0, - language=self.language_to_service_language(params.language) - if params.language - else None, - ), + settings=default_settings, **kwargs, ) @@ -471,6 +500,9 @@ class AsyncAIHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Async API. + .. deprecated:: 1.0 + Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language to use for synthesis. """ @@ -481,15 +513,16 @@ class AsyncAIHttpTTSService(TTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, - model: str = "async_flash_v1.0", + model: Optional[str] = None, url: str = "https://api.async.com", version: str = "v1", sample_rate: Optional[int] = None, encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, + settings: Optional[AsyncAITTSSettings] = None, **kwargs, ): """Initialize the Async TTS service. @@ -497,30 +530,55 @@ class AsyncAIHttpTTSService(TTSService): Args: api_key: Async API key. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=AsyncAITTSSettings(voice=...)`` instead. + aiohttp_session: An aiohttp session for making HTTP requests. model: TTS model to use (e.g., "async_flash_v1.0"). + + .. deprecated:: 1.0 + Use ``settings=AsyncAITTSSettings(model=...)`` instead. + url: Base URL for Async API. version: API version string for Async API. sample_rate: Audio sample rate. encoding: Audio encoding format. container: Audio container format. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=AsyncAITTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ - params = params or AsyncAIHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "AsyncAITTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "AsyncAITTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "AsyncAITTSSettings") + + _params = params or AsyncAIHttpTTSService.InputParams() + + default_settings = AsyncAITTSSettings( + model=model or "async_flash_v1.0", + voice=voice_id, + output_container=container, + output_encoding=encoding, + output_sample_rate=0, + language=self.language_to_service_language(_params.language) + if _params.language + else None, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=AsyncAITTSSettings( - model=model, - voice=voice_id, - output_container=container, - output_encoding=encoding, - output_sample_rate=0, - language=self.language_to_service_language(params.language) - if params.language - else None, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index e465ae460..b8a92eccb 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -55,7 +55,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import LLMService -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param from pipecat.utils.tracing.service_decorators import traced_llm try: @@ -752,6 +752,10 @@ class AWSBedrockLLMService(LLMService): class InputParams(BaseModel): """Input parameters for AWS Bedrock LLM service. + .. deprecated:: + Use ``AWSBedrockLLMSettings`` instead. Pass settings directly via the + ``settings`` parameter of :class:`AWSBedrockLLMService`. + Parameters: max_tokens: Maximum number of tokens to generate. temperature: Sampling temperature between 0.0 and 1.0. @@ -771,12 +775,14 @@ class AWSBedrockLLMService(LLMService): def __init__( self, *, - model: str, + model: Optional[str] = None, aws_access_key: Optional[str] = None, aws_secret_key: Optional[str] = None, aws_session_token: Optional[str] = None, aws_region: Optional[str] = None, params: Optional[InputParams] = None, + settings: Optional[AWSBedrockLLMSettings] = None, + stop_sequences: Optional[List[str]] = None, client_config: Optional[Config] = None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, @@ -787,37 +793,59 @@ class AWSBedrockLLMService(LLMService): Args: model: The AWS Bedrock model identifier to use. + + .. deprecated:: + Use ``settings=AWSBedrockLLMSettings(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. aws_session_token: AWS session token for temporary credentials. aws_region: AWS region for the Bedrock service. params: Model parameters and configuration. + + .. deprecated:: + Use ``settings=AWSBedrockLLMSettings(...)`` instead. + + settings: Runtime-updatable settings for this service. When both + deprecated parameters and *settings* are provided, *settings* + values take precedence. + stop_sequences: List of strings that stop generation. client_config: Custom boto3 client configuration. retry_timeout_secs: Request timeout in seconds for retry logic. retry_on_timeout: Whether to retry the request once if it times out. system_instruction: Optional system instruction to use as the system prompt. **kwargs: Additional arguments passed to parent LLMService. """ - params = params or AWSBedrockLLMService.InputParams() + if model is not None: + _warn_deprecated_param("model", "AWSBedrockLLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "AWSBedrockLLMSettings") - super().__init__( - settings=AWSBedrockLLMSettings( - model=model, - max_tokens=params.max_tokens, - temperature=params.temperature, - top_p=params.top_p, - top_k=None, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - latency=params.latency, - additional_model_request_fields=params.additional_model_request_fields - if isinstance(params.additional_model_request_fields, dict) - else {}, - ), - **kwargs, + _params = params or AWSBedrockLLMService.InputParams() + + default_settings = AWSBedrockLLMSettings( + model=model or "us.amazon.nova-lite-v1:0", + max_tokens=_params.max_tokens, + temperature=_params.temperature, + top_p=_params.top_p, + top_k=None, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + latency=_params.latency, + additional_model_request_fields=_params.additional_model_request_fields + if isinstance(_params.additional_model_request_fields, dict) + else {}, + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) + + self._stop_sequences = ( + stop_sequences if stop_sequences is not None else (_params.stop_sequences or []) ) # Initialize the AWS Bedrock client @@ -843,7 +871,7 @@ class AWSBedrockLLMService(LLMService): self._retry_on_timeout = retry_on_timeout self._system_instruction = system_instruction - logger.info(f"Using AWS Bedrock model: {model}") + logger.info(f"Using AWS Bedrock model: {self._settings.model}") if self._system_instruction: logger.debug(f"{self}: Using system instruction: {self._system_instruction}") diff --git a/src/pipecat/services/aws/nova_sonic/llm.py b/src/pipecat/services/aws/nova_sonic/llm.py index 29612e593..887c3f46c 100644 --- a/src/pipecat/services/aws/nova_sonic/llm.py +++ b/src/pipecat/services/aws/nova_sonic/llm.py @@ -60,7 +60,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import LLMService -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param from pipecat.utils.time import time_now_iso8601 try: @@ -222,6 +222,7 @@ class AWSNovaSonicLLMService(LLMService): model: str = "amazon.nova-2-sonic-v1:0", voice_id: str = "matthew", params: Optional[Params] = None, + settings: Optional[AWSNovaSonicLLMSettings] = None, system_instruction: Optional[str] = None, tools: Optional[ToolsSchema] = None, send_transcription_frames: bool = True, @@ -238,12 +239,27 @@ class AWSNovaSonicLLMService(LLMService): - Nova 2 Sonic (the default model): "us-east-1", "us-west-2", "ap-northeast-1" - Nova Sonic (the older model): "us-east-1", "ap-northeast-1" model: Model identifier. Defaults to "amazon.nova-2-sonic-v1:0". + + .. deprecated:: + Use ``settings=AWSNovaSonicLLMSettings(model=...)`` instead. + voice_id: Voice ID for speech synthesis. Note that some voices are designed for use with a specific language. Options: - Nova 2 Sonic (the default model): see https://docs.aws.amazon.com/nova/latest/nova2-userguide/sonic-language-support.html - Nova Sonic (the older model): see https://docs.aws.amazon.com/nova/latest/userguide/available-voices.html. + + .. deprecated:: + Use ``settings=AWSNovaSonicLLMSettings(voice_id=...)`` instead. + params: Model parameters for audio configuration and inference. + + .. deprecated:: + Use ``settings=AWSNovaSonicLLMSettings(...)`` instead. + + settings: AWS Nova Sonic LLM settings. If provided together with + deprecated top-level parameters, the ``settings`` values take + precedence. system_instruction: System-level instruction for the model. tools: Available tools/functions for the model to use. send_transcription_frames: Whether to emit transcription frames. @@ -254,23 +270,35 @@ class AWSNovaSonicLLMService(LLMService): **kwargs: Additional arguments passed to the parent LLMService. """ - params = params or Params() + # Check for deprecated parameter usage + if model != "amazon.nova-2-sonic-v1:0": + _warn_deprecated_param("model", "AWSNovaSonicLLMSettings", "model") + if voice_id != "matthew": + _warn_deprecated_param("voice_id", "AWSNovaSonicLLMSettings", "voice_id") + if params is not None: + _warn_deprecated_param("params", "AWSNovaSonicLLMSettings") + + _params = params or Params() + + default_settings = AWSNovaSonicLLMSettings( + model=model, + voice_id=voice_id, + temperature=_params.temperature, + max_tokens=_params.max_tokens, + top_p=_params.top_p, + top_k=None, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + endpointing_sensitivity=_params.endpointing_sensitivity, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( - settings=AWSNovaSonicLLMSettings( - model=model, - voice_id=voice_id, - temperature=params.temperature, - max_tokens=params.max_tokens, - top_p=params.top_p, - top_k=None, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - endpointing_sensitivity=params.endpointing_sensitivity, - ), + settings=default_settings, **kwargs, ) self._secret_access_key = secret_access_key @@ -280,12 +308,12 @@ class AWSNovaSonicLLMService(LLMService): self._client: Optional[BedrockRuntimeClient] = None # Audio I/O config (hardware settings, not runtime-tunable) - self._input_sample_rate = params.input_sample_rate - self._input_sample_size = params.input_sample_size - self._input_channel_count = params.input_channel_count - self._output_sample_rate = params.output_sample_rate - self._output_sample_size = params.output_sample_size - self._output_channel_count = params.output_channel_count + self._input_sample_rate = _params.input_sample_rate + self._input_sample_size = _params.input_sample_size + self._input_channel_count = _params.input_channel_count + self._output_sample_rate = _params.output_sample_rate + self._output_sample_size = _params.output_sample_size + self._output_channel_count = _params.output_channel_count self._system_instruction = system_instruction self._tools = tools @@ -295,7 +323,7 @@ class AWSNovaSonicLLMService(LLMService): and not self._is_endpointing_sensitivity_supported() ): logger.warning( - f"endpointing_sensitivity is not supported for model '{model}' and will be ignored. " + f"endpointing_sensitivity is not supported for model '{self._settings.model}' and will be ignored. " "This parameter is only supported starting with Nova 2 Sonic (amazon.nova-2-sonic-v1:0)." ) self._settings.endpointing_sensitivity = None diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index 7c3fb398e..1cbfa7329 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -29,7 +29,7 @@ from pipecat.frames.frames import ( TranscriptionFrame, ) from pipecat.services.aws.utils import build_event_message, decode_event, get_presigned_url -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import AWS_TRANSCRIBE_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -81,8 +81,9 @@ class AWSTranscribeSTTService(WebsocketSTTService): aws_access_key_id: Optional[str] = None, aws_session_token: Optional[str] = None, region: Optional[str] = None, - sample_rate: int = 16000, - language: Language = Language.EN, + sample_rate: Optional[int] = None, + language: Optional[Language] = None, + settings: Optional[AWSTranscribeSTTSettings] = None, ttfs_p99_latency: Optional[float] = AWS_TRANSCRIBE_TTFS_P99, **kwargs, ): @@ -93,29 +94,51 @@ class AWSTranscribeSTTService(WebsocketSTTService): aws_access_key_id: AWS access key ID. If None, uses AWS_ACCESS_KEY_ID environment variable. aws_session_token: AWS session token for temporary credentials. If None, uses AWS_SESSION_TOKEN environment variable. region: AWS region for the service. - sample_rate: Audio sample rate in Hz. Must be 8000 or 16000. Defaults to 16000. - language: Language for transcription. Defaults to English. + sample_rate: Audio sample rate in Hz. Must be 8000 or 16000. + + .. deprecated:: 1.0 + Use ``settings=AWSTranscribeSTTSettings(sample_rate=...)`` instead. + + language: Language for transcription. + + .. deprecated:: 1.0 + Use ``settings=AWSTranscribeSTTSettings(language=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService class. """ + if sample_rate is not None: + _warn_deprecated_param("sample_rate", "AWSTranscribeSTTSettings", "sample_rate") + if language is not None: + _warn_deprecated_param("language", "AWSTranscribeSTTSettings", "language") + + _sample_rate = sample_rate or 16000 + _language = language or Language.EN + + default_settings = AWSTranscribeSTTSettings( + language=self.language_to_service_language(_language) or "en-US", + sample_rate=_sample_rate, + media_encoding="linear16", + number_of_channels=1, + show_speaker_label=False, + enable_channel_identification=False, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( ttfs_p99_latency=ttfs_p99_latency, - settings=AWSTranscribeSTTSettings( - language=self.language_to_service_language(language) or "en-US", - sample_rate=sample_rate, - media_encoding="linear16", - number_of_channels=1, - show_speaker_label=False, - enable_channel_identification=False, - ), + settings=default_settings, **kwargs, ) # Validate sample rate - AWS Transcribe only supports 8000 Hz or 16000 Hz - if sample_rate not in [8000, 16000]: + if _sample_rate not in [8000, 16000]: logger.warning( - f"AWS Transcribe only supports 8000 Hz or 16000 Hz sample rates. Converting from {sample_rate} Hz to 16000 Hz." + f"AWS Transcribe only supports 8000 Hz or 16000 Hz sample rates. Converting from {_sample_rate} Hz to 16000 Hz." ) self._settings.sample_rate = 16000 diff --git a/src/pipecat/services/aws/tts.py b/src/pipecat/services/aws/tts.py index 017477a7a..8e11cb3cd 100644 --- a/src/pipecat/services/aws/tts.py +++ b/src/pipecat/services/aws/tts.py @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -155,6 +155,9 @@ class AWSPollyTTSService(TTSService): class InputParams(BaseModel): """Input parameters for AWS Polly TTS configuration. + .. deprecated:: 1.0 + Use ``AWSPollyTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: engine: TTS engine to use ('standard', 'neural', etc.). language: Language for synthesis. Defaults to English. @@ -178,9 +181,10 @@ class AWSPollyTTSService(TTSService): aws_access_key_id: Optional[str] = None, aws_session_token: Optional[str] = None, region: Optional[str] = None, - voice_id: str = "Joanna", + voice_id: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[AWSPollyTTSSettings] = None, **kwargs, ): """Initializes the AWS Polly TTS service. @@ -191,26 +195,45 @@ class AWSPollyTTSService(TTSService): aws_session_token: AWS session token for temporary credentials. region: AWS region for Polly service. Defaults to 'us-east-1'. voice_id: Voice ID to use for synthesis. Defaults to 'Joanna'. + + .. deprecated:: 1.0 + Use ``settings=AWSPollyTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate. If None, uses service default. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=AWSPollyTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ - params = params or AWSPollyTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "AWSPollyTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "AWSPollyTTSSettings") + + _params = params or AWSPollyTTSService.InputParams() + + default_settings = AWSPollyTTSSettings( + model=None, + voice=voice_id or "Joanna", + engine=_params.engine, + language=self.language_to_service_language(_params.language) + if _params.language + else "en-US", + pitch=_params.pitch, + rate=_params.rate, + volume=_params.volume, + lexicon_names=_params.lexicon_names, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=AWSPollyTTSSettings( - model=None, - voice=voice_id, - engine=params.engine, - language=self.language_to_service_language(params.language) - if params.language - else "en-US", - pitch=params.pitch, - rate=params.rate, - volume=params.volume, - lexicon_names=params.lexicon_names, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/azure/image.py b/src/pipecat/services/azure/image.py index 66cc28504..e64e5c7d8 100644 --- a/src/pipecat/services/azure/image.py +++ b/src/pipecat/services/azure/image.py @@ -13,14 +13,14 @@ using REST endpoints for creating images from text prompts. import asyncio import io from dataclasses import dataclass -from typing import AsyncGenerator +from typing import AsyncGenerator, Optional import aiohttp from PIL import Image from pipecat.frames.frames import ErrorFrame, Frame, URLImageRawFrame from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings +from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param @dataclass @@ -46,9 +46,10 @@ class AzureImageGenServiceREST(ImageGenService): image_size: str, api_key: str, endpoint: str, - model: str, + model: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, api_version="2023-06-01-preview", + settings: Optional[AzureImageGenSettings] = None, ): """Initialize the AzureImageGenServiceREST. @@ -57,10 +58,23 @@ class AzureImageGenServiceREST(ImageGenService): api_key: Azure OpenAI API key for authentication. endpoint: Azure OpenAI endpoint URL. model: The image generation model to use. + + .. deprecated:: 1.0 + Use ``settings=AzureImageGenSettings(model=...)`` instead. + aiohttp_session: Shared aiohttp session for HTTP requests. api_version: Azure API version string. Defaults to "2023-06-01-preview". + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. """ - super().__init__(settings=AzureImageGenSettings(model=model)) + if model is not None: + _warn_deprecated_param("model", "AzureImageGenSettings", "model") + + default_settings = AzureImageGenSettings(model=model) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings) self._api_key = api_key self._azure_endpoint = endpoint diff --git a/src/pipecat/services/azure/llm.py b/src/pipecat/services/azure/llm.py index b1807ad13..b828f0e4e 100644 --- a/src/pipecat/services/azure/llm.py +++ b/src/pipecat/services/azure/llm.py @@ -6,10 +6,14 @@ """Azure OpenAI service implementation for the Pipecat AI framework.""" +from typing import Optional + from loguru import logger from openai import AsyncAzureOpenAI +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class AzureLLMService(OpenAILLMService): @@ -24,8 +28,9 @@ class AzureLLMService(OpenAILLMService): *, api_key: str, endpoint: str, - model: str, + model: Optional[str] = None, api_version: str = "2024-09-01-preview", + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Azure LLM service. @@ -33,15 +38,28 @@ class AzureLLMService(OpenAILLMService): Args: api_key: The API key for accessing Azure OpenAI. endpoint: The Azure endpoint URL. - model: The model identifier to use. + model: The model identifier to use. Defaults to "gpt-4o". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + api_version: Azure API version. Defaults to "2024-09-01-preview". + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "gpt-4o") + if settings is not None: + default_settings.apply_update(settings) + # Initialize variables before calling parent __init__() because that # will call create_client() and we need those values there. self._endpoint = endpoint self._api_version = api_version - super().__init__(api_key=api_key, model=model, **kwargs) + super().__init__(api_key=api_key, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Azure OpenAI endpoint. diff --git a/src/pipecat/services/azure/stt.py b/src/pipecat/services/azure/stt.py index 5533e350e..5ab88c8dd 100644 --- a/src/pipecat/services/azure/stt.py +++ b/src/pipecat/services/azure/stt.py @@ -26,7 +26,7 @@ from pipecat.frames.frames import ( TranscriptionFrame, ) from pipecat.services.azure.common import language_to_azure_language -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import AZURE_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language @@ -79,10 +79,11 @@ class AzureSTTService(STTService): *, api_key: str, region: str, - language: Language = Language.EN_US, + language: Optional[Language] = Language.EN_US, sample_rate: Optional[int] = None, private_endpoint: Optional[str] = None, endpoint_id: Optional[str] = None, + settings: Optional[AzureSTTSettings] = None, ttfs_p99_latency: Optional[float] = AZURE_TTFS_P99, **kwargs, ): @@ -92,30 +93,44 @@ class AzureSTTService(STTService): api_key: Azure Cognitive Services subscription key. region: Azure region for the Speech service (e.g., 'eastus'). language: Language for speech recognition. Defaults to English (US). + + .. deprecated:: 1.0 + Use ``settings=AzureSTTSettings(language=...)`` instead. + sample_rate: Audio sample rate in Hz. If None, uses service default. private_endpoint: Private endpoint for STT behind firewall. See https://docs.azure.cn/en-us/ai-services/speech-service/speech-services-private-link?tabs=portal endpoint_id: Custom model endpoint id. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService. """ + if language != Language.EN_US: + _warn_deprecated_param("language", "AzureSTTSettings", "language") + + default_settings = AzureSTTSettings( + model=None, + region=region, + language=language_to_azure_language(language) if language else None, + sample_rate=sample_rate, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=AzureSTTSettings( - model=None, - region=region, - language=language_to_azure_language(language), - sample_rate=sample_rate, - ), + settings=default_settings, **kwargs, ) self._speech_config = SpeechConfig( subscription=api_key, region=region, - speech_recognition_language=language_to_azure_language(language), + speech_recognition_language=default_settings.language + or language_to_azure_language(Language.EN_US), endpoint=private_endpoint, ) diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index 6e62c73bf..d37874825 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -26,7 +26,7 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.azure.common import language_to_azure_language -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TextAggregationMode, TTSService from pipecat.transcriptions.language import Language from pipecat.utils.tracing.service_decorators import traced_tts @@ -115,6 +115,9 @@ class AzureBaseTTSService: class InputParams(BaseModel): """Input parameters for Azure TTS voice configuration. + .. deprecated:: 1.0 + Use ``settings=AzureTTSSettings(...)`` instead. + Parameters: emphasis: Emphasis level for speech ("strong", "moderate", "reduced"). language: Language for synthesis. Defaults to English (US). @@ -253,9 +256,10 @@ class AzureTTSService(TTSService, AzureBaseTTSService): *, api_key: str, region: str, - voice: str = "en-US-SaraNeural", + voice: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[AzureBaseTTSService.InputParams] = None, + settings: Optional[AzureTTSSettings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -265,9 +269,19 @@ class AzureTTSService(TTSService, AzureBaseTTSService): Args: api_key: Azure Cognitive Services subscription key. region: Azure region identifier (e.g., "eastus", "westus2"). - voice: Voice name to use for synthesis. Defaults to "en-US-SaraNeural". + voice: Voice name to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=AzureTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. + + .. deprecated:: 1.0 + Use ``settings=AzureTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. aggregate_sentences: Deprecated. Use text_aggregation_mode instead. .. deprecated:: 0.0.104 @@ -276,7 +290,29 @@ class AzureTTSService(TTSService, AzureBaseTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to parent WordTTSService. """ - params = params or AzureBaseTTSService.InputParams() + if voice is not None: + _warn_deprecated_param("voice", "AzureTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "AzureTTSSettings") + + _params = params or AzureBaseTTSService.InputParams() + + default_settings = AzureTTSSettings( + model=None, + emphasis=_params.emphasis, + language=self.language_to_service_language(_params.language) + if _params.language + else "en-US", + pitch=_params.pitch, + rate=_params.rate, + role=_params.role, + style=_params.style, + style_degree=_params.style_degree, + voice=voice or "en-US-SaraNeural", + volume=_params.volume, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( aggregate_sentences=aggregate_sentences, @@ -286,25 +322,12 @@ class AzureTTSService(TTSService, AzureBaseTTSService): pause_frame_processing=True, supports_word_timestamps=True, sample_rate=sample_rate, - settings=AzureTTSSettings( - model=None, - emphasis=params.emphasis, - language=self.language_to_service_language(params.language) - if params.language - else "en-US", - pitch=params.pitch, - rate=params.rate, - role=params.role, - style=params.style, - style_degree=params.style_degree, - voice=voice, - volume=params.volume, - ), + settings=default_settings, **kwargs, ) # Initialize Azure-specific functionality from mixin - self._init_azure_base(api_key=api_key, region=region, voice=voice) + self._init_azure_base(api_key=api_key, region=region, voice=default_settings.voice) self._speech_config = None self._speech_synthesizer = None @@ -730,9 +753,10 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): *, api_key: str, region: str, - voice: str = "en-US-SaraNeural", + voice: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[AzureBaseTTSService.InputParams] = None, + settings: Optional[AzureTTSSettings] = None, **kwargs, ): """Initialize the Azure HTTP TTS service. @@ -740,34 +764,53 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): Args: api_key: Azure Cognitive Services subscription key. region: Azure region identifier (e.g., "eastus", "westus2"). - voice: Voice name to use for synthesis. Defaults to "en-US-SaraNeural". + voice: Voice name to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=AzureTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. + + .. deprecated:: 1.0 + Use ``settings=AzureTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or AzureBaseTTSService.InputParams() + if voice is not None: + _warn_deprecated_param("voice", "AzureTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "AzureTTSSettings") + + _params = params or AzureBaseTTSService.InputParams() + + default_settings = AzureTTSSettings( + model=None, + emphasis=_params.emphasis, + language=self.language_to_service_language(_params.language) + if _params.language + else "en-US", + pitch=_params.pitch, + rate=_params.rate, + role=_params.role, + style=_params.style, + style_degree=_params.style_degree, + voice=voice or "en-US-SaraNeural", + volume=_params.volume, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=AzureTTSSettings( - model=None, - emphasis=params.emphasis, - language=self.language_to_service_language(params.language) - if params.language - else "en-US", - pitch=params.pitch, - rate=params.rate, - role=params.role, - style=params.style, - style_degree=params.style_degree, - voice=voice, - volume=params.volume, - ), + settings=default_settings, **kwargs, ) # Initialize Azure-specific functionality from mixin - self._init_azure_base(api_key=api_key, region=region, voice=voice) + self._init_azure_base(api_key=api_key, region=region, voice=default_settings.voice) self._speech_config = None self._speech_synthesizer = None diff --git a/src/pipecat/services/camb/tts.py b/src/pipecat/services/camb/tts.py index 75b299569..4ee2d5171 100644 --- a/src/pipecat/services/camb/tts.py +++ b/src/pipecat/services/camb/tts.py @@ -32,7 +32,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -175,6 +175,9 @@ class CambTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Camb.ai TTS configuration. + .. deprecated:: 1.0 + Use ``settings=CambTTSSettings(...)`` instead. + Parameters: language: Language for synthesis (BCP-47 format). Defaults to English. user_instructions: Custom instructions for mars-instruct model only. @@ -193,47 +196,71 @@ class CambTTSService(TTSService): self, *, api_key: str, - voice_id: int = 147320, - model: str = "mars-flash", + voice_id: Optional[int] = None, + model: Optional[str] = None, timeout: float = 60.0, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[CambTTSSettings] = None, **kwargs, ): """Initialize the Camb.ai TTS service. Args: api_key: Camb.ai API key for authentication. - voice_id: Voice ID to use. Defaults to 147320. + voice_id: Voice ID to use. + + .. deprecated:: 1.0 + Use ``settings=CambTTSSettings(voice=...)`` instead. + model: TTS model to use. Options: "mars-flash" (fast), "mars-pro" (high quality). - Defaults to "mars-flash". + + .. deprecated:: 1.0 + Use ``settings=CambTTSSettings(model=...)`` instead. + timeout: Request timeout in seconds. Defaults to 60.0 (minimum recommended by Camb.ai). sample_rate: Audio sample rate in Hz. If None, uses model-specific default. params: Additional voice parameters. If None, uses defaults. + + .. deprecated:: 1.0 + Use ``settings=CambTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or CambTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "CambTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "CambTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "CambTTSSettings") + + _params = params or CambTTSService.InputParams() + _model = model or "mars-flash" # Warn if sample rate doesn't match model's supported rate - if sample_rate and sample_rate != MODEL_SAMPLE_RATES.get(model): + if sample_rate and sample_rate != MODEL_SAMPLE_RATES.get(_model): logger.warning( - f"Camb.ai's {model} model only supports {MODEL_SAMPLE_RATES.get(model)}Hz " + f"Camb.ai's {_model} model only supports {MODEL_SAMPLE_RATES.get(_model)}Hz " f"sample rate. Current rate of {sample_rate}Hz may cause issues." ) + default_settings = CambTTSSettings( + model=_model, + voice=voice_id or 147320, + language=( + self.language_to_service_language(_params.language) if _params.language else "en-us" + ), + user_instructions=_params.user_instructions, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, - settings=CambTTSSettings( - model=model, - voice=voice_id, - language=( - self.language_to_service_language(params.language) - if params.language - else "en-us" - ), - user_instructions=params.user_instructions, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/cartesia/stt.py b/src/pipecat/services/cartesia/stt.py index 526fc9116..530f6a4d1 100644 --- a/src/pipecat/services/cartesia/stt.py +++ b/src/pipecat/services/cartesia/stt.py @@ -158,6 +158,7 @@ class CartesiaSTTService(WebsocketSTTService): base_url: str = "", sample_rate: int = 16000, live_options: Optional[CartesiaLiveOptions] = None, + settings: Optional[CartesiaSTTSettings] = None, ttfs_p99_latency: Optional[float] = CARTESIA_TTFS_P99, **kwargs, ): @@ -168,6 +169,8 @@ class CartesiaSTTService(WebsocketSTTService): base_url: Custom API endpoint URL. If empty, uses default. sample_rate: Audio sample rate in Hz. Defaults to 16000. live_options: Configuration options for transcription service. + settings: Runtime-updatable settings. When provided alongside + ``live_options``, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService. @@ -189,16 +192,20 @@ class CartesiaSTTService(WebsocketSTTService): k: v for k, v in merged_options.items() if not isinstance(v, str) or v != "None" } + default_settings = CartesiaSTTSettings( + model=merged_options["model"], + language=merged_options.get("language"), + encoding=merged_options.get("encoding", "pcm_s16le"), + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, keepalive_timeout=120, keepalive_interval=30, - settings=CartesiaSTTSettings( - model=merged_options["model"], - language=merged_options.get("language"), - encoding=merged_options.get("encoding", "pcm_s16le"), - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index a096a36b3..bc8b04dfd 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -27,7 +27,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService, TextAggregationMode, TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.text.base_text_aggregator import BaseTextAggregator @@ -259,14 +259,15 @@ class CartesiaTTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, cartesia_version: str = "2025-04-16", url: str = "wss://api.cartesia.ai/tts/websocket", - model: str = "sonic-3", + model: Optional[str] = None, sample_rate: Optional[int] = None, encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, + settings: Optional[CartesiaTTSSettings] = None, text_aggregator: Optional[BaseTextAggregator] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, @@ -277,13 +278,27 @@ class CartesiaTTSService(AudioContextTTSService): Args: api_key: Cartesia API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=CartesiaTTSSettings(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:: 1.0 + Use ``settings=CartesiaTTSSettings(model=...)`` instead. + sample_rate: Audio sample rate. If None, uses default. encoding: Audio encoding format. container: Audio container format. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=CartesiaTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. text_aggregator: Custom text aggregator for processing input text. .. deprecated:: 0.0.95 @@ -297,6 +312,13 @@ class CartesiaTTSService(AudioContextTTSService): **kwargs: Additional arguments passed to the parent service. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "CartesiaTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "CartesiaTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "CartesiaTTSSettings") + # By default, we aggregate sentences before sending to TTS. This adds # ~200-300ms of latency per sentence (waiting for the sentence-ending # punctuation token from the LLM). Setting @@ -310,7 +332,24 @@ class CartesiaTTSService(AudioContextTTSService): # if we're interrupted. Cartesia gives us word-by-word timestamps. We # can use those to generate text frames ourselves aligned with the # playout timing of the audio! - params = params or CartesiaTTSService.InputParams() + _params = params or CartesiaTTSService.InputParams() + + default_settings = CartesiaTTSSettings( + model=model or "sonic-3", + voice=voice_id, + output_container=container, + output_encoding=encoding, + output_sample_rate=0, + language=( + self.language_to_service_language(_params.language) if _params.language else None + ), + speed=_params.speed, + emotion=_params.emotion, + generation_config=_params.generation_config, + pronunciation_dict_id=_params.pronunciation_dict_id, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( text_aggregation_mode=text_aggregation_mode, @@ -320,20 +359,7 @@ class CartesiaTTSService(AudioContextTTSService): supports_word_timestamps=True, sample_rate=sample_rate, text_aggregator=text_aggregator, - settings=CartesiaTTSSettings( - model=model, - output_container=container, - output_encoding=encoding, - output_sample_rate=0, - language=self.language_to_service_language(params.language) - if params.language - else None, - speed=params.speed, - emotion=params.emotion, - generation_config=params.generation_config, - pronunciation_dict_id=params.pronunciation_dict_id, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -713,8 +739,8 @@ class CartesiaHttpTTSService(TTSService): self, *, api_key: str, - voice_id: str, - model: str = "sonic-3", + voice_id: Optional[str] = None, + model: Optional[str] = None, base_url: str = "https://api.cartesia.ai", cartesia_version: str = "2024-11-13", aiohttp_session: Optional[aiohttp.ClientSession] = None, @@ -722,6 +748,7 @@ class CartesiaHttpTTSService(TTSService): encoding: str = "pcm_s16le", container: str = "raw", params: Optional[InputParams] = None, + settings: Optional[CartesiaTTSSettings] = None, **kwargs, ): """Initialize the Cartesia HTTP TTS service. @@ -729,7 +756,15 @@ class CartesiaHttpTTSService(TTSService): Args: api_key: Cartesia API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=CartesiaTTSSettings(voice=...)`` instead. + model: TTS model to use (e.g., "sonic-3"). + + .. deprecated:: 1.0 + Use ``settings=CartesiaTTSSettings(model=...)`` instead. + base_url: Base URL for Cartesia HTTP API. cartesia_version: API version string for Cartesia service. aiohttp_session: Optional aiohttp ClientSession for HTTP requests. @@ -738,26 +773,43 @@ class CartesiaHttpTTSService(TTSService): encoding: Audio encoding format. container: Audio container format. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=CartesiaTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ - params = params or CartesiaHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "CartesiaTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "CartesiaTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "CartesiaTTSSettings") + + _params = params or CartesiaHttpTTSService.InputParams() + + default_settings = CartesiaTTSSettings( + model=model or "sonic-3", + voice=voice_id, + output_container=container, + output_encoding=encoding, + output_sample_rate=0, + language=( + self.language_to_service_language(_params.language) if _params.language else None + ), + speed=_params.speed, + emotion=_params.emotion, + generation_config=_params.generation_config, + pronunciation_dict_id=_params.pronunciation_dict_id, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=CartesiaTTSSettings( - model=model, - voice=voice_id, - output_container=container, - output_encoding=encoding, - output_sample_rate=0, - language=self.language_to_service_language(params.language) - if params.language - else None, - speed=params.speed, - emotion=params.emotion, - generation_config=params.generation_config, - pronunciation_dict_id=params.pronunciation_dict_id, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index e1ecceef7..ec3c3f09b 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -6,10 +6,14 @@ """Cerebras LLM service implementation using OpenAI-compatible interface.""" +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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class CerebrasLLMService(OpenAILLMService): @@ -24,7 +28,8 @@ class CerebrasLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.cerebras.ai/v1", - model: str = "gpt-oss-120b", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Cerebras LLM service. @@ -33,9 +38,22 @@ class CerebrasLLMService(OpenAILLMService): api_key: The API key for accessing Cerebras's API. base_url: The base URL for Cerebras API. Defaults to "https://api.cerebras.ai/v1". model: The model identifier to use. Defaults to "gpt-oss-120b". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "gpt-oss-120b") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Cerebras API endpoint. diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index 984906c6c..fdfd65613 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -28,7 +28,7 @@ from pipecat.frames.frames import ( UserStartedSpeakingFrame, UserStoppedSpeakingFrame, ) -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 @@ -124,8 +124,8 @@ class DeepgramFluxSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for Deepgram Flux API. - This class defines all available connection parameters for the Deepgram Flux API - based on the official documentation. + .. deprecated:: 1.0 + Use ``settings=DeepgramFluxSTTSettings(...)`` instead. Parameters: eager_eot_threshold: Optional. EagerEndOfTurn/TurnResumed are off by default. @@ -158,10 +158,11 @@ class DeepgramFluxSTTService(WebsocketSTTService): api_key: str, url: str = "wss://api.deepgram.com/v2/listen", sample_rate: Optional[int] = None, - model: str = "flux-general-en", + model: Optional[str] = None, flux_encoding: str = "linear16", params: Optional[InputParams] = None, should_interrupt: bool = True, + settings: Optional[DeepgramFluxSTTSettings] = None, **kwargs, ): """Initialize the Deepgram Flux STT service. @@ -170,12 +171,21 @@ class DeepgramFluxSTTService(WebsocketSTTService): api_key: Deepgram API key for authentication. Required for API access. url: WebSocket URL for the Deepgram Flux API. Defaults to the preview endpoint. sample_rate: Audio sample rate in Hz. If None, uses the rate from params or 16000. - model: Deepgram Flux model to use for transcription. Currently only supports "flux-general-en". + model: Deepgram Flux model to use for transcription. + + .. deprecated:: 1.0 + Use ``settings=DeepgramFluxSTTSettings(model=...)`` instead. + flux_encoding: Audio encoding format required by Flux API. Must be "linear16". Raw signed little-endian 16-bit PCM encoding. params: InputParams instance containing detailed API configuration options. - If None, default parameters will be used. + + .. deprecated:: 1.0 + Use ``settings=DeepgramFluxSTTSettings(...)`` 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 + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent WebsocketSTTService class. Examples: @@ -185,18 +195,21 @@ class DeepgramFluxSTTService(WebsocketSTTService): Advanced usage with custom parameters:: - params = DeepgramFluxSTTService.InputParams( - eager_eot_threshold=0.5, - eot_threshold=0.8, - keyterm=["AI", "machine learning", "neural network"], - tag=["production", "voice-agent"] - ) stt = DeepgramFluxSTTService( api_key="your-api-key", - model="flux-general-en", - params=params + settings=DeepgramFluxSTTSettings( + model="flux-general-en", + eager_eot_threshold=0.5, + eot_threshold=0.8, + keyterm=["AI", "machine learning", "neural network"], + tag=["production", "voice-agent"], + ), ) """ + if model is not None: + _warn_deprecated_param("model", "DeepgramFluxSTTSettings", "model") + if params is not None: + _warn_deprecated_param("params", "DeepgramFluxSTTSettings") # Note: For DeepgramFluxSTTService, differently from other processes, we need to create # the _receive_task inside _connect_websocket, because the websocket should only be # considered connected and ready to send audio once we receive from Flux the message @@ -207,22 +220,27 @@ class DeepgramFluxSTTService(WebsocketSTTService): # was never destroyed. # So we can keep it here as false, because inside the method send_with_retry, it will # already try to reconnect if needed. - params = params or DeepgramFluxSTTService.InputParams() + _params = params or DeepgramFluxSTTService.InputParams() + + default_settings = DeepgramFluxSTTSettings( + model=model or "flux-general-en", + language=Language.EN, + encoding=flux_encoding, + eager_eot_threshold=_params.eager_eot_threshold, + eot_threshold=_params.eot_threshold, + eot_timeout_ms=_params.eot_timeout_ms, + keyterm=_params.keyterm or [], + mip_opt_out=_params.mip_opt_out, + tag=_params.tag or [], + min_confidence=_params.min_confidence, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, reconnect_on_error=False, - settings=DeepgramFluxSTTSettings( - model=model, - language=Language.EN, - encoding=flux_encoding, - eager_eot_threshold=params.eager_eot_threshold, - eot_threshold=params.eot_threshold, - eot_timeout_ms=params.eot_timeout_ms, - keyterm=params.keyterm or [], - mip_opt_out=params.mip_opt_out, - tag=params.tag or [], - min_confidence=params.min_confidence, - ), + settings=default_settings, **kwargs, ) self._api_key = api_key diff --git a/src/pipecat/services/deepgram/sagemaker/stt.py b/src/pipecat/services/deepgram/sagemaker/stt.py index 24a25e5fd..6d813157d 100644 --- a/src/pipecat/services/deepgram/sagemaker/stt.py +++ b/src/pipecat/services/deepgram/sagemaker/stt.py @@ -41,7 +41,7 @@ from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_stt try: - from pipecat.services.deepgram.stt import LiveOptions + from deepgram import LiveOptions except ModuleNotFoundError as e: logger.error(f"Exception: {e}") logger.error( @@ -51,10 +51,10 @@ except ModuleNotFoundError as e: @dataclass -class DeepgramSageMakerSTTSettings(DeepgramSTTSettings): +class DeepgramSageMakerSTTSettings(_DeepgramSTTSettingsBase): """Settings for the Deepgram SageMaker STT service. - See ``DeepgramSTTSettings`` for full documentation. + See ``_DeepgramSTTSettingsBase`` for full documentation. """ pass @@ -97,6 +97,7 @@ class DeepgramSageMakerSTTService(STTService): region: str, sample_rate: Optional[int] = None, live_options: Optional[LiveOptions] = None, + settings: Optional[DeepgramSageMakerSTTSettings] = None, ttfs_p99_latency: Optional[float] = DEEPGRAM_SAGEMAKER_TTFS_P99, **kwargs, ): @@ -111,37 +112,38 @@ class DeepgramSageMakerSTTService(STTService): live_options: Deepgram LiveOptions configuration. Treated as a delta from a set of sensible defaults — only the fields you set are overridden; all others keep their default values. + settings: Runtime-updatable settings. When provided alongside + ``live_options``, ``settings`` values take precedence (applied + after the ``live_options`` merge). ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the parent STTService. """ sample_rate = sample_rate or (live_options.sample_rate if live_options else None) - settings = DeepgramSageMakerSTTSettings( - model="nova-3", - language=Language.EN, + default_options = LiveOptions( encoding="linear16", + language=Language.EN, + model="nova-3", channels=1, interim_results=True, - smart_format=False, punctuate=True, - profanity_filter=True, - vad_events=False, - diarize=False, - endpointing=None, ) + default_settings = DeepgramSageMakerSTTSettings( + model=default_options.model, + language=default_options.language, + live_options=default_options, + ) if live_options: - lo_dict = live_options.to_dict() - delta = DeepgramSageMakerSTTSettings.from_mapping( - {k: v for k, v in lo_dict.items() if k != "sample_rate"} - ) - settings.apply_update(delta) + default_settings._merge_live_options_delta(live_options) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=settings, + settings=default_settings, **kwargs, ) @@ -228,8 +230,9 @@ class DeepgramSageMakerSTTService(STTService): """ logger.debug("Connecting to Deepgram on SageMaker...") - # Reconstruct a LiveOptions from the flat settings to build the query string. - live_options = LiveOptions(**self._settings.given_fields()) + live_options = LiveOptions( + **{**self._settings.live_options.to_dict(), "sample_rate": self.sample_rate} + ) # Build query string from live_options, converting booleans to strings query_params = {} @@ -240,7 +243,6 @@ class DeepgramSageMakerSTTService(STTService): query_params[key] = str(value).lower() else: query_params[key] = str(value) - query_params["sample_rate"] = str(self.sample_rate) query_string = "&".join(f"{k}={v}" for k, v in query_params.items()) diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index b583ce76c..0c141bac0 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -33,7 +33,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.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -78,9 +78,10 @@ class DeepgramSageMakerTTSService(TTSService): *, endpoint_name: str, region: str, - voice: str = "aura-2-helena-en", + voice: Optional[str] = None, sample_rate: Optional[int] = None, encoding: str = "linear16", + settings: Optional[DeepgramSageMakerTTSSettings] = None, **kwargs, ): """Initialize the Deepgram SageMaker TTS service. @@ -90,21 +91,36 @@ class DeepgramSageMakerTTSService(TTSService): deployed (e.g., "my-deepgram-tts-endpoint"). region: AWS region where the endpoint is deployed (e.g., "us-east-2"). voice: Voice model to use for synthesis. Defaults to "aura-2-helena-en". + + .. deprecated:: 1.0 + Use ``settings=DeepgramSageMakerTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate in Hz. If None, uses the value from StartFrame. encoding: Audio encoding format. Defaults to "linear16". + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ + if voice is not None: + _warn_deprecated_param("voice", "DeepgramSageMakerTTSSettings", "voice") + + voice = voice or "aura-2-helena-en" + + default_settings = DeepgramSageMakerTTSSettings( + model=voice, + voice=voice, + language=None, + encoding=encoding, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, push_stop_frames=True, pause_frame_processing=True, append_trailing_space=True, - settings=DeepgramSageMakerTTSSettings( - model=voice, - voice=voice, - language=None, - encoding=encoding, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/deepgram/stt.py b/src/pipecat/services/deepgram/stt.py index 343a87e2a..fe3add7cf 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -256,6 +256,7 @@ class DeepgramSTTService(STTService): live_options: Optional[LiveOptions] = None, addons: Optional[Dict] = None, should_interrupt: bool = True, + settings: Optional[DeepgramSTTSettings] = None, ttfs_p99_latency: Optional[float] = DEEPGRAM_TTFS_P99, **kwargs, ): @@ -279,6 +280,9 @@ class DeepgramSTTService(STTService): .. deprecated:: 0.0.99 This parameter will be removed along with `vad_events` support. + settings: Runtime-updatable settings. When provided alongside + ``live_options``, ``settings`` values take precedence (applied + after the ``live_options`` merge). ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the parent STTService. @@ -299,7 +303,7 @@ class DeepgramSTTService(STTService): ) base_url = url - settings = DeepgramSTTSettings( + default_settings = DeepgramSTTSettings( model="nova-3-general", language=Language.EN, encoding="linear16", @@ -318,15 +322,18 @@ class DeepgramSTTService(STTService): delta = DeepgramSTTSettings.from_mapping( {k: v for k, v in lo_dict.items() if k != "sample_rate"} ) - settings.apply_update(delta) + default_settings.apply_update(delta) + + if settings is not None: + default_settings.apply_update(settings) # Sync extra to top-level fields so self._settings is unambiguous - settings._sync_extra_to_fields() + default_settings._sync_extra_to_fields() super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=settings, + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/deepgram/tts.py b/src/pipecat/services/deepgram/tts.py index c05b90868..4524d17b6 100644 --- a/src/pipecat/services/deepgram/tts.py +++ b/src/pipecat/services/deepgram/tts.py @@ -30,7 +30,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService, WebsocketTTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -72,41 +72,55 @@ class DeepgramTTSService(WebsocketTTSService): self, *, api_key: str, - voice: str = "aura-2-helena-en", + voice: Optional[str] = None, base_url: str = "wss://api.deepgram.com", sample_rate: Optional[int] = None, encoding: str = "linear16", + settings: Optional[DeepgramTTSSettings] = None, **kwargs, ): """Initialize the Deepgram WebSocket TTS service. Args: api_key: Deepgram API key for authentication. - voice: Voice model to use for synthesis. Defaults to "aura-2-helena-en". + voice: Voice model to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=DeepgramTTSSettings(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. encoding: Audio encoding format. Defaults to "linear16". Must be one of SUPPORTED_ENCODINGS. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent InterruptibleTTSService class. Raises: ValueError: If encoding is not in SUPPORTED_ENCODINGS. """ + if voice is not None: + _warn_deprecated_param("voice", "DeepgramTTSSettings", "voice") + if encoding.lower() not in self.SUPPORTED_ENCODINGS: raise ValueError( f"Unsupported encoding '{encoding}'. Must be one of {', '.join(self.SUPPORTED_ENCODINGS)} for WebSocket TTS." ) + default_settings = DeepgramTTSSettings( + model=voice or "aura-2-helena-en", + voice=voice or "aura-2-helena-en", + language=None, + encoding=encoding, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, pause_frame_processing=True, push_stop_frames=True, append_trailing_space=True, - settings=DeepgramTTSSettings( - model=voice, - voice=voice, - language=None, - encoding=encoding, - ), + settings=default_settings, **kwargs, ) @@ -375,32 +389,46 @@ class DeepgramHttpTTSService(TTSService): self, *, api_key: str, - voice: str = "aura-2-helena-en", + voice: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, base_url: str = "https://api.deepgram.com", sample_rate: Optional[int] = None, encoding: str = "linear16", + settings: Optional[DeepgramTTSSettings] = None, **kwargs, ): """Initialize the Deepgram TTS service. Args: api_key: Deepgram API key for authentication. - voice: Voice model to use for synthesis. Defaults to "aura-2-helena-en". + voice: Voice model to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=DeepgramTTSSettings(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". sample_rate: Audio sample rate in Hz. If None, uses service default. encoding: Audio encoding format. Defaults to "linear16". + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ + if voice is not None: + _warn_deprecated_param("voice", "DeepgramTTSSettings", "voice") + + default_settings = DeepgramTTSSettings( + model=voice or "aura-2-helena-en", + voice=voice or "aura-2-helena-en", + language=None, + encoding=encoding, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, - settings=DeepgramTTSSettings( - model=voice, - voice=voice, - language=None, - encoding=encoding, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index 70318c9ba..2ebc2e6eb 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -6,10 +6,14 @@ """DeepSeek LLM service implementation using OpenAI-compatible interface.""" +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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class DeepSeekLLMService(OpenAILLMService): @@ -24,7 +28,8 @@ class DeepSeekLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.deepseek.com/v1", - model: str = "deepseek-chat", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the DeepSeek LLM service. @@ -33,9 +38,22 @@ class DeepSeekLLMService(OpenAILLMService): api_key: The API key for accessing DeepSeek's API. base_url: The base URL for DeepSeek API. Defaults to "https://api.deepseek.com/v1". model: The model identifier to use. Defaults to "deepseek-chat". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "deepseek-chat") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for DeepSeek API endpoint. diff --git a/src/pipecat/services/elevenlabs/stt.py b/src/pipecat/services/elevenlabs/stt.py index 0cf13121e..d5897b5c5 100644 --- a/src/pipecat/services/elevenlabs/stt.py +++ b/src/pipecat/services/elevenlabs/stt.py @@ -35,7 +35,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import ELEVENLABS_REALTIME_TTFS_P99, ELEVENLABS_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService, WebsocketSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -228,6 +228,9 @@ class ElevenLabsSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for ElevenLabs STT API. + .. deprecated:: 1.0 + Use ``settings=ElevenLabsSTTSettings(...)`` instead. + Parameters: language: Target language for transcription. tag_audio_events: Whether to include audio events like (laughter), (coughing), in the transcription. @@ -242,9 +245,10 @@ class ElevenLabsSTTService(SegmentedSTTService): api_key: str, aiohttp_session: aiohttp.ClientSession, base_url: str = "https://api.elevenlabs.io", - model: str = "scribe_v2", + model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[ElevenLabsSTTSettings] = None, ttfs_p99_latency: Optional[float] = ELEVENLABS_TTFS_P99, **kwargs, ): @@ -254,25 +258,44 @@ class ElevenLabsSTTService(SegmentedSTTService): api_key: ElevenLabs API key for authentication. aiohttp_session: aiohttp ClientSession for HTTP requests. base_url: Base URL for ElevenLabs API. - model: Model ID for transcription. Defaults to "scribe_v2". + model: Model ID for transcription. + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsSTTSettings(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:: 1.0 + Use ``settings=ElevenLabsSTTSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService. """ - params = params or ElevenLabsSTTService.InputParams() + if model is not None: + _warn_deprecated_param("model", "ElevenLabsSTTSettings", "model") + if params is not None: + _warn_deprecated_param("params", "ElevenLabsSTTSettings") + + _params = params or ElevenLabsSTTService.InputParams() + + default_settings = ElevenLabsSTTSettings( + model=model or "scribe_v2", + language=self.language_to_service_language(_params.language) + if _params.language + else "eng", + tag_audio_events=_params.tag_audio_events, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=ElevenLabsSTTSettings( - model=model, - language=self.language_to_service_language(params.language) - if params.language - else "eng", - tag_audio_events=params.tag_audio_events, - ), + settings=default_settings, **kwargs, ) @@ -429,6 +452,9 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for ElevenLabs Realtime STT API. + .. deprecated:: 1.0 + Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. + Parameters: language_code: ISO-639-1 or ISO-639-3 language code. Leave None for auto-detection. commit_strategy: How to segment speech - manual (Pipecat VAD) or vad (ElevenLabs VAD). @@ -460,9 +486,10 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): *, api_key: str, base_url: str = "api.elevenlabs.io", - model: str = "scribe_v2_realtime", + model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[ElevenLabsRealtimeSTTSettings] = None, ttfs_p99_latency: Optional[float] = ELEVENLABS_REALTIME_TTFS_P99, **kwargs, ): @@ -471,32 +498,51 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): Args: api_key: ElevenLabs API key for authentication. base_url: Base URL for ElevenLabs WebSocket API. - model: Model ID for transcription. Defaults to "scribe_v2_realtime". + model: Model ID for transcription. + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsRealtimeSTTSettings(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:: 1.0 + Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to WebsocketSTTService. """ - params = params or ElevenLabsRealtimeSTTService.InputParams() + if model is not None: + _warn_deprecated_param("model", "ElevenLabsRealtimeSTTSettings", "model") + if params is not None: + _warn_deprecated_param("params", "ElevenLabsRealtimeSTTSettings") + + _params = params or ElevenLabsRealtimeSTTService.InputParams() + + default_settings = ElevenLabsRealtimeSTTSettings( + model=model or "scribe_v2_realtime", + language=_params.language_code, + commit_strategy=_params.commit_strategy, + vad_silence_threshold_secs=_params.vad_silence_threshold_secs, + vad_threshold=_params.vad_threshold, + min_speech_duration_ms=_params.min_speech_duration_ms, + min_silence_duration_ms=_params.min_silence_duration_ms, + include_timestamps=_params.include_timestamps, + enable_logging=_params.enable_logging, + include_language_detection=_params.include_language_detection, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, keepalive_timeout=10, keepalive_interval=5, - settings=ElevenLabsRealtimeSTTSettings( - model=model, - language=params.language_code, - commit_strategy=params.commit_strategy, - vad_silence_threshold_secs=params.vad_silence_threshold_secs, - vad_threshold=params.vad_threshold, - min_speech_duration_ms=params.min_speech_duration_ms, - min_silence_duration_ms=params.min_silence_duration_ms, - include_timestamps=params.include_timestamps, - enable_logging=params.enable_logging, - include_language_detection=params.include_language_detection, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 1811ed971..b98ce6e1b 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -44,7 +44,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import ( AudioContextTTSService, TextAggregationMode, @@ -331,6 +331,9 @@ class ElevenLabsTTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for ElevenLabs TTS configuration. + .. deprecated:: 1.0 + Use ``settings=ElevenLabsTTSSettings(...)`` instead. + Parameters: language: Language to use for synthesis. stability: Voice stability control (0.0 to 1.0). @@ -361,11 +364,13 @@ class ElevenLabsTTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str, - model: str = "eleven_turbo_v2_5", + voice_id: Optional[str] = None, + model: Optional[str] = None, url: str = "wss://api.elevenlabs.io", sample_rate: Optional[int] = None, + pronunciation_dictionary_locators: Optional[List[PronunciationDictionaryLocator]] = None, params: Optional[InputParams] = None, + settings: Optional[ElevenLabsTTSSettings] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, **kwargs, @@ -375,10 +380,26 @@ class ElevenLabsTTSService(AudioContextTTSService): Args: api_key: ElevenLabs API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsTTSSettings(voice=...)`` instead. + model: TTS model to use (e.g., "eleven_turbo_v2_5"). + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsTTSSettings(model=...)`` instead. + url: WebSocket URL for ElevenLabs TTS API. sample_rate: Audio sample rate. If None, uses default. + pronunciation_dictionary_locators: List of pronunciation dictionary + locators to use. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. text_aggregation_mode: How to aggregate incoming text before synthesis. aggregate_sentences: Whether to aggregate sentences within the TTSService. @@ -387,6 +408,13 @@ class ElevenLabsTTSService(AudioContextTTSService): **kwargs: Additional arguments passed to the parent service. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "ElevenLabsTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "ElevenLabsTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "ElevenLabsTTSSettings") + # By default, we aggregate sentences before sending to TTS. This adds # ~200-300ms of latency per sentence (waiting for the sentence-ending # punctuation token from the LLM). Setting @@ -403,7 +431,26 @@ class ElevenLabsTTSService(AudioContextTTSService): # Finally, ElevenLabs doesn't provide information on when the bot stops # speaking for a while, so we want the parent class to send TTSStopFrame # after a short period not receiving any audio. - params = params or ElevenLabsTTSService.InputParams() + _params = params or ElevenLabsTTSService.InputParams() + + default_settings = ElevenLabsTTSSettings( + model=model or "eleven_turbo_v2_5", + voice=voice_id, + language=( + self.language_to_service_language(_params.language) if _params.language else None + ), + stability=_params.stability, + similarity_boost=_params.similarity_boost, + style=_params.style, + use_speaker_boost=_params.use_speaker_boost, + speed=_params.speed, + auto_mode=str(_params.auto_mode).lower(), + enable_ssml_parsing=_params.enable_ssml_parsing, + enable_logging=_params.enable_logging, + apply_text_normalization=_params.apply_text_normalization, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( text_aggregation_mode=text_aggregation_mode, @@ -413,22 +460,7 @@ class ElevenLabsTTSService(AudioContextTTSService): pause_frame_processing=True, supports_word_timestamps=True, sample_rate=sample_rate, - settings=ElevenLabsTTSSettings( - model=model, - voice=voice_id, - language=( - self.language_to_service_language(params.language) if params.language else None - ), - stability=params.stability, - similarity_boost=params.similarity_boost, - style=params.style, - use_speaker_boost=params.use_speaker_boost, - speed=params.speed, - auto_mode=str(params.auto_mode).lower(), - enable_ssml_parsing=params.enable_ssml_parsing, - enable_logging=params.enable_logging, - apply_text_normalization=params.apply_text_normalization, - ), + settings=default_settings, **kwargs, ) @@ -437,7 +469,11 @@ class ElevenLabsTTSService(AudioContextTTSService): self._output_format = "" # initialized in start() self._voice_settings = self._set_voice_settings() - self._pronunciation_dictionary_locators = params.pronunciation_dictionary_locators + self._pronunciation_dictionary_locators = ( + pronunciation_dictionary_locators + if pronunciation_dictionary_locators is not None + else _params.pronunciation_dictionary_locators + ) self._cumulative_time = 0 # Track partial words that span across alignment chunks @@ -871,6 +907,9 @@ class ElevenLabsHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for ElevenLabs HTTP TTS configuration. + .. deprecated:: 1.0 + Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. + Parameters: language: Language to use for synthesis. optimize_streaming_latency: Latency optimization level (0-4). @@ -897,12 +936,14 @@ class ElevenLabsHttpTTSService(TTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, - model: str = "eleven_turbo_v2_5", + model: Optional[str] = None, base_url: str = "https://api.elevenlabs.io", sample_rate: Optional[int] = None, + pronunciation_dictionary_locators: Optional[List[PronunciationDictionaryLocator]] = None, params: Optional[InputParams] = None, + settings: Optional[ElevenLabsHttpTTSSettings] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, **kwargs, @@ -912,11 +953,27 @@ class ElevenLabsHttpTTSService(TTSService): Args: api_key: ElevenLabs API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsHttpTTSSettings(voice=...)`` instead. + aiohttp_session: aiohttp ClientSession for HTTP requests. model: TTS model to use (e.g., "eleven_turbo_v2_5"). + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsHttpTTSSettings(model=...)`` instead. + base_url: Base URL for ElevenLabs HTTP API. sample_rate: Audio sample rate. If None, uses default. + pronunciation_dictionary_locators: List of pronunciation dictionary + locators to use. params: Additional input parameters for voice customization. + + .. deprecated:: 1.0 + Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. text_aggregation_mode: How to aggregate incoming text before synthesis. aggregate_sentences: Whether to aggregate sentences within the TTSService. @@ -925,7 +982,31 @@ class ElevenLabsHttpTTSService(TTSService): **kwargs: Additional arguments passed to the parent service. """ - params = params or ElevenLabsHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "ElevenLabsHttpTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "ElevenLabsHttpTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "ElevenLabsHttpTTSSettings") + + _params = params or ElevenLabsHttpTTSService.InputParams() + + default_settings = ElevenLabsHttpTTSSettings( + model=model or "eleven_turbo_v2_5", + voice=voice_id, + language=( + self.language_to_service_language(_params.language) if _params.language else None + ), + optimize_streaming_latency=_params.optimize_streaming_latency, + stability=_params.stability, + similarity_boost=_params.similarity_boost, + style=_params.style, + use_speaker_boost=_params.use_speaker_boost, + speed=_params.speed, + apply_text_normalization=_params.apply_text_normalization, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( text_aggregation_mode=text_aggregation_mode, @@ -934,20 +1015,7 @@ class ElevenLabsHttpTTSService(TTSService): push_stop_frames=True, supports_word_timestamps=True, sample_rate=sample_rate, - settings=ElevenLabsHttpTTSSettings( - model=model, - voice=voice_id, - language=self.language_to_service_language(params.language) - if params.language - else None, - optimize_streaming_latency=params.optimize_streaming_latency, - stability=params.stability, - similarity_boost=params.similarity_boost, - style=params.style, - use_speaker_boost=params.use_speaker_boost, - speed=params.speed, - apply_text_normalization=params.apply_text_normalization, - ), + settings=default_settings, **kwargs, ) @@ -957,7 +1025,11 @@ class ElevenLabsHttpTTSService(TTSService): self._output_format = "" # initialized in start() self._voice_settings = self._set_voice_settings() - self._pronunciation_dictionary_locators = params.pronunciation_dictionary_locators + self._pronunciation_dictionary_locators = ( + pronunciation_dictionary_locators + if pronunciation_dictionary_locators is not None + else _params.pronunciation_dictionary_locators + ) # Track cumulative time to properly sequence word timestamps across utterances self._cumulative_time = 0 diff --git a/src/pipecat/services/fal/image.py b/src/pipecat/services/fal/image.py index 3de48a984..8847e3f24 100644 --- a/src/pipecat/services/fal/image.py +++ b/src/pipecat/services/fal/image.py @@ -23,7 +23,7 @@ from pydantic import BaseModel from pipecat.frames.frames import ErrorFrame, Frame, URLImageRawFrame from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings +from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param @dataclass @@ -68,8 +68,9 @@ class FalImageGenService(ImageGenService): *, params: InputParams, aiohttp_session: aiohttp.ClientSession, - model: str = "fal-ai/fast-sdxl", + model: Optional[str] = None, key: Optional[str] = None, + settings: Optional[FalImageGenSettings] = None, **kwargs, ): """Initialize the FalImageGenService. @@ -78,10 +79,23 @@ class FalImageGenService(ImageGenService): params: Input parameters for image generation configuration. 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:: 1.0 + Use ``settings=FalImageGenSettings(model=...)`` instead. + key: Optional API key for Fal.ai. If provided, sets FAL_KEY environment variable. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent ImageGenService. """ - super().__init__(settings=FalImageGenSettings(model=model), **kwargs) + if model is not None: + _warn_deprecated_param("model", "FalImageGenSettings", "model") + + default_settings = FalImageGenSettings(model=model or "fal-ai/fast-sdxl") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) self._params = params self._aiohttp_session = aiohttp_session self._api_key = key or os.getenv("FAL_KEY", "") diff --git a/src/pipecat/services/fal/stt.py b/src/pipecat/services/fal/stt.py index 8a82904d7..d2c1441d0 100644 --- a/src/pipecat/services/fal/stt.py +++ b/src/pipecat/services/fal/stt.py @@ -20,7 +20,7 @@ from loguru import logger from pydantic import BaseModel from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import FAL_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -169,6 +169,9 @@ class FalSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for Fal's Wizper API. + .. deprecated:: 1.0 + Use ``settings=FalSTTSettings(...)`` instead. + Parameters: language: Language of the audio input. Defaults to English. task: Task to perform ('transcribe' or 'translate'). Defaults to 'transcribe'. @@ -188,6 +191,7 @@ class FalSTTService(SegmentedSTTService): aiohttp_session: Optional[aiohttp.ClientSession] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[FalSTTSettings] = None, ttfs_p99_latency: Optional[float] = FAL_TTFS_P99, **kwargs, ): @@ -199,24 +203,37 @@ class FalSTTService(SegmentedSTTService): If not provided, a session will be created and managed internally. sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate. params: Configuration parameters for the Wizper API. + + .. deprecated:: 1.0 + Use ``settings=FalSTTSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService. """ - params = params or FalSTTService.InputParams() + if params is not None: + _warn_deprecated_param("params", "FalSTTSettings") + + _params = params or FalSTTService.InputParams() + + default_settings = FalSTTSettings( + model=None, + language=self.language_to_service_language(_params.language) + if _params.language + else "en", + task=_params.task, + chunk_level=_params.chunk_level, + version=_params.version, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=FalSTTSettings( - model=None, - language=self.language_to_service_language(params.language) - if params.language - else "en", - task=params.task, - chunk_level=params.chunk_level, - version=params.version, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index 92deb00b9..9fa9e44bd 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -6,10 +6,14 @@ """Fireworks AI service implementation using OpenAI-compatible interface.""" +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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class FireworksLLMService(OpenAILLMService): @@ -23,8 +27,9 @@ class FireworksLLMService(OpenAILLMService): self, *, api_key: str, - model: str = "accounts/fireworks/models/firefunction-v2", + model: Optional[str] = None, base_url: str = "https://api.fireworks.ai/inference/v1", + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Fireworks LLM service. @@ -32,10 +37,25 @@ class FireworksLLMService(OpenAILLMService): Args: api_key: The API key for accessing Fireworks AI. model: The model identifier to use. Defaults to "accounts/fireworks/models/firefunction-v2". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(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 + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings( + model=model or "accounts/fireworks/models/firefunction-v2" + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Fireworks API endpoint. diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index 9f9d753de..e95cceebd 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -29,7 +29,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import InterruptibleTTSService from pipecat.transcriptions.language import Language from pipecat.utils.tracing.service_decorators import traced_tts @@ -95,6 +95,9 @@ class FishAudioTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Input parameters for Fish Audio TTS configuration. + .. deprecated:: 1.0 + Use ``settings=FishAudioTTSSettings(...)`` instead. + Parameters: language: Language for synthesis. Defaults to English. latency: Latency mode ("normal" or "balanced"). Defaults to "normal". @@ -115,10 +118,11 @@ class FishAudioTTSService(InterruptibleTTSService): api_key: str, reference_id: Optional[str] = None, # This is the voice ID model: Optional[str] = None, # Deprecated - model_id: str = "s1", + model_id: Optional[str] = None, output_format: FishAudioOutputFormat = "pcm", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[FishAudioTTSSettings] = None, **kwargs, ): """Initialize the Fish Audio TTS service. @@ -126,19 +130,40 @@ class FishAudioTTSService(InterruptibleTTSService): Args: api_key: Fish Audio API key for authentication. reference_id: Reference ID of the voice model to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=FishAudioTTSSettings(voice=...)`` instead. + model: Deprecated. Reference ID of the voice model to use for synthesis. - .. deprecated:: 0.0.74 - The `model` parameter is deprecated and will be removed in version 0.1.0. - Use `reference_id` instead to specify the voice model. + .. deprecated:: 0.0.74 + The ``model`` parameter is deprecated and will be removed in version 0.1.0. + Use ``reference_id`` instead to specify the voice model. + + model_id: Specify which Fish Audio TTS model to use (e.g. "s1"). + + .. deprecated:: 1.0 + Use ``settings=FishAudioTTSSettings(model=...)`` instead. - model_id: Specify which Fish Audio TTS model to use (e.g. "s1") 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:: 1.0 + Use ``settings=FishAudioTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent service. """ - params = params or FishAudioTTSService.InputParams() + if reference_id is not None: + _warn_deprecated_param("reference_id", "FishAudioTTSSettings", "voice") + if model_id is not None: + _warn_deprecated_param("model_id", "FishAudioTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "FishAudioTTSSettings") + + _params = params or FishAudioTTSService.InputParams() # Validation for model and reference_id parameters if model and reference_id: @@ -146,9 +171,6 @@ class FishAudioTTSService(InterruptibleTTSService): "Cannot specify both 'model' and 'reference_id'. Use 'reference_id' only." ) - if model is None and reference_id is None: - raise ValueError("Must specify 'reference_id' (or deprecated 'model') parameter.") - if model: import warnings @@ -162,21 +184,25 @@ class FishAudioTTSService(InterruptibleTTSService): ) reference_id = model + default_settings = FishAudioTTSSettings( + model=model_id or "s1", + voice=reference_id, + fish_sample_rate=0, + latency=_params.latency, + format=output_format, + normalize=_params.normalize, + prosody_speed=_params.prosody_speed, + prosody_volume=_params.prosody_volume, + reference_id=reference_id, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( push_stop_frames=True, pause_frame_processing=True, sample_rate=sample_rate, - settings=FishAudioTTSSettings( - model=model_id, - voice=reference_id, - fish_sample_rate=0, - latency=params.latency, - format=output_format, - normalize=params.normalize, - prosody_speed=params.prosody_speed, - prosody_volume=params.prosody_volume, - reference_id=reference_id, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index bba554b4a..f2376d93e 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -39,7 +39,7 @@ from pipecat.services.gladia.config import ( PreProcessingConfig, RealtimeProcessingConfig, ) -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import GLADIA_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -249,10 +249,11 @@ class GladiaSTTService(WebsocketSTTService): url: str = "https://api.gladia.io/v2/live", confidence: Optional[float] = None, sample_rate: Optional[int] = None, - model: str = "solaria-1", + model: Optional[str] = None, params: Optional[GladiaInputParams] = None, max_buffer_size: int = 1024 * 1024 * 20, # 20MB default buffer should_interrupt: bool = True, + settings: Optional[GladiaSTTSettings] = None, ttfs_p99_latency: Optional[float] = GLADIA_TTFS_P99, **kwargs, ): @@ -269,15 +270,30 @@ class GladiaSTTService(WebsocketSTTService): No confidence threshold is applied. sample_rate: Audio sample rate in Hz. If None, uses service default. - model: Model to use for transcription. Defaults to "solaria-1". + model: Model to use for transcription. + + .. deprecated:: 1.0 + Use ``settings=GladiaSTTSettings(model=...)`` instead. + params: Additional configuration parameters for Gladia service. + + .. deprecated:: 1.0 + Use ``settings=GladiaSTTSettings(...)`` instead. + max_buffer_size: Maximum size of audio buffer in bytes. Defaults to 20MB. should_interrupt: Determine whether the bot should be interrupted when Gladia VAD detects user speech. Defaults to True. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the STTService parent class. """ + if model is not None: + _warn_deprecated_param("model", "GladiaSTTSettings", "model") + if params is not None: + _warn_deprecated_param("params", "GladiaSTTSettings") + params = params or GladiaInputParams() if params.language is not None: @@ -307,26 +323,30 @@ class GladiaSTTService(WebsocketSTTService): if language_code: language_config = LanguageConfig(languages=[language_code], code_switching=False) + default_settings = GladiaSTTSettings( + model=model or "solaria-1", + language=None, + encoding=params.encoding, + bit_depth=params.bit_depth, + channels=params.channels, + custom_metadata=params.custom_metadata, + endpointing=params.endpointing, + maximum_duration_without_endpointing=params.maximum_duration_without_endpointing, + language_config=language_config, + pre_processing=params.pre_processing, + realtime_processing=params.realtime_processing, + messages_config=params.messages_config, + enable_vad=params.enable_vad, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, keepalive_timeout=20, keepalive_interval=5, - settings=GladiaSTTSettings( - model=model, - language=None, - encoding=params.encoding, - bit_depth=params.bit_depth, - channels=params.channels, - custom_metadata=params.custom_metadata, - endpointing=params.endpointing, - maximum_duration_without_endpointing=params.maximum_duration_without_endpointing, - language_config=language_config, - pre_processing=params.pre_processing, - realtime_processing=params.realtime_processing, - messages_config=params.messages_config, - enable_vad=params.enable_vad, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index 2ed11c739..518684dfb 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -76,7 +76,7 @@ from pipecat.services.openai.llm import ( OpenAIAssistantContextAggregator, OpenAIUserContextAggregator, ) -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.string import match_endofsentence from pipecat.utils.time import time_now_iso8601 @@ -552,6 +552,9 @@ class ContextWindowCompressionParams(BaseModel): class InputParams(BaseModel): """Input parameters for Gemini Live generation. + .. deprecated:: + Use ``GeminiLiveLLMSettings`` instead. + Parameters: frequency_penalty: Frequency penalty for generation (0.0-2.0). Defaults to None. max_tokens: Maximum tokens to generate. Must be >= 1. Defaults to 4096. @@ -647,13 +650,14 @@ class GeminiLiveLLMService(LLMService): *, api_key: str, base_url: Optional[str] = None, - model="models/gemini-2.5-flash-native-audio-preview-12-2025", + model: Optional[str] = None, voice_id: str = "Charon", start_audio_paused: bool = False, start_video_paused: bool = False, system_instruction: Optional[str] = None, tools: Optional[Union[List[dict], ToolsSchema]] = None, params: Optional[InputParams] = None, + settings: Optional[GeminiLiveLLMSettings] = None, inference_on_context_initialization: bool = True, file_api_base_url: str = "https://generativelanguage.googleapis.com/v1beta/files", http_options: Optional[HttpOptions] = None, @@ -670,13 +674,23 @@ class GeminiLiveLLMService(LLMService): Please use `http_options` to customize requests made by the API client. - model: Model identifier to use. Defaults to "models/gemini-2.5-flash-native-audio-preview-12-2025". + model: Model identifier to use. + + .. deprecated:: + Use ``settings=GeminiLiveLLMSettings(model=...)`` instead. + voice_id: TTS voice identifier. Defaults to "Charon". 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. tools: Tools/functions available to the model. Defaults to None. - params: Configuration parameters for the model. Defaults to InputParams(). + params: Configuration parameters for the model. + + .. deprecated:: + Use ``settings=GeminiLiveLLMSettings(...)`` instead. + + settings: Gemini Live LLM settings. If provided together with deprecated + top-level parameters, the ``settings`` values take precedence. inference_on_context_initialization: Whether to generate a response when context is first set. Defaults to True. file_api_base_url: Base URL for the Gemini File API. Defaults to the official endpoint. @@ -694,43 +708,49 @@ class GeminiLiveLLMService(LLMService): DeprecationWarning, stacklevel=2, ) + if model is not None: + _warn_deprecated_param("model", "GeminiLiveLLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "GeminiLiveLLMSettings") - params = params or InputParams() + _params = params or InputParams() + + default_settings = GeminiLiveLLMSettings( + model=model or "models/gemini-2.5-flash-native-audio-preview-12-2025", + frequency_penalty=_params.frequency_penalty, + max_tokens=_params.max_tokens, + presence_penalty=_params.presence_penalty, + temperature=_params.temperature, + top_k=_params.top_k, + top_p=_params.top_p, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + modalities=_params.modalities, + language=language_to_gemini_language(_params.language) if _params.language else "en-US", + media_resolution=_params.media_resolution, + vad=_params.vad, + context_window_compression=_params.context_window_compression.model_dump() + if _params.context_window_compression + else {}, + thinking=_params.thinking or {}, + enable_affective_dialog=_params.enable_affective_dialog or False, + proactivity=_params.proactivity or {}, + extra=_params.extra if isinstance(_params.extra, dict) else {}, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( base_url=base_url, - settings=GeminiLiveLLMSettings( - model=model, - frequency_penalty=params.frequency_penalty, - max_tokens=params.max_tokens, - presence_penalty=params.presence_penalty, - temperature=params.temperature, - top_k=params.top_k, - top_p=params.top_p, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - modalities=params.modalities, - language=language_to_gemini_language(params.language) - if params.language - else "en-US", - media_resolution=params.media_resolution, - vad=params.vad, - context_window_compression=params.context_window_compression.model_dump() - if params.context_window_compression - else {}, - thinking=params.thinking or {}, - enable_affective_dialog=params.enable_affective_dialog or False, - proactivity=params.proactivity or {}, - extra=params.extra if isinstance(params.extra, dict) else {}, - ), + settings=default_settings, **kwargs, ) self._last_sent_time = 0 self._base_url = base_url self._voice_id = voice_id - self._language_code = params.language + self._language_code = _params.language self._system_instruction_from_init = system_instruction self._tools_from_init = tools @@ -760,11 +780,11 @@ class GeminiLiveLLMService(LLMService): self._sample_rate = 24000 - self._language = params.language + self._language = _params.language self._language_code = ( - language_to_gemini_language(params.language) if params.language else "en-US" + language_to_gemini_language(_params.language) if _params.language else "en-US" ) - self._vad_params = params.vad + self._vad_params = _params.vad # Reconnection tracking self._consecutive_failures = 0 diff --git a/src/pipecat/services/google/gemini_live/llm_vertex.py b/src/pipecat/services/google/gemini_live/llm_vertex.py index bb61033b3..eadcb66d1 100644 --- a/src/pipecat/services/google/gemini_live/llm_vertex.py +++ b/src/pipecat/services/google/gemini_live/llm_vertex.py @@ -19,9 +19,12 @@ from loguru import logger from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.services.google.gemini_live.llm import ( GeminiLiveLLMService, + GeminiLiveLLMSettings, HttpOptions, InputParams, + language_to_gemini_language, ) +from pipecat.services.settings import _warn_deprecated_param try: from google.auth import default @@ -51,13 +54,14 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): credentials_path: Optional[str] = None, location: str, project_id: str, - model="google/gemini-live-2.5-flash-native-audio", + model: Optional[str] = None, voice_id: str = "Charon", start_audio_paused: bool = False, start_video_paused: bool = False, system_instruction: Optional[str] = None, tools: Optional[Union[List[dict], ToolsSchema]] = None, params: Optional[InputParams] = None, + settings: Optional[GeminiLiveLLMSettings] = None, inference_on_context_initialization: bool = True, file_api_base_url: str = "https://generativelanguage.googleapis.com/v1beta/files", http_options: Optional[HttpOptions] = None, @@ -70,7 +74,11 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): credentials_path: Path to the service account JSON file. location: GCP region for Vertex AI endpoint (e.g., "us-east4"). project_id: Google Cloud project ID. - model: Model identifier to use. Defaults to "models/gemini-live-2.5-flash-native-audio". + model: Model identifier to use. + + .. deprecated:: + Use ``settings=GeminiLiveLLMSettings(model=...)`` instead. + voice_id: TTS voice identifier. Defaults to "Charon". 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. @@ -78,6 +86,12 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): tools: Tools/functions available to the model. Defaults to None. params: Configuration parameters for the model along with Vertex AI location and project ID. + + .. deprecated:: + Use ``settings=GeminiLiveLLMSettings(...)`` instead. + + settings: Gemini Live LLM settings. If provided together with deprecated + top-level parameters, the ``settings`` values take precedence. inference_on_context_initialization: Whether to generate a response when context is first set. Defaults to True. file_api_base_url: Base URL for the Gemini File API. Defaults to the official endpoint. @@ -95,24 +109,59 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): "Invalid parameter 'api_key'. Use 'credentials' or 'credentials_path' for Vertex AI authentication." ) + if model is not None: + _warn_deprecated_param("model", "GeminiLiveLLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "GeminiLiveLLMSettings") + # These need to be set before calling super().__init__() because # super().__init__() invokes create_client(), which needs these. self._credentials = self._get_credentials(credentials, credentials_path) self._project_id = project_id self._location = location - # Call parent constructor with the obtained API key + # Build default_settings from deprecated args, then apply settings delta. + # We pass settings= to super() instead of model=/params= to avoid + # double deprecation warnings from the parent. + _params = params or InputParams() + + default_settings = GeminiLiveLLMSettings( + model=model or "google/gemini-live-2.5-flash-native-audio", + frequency_penalty=_params.frequency_penalty, + max_tokens=_params.max_tokens, + presence_penalty=_params.presence_penalty, + temperature=_params.temperature, + top_k=_params.top_k, + top_p=_params.top_p, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + modalities=_params.modalities, + language=language_to_gemini_language(_params.language) if _params.language else "en-US", + media_resolution=_params.media_resolution, + vad=_params.vad, + context_window_compression=_params.context_window_compression.model_dump() + if _params.context_window_compression + else {}, + thinking=_params.thinking or {}, + enable_affective_dialog=_params.enable_affective_dialog or False, + proactivity=_params.proactivity or {}, + extra=_params.extra if isinstance(_params.extra, dict) else {}, + ) + if settings is not None: + default_settings.apply_update(settings) + + # Call parent constructor with the obtained settings super().__init__( # api_key is required by parent class, but actually not used with # Vertex api_key="dummy", - model=model, voice_id=voice_id, start_audio_paused=start_audio_paused, start_video_paused=start_video_paused, system_instruction=system_instruction, tools=tools, - params=params, + settings=default_settings, inference_on_context_initialization=inference_on_context_initialization, file_api_base_url=file_api_base_url, http_options=http_options, diff --git a/src/pipecat/services/google/image.py b/src/pipecat/services/google/image.py index e69faf65e..3d7cf8c94 100644 --- a/src/pipecat/services/google/image.py +++ b/src/pipecat/services/google/image.py @@ -26,7 +26,7 @@ from pydantic import BaseModel, Field from pipecat.frames.frames import ErrorFrame, Frame, URLImageRawFrame from pipecat.services.google.utils import update_google_client_http_options from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings +from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param try: from google import genai @@ -73,18 +73,33 @@ class GoogleImageGenService(ImageGenService): api_key: str, params: Optional[InputParams] = None, http_options: Optional[Any] = None, + settings: Optional[GoogleImageGenSettings] = None, **kwargs, ): """Initialize the GoogleImageGenService with API key and parameters. Args: api_key: Google AI API key for authentication. - params: Configuration parameters for image generation. Defaults to InputParams(). + params: Configuration parameters for image generation. + + .. deprecated:: 1.0 + Use ``settings=GoogleImageGenSettings(model=...)`` instead. + http_options: HTTP options for the client. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent ImageGenService. """ + if params is not None: + _warn_deprecated_param("params", "GoogleImageGenSettings") + params = params or GoogleImageGenService.InputParams() - super().__init__(settings=GoogleImageGenSettings(model=params.model), **kwargs) + + default_settings = GoogleImageGenSettings(model=params.model) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) self._params = params # Add client header diff --git a/src/pipecat/services/google/llm.py b/src/pipecat/services/google/llm.py index 37ccfae9a..5d5a87188 100644 --- a/src/pipecat/services/google/llm.py +++ b/src/pipecat/services/google/llm.py @@ -58,7 +58,13 @@ from pipecat.services.openai.llm import ( OpenAIAssistantContextAggregator, OpenAIUserContextAggregator, ) -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, is_given +from pipecat.services.settings import ( + NOT_GIVEN, + LLMSettings, + _NotGiven, + _warn_deprecated_param, + is_given, +) from pipecat.utils.tracing.service_decorators import traced_llm # Suppress gRPC fork warnings @@ -748,6 +754,9 @@ class GoogleLLMService(LLMService): class InputParams(BaseModel): """Input parameters for Google AI models. + .. deprecated:: + Use ``settings=GoogleLLMSettings(...)`` instead. + Parameters: max_tokens: Maximum number of tokens to generate. temperature: Sampling temperature between 0.0 and 2.0. @@ -773,8 +782,9 @@ class GoogleLLMService(LLMService): self, *, api_key: str, - model: str = "gemini-2.5-flash", + model: Optional[str] = None, params: Optional[InputParams] = None, + settings: Optional[GoogleLLMSettings] = None, system_instruction: Optional[str] = None, tools: Optional[List[Dict[str, Any]]] = None, tool_config: Optional[Dict[str, Any]] = None, @@ -785,33 +795,50 @@ class GoogleLLMService(LLMService): Args: api_key: Google AI API key for authentication. - model: Model name to use. Defaults to "gemini-2.0-flash". - params: Input parameters for the model. + model: Model name to use. + + .. deprecated:: + Use ``settings=GoogleLLMSettings(model=...)`` instead. + + params: Optional model parameters for inference. + + .. deprecated:: + Use ``settings=GoogleLLMSettings(...)`` instead. + + settings: Runtime-updatable settings for this service. When both + deprecated parameters and *settings* are provided, *settings* + values take precedence. system_instruction: System instruction/prompt for the model. 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. """ - params = params or GoogleLLMService.InputParams() + if model is not None: + _warn_deprecated_param("model", "GoogleLLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "GoogleLLMSettings") - super().__init__( - settings=GoogleLLMSettings( - model=model, - max_tokens=params.max_tokens, - temperature=params.temperature, - top_k=params.top_k, - top_p=params.top_p, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - thinking=params.thinking, - extra=params.extra if isinstance(params.extra, dict) else {}, - ), - **kwargs, + _params = params or GoogleLLMService.InputParams() + + default_settings = GoogleLLMSettings( + model=model or "gemini-2.5-flash", + max_tokens=_params.max_tokens, + temperature=_params.temperature, + top_k=_params.top_k, + top_p=_params.top_p, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + thinking=_params.thinking, + extra=_params.extra if isinstance(_params.extra, dict) else {}, ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) self._api_key = api_key self._system_instruction = system_instruction diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index 5d396b583..22703ae55 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -12,6 +12,7 @@ API format through Google's Gemini API OpenAI compatibility layer. import json import os +from typing import Optional from openai import AsyncStream from openai.types.chat import ChatCompletionChunk @@ -26,7 +27,9 @@ 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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class GoogleLLMOpenAIBetaService(OpenAILLMService): @@ -52,7 +55,8 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): *, api_key: str, base_url: str = "https://generativelanguage.googleapis.com/v1beta/openai/", - model: str = "gemini-2.0-flash", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Google LLM service. @@ -61,6 +65,12 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): api_key: Google API key for authentication. base_url: Base URL for Google's OpenAI-compatible API. model: Google model name to use (e.g., "gemini-2.0-flash"). + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent OpenAILLMService. """ import warnings @@ -74,7 +84,14 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): stacklevel=2, ) - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "gemini-2.0-flash") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) async def _process_context(self, context: OpenAILLMContext): functions_list = [] diff --git a/src/pipecat/services/google/llm_vertex.py b/src/pipecat/services/google/llm_vertex.py index ef222c97e..9258a4d67 100644 --- a/src/pipecat/services/google/llm_vertex.py +++ b/src/pipecat/services/google/llm_vertex.py @@ -20,7 +20,8 @@ from typing import Optional from loguru import logger -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.settings import _warn_deprecated_param try: from google.auth import default @@ -99,10 +100,11 @@ class GoogleVertexLLMService(GoogleLLMService): *, credentials: Optional[str] = None, credentials_path: Optional[str] = None, - model: str = "gemini-2.5-flash", + model: Optional[str] = None, location: Optional[str] = None, project_id: Optional[str] = None, params: Optional[GoogleLLMService.InputParams] = None, + settings: Optional[GoogleLLMSettings] = None, system_instruction: Optional[str] = None, tools: Optional[list] = None, tool_config: Optional[dict] = None, @@ -115,9 +117,20 @@ class GoogleVertexLLMService(GoogleLLMService): credentials: JSON string of service account credentials. credentials_path: Path to the service account JSON file. model: Model identifier (e.g., "gemini-2.5-flash"). + + .. deprecated:: + Use ``settings=GoogleLLMSettings(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:: + Use ``settings=GoogleLLMSettings(...)`` instead. + + settings: Runtime-updatable settings for this service. When both + deprecated parameters and *settings* are provided, *settings* + values take precedence. system_instruction: System instruction/prompt for the model. tools: List of available tools/functions. tool_config: Configuration for tool usage. @@ -135,6 +148,11 @@ class GoogleVertexLLMService(GoogleLLMService): "Invalid parameter 'api_key'. Use 'credentials' or 'credentials_path' for Vertex AI authentication." ) + if model is not None: + _warn_deprecated_param("model", "GoogleLLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "GoogleLLMSettings") + # Handle deprecated InputParams fields if params and isinstance(params, GoogleVertexLLMService.InputParams): # Extract location and project_id from params if not provided @@ -170,12 +188,30 @@ class GoogleVertexLLMService(GoogleLLMService): self._project_id = project_id self._location = location + # Build default_settings from deprecated args + _params = params or GoogleLLMService.InputParams() + default_settings = GoogleLLMSettings( + model=model or "gemini-2.5-flash", + max_tokens=_params.max_tokens, + temperature=_params.temperature, + top_k=_params.top_k, + top_p=_params.top_p, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + thinking=_params.thinking, + extra=_params.extra if isinstance(_params.extra, dict) else {}, + ) + if settings is not None: + default_settings.apply_update(settings) + # Call parent constructor with dummy api_key # (api_key is required by parent class, but not actually used with Vertex) super().__init__( api_key="dummy", - model=model, - params=params, + settings=default_settings, system_instruction=system_instruction, tools=tools, tool_config=tool_config, diff --git a/src/pipecat/services/google/stt.py b/src/pipecat/services/google/stt.py index 95d91d462..818df0214 100644 --- a/src/pipecat/services/google/stt.py +++ b/src/pipecat/services/google/stt.py @@ -36,7 +36,7 @@ from pipecat.frames.frames import ( StartFrame, TranscriptionFrame, ) -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import GOOGLE_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language, resolve_language @@ -425,6 +425,9 @@ class GoogleSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for Google Speech-to-Text. + .. deprecated:: 1.0 + Use ``settings=GoogleSTTSettings(...)`` instead. + Parameters: languages: Single language or list of recognition languages. First language is primary. model: Speech recognition model to use. @@ -484,6 +487,7 @@ class GoogleSTTService(STTService): location: str = "global", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[GoogleSTTSettings] = None, ttfs_p99_latency: Optional[float] = GOOGLE_TTFS_P99, **kwargs, ): @@ -495,30 +499,43 @@ class GoogleSTTService(STTService): location: Google Cloud location (e.g., "global", "us-central1"). sample_rate: Audio sample rate in Hertz. params: Configuration parameters for the service. + + .. deprecated:: 1.0 + Use ``settings=GoogleSTTSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + ``params``, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to STTService. """ - params = params or GoogleSTTService.InputParams() + if params is not None: + _warn_deprecated_param("params", "GoogleSTTSettings") + + _params = params or GoogleSTTService.InputParams() + + default_settings = GoogleSTTSettings( + language=None, + languages=list(_params.language_list), + language_codes=None, + model=_params.model, + use_separate_recognition_per_channel=_params.use_separate_recognition_per_channel, + enable_automatic_punctuation=_params.enable_automatic_punctuation, + enable_spoken_punctuation=_params.enable_spoken_punctuation, + enable_spoken_emojis=_params.enable_spoken_emojis, + profanity_filter=_params.profanity_filter, + enable_word_time_offsets=_params.enable_word_time_offsets, + enable_word_confidence=_params.enable_word_confidence, + enable_interim_results=_params.enable_interim_results, + enable_voice_activity_events=_params.enable_voice_activity_events, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=GoogleSTTSettings( - language=None, - languages=list(params.language_list), - language_codes=None, - model=params.model, - use_separate_recognition_per_channel=params.use_separate_recognition_per_channel, - enable_automatic_punctuation=params.enable_automatic_punctuation, - enable_spoken_punctuation=params.enable_spoken_punctuation, - enable_spoken_emojis=params.enable_spoken_emojis, - profanity_filter=params.profanity_filter, - enable_word_time_offsets=params.enable_word_time_offsets, - enable_word_confidence=params.enable_word_confidence, - enable_interim_results=params.enable_interim_results, - enable_voice_activity_events=params.enable_voice_activity_events, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index 6c71977a0..86ec845a5 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -37,7 +37,13 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, is_given +from pipecat.services.settings import ( + NOT_GIVEN, + TTSSettings, + _NotGiven, + _warn_deprecated_param, + is_given, +) from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language @@ -560,6 +566,9 @@ class GoogleHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Google HTTP TTS voice customization. + .. deprecated:: 1.0 + Use ``GoogleHttpTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: pitch: Voice pitch adjustment (e.g., "+2st", "-50%"). rate: Speaking rate adjustment (e.g., "slow", "fast", "125%"). Used for SSML prosody tags (non-Chirp voices). @@ -586,9 +595,10 @@ class GoogleHttpTTSService(TTSService): credentials: Optional[str] = None, credentials_path: Optional[str] = None, location: Optional[str] = None, - voice_id: str = "en-US-Chirp3-HD-Charon", + voice_id: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[GoogleHttpTTSSettings] = None, **kwargs, ): """Initializes the Google HTTP TTS service. @@ -598,28 +608,47 @@ class GoogleHttpTTSService(TTSService): credentials_path: Path to Google Cloud service account JSON file. location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Google TTS voice identifier (e.g., "en-US-Standard-A"). + + .. deprecated:: 1.0 + Use ``settings=GoogleHttpTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate in Hz. If None, uses default. params: Voice customization parameters including pitch, rate, volume, etc. + + .. deprecated:: 1.0 + Use ``settings=GoogleHttpTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or GoogleHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "GoogleHttpTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "GoogleHttpTTSSettings") + + _params = params or GoogleHttpTTSService.InputParams() + + default_settings = GoogleHttpTTSSettings( + model=None, + pitch=_params.pitch, + rate=_params.rate, + speaking_rate=_params.speaking_rate, + volume=_params.volume, + emphasis=_params.emphasis, + language=self.language_to_service_language(_params.language) + if _params.language + else "en-US", + gender=_params.gender, + google_style=_params.google_style, + voice=voice_id or "en-US-Chirp3-HD-Charon", + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=GoogleHttpTTSSettings( - model=None, - pitch=params.pitch, - rate=params.rate, - speaking_rate=params.speaking_rate, - volume=params.volume, - emphasis=params.emphasis, - language=self.language_to_service_language(params.language) - if params.language - else "en-US", - gender=params.gender, - google_style=params.google_style, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -987,6 +1016,9 @@ class GoogleTTSService(GoogleBaseTTSService): class InputParams(BaseModel): """Input parameters for Google streaming TTS configuration. + .. deprecated:: 1.0 + Use ``GoogleStreamTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language for synthesis. Defaults to English. speaking_rate: The speaking rate, in the range [0.25, 2.0]. @@ -1001,10 +1033,11 @@ class GoogleTTSService(GoogleBaseTTSService): credentials: Optional[str] = None, credentials_path: Optional[str] = None, location: Optional[str] = None, - voice_id: str = "en-US-Chirp3-HD-Charon", + voice_id: Optional[str] = None, voice_cloning_key: Optional[str] = None, sample_rate: Optional[int] = None, - params: InputParams = InputParams(), + params: Optional[InputParams] = None, + settings: Optional[GoogleStreamTTSSettings] = None, **kwargs, ): """Initializes the Google streaming TTS service. @@ -1014,23 +1047,42 @@ class GoogleTTSService(GoogleBaseTTSService): credentials_path: Path to Google Cloud service account JSON file. location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Google TTS voice identifier (e.g., "en-US-Chirp3-HD-Charon"). + + .. deprecated:: 1.0 + Use ``settings=GoogleStreamTTSSettings(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:: 1.0 + Use ``settings=GoogleStreamTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or GoogleTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "GoogleStreamTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "GoogleStreamTTSSettings") + + _params = params or GoogleTTSService.InputParams() + + default_settings = GoogleStreamTTSSettings( + model=None, + language=self.language_to_service_language(_params.language) + if _params.language + else "en-US", + speaking_rate=_params.speaking_rate, + voice=voice_id or "en-US-Chirp3-HD-Charon", + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=GoogleStreamTTSSettings( - model=None, - language=self.language_to_service_language(params.language) - if params.language - else "en-US", - speaking_rate=params.speaking_rate, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -1170,6 +1222,9 @@ class GeminiTTSService(GoogleBaseTTSService): class InputParams(BaseModel): """Input parameters for Gemini TTS configuration. + .. deprecated:: 1.0 + Use ``GeminiTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language for synthesis. Defaults to English. prompt: Optional style instructions for how to synthesize the content. @@ -1186,13 +1241,14 @@ class GeminiTTSService(GoogleBaseTTSService): self, *, api_key: Optional[str] = None, - model: str = "gemini-2.5-flash-tts", + model: Optional[str] = None, credentials: Optional[str] = None, credentials_path: Optional[str] = None, location: Optional[str] = None, - voice_id: str = "Kore", + voice_id: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[GeminiTTSSettings] = None, **kwargs, ): """Initializes the Gemini TTS service. @@ -1206,12 +1262,26 @@ class GeminiTTSService(GoogleBaseTTSService): model: Gemini TTS model to use. Must be a TTS model like "gemini-2.5-flash-tts" or "gemini-2.5-pro-tts". + + .. deprecated:: 1.0 + Use ``settings=GeminiTTSSettings(model=...)`` instead. + credentials: JSON string containing Google Cloud service account credentials. credentials_path: Path to Google Cloud service account JSON file. location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Voice name from the available Gemini voices. + + .. deprecated:: 1.0 + Use ``settings=GeminiTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate in Hz. If None, uses Google's default 24kHz. params: TTS configuration parameters. + + .. deprecated:: 1.0 + Use ``settings=GeminiTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ # Handle deprecated api_key parameter @@ -1222,29 +1292,40 @@ class GeminiTTSService(GoogleBaseTTSService): DeprecationWarning, stacklevel=2, ) + if model is not None: + _warn_deprecated_param("model", "GeminiTTSSettings", "model") + if voice_id is not None: + _warn_deprecated_param("voice_id", "GeminiTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "GeminiTTSSettings") if sample_rate and sample_rate != self.GOOGLE_SAMPLE_RATE: logger.warning( f"Google TTS only supports {self.GOOGLE_SAMPLE_RATE}Hz sample rate. " f"Current rate of {sample_rate}Hz may cause issues." ) - params = params or GeminiTTSService.InputParams() + _params = params or GeminiTTSService.InputParams() + voice_id = voice_id or "Kore" if voice_id not in self.AVAILABLE_VOICES: logger.warning(f"Voice '{voice_id}' not in known voices list. Using anyway.") + default_settings = GeminiTTSSettings( + model=model or "gemini-2.5-flash-tts", + language=self.language_to_service_language(_params.language) + if _params.language + else "en-US", + prompt=_params.prompt, + multi_speaker=_params.multi_speaker, + speaker_configs=_params.speaker_configs, + voice=voice_id, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, - settings=GeminiTTSSettings( - model=model, - language=self.language_to_service_language(params.language) - if params.language - else "en-US", - prompt=params.prompt, - multi_speaker=params.multi_speaker, - speaker_configs=params.speaker_configs, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index ac35c6e52..e1d2b74d4 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -28,7 +28,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import GRADIUM_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -91,6 +91,9 @@ class GradiumSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for Gradium STT API. + .. deprecated:: 1.0 + Use ``settings=GradiumSTTSettings(...)`` instead. + Parameters: language: Expected language of the audio (e.g., "en", "es", "fr"). This helps ground the model to a specific language and improve @@ -111,6 +114,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, ttfs_p99_latency: Optional[float] = GRADIUM_TTFS_P99, **kwargs, ): @@ -120,11 +124,17 @@ class GradiumSTTService(WebsocketSTTService): api_key: Gradium API key for authentication. api_endpoint_base_url: WebSocket endpoint URL. Defaults to Gradium's streaming endpoint. params: Configuration parameters for language and delay settings. + + .. deprecated:: 1.0 + Use ``settings=GradiumSTTSettings(...)`` instead. + json_config: Optional JSON configuration string for additional model settings. .. deprecated:: 0.0.101 Use `params` instead for type-safe configuration. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService class. @@ -138,16 +148,23 @@ class GradiumSTTService(WebsocketSTTService): stacklevel=2, ) - params = params or GradiumSTTService.InputParams() + if params is not None: + _warn_deprecated_param("params", "GradiumSTTSettings") + + _params = params or GradiumSTTService.InputParams() + + default_settings = GradiumSTTSettings( + model=None, + language=_params.language, + delay_in_frames=_params.delay_in_frames or None, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=SAMPLE_RATE, ttfs_p99_latency=ttfs_p99_latency, - settings=GradiumSTTSettings( - model=None, - language=params.language, - delay_in_frames=params.delay_in_frames or None, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/gradium/tts.py b/src/pipecat/services/gradium/tts.py index c8a83a7f2..75455cf54 100644 --- a/src/pipecat/services/gradium/tts.py +++ b/src/pipecat/services/gradium/tts.py @@ -22,7 +22,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -57,6 +57,9 @@ class GradiumTTSService(AudioContextTTSService): class InputParams(BaseModel): """Configuration parameters for Gradium TTS service. + .. deprecated:: 1.0 + Use ``GradiumTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: temp: Temperature to be used for generation, defaults to 0.6. """ @@ -67,11 +70,12 @@ class GradiumTTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str = "YTpq7expH9539ERJ", + voice_id: Optional[str] = None, url: str = "wss://eu.api.gradium.ai/api/speech/tts", - model: str = "default", + model: Optional[str] = None, json_config: Optional[str] = None, params: Optional[InputParams] = None, + settings: Optional[GradiumTTSSettings] = None, **kwargs, ): """Initialize the Gradium TTS service. @@ -79,13 +83,41 @@ class GradiumTTSService(AudioContextTTSService): Args: api_key: Gradium API key for authentication. voice_id: the voice identifier. + + .. deprecated:: 1.0 + Use ``settings=GradiumTTSSettings(voice=...)`` instead. + url: Gradium websocket API endpoint. model: Model ID to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=GradiumTTSSettings(model=...)`` instead. + json_config: Optional JSON configuration string for additional model settings. params: Additional configuration parameters. + + .. deprecated:: 1.0 + Use ``settings=GradiumTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent class. """ - params = params or GradiumTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "GradiumTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "GradiumTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "GradiumTTSSettings") + + default_settings = GradiumTTSSettings( + model=model or "default", + voice=voice_id or "YTpq7expH9539ERJ", + language=None, + output_format="pcm", + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( push_stop_frames=True, @@ -93,12 +125,7 @@ class GradiumTTSService(AudioContextTTSService): pause_frame_processing=True, supports_word_timestamps=True, sample_rate=SAMPLE_RATE, - settings=GradiumTTSSettings( - model=model, - voice=voice_id, - language=None, - output_format="pcm", - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index fa905a92c..0ef6d36f2 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -12,6 +12,7 @@ and context aggregation functionality. """ from dataclasses import dataclass +from typing import Optional from loguru import logger @@ -22,11 +23,13 @@ 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.llm import ( OpenAIAssistantContextAggregator, OpenAILLMService, OpenAIUserContextAggregator, ) +from pipecat.services.settings import _warn_deprecated_param @dataclass @@ -81,7 +84,8 @@ class GrokLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.x.ai/v1", - model: str = "grok-3-beta", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the GrokLLMService with API key and model. @@ -90,9 +94,22 @@ class GrokLLMService(OpenAILLMService): api_key: The API key for accessing Grok's API. base_url: The base URL for Grok API. Defaults to "https://api.x.ai/v1". model: The model identifier to use. Defaults to "grok-3-beta". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "grok-3-beta") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) # Initialize counters for token usage metrics self._prompt_tokens = 0 self._completion_tokens = 0 diff --git a/src/pipecat/services/grok/realtime/llm.py b/src/pipecat/services/grok/realtime/llm.py index 7a4e73806..87f5eaaaa 100644 --- a/src/pipecat/services/grok/realtime/llm.py +++ b/src/pipecat/services/grok/realtime/llm.py @@ -56,7 +56,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param from pipecat.utils.time import time_now_iso8601 from . import events @@ -126,6 +126,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, start_audio_paused: bool = False, **kwargs, ): @@ -136,30 +137,46 @@ class GrokRealtimeLLMService(LLMService): base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.x.ai/v1/realtime". session_properties: Configuration properties for the realtime session. + + .. deprecated:: + Use ``settings=GrokRealtimeLLMSettings(session_properties=...)`` + instead. + If None, uses default SessionProperties with voice "Ara". To set a different voice, configure it in session_properties: session_properties = events.SessionProperties(voice="Rex") Available voices: Ara, Rex, Sal, Eve, Leo. + settings: Grok Realtime LLM settings. If provided together with deprecated + top-level parameters, the ``settings`` values take precedence. start_audio_paused: Whether to start with audio input paused. Defaults to False. **kwargs: Additional arguments passed to parent LLMService. """ + if session_properties is not None: + _warn_deprecated_param( + "session_properties", "GrokRealtimeLLMSettings", "session_properties" + ) + + default_settings = GrokRealtimeLLMSettings( + model=None, + temperature=None, + max_tokens=None, + top_p=None, + top_k=None, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + session_properties=session_properties or events.SessionProperties(), + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( base_url=base_url, - settings=GrokRealtimeLLMSettings( - model=None, - temperature=None, - max_tokens=None, - top_p=None, - top_k=None, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - session_properties=session_properties or events.SessionProperties(), - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index 9dae88c31..23cce68a2 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -6,9 +6,13 @@ """Groq LLM Service implementation using OpenAI-compatible interface.""" +from typing import Optional + from loguru import logger +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class GroqLLMService(OpenAILLMService): @@ -23,7 +27,8 @@ class GroqLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.groq.com/openai/v1", - model: str = "llama-3.3-70b-versatile", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize Groq LLM service. @@ -32,9 +37,22 @@ class GroqLLMService(OpenAILLMService): api_key: The API key for accessing Groq's API. base_url: The base URL for Groq API. Defaults to "https://api.groq.com/openai/v1". model: The model identifier to use. Defaults to "llama-3.3-70b-versatile". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "llama-3.3-70b-versatile") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Groq API endpoint. diff --git a/src/pipecat/services/groq/stt.py b/src/pipecat/services/groq/stt.py index d51e93c68..8018ec702 100644 --- a/src/pipecat/services/groq/stt.py +++ b/src/pipecat/services/groq/stt.py @@ -8,8 +8,13 @@ from typing import Optional +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, Transcription +from pipecat.services.whisper.base_stt import ( + BaseWhisperSTTService, + BaseWhisperSTTSettings, + Transcription, +) from pipecat.transcriptions.language import Language @@ -23,35 +28,75 @@ class GroqSTTService(BaseWhisperSTTService): def __init__( self, *, - model: str = "whisper-large-v3-turbo", + model: Optional[str] = None, api_key: Optional[str] = None, base_url: str = "https://api.groq.com/openai/v1", - language: Optional[Language] = Language.EN, + language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, + settings: Optional[BaseWhisperSTTSettings] = None, ttfs_p99_latency: Optional[float] = GROQ_TTFS_P99, **kwargs, ): """Initialize Groq STT service. Args: - model: Whisper model to use. Defaults to "whisper-large-v3-turbo". + model: Whisper model to use. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(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. Defaults to English. + language: Language of the audio input. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. + prompt: Optional text to guide the model's style or continue a previous segment. - temperature: Optional sampling temperature between 0 and 1. Defaults to 0.0. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. + + temperature: Optional sampling temperature between 0 and 1. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to BaseWhisperSTTService. """ - super().__init__( + if model is not None: + _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") + if language is not None: + _warn_deprecated_param("language", "BaseWhisperSTTSettings", "language") + if prompt is not None: + _warn_deprecated_param("prompt", "BaseWhisperSTTSettings", "prompt") + if temperature is not None: + _warn_deprecated_param("temperature", "BaseWhisperSTTSettings", "temperature") + + model = model or "whisper-large-v3-turbo" + language = language or Language.EN + + # Build settings from deprecated params and pass via settings= + # to avoid double deprecation warnings in BaseWhisperSTTService. + default_settings = BaseWhisperSTTSettings( model=model, - api_key=api_key, + language=self.language_to_service_language(language), base_url=base_url, - language=language, prompt=prompt, temperature=temperature, + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__( + api_key=api_key, + base_url=base_url, + settings=default_settings, ttfs_p99_latency=ttfs_p99_latency, **kwargs, ) diff --git a/src/pipecat/services/groq/tts.py b/src/pipecat/services/groq/tts.py index 901b786c0..c6cc46e23 100644 --- a/src/pipecat/services/groq/tts.py +++ b/src/pipecat/services/groq/tts.py @@ -21,7 +21,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language from pipecat.utils.tracing.service_decorators import traced_tts @@ -64,6 +64,9 @@ class GroqTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Groq TTS configuration. + .. deprecated:: 1.0 + Use ``settings=GroqTTSSettings(...)`` instead. + Parameters: language: Language for speech synthesis. Defaults to English. speed: Speech speed multiplier. Defaults to 1.0. @@ -80,9 +83,10 @@ class GroqTTSService(TTSService): api_key: str, output_format: str = "wav", params: Optional[InputParams] = None, - model_name: str = "canopylabs/orpheus-v1-english", - voice_id: str = "autumn", + model_name: Optional[str] = None, + voice_id: Optional[str] = None, sample_rate: Optional[int] = GROQ_SAMPLE_RATE, + settings: Optional[GroqTTSSettings] = None, **kwargs, ): """Initialize Groq TTS service. @@ -91,27 +95,52 @@ class GroqTTSService(TTSService): api_key: Groq API key for authentication. output_format: Audio output format. Defaults to "wav". params: Additional input parameters for voice customization. - model_name: TTS model to use. Defaults to "playai-tts". - voice_id: Voice identifier to use. Defaults to "Celeste-PlayAI". + + .. deprecated:: 1.0 + Use ``settings=GroqTTSSettings(...)`` instead. + + model_name: TTS model to use. + + .. deprecated:: 1.0 + Use ``settings=GroqTTSSettings(model=...)`` instead. + + voice_id: Voice identifier to use. + + .. deprecated:: 1.0 + Use ``settings=GroqTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate. Must be 48000 Hz for Groq TTS. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ + if model_name is not None: + _warn_deprecated_param("model_name", "GroqTTSSettings", "model") + if voice_id is not None: + _warn_deprecated_param("voice_id", "GroqTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "GroqTTSSettings") + if sample_rate != self.GROQ_SAMPLE_RATE: logger.warning(f"Groq TTS only supports {self.GROQ_SAMPLE_RATE}Hz sample rate. ") - params = params or GroqTTSService.InputParams() + _params = params or GroqTTSService.InputParams() + + default_settings = GroqTTSSettings( + model=model_name or "canopylabs/orpheus-v1-english", + voice=voice_id or "autumn", + language=str(_params.language) if _params.language else "en", + output_format=output_format, + speed=_params.speed, + groq_sample_rate=sample_rate, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( pause_frame_processing=True, sample_rate=sample_rate, - settings=GroqTTSSettings( - model=model_name, - voice=voice_id, - language=str(params.language) if params.language else "en", - output_format=output_format, - speed=params.speed, - groq_sample_rate=sample_rate, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/heygen/video.py b/src/pipecat/services/heygen/video.py index 7f3624f35..020ecdfcf 100644 --- a/src/pipecat/services/heygen/video.py +++ b/src/pipecat/services/heygen/video.py @@ -45,6 +45,7 @@ from pipecat.services.heygen.client import ( HeyGenClient, ServiceType, ) +from pipecat.services.settings import ServiceSettings from pipecat.transports.base_transport import TransportParams # Using the same values that we do in the BaseOutputTransport @@ -80,6 +81,7 @@ class HeyGenVideoService(AIService): session: aiohttp.ClientSession, session_request: Optional[Union[LiveAvatarNewSessionRequest, NewSessionRequest]] = None, service_type: Optional[ServiceType] = None, + settings: Optional[ServiceSettings] = None, **kwargs, ) -> None: """Initialize the HeyGen video service. @@ -89,9 +91,15 @@ class HeyGenVideoService(AIService): session: HTTP client session for API requests session_request: Configuration for the HeyGen session service_type: Service type for the avatar session + settings: Runtime-updatable settings. HeyGen has no model concept, so this + is primarily used for the ``extra`` dict. **kwargs: Additional arguments passed to parent AIService """ - super().__init__(**kwargs) + default_settings = ServiceSettings(model=None) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) self._api_key = api_key self._session = session self._client: Optional[HeyGenClient] = None diff --git a/src/pipecat/services/hume/tts.py b/src/pipecat/services/hume/tts.py index 2a075ab36..35b6fbbc4 100644 --- a/src/pipecat/services/hume/tts.py +++ b/src/pipecat/services/hume/tts.py @@ -26,7 +26,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -84,6 +84,9 @@ class HumeTTSService(TTSService): class InputParams(BaseModel): """Optional synthesis parameters for Hume TTS. + .. deprecated:: 1.0 + Use ``settings=HumeTTSSettings(...)`` instead. + Parameters: description: Natural-language acting directions (up to 100 characters). speed: Speaking-rate multiplier (0.5-2.0). @@ -98,9 +101,10 @@ class HumeTTSService(TTSService): self, *, api_key: Optional[str] = None, - voice_id: str, + voice_id: Optional[str] = None, params: Optional[InputParams] = None, sample_rate: Optional[int] = HUME_SAMPLE_RATE, + settings: Optional[HumeTTSSettings] = None, **kwargs, ) -> None: """Initialize the HumeTTSService. @@ -108,10 +112,25 @@ class HumeTTSService(TTSService): Args: api_key: Hume API key. If omitted, reads the ``HUME_API_KEY`` environment variable. voice_id: ID of the voice to use. Only voice IDs are supported; voice names are not. + + .. deprecated:: 1.0 + Use ``settings=HumeTTSSettings(voice=...)`` instead. + params: Optional synthesis controls (acting instructions, speed, trailing silence). + + .. deprecated:: 1.0 + Use ``settings=HumeTTSSettings(...)`` instead. + sample_rate: Output sample rate for emitted PCM frames. Defaults to 48_000 (Hume). + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent class. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "HumeTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "HumeTTSSettings") + api_key = api_key or os.getenv("HUME_API_KEY") if not api_key: raise ValueError("HumeTTSService requires an API key (env HUME_API_KEY or api_key=)") @@ -121,21 +140,25 @@ class HumeTTSService(TTSService): f"Hume TTS streams at {HUME_SAMPLE_RATE} Hz; configured sample_rate={sample_rate}" ) - params = params or HumeTTSService.InputParams() + _params = params or HumeTTSService.InputParams() + + default_settings = HumeTTSSettings( + model=None, + voice=voice_id, + language=None, # Not applicable here + description=_params.description, + speed=_params.speed, + trailing_silence=_params.trailing_silence, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, push_text_frames=False, push_stop_frames=True, supports_word_timestamps=True, - settings=HumeTTSSettings( - model=None, - voice=voice_id, - language=None, # Not applicable here - description=params.description, - speed=params.speed, - trailing_silence=params.trailing_silence, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index d3f64c16f..23c3b36e4 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -29,7 +29,7 @@ from pipecat import version as pipecat_version USER_AGENT = f"pipecat/{pipecat_version()}" from pydantic import BaseModel -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param try: from websockets.asyncio.client import connect as websocket_connect @@ -114,6 +114,9 @@ class InworldHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Inworld TTS configuration. + .. deprecated:: 1.0 + Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: temperature: Temperature for speech synthesis. speaking_rate: Speaking rate for speech synthesis. @@ -129,12 +132,13 @@ class InworldHttpTTSService(TTSService): *, api_key: str, aiohttp_session: aiohttp.ClientSession, - voice_id: str = "Ashley", - model: str = "inworld-tts-1.5-max", + voice_id: Optional[str] = None, + model: Optional[str] = None, streaming: bool = True, sample_rate: Optional[int] = None, encoding: str = "LINEAR16", - params: InputParams = None, + params: Optional[InputParams] = None, + settings: Optional[InworldTTSSettings] = None, **kwargs, ): """Initialize the Inworld TTS service. @@ -143,32 +147,57 @@ class InworldHttpTTSService(TTSService): api_key: Inworld API key. aiohttp_session: aiohttp ClientSession for HTTP requests. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=InworldTTSSettings(voice=...)`` instead. + model: ID of the model to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=InworldTTSSettings(model=...)`` instead. + streaming: Whether to use streaming mode. sample_rate: Audio sample rate in Hz. encoding: Audio encoding format. params: Input parameters for Inworld TTS configuration. + + .. deprecated:: 1.0 + Use ``settings=InworldTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent class. """ - params = params or InworldHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "InworldTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "InworldTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "InworldTTSSettings") + + _params = params or InworldHttpTTSService.InputParams() + + default_settings = InworldTTSSettings( + model=model or "inworld-tts-1.5-max", + voice=voice_id or "Ashley", + language=None, + audio_encoding=encoding, + audio_sample_rate=0, + speaking_rate=_params.speaking_rate, + temperature=_params.temperature, + timestamp_transport_strategy=_params.timestamp_transport_strategy, + auto_mode=None, # Not applicable for HTTP TTS + apply_text_normalization=None, # Not applicable for HTTP TTS + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( push_text_frames=False, push_stop_frames=True, supports_word_timestamps=True, sample_rate=sample_rate, - settings=InworldTTSSettings( - model=model, - voice=voice_id, - language=None, - audio_encoding=encoding, - audio_sample_rate=0, - speaking_rate=params.speaking_rate, - temperature=params.temperature, - timestamp_transport_strategy=params.timestamp_transport_strategy, - auto_mode=None, # Not applicable for HTTP TTS - apply_text_normalization=None, # Not applicable for HTTP TTS - ), + settings=default_settings, **kwargs, ) @@ -477,6 +506,9 @@ class InworldTTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for Inworld WebSocket TTS configuration. + .. deprecated:: 1.0 + Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: temperature: Temperature for speech synthesis. speaking_rate: Speaking rate for speech synthesis. @@ -503,12 +535,13 @@ class InworldTTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str = "Ashley", - model: str = "inworld-tts-1.5-max", + voice_id: Optional[str] = None, + model: Optional[str] = None, url: str = "wss://api.inworld.ai/tts/v1/voice:streamBidirectional", sample_rate: Optional[int] = None, encoding: str = "LINEAR16", - params: InputParams = None, + params: Optional[InputParams] = None, + settings: Optional[InworldTTSSettings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, append_trailing_space: bool = True, @@ -519,11 +552,25 @@ class InworldTTSService(AudioContextTTSService): Args: api_key: Inworld API key. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=InworldTTSSettings(voice=...)`` instead. + model: ID of the model to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=InworldTTSSettings(model=...)`` instead. + url: URL of the Inworld WebSocket API. sample_rate: Audio sample rate in Hz. encoding: Audio encoding format. params: Input parameters for Inworld WebSocket TTS configuration. + + .. deprecated:: 1.0 + Use ``settings=InworldTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. aggregate_sentences: Deprecated. Use text_aggregation_mode instead. .. deprecated:: 0.0.104 @@ -533,7 +580,29 @@ class InworldTTSService(AudioContextTTSService): append_trailing_space: Whether to append a trailing space to text before sending to TTS. **kwargs: Additional arguments passed to the parent class. """ - params = params or InworldTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "InworldTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "InworldTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "InworldTTSSettings") + + _params = params or InworldTTSService.InputParams() + + default_settings = InworldTTSSettings( + model=model or "inworld-tts-1.5-max", + voice=voice_id or "Ashley", + language=None, + audio_encoding=encoding, + audio_sample_rate=0, + speaking_rate=_params.speaking_rate, + temperature=_params.temperature, + apply_text_normalization=_params.apply_text_normalization, + timestamp_transport_strategy=_params.timestamp_transport_strategy, + auto_mode=_params.auto_mode if _params.auto_mode is not None else aggregate_sentences, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( push_text_frames=False, @@ -544,18 +613,7 @@ class InworldTTSService(AudioContextTTSService): aggregate_sentences=aggregate_sentences, text_aggregation_mode=text_aggregation_mode, append_trailing_space=append_trailing_space, - settings=InworldTTSSettings( - model=model, - voice=voice_id, - language=None, - audio_encoding=encoding, - audio_sample_rate=0, - speaking_rate=params.speaking_rate, - temperature=params.temperature, - apply_text_normalization=params.apply_text_normalization, - timestamp_transport_strategy=params.timestamp_transport_strategy, - auto_mode=params.auto_mode if params.auto_mode is not None else aggregate_sentences, - ), + settings=default_settings, **kwargs, ) @@ -564,8 +622,8 @@ class InworldTTSService(AudioContextTTSService): self._timestamp_type = "WORD" self._buffer_settings = { - "maxBufferDelayMs": params.max_buffer_delay_ms, - "bufferCharThreshold": params.buffer_char_threshold, + "maxBufferDelayMs": _params.max_buffer_delay_ms, + "bufferCharThreshold": _params.buffer_char_threshold, } self._receive_task = None diff --git a/src/pipecat/services/kokoro/tts.py b/src/pipecat/services/kokoro/tts.py index 4b35fa46d..fed53049c 100644 --- a/src/pipecat/services/kokoro/tts.py +++ b/src/pipecat/services/kokoro/tts.py @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -112,6 +112,9 @@ class KokoroTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Kokoro TTS configuration. + .. deprecated:: 1.0 + Use ``KokoroTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language to use for synthesis. """ @@ -121,35 +124,55 @@ class KokoroTTSService(TTSService): def __init__( self, *, - voice_id: str, + voice_id: Optional[str] = None, model_path: Optional[str] = None, voices_path: Optional[str] = None, params: Optional[InputParams] = None, + settings: Optional[KokoroTTSSettings] = None, **kwargs, ): """Initialize the Kokoro TTS service. Args: voice_id: Voice identifier to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=KokoroTTSSettings(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:: 1.0 + Use ``settings=KokoroTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent `TTSService`. """ - params = params or KokoroTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "KokoroTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "KokoroTTSSettings") + + _params = params or KokoroTTSService.InputParams() + + default_settings = KokoroTTSSettings( + model=None, + voice=voice_id, + language=language_to_kokoro_language(_params.language), + lang_code=language_to_kokoro_language(_params.language), + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( - settings=KokoroTTSSettings( - model=None, - voice=voice_id, - language=language_to_kokoro_language(params.language), - lang_code=language_to_kokoro_language(params.language), - ), + settings=default_settings, **kwargs, ) - self._lang_code = language_to_kokoro_language(params.language) + self._lang_code = language_to_kokoro_language(_params.language) model = Path(model_path) if model_path else KOKORO_CACHE_DIR / "kokoro-v1.0.onnx" voices = Path(voices_path) if voices_path else KOKORO_CACHE_DIR / "voices-v1.0.bin" diff --git a/src/pipecat/services/lmnt/tts.py b/src/pipecat/services/lmnt/tts.py index a2c500ca2..1e7cff994 100644 --- a/src/pipecat/services/lmnt/tts.py +++ b/src/pipecat/services/lmnt/tts.py @@ -24,7 +24,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import InterruptibleTTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -98,10 +98,11 @@ class LmntTTSService(InterruptibleTTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, sample_rate: Optional[int] = None, language: Language = Language.EN, - model: str = "blizzard", + model: Optional[str] = None, + settings: Optional[LmntTTSSettings] = None, **kwargs, ): """Initialize the LMNT TTS service. @@ -109,21 +110,40 @@ class LmntTTSService(InterruptibleTTSService): Args: api_key: LMNT API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=LmntTTSSettings(voice=...)`` instead. + sample_rate: Audio sample rate. If None, uses default. language: Language for synthesis. Defaults to English. - model: TTS model to use. Defaults to "blizzard". + model: TTS model to use. + + .. deprecated:: 1.0 + Use ``settings=LmntTTSSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent InterruptibleTTSService. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "LmntTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "LmntTTSSettings", "model") + + default_settings = LmntTTSSettings( + model=model or "blizzard", + voice=voice_id, + language=self.language_to_service_language(language), + format="raw", + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( push_stop_frames=True, pause_frame_processing=True, sample_rate=sample_rate, - settings=LmntTTSSettings( - model=model, - voice=voice_id, - language=self.language_to_service_language(language), - format="raw", - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/minimax/tts.py b/src/pipecat/services/minimax/tts.py index 116d24a34..602654e2f 100644 --- a/src/pipecat/services/minimax/tts.py +++ b/src/pipecat/services/minimax/tts.py @@ -26,7 +26,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -166,6 +166,9 @@ class MiniMaxHttpTTSService(TTSService): class InputParams(BaseModel): """Configuration parameters for MiniMax TTS. + .. deprecated:: 1.0 + Use ``MiniMaxTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language for TTS generation. Supports 40 languages. Note: Filipino, Tamil, and Persian require speech-2.6-* models. @@ -201,11 +204,12 @@ class MiniMaxHttpTTSService(TTSService): api_key: str, base_url: str = "https://api.minimax.io/v1/t2a_v2", group_id: str, - model: str = "speech-02-turbo", - voice_id: str = "Calm_Woman", + model: Optional[str] = None, + voice_id: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[MiniMaxTTSSettings] = None, **kwargs, ): """Initialize the MiniMax TTS service. @@ -221,50 +225,45 @@ class MiniMaxHttpTTSService(TTSService): "speech-2.6-hd", "speech-2.6-turbo" (latest, supports Filipino/Tamil/Persian), "speech-02-hd", "speech-02-turbo", "speech-01-hd", "speech-01-turbo". + + .. deprecated:: 1.0 + Use ``settings=MiniMaxTTSSettings(model=...)`` instead. + voice_id: Voice identifier. Defaults to "Calm_Woman". + + .. deprecated:: 1.0 + Use ``settings=MiniMaxTTSSettings(voice=...)`` instead. + aiohttp_session: aiohttp.ClientSession for API communication. sample_rate: Output audio sample rate in Hz. If None, uses pipeline default. params: Additional configuration parameters. + + .. deprecated:: 1.0 + Use ``settings=MiniMaxTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or MiniMaxHttpTTSService.InputParams() + if model is not None: + _warn_deprecated_param("model", "MiniMaxTTSSettings", "model") + if voice_id is not None: + _warn_deprecated_param("voice_id", "MiniMaxTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "MiniMaxTTSSettings") - super().__init__( - sample_rate=sample_rate, - settings=MiniMaxTTSSettings( - model=model, - voice=voice_id, - language=None, - stream=True, - speed=params.speed, - volume=params.volume, - pitch=params.pitch, - language_boost=None, - emotion=None, - text_normalization=None, - latex_read=None, - audio_bitrate=128000, - audio_format="pcm", - audio_channel=1, - audio_sample_rate=0, - ), - **kwargs, - ) + _params = params or MiniMaxHttpTTSService.InputParams() - self._api_key = api_key - self._group_id = group_id - self._base_url = f"{base_url}?GroupId={group_id}" - self._session = aiohttp_session - - # Add language boost if provided - if params.language: - service_lang = self.language_to_service_language(params.language) + # Resolve language boost + language_boost = None + if _params.language: + service_lang = self.language_to_service_language(_params.language) if service_lang: - self._settings.language_boost = service_lang + language_boost = service_lang - # Add optional emotion if provided - if params.emotion: - # Validate emotion is in the supported list + # Resolve emotion + emotion = None + if _params.emotion: supported_emotions = [ "happy", "sad", @@ -275,15 +274,16 @@ class MiniMaxHttpTTSService(TTSService): "neutral", "fluent", ] - if params.emotion in supported_emotions: - self._settings.emotion = params.emotion + if _params.emotion in supported_emotions: + emotion = _params.emotion else: logger.warning( - f"Unsupported emotion: {params.emotion}. Supported emotions: {supported_emotions}" + f"Unsupported emotion: {_params.emotion}. Supported emotions: {supported_emotions}" ) - # If `english_normalization`, add `text_normalization` and print warning - if params.english_normalization is not None: + # Resolve text_normalization + text_normalization = None + if _params.english_normalization is not None: import warnings with warnings.catch_warnings(): @@ -292,15 +292,40 @@ class MiniMaxHttpTTSService(TTSService): "Parameter `english_normalization` is deprecated and will be removed in a future version. Use `text_normalization` instead.", DeprecationWarning, ) - self._settings.text_normalization = params.english_normalization + text_normalization = _params.english_normalization + if _params.text_normalization is not None: + text_normalization = _params.text_normalization - # Add text_normalization if provided (corrected parameter name) - if params.text_normalization is not None: - self._settings.text_normalization = params.text_normalization + default_settings = MiniMaxTTSSettings( + model=model or "speech-02-turbo", + voice=voice_id or "Calm_Woman", + language=None, + stream=True, + speed=_params.speed, + volume=_params.volume, + pitch=_params.pitch, + language_boost=language_boost, + emotion=emotion, + text_normalization=text_normalization, + latex_read=_params.latex_read, + audio_bitrate=128000, + audio_format="pcm", + audio_channel=1, + audio_sample_rate=0, + ) + if settings is not None: + default_settings.apply_update(settings) - # Add latex_read if provided - if params.latex_read is not None: - self._settings.latex_read = params.latex_read + super().__init__( + sample_rate=sample_rate, + settings=default_settings, + **kwargs, + ) + + self._api_key = api_key + self._group_id = group_id + self._base_url = f"{base_url}?GroupId={group_id}" + self._session = aiohttp_session def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index 984ffb7dd..e4249741e 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -6,14 +6,16 @@ """Mistral LLM service implementation using OpenAI-compatible interface.""" -from typing import List, Sequence +from typing import List, Optional, Sequence from loguru import logger 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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class MistralLLMService(OpenAILLMService): @@ -28,7 +30,8 @@ class MistralLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.mistral.ai/v1", - model: str = "mistral-small-latest", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Mistral LLM service. @@ -37,9 +40,22 @@ class MistralLLMService(OpenAILLMService): api_key: The API key for accessing Mistral's API. base_url: The base URL for Mistral API. Defaults to "https://api.mistral.ai/v1". model: The model identifier to use. Defaults to "mistral-small-latest". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "mistral-small-latest") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Mistral API endpoint. diff --git a/src/pipecat/services/moondream/vision.py b/src/pipecat/services/moondream/vision.py index 53b98b77a..db449d7ed 100644 --- a/src/pipecat/services/moondream/vision.py +++ b/src/pipecat/services/moondream/vision.py @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( VisionFullResponseStartFrame, VisionTextFrame, ) -from pipecat.services.settings import VisionSettings +from pipecat.services.settings import VisionSettings, _warn_deprecated_param from pipecat.services.vision_service import VisionService try: @@ -80,17 +80,36 @@ class MoondreamService(VisionService): """ def __init__( - self, *, model="vikhyatk/moondream2", revision="2025-01-09", use_cpu=False, **kwargs + self, + *, + model: Optional[str] = None, + revision="2025-01-09", + use_cpu=False, + settings: Optional[MoondreamSettings] = None, + **kwargs, ): """Initialize the Moondream service. Args: model: Hugging Face model identifier for the Moondream model. + + .. deprecated:: 1.0 + Use ``settings=MoondreamSettings(model=...)`` instead. + revision: Specific model revision to use. use_cpu: Whether to force CPU usage instead of hardware acceleration. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent VisionService. """ - super().__init__(settings=MoondreamSettings(model=model), **kwargs) + if model is not None: + _warn_deprecated_param("model", "MoondreamSettings", "model") + + default_settings = MoondreamSettings(model=model or "vikhyatk/moondream2") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) if not use_cpu: device, dtype = detect_device() @@ -101,7 +120,7 @@ class MoondreamService(VisionService): logger.debug("Loading Moondream model...") self._model = AutoModelForCausalLM.from_pretrained( - model, + self._settings.model, trust_remote_code=True, revision=revision, device_map={"": device}, diff --git a/src/pipecat/services/neuphonic/tts.py b/src/pipecat/services/neuphonic/tts.py index 63411c3eb..21c7b57dd 100644 --- a/src/pipecat/services/neuphonic/tts.py +++ b/src/pipecat/services/neuphonic/tts.py @@ -35,7 +35,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import InterruptibleTTSService, TextAggregationMode, TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -102,6 +102,9 @@ class NeuphonicTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Input parameters for Neuphonic TTS configuration. + .. deprecated:: 1.0 + Use ``settings=NeuphonicTTSSettings(...)`` instead. + Parameters: language: Language for synthesis. Defaults to English. speed: Speech speed multiplier. Defaults to 1.0. @@ -119,6 +122,7 @@ class NeuphonicTTSService(InterruptibleTTSService): sample_rate: Optional[int] = 22050, encoding: str = "pcm_linear", params: Optional[InputParams] = None, + settings: Optional[NeuphonicTTSSettings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -128,10 +132,20 @@ class NeuphonicTTSService(InterruptibleTTSService): Args: api_key: Neuphonic API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. + url: WebSocket URL for the Neuphonic API. sample_rate: Audio sample rate in Hz. Defaults to 22050. encoding: Audio encoding format. Defaults to "pcm_linear". params: Additional input parameters for TTS configuration. + + .. deprecated:: 1.0 + Use ``settings=NeuphonicTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. aggregate_sentences: Deprecated. Use text_aggregation_mode instead. .. deprecated:: 0.0.104 @@ -140,7 +154,23 @@ class NeuphonicTTSService(InterruptibleTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to parent InterruptibleTTSService. """ - params = params or NeuphonicTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "NeuphonicTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "NeuphonicTTSSettings") + + _params = params or NeuphonicTTSService.InputParams() + + default_settings = NeuphonicTTSSettings( + model=None, + language=self.language_to_service_language(_params.language), + speed=_params.speed, + encoding=encoding, + sampling_rate=sample_rate, + voice=voice_id, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( aggregate_sentences=aggregate_sentences, @@ -148,14 +178,7 @@ class NeuphonicTTSService(InterruptibleTTSService): push_stop_frames=True, stop_frame_timeout_s=2.0, sample_rate=sample_rate, - settings=NeuphonicTTSSettings( - model=None, - language=self.language_to_service_language(params.language), - speed=params.speed, - encoding=encoding, - sampling_rate=sample_rate, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -418,6 +441,9 @@ class NeuphonicHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Neuphonic HTTP TTS configuration. + .. deprecated:: 1.0 + Use ``settings=NeuphonicTTSSettings(...)`` instead. + Parameters: language: Language for synthesis. Defaults to English. speed: Speech speed multiplier. Defaults to 1.0. @@ -436,6 +462,7 @@ class NeuphonicHttpTTSService(TTSService): sample_rate: Optional[int] = 22050, encoding: Optional[str] = "pcm_linear", params: Optional[InputParams] = None, + settings: Optional[NeuphonicTTSSettings] = None, **kwargs, ): """Initialize the Neuphonic HTTP TTS service. @@ -443,25 +470,44 @@ class NeuphonicHttpTTSService(TTSService): Args: api_key: Neuphonic API key for authentication. voice_id: ID of the voice to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. + aiohttp_session: Shared aiohttp session for HTTP requests. url: Base URL for the Neuphonic HTTP API. sample_rate: Audio sample rate in Hz. Defaults to 22050. encoding: Audio encoding format. Defaults to "pcm_linear". params: Additional input parameters for TTS configuration. + + .. deprecated:: 1.0 + Use ``settings=NeuphonicTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or NeuphonicHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "NeuphonicTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "NeuphonicTTSSettings") + + _params = params or NeuphonicHttpTTSService.InputParams() + + default_settings = NeuphonicTTSSettings( + model=None, + voice=voice_id, + language=self.language_to_service_language(_params.language) or "en", + speed=_params.speed, + encoding=encoding, + sampling_rate=sample_rate, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=NeuphonicTTSSettings( - model=None, - voice=voice_id, - language=self.language_to_service_language(params.language) or "en", - speed=params.speed, - encoding=encoding, - sampling_rate=sample_rate, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index c5db58f31..ef4afe848 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -10,10 +10,14 @@ This module provides a service for interacting with NVIDIA's NIM (NVIDIA Inferen Microservice) API while maintaining compatibility with the OpenAI-style interface. """ +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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class NvidiaLLMService(OpenAILLMService): @@ -29,7 +33,8 @@ class NvidiaLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://integrate.api.nvidia.com/v1", - model: str = "nvidia/llama-3.1-nemotron-70b-instruct", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the NvidiaLLMService. @@ -37,10 +42,26 @@ class NvidiaLLMService(OpenAILLMService): Args: api_key: The API key for accessing NVIDIA's NIM API. base_url: The base URL for NIM API. Defaults to "https://integrate.api.nvidia.com/v1". - model: The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct". + model: The model identifier to use. Defaults to + "nvidia/llama-3.1-nemotron-70b-instruct". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings( + model=model or "nvidia/llama-3.1-nemotron-70b-instruct" + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) # Counters for accumulating token usage metrics self._prompt_tokens = 0 self._completion_tokens = 0 diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index 950515096..7f9c28f8f 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( StartFrame, TranscriptionFrame, ) -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import NVIDIA_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService, STTService from pipecat.transcriptions.language import Language, resolve_language @@ -130,6 +130,9 @@ class NvidiaSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva STT service. + .. deprecated:: 1.0 + Use ``settings=NvidiaSTTSettings(...)`` instead. + Parameters: language: Target language for transcription. Defaults to EN_US. """ @@ -148,6 +151,7 @@ class NvidiaSTTService(STTService): sample_rate: Optional[int] = None, params: Optional[InputParams] = None, use_ssl: bool = True, + settings: Optional[NvidiaSTTSettings] = None, ttfs_p99_latency: Optional[float] = NVIDIA_TTFS_P99, **kwargs, ): @@ -159,20 +163,33 @@ class NvidiaSTTService(STTService): model_function_map: Mapping containing 'function_id' and 'model_name' for the ASR model. sample_rate: Audio sample rate in Hz. If None, uses pipeline default. params: Additional configuration parameters for NVIDIA Riva. + + .. deprecated:: 1.0 + Use ``settings=NvidiaSTTSettings(...)`` instead. + use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to STTService. """ - params = params or NvidiaSTTService.InputParams() + if params is not None: + _warn_deprecated_param("params", "NvidiaSTTSettings") + + _params = params or NvidiaSTTService.InputParams() + + default_settings = NvidiaSTTSettings( + model=model_function_map.get("model_name"), + language=_params.language, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=NvidiaSTTSettings( - model=model_function_map.get("model_name"), - language=params.language, - ), + settings=default_settings, **kwargs, ) @@ -421,6 +438,9 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva segmented STT service. + .. deprecated:: 1.0 + Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. + Parameters: language: Target language for transcription. Defaults to EN_US. profanity_filter: Whether to filter profanity from results. @@ -449,6 +469,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): sample_rate: Optional[int] = None, params: Optional[InputParams] = None, use_ssl: bool = True, + settings: Optional[NvidiaSegmentedSTTSettings] = None, ttfs_p99_latency: Optional[float] = NVIDIA_TTFS_P99, **kwargs, ): @@ -460,26 +481,39 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): model_function_map: Mapping of model name and its corresponding NVIDIA Cloud Function ID sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate params: Additional configuration parameters for NVIDIA Riva + + .. deprecated:: 1.0 + Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. + use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService """ - params = params or NvidiaSegmentedSTTService.InputParams() + if params is not None: + _warn_deprecated_param("params", "NvidiaSegmentedSTTSettings") + + _params = params or NvidiaSegmentedSTTService.InputParams() + + default_settings = NvidiaSegmentedSTTSettings( + model=model_function_map.get("model_name"), + language=self.language_to_service_language(_params.language or Language.EN_US) + or "en-US", + profanity_filter=_params.profanity_filter, + automatic_punctuation=_params.automatic_punctuation, + verbatim_transcripts=_params.verbatim_transcripts, + boosted_lm_words=_params.boosted_lm_words, + boosted_lm_score=_params.boosted_lm_score, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=NvidiaSegmentedSTTSettings( - model=model_function_map.get("model_name"), - language=self.language_to_service_language(params.language or Language.EN_US) - or "en-US", - profanity_filter=params.profanity_filter, - automatic_punctuation=params.automatic_punctuation, - verbatim_transcripts=params.verbatim_transcripts, - boosted_lm_words=params.boosted_lm_words, - boosted_lm_score=params.boosted_lm_score, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/nvidia/tts.py b/src/pipecat/services/nvidia/tts.py index 6785e9631..0f7491645 100644 --- a/src/pipecat/services/nvidia/tts.py +++ b/src/pipecat/services/nvidia/tts.py @@ -31,7 +31,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language @@ -68,6 +68,9 @@ class NvidiaTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Riva TTS configuration. + .. deprecated:: 1.0 + Use ``NvidiaTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language code for synthesis. Defaults to US English. quality: Audio quality setting (0-100). Defaults to 20. @@ -81,13 +84,14 @@ class NvidiaTTSService(TTSService): *, api_key: str, server: str = "grpc.nvcf.nvidia.com:443", - voice_id: str = "Magpie-Multilingual.EN-US.Aria", + voice_id: Optional[str] = None, sample_rate: Optional[int] = None, model_function_map: Mapping[str, str] = { "function_id": "877104f7-e885-42b9-8de8-f6e4c6303969", "model_name": "magpie-tts-multilingual", }, params: Optional[InputParams] = None, + settings: Optional[NvidiaTTSSettings] = None, use_ssl: bool = True, **kwargs, ): @@ -96,23 +100,42 @@ class NvidiaTTSService(TTSService): Args: api_key: NVIDIA API key for authentication. server: gRPC server endpoint. Defaults to NVIDIA's cloud endpoint. - voice_id: Voice model identifier. Defaults to multilingual Ray voice. + voice_id: Voice model identifier. Defaults to multilingual Aria voice. + + .. deprecated:: 1.0 + Use ``settings=NvidiaTTSSettings(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:: 1.0 + Use ``settings=NvidiaTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or NvidiaTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "NvidiaTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "NvidiaTTSSettings") + + _params = params or NvidiaTTSService.InputParams() + + default_settings = NvidiaTTSSettings( + model=model_function_map.get("model_name"), + voice=voice_id or "Magpie-Multilingual.EN-US.Aria", + language=_params.language, + quality=_params.quality, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=NvidiaTTSSettings( - model=model_function_map.get("model_name"), - voice=voice_id, - language=params.language, - quality=params.quality, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index 04f22bbae..ecae3fc95 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -6,9 +6,13 @@ """OLLama LLM service implementation for Pipecat AI framework.""" +from typing import Optional + from loguru import logger +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class OLLamaLLMService(OpenAILLMService): @@ -19,17 +23,35 @@ class OLLamaLLMService(OpenAILLMService): """ def __init__( - self, *, model: str = "llama2", base_url: str = "http://localhost:11434/v1", **kwargs + self, + *, + model: Optional[str] = None, + base_url: str = "http://localhost:11434/v1", + settings: Optional[OpenAILLMSettings] = None, + **kwargs, ): """Initialize OLLama LLM service. Args: model: The OLLama model to use. Defaults to "llama2". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + base_url: The base URL for the OLLama API endpoint. Defaults to "http://localhost:11434/v1". + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(model=model, base_url=base_url, api_key="ollama", **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "llama2") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(base_url=base_url, api_key="ollama", settings=default_settings, **kwargs) def create_client(self, base_url=None, **kwargs): """Create OpenAI-compatible client for Ollama. diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index dfef1ae90..9ff3af0ab 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -75,6 +75,10 @@ class BaseOpenAILLMService(LLMService): class InputParams(BaseModel): """Input parameters for OpenAI model configuration. + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(...)`` instead of + ``params=InputParams(...)``. + Parameters: frequency_penalty: Penalty for frequent tokens (-2.0 to 2.0). presence_penalty: Penalty for new tokens (-2.0 to 2.0). @@ -108,13 +112,14 @@ class BaseOpenAILLMService(LLMService): def __init__( self, *, - model: str, + model: Optional[str] = None, api_key=None, base_url=None, organization=None, project=None, default_headers: Optional[Mapping[str, str]] = None, params: Optional[InputParams] = None, + settings: Optional[OpenAILLMSettings] = None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, system_instruction: Optional[str] = None, @@ -124,35 +129,50 @@ class BaseOpenAILLMService(LLMService): Args: model: The OpenAI model name to use (e.g., "gpt-4.1", "gpt-4o"). + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + api_key: OpenAI API key. If None, uses environment variable. base_url: Custom base URL for OpenAI API. If None, uses default. organization: OpenAI organization ID. project: OpenAI project ID. default_headers: Additional HTTP headers to include in requests. params: Input parameters for model configuration and behavior. + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. retry_timeout_secs: Request timeout in seconds. Defaults to 5.0 seconds. retry_on_timeout: Whether to retry the request once if it times out. system_instruction: Optional system instruction to prepend to messages. **kwargs: Additional arguments passed to the parent LLMService. """ - params = params or BaseOpenAILLMService.InputParams() + _params = params or BaseOpenAILLMService.InputParams() + + default_settings = OpenAILLMSettings( + model=model or "gpt-4o", + frequency_penalty=_params.frequency_penalty, + presence_penalty=_params.presence_penalty, + seed=_params.seed, + temperature=_params.temperature, + top_p=_params.top_p, + top_k=None, + max_tokens=_params.max_tokens, + max_completion_tokens=_params.max_completion_tokens, + service_tier=_params.service_tier, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + extra=_params.extra if isinstance(_params.extra, dict) else {}, + ) + + if settings is not None: + default_settings.apply_update(settings) super().__init__( - settings=OpenAILLMSettings( - model=model, - frequency_penalty=params.frequency_penalty, - presence_penalty=params.presence_penalty, - seed=params.seed, - temperature=params.temperature, - top_p=params.top_p, - top_k=None, - max_tokens=params.max_tokens, - max_completion_tokens=params.max_completion_tokens, - service_tier=params.service_tier, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - extra=params.extra if isinstance(params.extra, dict) else {}, - ), + settings=default_settings, **kwargs, ) self._retry_timeout_secs = retry_timeout_secs diff --git a/src/pipecat/services/openai/image.py b/src/pipecat/services/openai/image.py index f35a5ded8..2dc66876c 100644 --- a/src/pipecat/services/openai/image.py +++ b/src/pipecat/services/openai/image.py @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( URLImageRawFrame, ) from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings +from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param @dataclass @@ -52,7 +52,8 @@ class OpenAIImageGenService(ImageGenService): base_url: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, image_size: Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"], - model: str = "dall-e-3", + model: Optional[str] = None, + settings: Optional[OpenAIImageGenSettings] = None, ): """Initialize the OpenAI image generation service. @@ -62,8 +63,21 @@ class OpenAIImageGenService(ImageGenService): aiohttp_session: HTTP session for downloading generated images. image_size: Target size for generated images. model: DALL-E model to use for generation. Defaults to "dall-e-3". + + .. deprecated:: 1.0 + Use ``settings=OpenAIImageGenSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. """ - super().__init__(settings=OpenAIImageGenSettings(model=model)) + if model is not None: + _warn_deprecated_param("model", "OpenAIImageGenSettings", "model") + + default_settings = OpenAIImageGenSettings(model=model or "dall-e-3") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings) self._image_size = image_size self._client = AsyncOpenAI(api_key=api_key, base_url=base_url) self._aiohttp_session = aiohttp_session diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index b760b0d6e..c259987a8 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -23,7 +23,8 @@ 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 +from pipecat.services.openai.base_llm import BaseOpenAILLMService, OpenAILLMSettings +from pipecat.services.settings import _warn_deprecated_param @dataclass @@ -72,18 +73,53 @@ class OpenAILLMService(BaseOpenAILLMService): def __init__( self, *, - model: str = "gpt-4.1", + model: Optional[str] = None, params: Optional[BaseOpenAILLMService.InputParams] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize OpenAI LLM service. Args: model: The OpenAI model name to use. Defaults to "gpt-4.1". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + params: Input parameters for model configuration. + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent BaseOpenAILLMService. """ - super().__init__(model=model, params=params, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + if params is not None: + _warn_deprecated_param("params", "OpenAILLMSettings") + + _params = params or BaseOpenAILLMService.InputParams() + default_settings = OpenAILLMSettings( + model=model or "gpt-4.1", + frequency_penalty=_params.frequency_penalty, + presence_penalty=_params.presence_penalty, + seed=_params.seed, + temperature=_params.temperature, + top_p=_params.top_p, + top_k=None, + max_tokens=_params.max_tokens, + max_completion_tokens=_params.max_completion_tokens, + service_tier=_params.service_tier, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + extra=_params.extra if isinstance(_params.extra, dict) else {}, + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) def create_context_aggregator( self, diff --git a/src/pipecat/services/openai/realtime/llm.py b/src/pipecat/services/openai/realtime/llm.py index 07b6aa82b..d6e7a71bd 100644 --- a/src/pipecat/services/openai/realtime/llm.py +++ b/src/pipecat/services/openai/realtime/llm.py @@ -59,7 +59,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_openai_realtime, traced_stt @@ -121,9 +121,10 @@ class OpenAIRealtimeLLMService(LLMService): self, *, api_key: str, - model: str = "gpt-realtime-1.5", + model: Optional[str] = None, base_url: str = "wss://api.openai.com/v1/realtime", session_properties: Optional[events.SessionProperties] = None, + settings: Optional[OpenAIRealtimeLLMSettings] = None, start_audio_paused: bool = False, start_video_paused: bool = False, video_frame_detail: str = "auto", @@ -134,14 +135,25 @@ class OpenAIRealtimeLLMService(LLMService): Args: api_key: OpenAI API key for authentication. - model: OpenAI model name. Defaults to "gpt-realtime". + model: OpenAI model name. + + .. deprecated:: + Use ``settings=OpenAIRealtimeLLMSettings(model=...)`` instead. + This is a connection-level parameter set via the WebSocket URL query parameter and cannot be changed during the session. base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.openai.com/v1/realtime". session_properties: Configuration properties for the realtime session. + + .. deprecated:: + Use ``settings=OpenAIRealtimeLLMSettings(session_properties=...)`` + instead. + These are session-level settings that can be updated during the session (except for voice and model). If None, uses default SessionProperties. + settings: Realtime LLM settings. If provided together with deprecated + top-level parameters, the ``settings`` values take precedence. 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. video_frame_detail: Detail level for video processing. Can be "auto", "low", or "high". @@ -156,6 +168,12 @@ class OpenAIRealtimeLLMService(LLMService): **kwargs: Additional arguments passed to parent LLMService. """ + if model is not None: + _warn_deprecated_param("model", "OpenAIRealtimeLLMSettings", "model") + if session_properties is not None: + _warn_deprecated_param( + "session_properties", "OpenAIRealtimeLLMSettings", "session_properties" + ) if send_transcription_frames is not None: import warnings @@ -168,24 +186,28 @@ class OpenAIRealtimeLLMService(LLMService): stacklevel=2, ) + default_settings = OpenAIRealtimeLLMSettings( + model=model or "gpt-realtime-1.5", + temperature=None, + max_tokens=None, + top_p=None, + top_k=None, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + session_properties=session_properties or events.SessionProperties(), + ) + if settings is not None: + default_settings.apply_update(settings) + # Build WebSocket URL with model query parameter # Source: https://platform.openai.com/docs/guides/realtime-websocket - full_url = f"{base_url}?model={model}" + full_url = f"{base_url}?model={default_settings.model}" super().__init__( base_url=full_url, - settings=OpenAIRealtimeLLMSettings( - model=model, - temperature=None, - max_tokens=None, - top_p=None, - top_k=None, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - session_properties=session_properties or events.SessionProperties(), - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index 32895f8b5..be933cd9a 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -35,10 +35,14 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import OPENAI_REALTIME_TTFS_P99, OPENAI_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService -from pipecat.services.whisper.base_stt import BaseWhisperSTTService, Transcription +from pipecat.services.whisper.base_stt import ( + BaseWhisperSTTService, + BaseWhisperSTTSettings, + Transcription, +) from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_stt @@ -61,30 +65,40 @@ class OpenAISTTService(BaseWhisperSTTService): def __init__( self, *, - model: str = "gpt-4o-transcribe", + model: Optional[str] = None, api_key: Optional[str] = None, base_url: Optional[str] = None, language: Optional[Language] = Language.EN, prompt: Optional[str] = None, temperature: Optional[float] = None, + settings: Optional[BaseWhisperSTTSettings] = None, ttfs_p99_latency: Optional[float] = OPENAI_TTFS_P99, **kwargs, ): """Initialize OpenAI STT service. Args: - model: Model to use — either gpt-4o or Whisper. Defaults to "gpt-4o-transcribe". + model: Model to use — either gpt-4o or Whisper. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(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. prompt: Optional text to guide the model's style or continue a previous segment. temperature: Optional sampling temperature between 0 and 1. Defaults to 0.0. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to BaseWhisperSTTService. """ + if model is not None: + _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") + super().__init__( - model=model, + model=model or "gpt-4o-transcribe", api_key=api_key, base_url=base_url, language=language, @@ -94,6 +108,9 @@ class OpenAISTTService(BaseWhisperSTTService): **kwargs, ) + if settings is not None: + self._settings.apply_update(settings) + async def _transcribe(self, audio: bytes) -> Transcription: assert self._language is not None # Assigned in the BaseWhisperSTTService class @@ -175,13 +192,14 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): self, *, api_key: str, - model: str = "gpt-4o-transcribe", + model: Optional[str] = None, base_url: str = "wss://api.openai.com/v1/realtime", language: Optional[Language] = Language.EN, prompt: Optional[str] = None, 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, ttfs_p99_latency: Optional[float] = OPENAI_REALTIME_TTFS_P99, **kwargs, ): @@ -191,7 +209,10 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): api_key: OpenAI API key for authentication. model: Transcription model. Supported values are ``"gpt-4o-transcribe"`` and ``"gpt-4o-mini-transcribe"``. - Defaults to ``"gpt-4o-transcribe"``. + + .. deprecated:: 1.0 + Use ``settings=OpenAIRealtimeSTTSettings(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. @@ -208,6 +229,8 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): 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. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent @@ -219,13 +242,20 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): "Install it with: pip install pipecat-ai[openai]" ) + if model is not None: + _warn_deprecated_param("model", "OpenAIRealtimeSTTSettings", "model") + + default_settings = OpenAIRealtimeSTTSettings( + model=model or "gpt-4o-transcribe", + language=language, + prompt=prompt, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( ttfs_p99_latency=ttfs_p99_latency, - settings=OpenAIRealtimeSTTSettings( - model=model, - language=language, - prompt=prompt, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index f95d79134..965b8faf7 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -90,6 +90,9 @@ class OpenAITTSService(TTSService): class InputParams(BaseModel): """Input parameters for OpenAI TTS configuration. + .. deprecated:: 1.0 + Use ``settings=OpenAITTSSettings(...)`` instead. + Parameters: instructions: Instructions to guide voice synthesis behavior. speed: Voice speed control (0.25 to 4.0, default 1.0). @@ -103,12 +106,13 @@ class OpenAITTSService(TTSService): *, api_key: Optional[str] = None, base_url: Optional[str] = None, - voice: str = "alloy", - model: str = "gpt-4o-mini-tts", + voice: Optional[str] = None, + model: Optional[str] = None, sample_rate: Optional[int] = None, instructions: Optional[str] = None, speed: Optional[float] = None, params: Optional[InputParams] = None, + settings: Optional[OpenAITTSSettings] = None, **kwargs, ): """Initialize OpenAI TTS service. @@ -117,40 +121,69 @@ class OpenAITTSService(TTSService): api_key: OpenAI API key for authentication. If None, uses environment variable. base_url: Custom base URL for OpenAI API. If None, uses default. voice: Voice ID to use for synthesis. Defaults to "alloy". + + .. deprecated:: 1.0 + Use ``settings=OpenAITTSSettings(voice=...)`` instead. + model: TTS model to use. Defaults to "gpt-4o-mini-tts". + + .. deprecated:: 1.0 + Use ``settings=OpenAITTSSettings(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. - speed: Voice speed control (0.25 to 4.0, default 1.0). - params: Optional synthesis controls (acting instructions, speed, ...). - **kwargs: Additional keyword arguments passed to TTSService. - .. deprecated:: 0.0.91 - The `instructions` and `speed` parameters are deprecated, use `InputParams` instead. + .. deprecated:: 1.0 + Use ``settings=OpenAITTSSettings(instructions=...)`` instead. + + speed: Voice speed control (0.25 to 4.0, default 1.0). + + .. deprecated:: 1.0 + Use ``settings=OpenAITTSSettings(speed=...)`` instead. + + params: Optional synthesis controls (acting instructions, speed, ...). + + .. deprecated:: 1.0 + Use ``settings=OpenAITTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. + **kwargs: Additional keyword arguments passed to TTSService. """ + if voice is not None: + _warn_deprecated_param("voice", "OpenAITTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "OpenAITTSSettings", "model") + if instructions is not None: + _warn_deprecated_param("instructions", "OpenAITTSSettings", "instructions") + if speed is not None: + _warn_deprecated_param("speed", "OpenAITTSSettings", "speed") + if params is not None: + _warn_deprecated_param("params", "OpenAITTSSettings") + if sample_rate and sample_rate != self.OPENAI_SAMPLE_RATE: logger.warning( f"OpenAI TTS only supports {self.OPENAI_SAMPLE_RATE}Hz sample rate. " f"Current rate of {sample_rate}Hz may cause issues." ) - if instructions or speed: - import warnings - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - "The `instructions` and `speed` parameters are deprecated, use `InputParams` instead.", - DeprecationWarning, - stacklevel=2, - ) + _params = params or OpenAITTSService.InputParams() + _instructions = instructions if instructions is not None else _params.instructions + _speed = speed if speed is not None else _params.speed + + default_settings = OpenAITTSSettings( + model=model or "gpt-4o-mini-tts", + voice=voice or "alloy", + language=None, + instructions=_instructions, + speed=_speed, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=OpenAITTSSettings( - model=model, - voice=voice, - instructions=params.instructions if params else instructions, - speed=params.speed if params else speed, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index c912ed45c..cb660ce72 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -54,7 +54,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService from pipecat.services.openai.llm import OpenAIContextAggregatorPair -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_openai_realtime, traced_stt @@ -126,9 +126,10 @@ class OpenAIRealtimeBetaLLMService(LLMService): self, *, api_key: str, - model: str = "gpt-4o-realtime-preview-2025-06-03", + model: Optional[str] = None, base_url: str = "wss://api.openai.com/v1/realtime", session_properties: Optional[events.SessionProperties] = None, + settings: Optional[OpenAIRealtimeBetaLLMSettings] = None, start_audio_paused: bool = False, send_transcription_frames: bool = True, **kwargs, @@ -137,11 +138,22 @@ class OpenAIRealtimeBetaLLMService(LLMService): Args: api_key: OpenAI API key for authentication. - model: OpenAI model name. Defaults to "gpt-4o-realtime-preview-2025-06-03". + model: OpenAI model name. + + .. deprecated:: + Use ``settings=OpenAIRealtimeBetaLLMSettings(model=...)`` instead. + base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.openai.com/v1/realtime". session_properties: Configuration properties for the realtime session. + + .. deprecated:: + Use ``settings=OpenAIRealtimeBetaLLMSettings(session_properties=...)`` + instead. + If None, uses default SessionProperties. + settings: Realtime Beta LLM settings. If provided together with deprecated + top-level parameters, the ``settings`` values take precedence. start_audio_paused: Whether to start with audio input paused. Defaults to False. send_transcription_frames: Whether to emit transcription frames. Defaults to True. **kwargs: Additional arguments passed to parent LLMService. @@ -155,22 +167,33 @@ class OpenAIRealtimeBetaLLMService(LLMService): stacklevel=2, ) - full_url = f"{base_url}?model={model}" + if model is not None: + _warn_deprecated_param("model", "OpenAIRealtimeBetaLLMSettings", "model") + if session_properties is not None: + _warn_deprecated_param( + "session_properties", "OpenAIRealtimeBetaLLMSettings", "session_properties" + ) + + default_settings = OpenAIRealtimeBetaLLMSettings( + model=model or "gpt-4o-realtime-preview-2025-06-03", + temperature=None, + max_tokens=None, + top_p=None, + top_k=None, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + session_properties=session_properties or events.SessionProperties(), + ) + if settings is not None: + default_settings.apply_update(settings) + + full_url = f"{base_url}?model={default_settings.model}" super().__init__( base_url=full_url, - settings=OpenAIRealtimeBetaLLMSettings( - model=model, - temperature=None, - max_tokens=None, - top_p=None, - top_k=None, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - session_properties=session_properties or events.SessionProperties(), - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index fa53c1554..524eff860 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -15,7 +15,9 @@ 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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param try: from openpipe import AsyncOpenAI as OpenPipeAI @@ -36,31 +38,45 @@ class OpenPipeLLMService(OpenAILLMService): def __init__( self, *, - model: str = "gpt-4.1", + model: Optional[str] = None, api_key: Optional[str] = None, base_url: Optional[str] = None, openpipe_api_key: Optional[str] = None, openpipe_base_url: str = "https://app.openpipe.ai/api/v1", tags: Optional[Dict[str, str]] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize OpenPipe LLM service. Args: model: The model name to use. Defaults to "gpt-4.1". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(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. openpipe_api_key: OpenPipe API key for enhanced features. If None, reads from environment. openpipe_base_url: OpenPipe API endpoint URL. Defaults to "https://app.openpipe.ai/api/v1". tags: Optional dictionary of tags to apply to all requests for tracking. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent OpenAILLMService. """ + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "gpt-4.1") + if settings is not None: + default_settings.apply_update(settings) + super().__init__( - model=model, api_key=api_key, base_url=base_url, openpipe_api_key=openpipe_api_key, openpipe_base_url=openpipe_base_url, + settings=default_settings, **kwargs, ) self._tags = tags diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index c33fda2fc..9b202c04d 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -14,7 +14,9 @@ from typing import Any, Dict, Optional from loguru import logger +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class OpenRouterLLMService(OpenAILLMService): @@ -28,8 +30,9 @@ class OpenRouterLLMService(OpenAILLMService): self, *, api_key: Optional[str] = None, - model: str = "openai/gpt-4o-2024-11-20", + model: Optional[str] = None, base_url: str = "https://openrouter.ai/api/v1", + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the OpenRouter LLM service. @@ -38,13 +41,26 @@ class OpenRouterLLMService(OpenAILLMService): api_key: The API key for accessing OpenRouter's API. If None, will attempt to read from environment variables. model: The model identifier to use. Defaults to "openai/gpt-4o-2024-11-20". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(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 + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "openai/gpt-4o-2024-11-20") + if settings is not None: + default_settings.apply_update(settings) + super().__init__( api_key=api_key, base_url=base_url, - model=model, + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index e03bace8d..b00f9e974 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -11,11 +11,15 @@ an OpenAI-compatible interface. It handles Perplexity's unique token usage reporting patterns while maintaining compatibility with the Pipecat framework. """ +from typing import Optional + 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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class PerplexityLLMService(OpenAILLMService): @@ -31,7 +35,8 @@ class PerplexityLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.perplexity.ai", - model: str = "sonar", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Perplexity LLM service. @@ -40,9 +45,22 @@ class PerplexityLLMService(OpenAILLMService): api_key: The API key for accessing Perplexity's API. base_url: The base URL for Perplexity's API. Defaults to "https://api.perplexity.ai". model: The model identifier to use. Defaults to "sonar". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "sonar") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) # Counters for accumulating token usage metrics self._prompt_tokens = 0 self._completion_tokens = 0 diff --git a/src/pipecat/services/piper/tts.py b/src/pipecat/services/piper/tts.py index c4831b839..559824b49 100644 --- a/src/pipecat/services/piper/tts.py +++ b/src/pipecat/services/piper/tts.py @@ -20,7 +20,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import TTSSettings +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -53,41 +53,56 @@ class PiperTTSService(TTSService): def __init__( self, *, - voice_id: str, + voice_id: Optional[str] = None, download_dir: Optional[Path] = None, force_redownload: bool = False, use_cuda: bool = False, + settings: Optional[PiperTTSSettings] = None, **kwargs, ): """Initialize the Piper TTS service. Args: voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). + + .. deprecated:: 1.0 + Use ``settings=PiperTTSSettings(voice=...)`` instead. + download_dir: Directory for storing voice model files. Defaults to the current working directory. force_redownload: Re-download the voice model even if it already exists. use_cuda: Use CUDA for GPU-accelerated inference. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent `TTSService`. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "PiperTTSSettings", "voice") + + default_settings = PiperTTSSettings(model=None, voice=voice_id, language=None) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( - settings=PiperTTSSettings(model=None, voice=voice_id, language=None), + settings=default_settings, **kwargs, ) download_dir = download_dir or Path.cwd() - model_file = f"{voice_id}.onnx" + _voice = self._settings.voice + model_file = f"{_voice}.onnx" model_path = Path(download_dir) / model_file if not model_path.exists(): - logger.debug(f"Downloading Piper '{voice_id}' model") - download_voice(voice_id, download_dir, force_redownload=force_redownload) + logger.debug(f"Downloading Piper '{_voice}' model") + download_voice(_voice, download_dir, force_redownload=force_redownload) - logger.debug(f"Loading Piper '{voice_id}' model from {model_path}") + logger.debug(f"Loading Piper '{_voice}' model from {model_path}") self._voice = PiperVoice.load(model_path, use_cuda=use_cuda) - logger.debug(f"Loaded Piper '{voice_id}' model") + logger.debug(f"Loaded Piper '{_voice}' model") def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -190,6 +205,7 @@ class PiperHttpTTSService(TTSService): base_url: str, aiohttp_session: aiohttp.ClientSession, voice_id: Optional[str] = None, + settings: Optional[PiperHttpTTSSettings] = None, **kwargs, ): """Initialize the Piper TTS service. @@ -198,10 +214,23 @@ class PiperHttpTTSService(TTSService): base_url: Base URL for the Piper TTS HTTP server. aiohttp_session: aiohttp ClientSession for making HTTP requests. voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). + + .. deprecated:: 1.0 + Use ``settings=PiperHttpTTSSettings(voice=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "PiperHttpTTSSettings", "voice") + + default_settings = PiperHttpTTSSettings(model=None, voice=voice_id, language=None) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( - settings=PiperHttpTTSSettings(model=None, voice=voice_id, language=None), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index 6b58faea2..132924662 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -6,9 +6,13 @@ """Qwen LLM service implementation using OpenAI-compatible interface.""" +from typing import Optional + from loguru import logger +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class QwenLLMService(OpenAILLMService): @@ -23,7 +27,8 @@ class QwenLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://dashscope-intl.aliyuncs.com/compatible-mode/v1", - model: str = "qwen-plus", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize the Qwen LLM service. @@ -32,10 +37,23 @@ class QwenLLMService(OpenAILLMService): api_key: The API key for accessing Qwen's API (DashScope API key). base_url: Base URL for Qwen API. Defaults to "https://dashscope-intl.aliyuncs.com/compatible-mode/v1". model: The model identifier to use. Defaults to "qwen-plus". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) - logger.info(f"Initialized Qwen LLM service with model: {model}") + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "qwen-plus") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) + logger.info(f"Initialized Qwen LLM service with model: {self._settings.model}") def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Qwen API endpoint. diff --git a/src/pipecat/services/resembleai/tts.py b/src/pipecat/services/resembleai/tts.py index 1c2953b72..148dacde2 100644 --- a/src/pipecat/services/resembleai/tts.py +++ b/src/pipecat/services/resembleai/tts.py @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -70,11 +70,12 @@ class ResembleAITTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, url: str = "wss://websocket.cluster.resemble.ai/stream", precision: Optional[str] = "PCM_16", output_format: Optional[str] = "wav", sample_rate: Optional[int] = 22050, + settings: Optional[ResembleAITTSSettings] = None, **kwargs, ): """Initialize the Resemble AI TTS service. @@ -82,24 +83,37 @@ class ResembleAITTSService(AudioContextTTSService): Args: api_key: Resemble AI API key for authentication. voice_id: Voice UUID to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=ResembleAITTSSettings(voice=...)`` instead. + url: WebSocket URL for Resemble AI TTS API. precision: PCM bit depth (PCM_32, PCM_24, PCM_16, or MULAW). output_format: Audio format (wav or mp3). sample_rate: Audio sample rate (8000, 16000, 22050, 32000, or 44100). Defaults to 22050. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent service. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "ResembleAITTSSettings", "voice") + + default_settings = ResembleAITTSSettings( + model=None, + voice=voice_id, + language=None, + precision=precision, + output_format=output_format, + resemble_sample_rate=sample_rate, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, reuse_context_id_within_turn=False, supports_word_timestamps=True, - settings=ResembleAITTSSettings( - model=None, - voice=voice_id, - language=None, - precision=precision, - output_format=output_format, - resemble_sample_rate=sample_rate, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index 944ff4e58..a44b738d1 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -31,7 +31,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import ( AudioContextTTSService, InterruptibleTTSService, @@ -144,6 +144,9 @@ class RimeTTSService(AudioContextTTSService): class InputParams(BaseModel): """Configuration parameters for Rime TTS service. + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(...)`` instead. + Parameters: language: Language for synthesis. Defaults to English. segment: Text segmentation mode ("immediate", "bySentence", "never"). @@ -176,11 +179,12 @@ class RimeTTSService(AudioContextTTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, url: str = "wss://users-ws.rime.ai/ws3", - model: str = "arcana", + model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[RimeTTSSettings] = None, text_aggregator: Optional[BaseTextAggregator] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, aggregate_sentences: Optional[bool] = None, @@ -191,10 +195,24 @@ class RimeTTSService(AudioContextTTSService): Args: api_key: Rime API key for authentication. voice_id: ID of the voice to use. + + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(voice=...)`` instead. + url: Rime websocket API endpoint. model: Model ID to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(model=...)`` instead. + sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. + + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. text_aggregator: Custom text aggregator for processing input text. .. deprecated:: 0.0.95 @@ -208,8 +226,40 @@ class RimeTTSService(AudioContextTTSService): **kwargs: Additional arguments passed to parent class. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "RimeTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "RimeTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "RimeTTSSettings") + # Initialize with parent class settings for proper frame handling - params = params or RimeTTSService.InputParams() + _params = params or RimeTTSService.InputParams() + + default_settings = RimeTTSSettings( + model=model or "arcana", + voice=voice_id, + audioFormat="pcm", + samplingRate=0, # updated in start() + language=self.language_to_service_language(_params.language) + if _params.language + else None, + segment=_params.segment, + inlineSpeedAlpha=None, # Not applicable here + speedAlpha=_params.speed_alpha, + # Arcana params + repetition_penalty=_params.repetition_penalty, + temperature=_params.temperature, + top_p=_params.top_p, + # Mistv2 params + reduceLatency=_params.reduce_latency, + pauseBetweenBrackets=_params.pause_between_brackets, + phonemizeBetweenBrackets=_params.phonemize_between_brackets, + noTextNormalization=_params.no_text_normalization, + saveOovs=_params.save_oovs, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( text_aggregation_mode=text_aggregation_mode, @@ -220,28 +270,7 @@ class RimeTTSService(AudioContextTTSService): supports_word_timestamps=True, append_trailing_space=True, sample_rate=sample_rate, - settings=RimeTTSSettings( - model=model, - voice=voice_id, - audioFormat="pcm", - samplingRate=0, # updated in start() - language=self.language_to_service_language(params.language) - if params.language - else None, - segment=params.segment, - inlineSpeedAlpha=None, # Not applicable here - speedAlpha=params.speed_alpha, - # Arcana params - repetition_penalty=params.repetition_penalty, - temperature=params.temperature, - top_p=params.top_p, - # Mistv2 params - reduceLatency=params.reduce_latency, - pauseBetweenBrackets=params.pause_between_brackets, - phonemizeBetweenBrackets=params.phonemize_between_brackets, - noTextNormalization=params.no_text_normalization, - saveOovs=params.save_oovs, - ), + settings=default_settings, **kwargs, ) @@ -628,6 +657,9 @@ class RimeHttpTTSService(TTSService): class InputParams(BaseModel): """Configuration parameters for Rime HTTP TTS service. + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(...)`` instead. + Parameters: language: Language for synthesis. Defaults to English. pause_between_brackets: Whether to add pauses between bracketed content. @@ -648,11 +680,12 @@ class RimeHttpTTSService(TTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, - model: str = "mistv2", + model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[RimeTTSSettings] = None, **kwargs, ): """Initialize Rime HTTP TTS service. @@ -660,36 +693,61 @@ class RimeHttpTTSService(TTSService): Args: api_key: Rime API key for authentication. voice_id: ID of the voice to use. + + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(voice=...)`` instead. + aiohttp_session: Shared aiohttp session for HTTP requests. model: Model ID to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(model=...)`` instead. + sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. + + .. deprecated:: 1.0 + Use ``settings=RimeTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - params = params or RimeHttpTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "RimeTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "RimeTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "RimeTTSSettings") + + _params = params or RimeHttpTTSService.InputParams() + + default_settings = RimeTTSSettings( + model=model or "mistv2", + language=self.language_to_service_language(_params.language) + if _params.language + else "eng", + audioFormat="pcm", + samplingRate=0, + segment=None, + speedAlpha=_params.speed_alpha, + reduceLatency=_params.reduce_latency, + pauseBetweenBrackets=_params.pause_between_brackets, + phonemizeBetweenBrackets=_params.phonemize_between_brackets, + noTextNormalization=None, + saveOovs=None, + inlineSpeedAlpha=_params.inline_speed_alpha if _params.inline_speed_alpha else None, + repetition_penalty=None, + temperature=None, + top_p=None, + voice=voice_id, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=RimeTTSSettings( - model=model, - language=self.language_to_service_language(params.language) - if params.language - else "eng", - audioFormat="pcm", - samplingRate=0, - segment=None, - speedAlpha=params.speed_alpha, - reduceLatency=params.reduce_latency, - pauseBetweenBrackets=params.pause_between_brackets, - phonemizeBetweenBrackets=params.phonemize_between_brackets, - noTextNormalization=None, - saveOovs=None, - inlineSpeedAlpha=params.inline_speed_alpha if params.inline_speed_alpha else None, - repetition_penalty=None, - temperature=None, - top_p=None, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -810,6 +868,9 @@ class RimeNonJsonTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Configuration parameters for Rime Non-JSON WebSocket TTS service. + .. deprecated:: 1.0 + Use ``settings=RimeNonJsonTTSSettings(...)`` instead. + Args: language: Language for synthesis. Defaults to English. segment: Text segmentation mode ("immediate", "bySentence", "never"). @@ -830,12 +891,13 @@ class RimeNonJsonTTSService(InterruptibleTTSService): self, *, api_key: str, - voice_id: str, + voice_id: Optional[str] = None, url: str = "wss://users.rime.ai/ws", - model: str = "arcana", + model: Optional[str] = None, audio_format: str = "pcm", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[RimeNonJsonTTSSettings] = None, aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, **kwargs, @@ -845,11 +907,25 @@ class RimeNonJsonTTSService(InterruptibleTTSService): Args: api_key: Rime API key for authentication. voice_id: ID of the voice to use. + + .. deprecated:: 1.0 + Use ``settings=RimeNonJsonTTSSettings(voice=...)`` instead. + url: Rime websocket API endpoint. model: Model ID to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=RimeNonJsonTTSSettings(model=...)`` instead. + audio_format: Audio format to use. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. + + .. deprecated:: 1.0 + Use ``settings=RimeNonJsonTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. aggregate_sentences: Deprecated. Use text_aggregation_mode instead. .. deprecated:: 0.0.104 @@ -860,7 +936,31 @@ class RimeNonJsonTTSService(InterruptibleTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to parent class. """ - params = params or RimeNonJsonTTSService.InputParams() + if voice_id is not None: + _warn_deprecated_param("voice_id", "RimeNonJsonTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "RimeNonJsonTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "RimeNonJsonTTSSettings") + + _params = params or RimeNonJsonTTSService.InputParams() + + default_settings = RimeNonJsonTTSSettings( + voice=voice_id, + model=model or "arcana", + audioFormat=audio_format, + samplingRate=sample_rate, + language=self.language_to_service_language(_params.language) + if _params.language + else None, + segment=_params.segment, + repetition_penalty=_params.repetition_penalty, + temperature=_params.temperature, + top_p=_params.top_p, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, aggregate_sentences=aggregate_sentences, @@ -868,26 +968,14 @@ class RimeNonJsonTTSService(InterruptibleTTSService): push_stop_frames=True, pause_frame_processing=True, append_trailing_space=True, - settings=RimeNonJsonTTSSettings( - voice=voice_id, - model=model, - audioFormat=audio_format, - samplingRate=sample_rate, - language=self.language_to_service_language(params.language) - if params.language - else None, - segment=params.segment, - repetition_penalty=params.repetition_penalty, - temperature=params.temperature, - top_p=params.top_p, - ), + settings=default_settings, **kwargs, ) self._api_key = api_key self._url = url # Add any extra parameters for future compatibility - if params.extra: - self._settings.extra.update(params.extra) + if _params.extra: + self._settings.extra.update(_params.extra) self._receive_task = None self._context_id: Optional[str] = None diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index 016e1740d..23d415598 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -21,7 +21,9 @@ 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.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param from pipecat.utils.tracing.service_decorators import traced_llm @@ -36,8 +38,9 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore self, *, api_key: str, - model: str = "Llama-4-Maverick-17B-128E-Instruct", + model: Optional[str] = None, base_url: str = "https://api.sambanova.ai/v1", + settings: Optional[OpenAILLMSettings] = None, **kwargs: Dict[Any, Any], ) -> None: """Initialize SambaNova LLM service. @@ -45,10 +48,23 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore Args: api_key: The API key for accessing SambaNova API. model: The model identifier to use. Defaults to "Llama-4-Maverick-17B-128E-Instruct". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(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 + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings(model=model or "Llama-4-Maverick-17B-128E-Instruct") + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client( self, diff --git a/src/pipecat/services/sambanova/stt.py b/src/pipecat/services/sambanova/stt.py index f313f0d7b..4e3c9e01d 100644 --- a/src/pipecat/services/sambanova/stt.py +++ b/src/pipecat/services/sambanova/stt.py @@ -10,8 +10,13 @@ from typing import Any, Optional from loguru import logger +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, Transcription +from pipecat.services.whisper.base_stt import ( + BaseWhisperSTTService, + BaseWhisperSTTSettings, + Transcription, +) from pipecat.transcriptions.language import Language @@ -25,35 +30,75 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore def __init__( self, *, - model: str = "Whisper-Large-v3", + model: Optional[str] = None, api_key: Optional[str] = None, base_url: str = "https://api.sambanova.ai/v1", - language: Optional[Language] = Language.EN, + language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, + settings: Optional[BaseWhisperSTTSettings] = None, ttfs_p99_latency: Optional[float] = SAMBANOVA_TTFS_P99, **kwargs: Any, ) -> None: """Initialize SambaNova STT service. Args: - model: Whisper model to use. Defaults to "Whisper-Large-v3". + model: Whisper model to use. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(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. Defaults to English. + language: Language of the audio input. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. + prompt: Optional text to guide the model's style or continue a previous segment. - temperature: Optional sampling temperature between 0 and 1. Defaults to 0.0. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. + + temperature: Optional sampling temperature between 0 and 1. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to `pipecat.services.whisper.base_stt.BaseWhisperSTTService`. """ - super().__init__( + if model is not None: + _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") + if language is not None: + _warn_deprecated_param("language", "BaseWhisperSTTSettings", "language") + if prompt is not None: + _warn_deprecated_param("prompt", "BaseWhisperSTTSettings", "prompt") + if temperature is not None: + _warn_deprecated_param("temperature", "BaseWhisperSTTSettings", "temperature") + + model = model or "Whisper-Large-v3" + language = language or Language.EN + + # Build settings from deprecated params and pass via settings= + # to avoid double deprecation warnings in BaseWhisperSTTService. + default_settings = BaseWhisperSTTSettings( model=model, - api_key=api_key, + language=self.language_to_service_language(language), base_url=base_url, - language=language, prompt=prompt, temperature=temperature, + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__( + api_key=api_key, + base_url=base_url, + settings=default_settings, ttfs_p99_latency=ttfs_p99_latency, **kwargs, ) diff --git a/src/pipecat/services/sarvam/stt.py b/src/pipecat/services/sarvam/stt.py index e368ceb02..b3ac41470 100644 --- a/src/pipecat/services/sarvam/stt.py +++ b/src/pipecat/services/sarvam/stt.py @@ -32,7 +32,13 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.sarvam._sdk import sdk_headers -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, is_given +from pipecat.services.settings import ( + NOT_GIVEN, + STTSettings, + _NotGiven, + _warn_deprecated_param, + is_given, +) from pipecat.services.stt_latency import SARVAM_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language, resolve_language @@ -171,6 +177,9 @@ class SarvamSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for Sarvam STT service. + .. deprecated:: 1.0 + Use ``settings=SarvamSTTSettings(...)`` instead. + Parameters: language: Target language for transcription. - saarika:v2.5: Defaults to "unknown" (auto-detect supported) @@ -194,10 +203,11 @@ class SarvamSTTService(STTService): self, *, api_key: str, - model: str = "saarika:v2.5", + model: Optional[str] = None, sample_rate: Optional[int] = None, input_audio_codec: str = "wav", params: Optional[InputParams] = None, + settings: Optional[SarvamSTTSettings] = None, ttfs_p99_latency: Optional[float] = SARVAM_TTFS_P99, keepalive_timeout: Optional[float] = None, keepalive_interval: float = 5.0, @@ -207,13 +217,20 @@ class SarvamSTTService(STTService): Args: api_key: Sarvam API key for authentication. - model: Sarvam model to use for transcription. Allowed values: - - "saarika:v2.5": Standard STT model - - "saaras:v2.5": STT-Translate model (auto-detects language, supports prompts) - - "saaras:v3": Advanced STT model (supports mode) + model: Sarvam model to use for transcription. + + .. deprecated:: 1.0 + Use ``settings=SarvamSTTSettings(model=...)`` instead. + sample_rate: Audio sample rate. Defaults to 16000 if not specified. input_audio_codec: Audio codec/format of the input file. Defaults to "wav". params: Configuration parameters for Sarvam STT service. + + .. deprecated:: 1.0 + Use ``settings=SarvamSTTSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark keepalive_timeout: Seconds of no audio before sending silence to keep the @@ -221,7 +238,13 @@ class SarvamSTTService(STTService): keepalive_interval: Seconds between idle checks when keepalive is enabled. **kwargs: Additional arguments passed to the parent STTService. """ - params = params or SarvamSTTService.InputParams() + if model is not None: + _warn_deprecated_param("model", "SarvamSTTSettings", "model") + if params is not None: + _warn_deprecated_param("params", "SarvamSTTSettings") + + model = model or "saarika:v2.5" + _params = params or SarvamSTTService.InputParams() # Get model configuration (validates model exists) if model not in MODEL_CONFIGS: @@ -231,31 +254,35 @@ class SarvamSTTService(STTService): self._config = MODEL_CONFIGS[model] # Validate parameters against model capabilities - if params.prompt is not None and not self._config.supports_prompt: + if _params.prompt is not None and not self._config.supports_prompt: raise ValueError(f"Model '{model}' does not support prompt parameter.") - if params.mode is not None and not self._config.supports_mode: + if _params.mode is not None and not self._config.supports_mode: raise ValueError(f"Model '{model}' does not support mode parameter.") - if params.language is not None and not self._config.supports_language: + if _params.language is not None and not self._config.supports_language: raise ValueError( f"Model '{model}' does not support language parameter (auto-detects language)." ) # Resolve mode default from model config - mode = params.mode if params.mode is not None else self._config.default_mode + mode = _params.mode if _params.mode is not None else self._config.default_mode + + default_settings = SarvamSTTSettings( + model=model, + language=_params.language, + prompt=_params.prompt, + mode=mode, + vad_signals=_params.vad_signals, + high_vad_sensitivity=_params.high_vad_sensitivity, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, keepalive_timeout=keepalive_timeout, keepalive_interval=keepalive_interval, - settings=SarvamSTTSettings( - model=model, - language=params.language, - prompt=params.prompt, - mode=mode, - vad_signals=params.vad_signals, - high_vad_sensitivity=params.high_vad_sensitivity, - ), + settings=default_settings, **kwargs, ) @@ -274,7 +301,7 @@ class SarvamSTTService(STTService): self._socket_client = None self._receive_task = None - if params.vad_signals: + if _params.vad_signals: self._register_event_handler("on_speech_started") self._register_event_handler("on_speech_stopped") self._register_event_handler("on_utterance_end") diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index c18933407..4d125dfc9 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -62,7 +62,7 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.sarvam._sdk import sdk_headers -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import InterruptibleTTSService, TextAggregationMode, TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -376,6 +376,9 @@ class SarvamHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Sarvam TTS configuration. + .. deprecated:: 1.0 + Use ``SarvamHttpTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: language: Language for synthesis. Defaults to English (India). pitch: Voice pitch adjustment (-0.75 to 0.75). Defaults to 0.0. @@ -428,10 +431,11 @@ class SarvamHttpTTSService(TTSService): api_key: str, aiohttp_session: aiohttp.ClientSession, voice_id: Optional[str] = None, - model: str = "bulbul:v2", + model: Optional[str] = None, base_url: str = "https://api.sarvam.ai", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[SarvamHttpTTSSettings] = None, **kwargs, ): """Initialize the Sarvam TTS service. @@ -440,15 +444,38 @@ class SarvamHttpTTSService(TTSService): api_key: Sarvam AI API subscription key. aiohttp_session: Shared aiohttp session for making requests. voice_id: Speaker voice ID. If None, uses model-appropriate default. + + .. deprecated:: 1.0 + Use ``settings=SarvamHttpTTSSettings(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:: 1.0 + Use ``settings=SarvamHttpTTSSettings(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). If None, uses model-specific default. params: Additional voice and preprocessing parameters. If None, uses defaults. + + .. deprecated:: 1.0 + Use ``settings=SarvamHttpTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "SarvamHttpTTSSettings", "voice") + if model is not None: + _warn_deprecated_param("model", "SarvamHttpTTSSettings", "model") + if params is not None: + _warn_deprecated_param("params", "SarvamHttpTTSSettings") + + model = model or "bulbul:v2" + # Get model configuration (validates model exists) if model not in TTS_MODEL_CONFIGS: allowed = ", ".join(sorted(TTS_MODEL_CONFIGS.keys())) @@ -460,39 +487,39 @@ class SarvamHttpTTSService(TTSService): if sample_rate is None: sample_rate = self._config.default_sample_rate - params = params or SarvamHttpTTSService.InputParams() + _params = params or SarvamHttpTTSService.InputParams() # Set default voice based on model if not specified if voice_id is None: voice_id = self._config.default_speaker # Validate and clamp pace to model's valid range - pace = params.pace + pace = _params.pace pace_min, pace_max = self._config.pace_range if pace is not None and (pace < pace_min or pace > pace_max): logger.warning(f"Pace {pace} is outside model range ({pace_min}-{pace_max}). Clamping.") pace = max(pace_min, min(pace_max, pace)) + default_settings = SarvamHttpTTSSettings( + language=( + self.language_to_service_language(_params.language) if _params.language else "en-IN" + ), + enable_preprocessing=( + True if self._config.preprocessing_always_enabled else _params.enable_preprocessing + ), + pace=pace, + pitch=None, + loudness=None, + temperature=None, + model=model, + voice=voice_id, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, - settings=SarvamHttpTTSSettings( - language=( - self.language_to_service_language(params.language) - if params.language - else "en-IN" - ), - enable_preprocessing=( - True - if self._config.preprocessing_always_enabled - else params.enable_preprocessing - ), - pace=pace, - pitch=None, - loudness=None, - temperature=None, - model=model, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -502,18 +529,18 @@ class SarvamHttpTTSService(TTSService): # Add parameters based on model support if self._config.supports_pitch: - self._settings.pitch = params.pitch - elif params.pitch != 0.0: + self._settings.pitch = _params.pitch + elif _params.pitch != 0.0: logger.warning(f"pitch parameter is ignored for {model}") if self._config.supports_loudness: - self._settings.loudness = params.loudness - elif params.loudness != 1.0: + self._settings.loudness = _params.loudness + elif _params.loudness != 1.0: logger.warning(f"loudness parameter is ignored for {model}") if self._config.supports_temperature: - self._settings.temperature = params.temperature - elif params.temperature != 0.6: + self._settings.temperature = _params.temperature + elif _params.temperature != 0.6: logger.warning(f"temperature parameter is ignored for {model}") def can_generate_metrics(self) -> bool: @@ -697,6 +724,9 @@ class SarvamTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Configuration parameters for Sarvam TTS WebSocket service. + .. deprecated:: 1.0 + Use ``SarvamTTSSettings`` directly via the ``settings`` parameter instead. + Parameters: pitch: Voice pitch adjustment (-0.75 to 0.75). Defaults to 0.0. **Note:** Only supported for bulbul:v2. Ignored for v3 models. @@ -782,13 +812,14 @@ class SarvamTTSService(InterruptibleTTSService): self, *, api_key: str, - model: str = "bulbul:v2", + model: Optional[str] = None, voice_id: Optional[str] = None, url: str = "wss://api.sarvam.ai/text-to-speech/ws", aggregate_sentences: Optional[bool] = None, text_aggregation_mode: Optional[TextAggregationMode] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, + settings: Optional[SarvamTTSSettings] = None, **kwargs, ): """Initialize the Sarvam TTS service with voice and transport configuration. @@ -798,7 +829,15 @@ class SarvamTTSService(InterruptibleTTSService): model: TTS model to use. Options: - "bulbul:v2" (default): Standard model with pitch/loudness support - "bulbul:v3-beta": Advanced model with temperature control + + .. deprecated:: 1.0 + Use ``settings=SarvamTTSSettings(model=...)`` instead. + voice_id: Speaker voice ID. If None, uses model-appropriate default. + + .. deprecated:: 1.0 + Use ``settings=SarvamTTSSettings(voice=...)`` instead. + url: WebSocket URL for the TTS backend (default production URL). aggregate_sentences: Deprecated. Use text_aggregation_mode instead. @@ -809,10 +848,25 @@ class SarvamTTSService(InterruptibleTTSService): sample_rate: Output audio sample rate in Hz (8000, 16000, 22050, 24000). If None, uses model-specific default. params: Optional input parameters to override defaults. + + .. deprecated:: 1.0 + Use ``settings=SarvamTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Arguments forwarded to InterruptibleTTSService. See https://docs.sarvam.ai/api-reference-docs/text-to-speech/stream """ + if model is not None: + _warn_deprecated_param("model", "SarvamTTSSettings", "model") + if voice_id is not None: + _warn_deprecated_param("voice_id", "SarvamTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "SarvamTTSSettings") + + model = model or "bulbul:v2" + # Get model configuration (validates model exists) if model not in TTS_MODEL_CONFIGS: allowed = ", ".join(sorted(TTS_MODEL_CONFIGS.keys())) @@ -828,15 +882,37 @@ class SarvamTTSService(InterruptibleTTSService): if voice_id is None: voice_id = self._config.default_speaker - params = params or SarvamTTSService.InputParams() + _params = params or SarvamTTSService.InputParams() # Validate and clamp pace to model's valid range - pace = params.pace + pace = _params.pace pace_min, pace_max = self._config.pace_range if pace is not None and (pace < pace_min or pace > pace_max): logger.warning(f"Pace {pace} is outside model range ({pace_min}-{pace_max}). Clamping.") pace = max(pace_min, min(pace_max, pace)) + default_settings = SarvamTTSSettings( + language=( + self.language_to_service_language(_params.language) if _params.language else "en-IN" + ), + speech_sample_rate=str(sample_rate), + enable_preprocessing=( + True if self._config.preprocessing_always_enabled else _params.enable_preprocessing + ), + min_buffer_size=_params.min_buffer_size, + max_chunk_length=_params.max_chunk_length, + output_audio_codec=_params.output_audio_codec, + output_audio_bitrate=_params.output_audio_bitrate, + pace=pace, + pitch=None, + loudness=None, + temperature=None, + model=model, + voice=voice_id, + ) + if settings is not None: + default_settings.apply_update(settings) + # Initialize parent class first super().__init__( aggregate_sentences=aggregate_sentences, @@ -845,29 +921,7 @@ class SarvamTTSService(InterruptibleTTSService): pause_frame_processing=True, push_stop_frames=True, sample_rate=sample_rate, - settings=SarvamTTSSettings( - language=( - self.language_to_service_language(params.language) - if params.language - else "en-IN" - ), - speech_sample_rate=str(sample_rate), - enable_preprocessing=( - True - if self._config.preprocessing_always_enabled - else params.enable_preprocessing - ), - min_buffer_size=params.min_buffer_size, - max_chunk_length=params.max_chunk_length, - output_audio_codec=params.output_audio_codec, - output_audio_bitrate=params.output_audio_bitrate, - pace=pace, - pitch=None, - loudness=None, - temperature=None, - model=model, - voice=voice_id, - ), + settings=default_settings, **kwargs, ) @@ -877,18 +931,18 @@ class SarvamTTSService(InterruptibleTTSService): # Add parameters based on model support if self._config.supports_pitch: - self._settings.pitch = params.pitch - elif params.pitch != 0.0: + self._settings.pitch = _params.pitch + elif _params.pitch != 0.0: logger.warning(f"pitch parameter is ignored for {model}") if self._config.supports_loudness: - self._settings.loudness = params.loudness - elif params.loudness != 1.0: + self._settings.loudness = _params.loudness + elif _params.loudness != 1.0: logger.warning(f"loudness parameter is ignored for {model}") if self._config.supports_temperature: - self._settings.temperature = params.temperature - elif params.temperature != 0.6: + self._settings.temperature = _params.temperature + elif _params.temperature != 0.6: logger.warning(f"temperature parameter is ignored for {model}") self._receive_task = None diff --git a/src/pipecat/services/settings.py b/src/pipecat/services/settings.py index 5d215273f..546104b9a 100644 --- a/src/pipecat/services/settings.py +++ b/src/pipecat/services/settings.py @@ -37,6 +37,7 @@ Key helpers: from __future__ import annotations import copy +import warnings from dataclasses import dataclass, field, fields from typing import TYPE_CHECKING, Any, ClassVar, Dict, Mapping, Optional, Type, TypeVar @@ -47,6 +48,45 @@ from pipecat.transcriptions.language import Language if TYPE_CHECKING: from pipecat.turns.user_turn_completion_mixin import UserTurnCompletionConfig + +# --------------------------------------------------------------------------- +# Deprecation helper +# --------------------------------------------------------------------------- + + +def _warn_deprecated_param( + param_name: str, + settings_class_name: str, + settings_field: str | None = None, + stacklevel: int = 3, +): + """Emit DeprecationWarning for a deprecated init parameter. + + Args: + param_name: Name of the deprecated parameter. + settings_class_name: Name of the settings class to use instead. + settings_field: Specific field on the settings class, if different + from *param_name*. + stacklevel: Stack depth for the warning. Default ``3`` targets + the caller's caller (i.e. user code that instantiated the service). + """ + if settings_field: + msg = ( + f"The `{param_name}` parameter is deprecated. " + f"Use `settings={settings_class_name}({settings_field}=...)` instead. " + f"If both are provided, `settings` takes precedence." + ) + else: + msg = ( + f"The `{param_name}` parameter is deprecated. " + f"Use `settings={settings_class_name}(...)` instead. " + f"If both are provided, `settings` takes precedence." + ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel) + + # --------------------------------------------------------------------------- # NOT_GIVEN sentinel # --------------------------------------------------------------------------- diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index 32cbee1f4..84c437f36 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -24,7 +24,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import SONIOX_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language @@ -79,6 +79,9 @@ class SonioxContextObject(BaseModel): class SonioxInputParams(BaseModel): """Real-time transcription settings. + .. deprecated:: 1.0 + Use ``settings=SonioxSTTSettings(...)`` instead. + See Soniox WebSocket API documentation for more details: https://soniox.com/docs/speech-to-text/api-reference/websocket-api#configuration-parameters @@ -183,8 +186,10 @@ class SonioxSTTService(WebsocketSTTService): api_key: str, url: str = "wss://stt-rt.soniox.com/transcribe-websocket", sample_rate: Optional[int] = None, + model: Optional[str] = None, params: Optional[SonioxInputParams] = None, vad_force_turn_endpoint: bool = True, + settings: Optional[SonioxSTTSettings] = None, ttfs_p99_latency: Optional[float] = SONIOX_TTFS_P99, **kwargs, ): @@ -194,33 +199,53 @@ class SonioxSTTService(WebsocketSTTService): api_key: Soniox API key. url: Soniox WebSocket API URL. sample_rate: Audio sample rate. + model: Soniox model to use for transcription. + + .. deprecated:: 1.0 + Use ``settings=SonioxSTTSettings(model=...)`` instead. + params: Additional configuration parameters, such as language hints, context and speaker diarization. + + .. deprecated:: 1.0 + Use ``settings=SonioxSTTSettings(...)`` 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. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the STTService. """ - params = params or SonioxInputParams() + if model is not None: + _warn_deprecated_param("model", "SonioxSTTSettings", "model") + if params is not None: + _warn_deprecated_param("params", "SonioxSTTSettings") + + _params = params or SonioxInputParams() + + default_settings = SonioxSTTSettings( + model=model or _params.model, + language=None, + audio_format=_params.audio_format, + num_channels=_params.num_channels, + language_hints=_params.language_hints, + language_hints_strict=_params.language_hints_strict, + context=_params.context, + enable_speaker_diarization=_params.enable_speaker_diarization, + enable_language_identification=_params.enable_language_identification, + client_reference_id=_params.client_reference_id, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, keepalive_timeout=1, keepalive_interval=5, - settings=SonioxSTTSettings( - model=params.model, - language=None, - audio_format=params.audio_format, - num_channels=params.num_channels, - language_hints=params.language_hints, - language_hints_strict=params.language_hints_strict, - context=params.context, - enable_speaker_diarization=params.enable_speaker_diarization, - enable_language_identification=params.enable_language_identification, - client_reference_id=params.client_reference_id, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index bdeb3b249..a0ca19f74 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -33,7 +33,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import SPEECHMATICS_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language, resolve_language @@ -381,6 +381,7 @@ class SpeechmaticsSTTService(STTService): sample_rate: int | None = None, params: InputParams | None = None, should_interrupt: bool = True, + settings: SpeechmaticsSTTSettings | None = None, ttfs_p99_latency: float | None = SPEECHMATICS_TTFS_P99, **kwargs, ): @@ -392,8 +393,14 @@ class SpeechmaticsSTTService(STTService): base_url: Base URL for Speechmatics API. Uses environment variable `SPEECHMATICS_RT_URL` or defaults to `wss://eu2.rt.speechmatics.com/v2`. sample_rate: Optional audio sample rate in Hz. - params: Optional[InputParams]: Input parameters for the service. + params: Input parameters for the service. + + .. deprecated:: 1.0 + Use ``settings=SpeechmaticsSTTSettings(...)`` 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 + ``params``, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to STTService. @@ -410,6 +417,9 @@ class SpeechmaticsSTTService(STTService): if not self._base_url: raise ValueError("Missing Speechmatics base URL") + if params is not None: + _warn_deprecated_param("params", "SpeechmaticsSTTSettings") + # Default params params = params or SpeechmaticsSTTService.InputParams() self._should_interrupt = should_interrupt @@ -426,7 +436,7 @@ class SpeechmaticsSTTService(STTService): speaker_passive_format = params.speaker_passive_format or speaker_active_format # Settings — seeded from InputParams - settings = SpeechmaticsSTTSettings( + default_settings = SpeechmaticsSTTSettings( model=None, # Will be resolved from operating_point after config is built language=params.language, domain=params.domain, @@ -455,13 +465,16 @@ class SpeechmaticsSTTService(STTService): # Build SDK config from settings, then resolve model from operating_point self._client: VoiceAgentClient | None = None - self._config: VoiceAgentConfig = self._build_config(settings) - settings.model = self._config.operating_point.value + self._config: VoiceAgentConfig = self._build_config(default_settings) + default_settings.model = self._config.operating_point.value + + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, - settings=settings, + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/speechmatics/tts.py b/src/pipecat/services/speechmatics/tts.py index 1ddb895aa..e1260fbe2 100644 --- a/src/pipecat/services/speechmatics/tts.py +++ b/src/pipecat/services/speechmatics/tts.py @@ -22,7 +22,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.utils.network import exponential_backoff_time from pipecat.utils.tracing.service_decorators import traced_tts @@ -62,6 +62,9 @@ class SpeechmaticsTTSService(TTSService): class InputParams(BaseModel): """Optional input parameters for Speechmatics TTS configuration. + .. deprecated:: 1.0 + Use ``settings=SpeechmaticsTTSSettings(...)`` instead. + Parameters: max_retries: Maximum number of retries for TTS requests. Defaults to 5. """ @@ -73,10 +76,11 @@ class SpeechmaticsTTSService(TTSService): *, api_key: str, base_url: str = "https://preview.tts.speechmatics.com", - voice_id: str = "sarah", + voice_id: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, sample_rate: Optional[int] = SPEECHMATICS_SAMPLE_RATE, params: Optional[InputParams] = None, + settings: Optional[SpeechmaticsTTSSettings] = None, **kwargs, ): """Initialize the Speechmatics TTS service. @@ -85,26 +89,45 @@ class SpeechmaticsTTSService(TTSService): api_key: Speechmatics API key for authentication. base_url: Base URL for Speechmatics TTS API. voice_id: Voice model to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=SpeechmaticsTTSSettings(voice=...)`` instead. + aiohttp_session: Shared aiohttp session for HTTP requests. sample_rate: Audio sample rate in Hz. - params: Optional[InputParams]: Input parameters for the service. + params: Input parameters for the service. + + .. deprecated:: 1.0 + Use ``settings=SpeechmaticsTTSSettings(...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to TTSService. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "SpeechmaticsTTSSettings", "voice") + if params is not None: + _warn_deprecated_param("params", "SpeechmaticsTTSSettings") + if sample_rate and sample_rate != self.SPEECHMATICS_SAMPLE_RATE: logger.warning( f"Speechmatics TTS only supports {self.SPEECHMATICS_SAMPLE_RATE}Hz sample rate. " f"Current rate of {sample_rate}Hz may cause issues." ) - params = params or SpeechmaticsTTSService.InputParams() + _params = params or SpeechmaticsTTSService.InputParams() + + default_settings = SpeechmaticsTTSSettings( + model=None, + voice=voice_id or "sarah", + language=None, + max_retries=_params.max_retries, + ) + if settings is not None: + default_settings.apply_update(settings) super().__init__( sample_rate=sample_rate, - settings=SpeechmaticsTTSSettings( - model=None, - voice=voice_id, - language=None, - max_retries=params.max_retries, - ), + settings=default_settings, **kwargs, ) diff --git a/src/pipecat/services/tavus/video.py b/src/pipecat/services/tavus/video.py index 8c63ff354..e6725fac1 100644 --- a/src/pipecat/services/tavus/video.py +++ b/src/pipecat/services/tavus/video.py @@ -34,6 +34,7 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessorSetup from pipecat.services.ai_service import AIService +from pipecat.services.settings import ServiceSettings from pipecat.transports.tavus.transport import TavusCallbacks, TavusParams, TavusTransportClient @@ -57,6 +58,7 @@ class TavusVideoService(AIService): replica_id: str, persona_id: str = "pipecat-stream", session: aiohttp.ClientSession, + settings: Optional[ServiceSettings] = None, **kwargs, ) -> None: """Initialize the Tavus video service. @@ -66,9 +68,15 @@ class TavusVideoService(AIService): replica_id: ID of the Tavus voice replica to use for speech synthesis. persona_id: ID of the Tavus persona. Defaults to "pipecat-stream" for Pipecat TTS voice. session: Async HTTP session used for communication with Tavus. + settings: Runtime-updatable settings. Tavus has no model concept, so this + is primarily used for the ``extra`` dict. **kwargs: Additional arguments passed to the parent AIService class. """ - super().__init__(**kwargs) + default_settings = ServiceSettings(model=None) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(settings=default_settings, **kwargs) self._api_key = api_key self._session = session self._replica_id = replica_id diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index 277e8bc9c..b1cb4ffea 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -6,9 +6,13 @@ """Together.ai LLM service implementation using OpenAI-compatible interface.""" +from typing import Optional + from loguru import logger +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.settings import _warn_deprecated_param class TogetherLLMService(OpenAILLMService): @@ -23,7 +27,8 @@ class TogetherLLMService(OpenAILLMService): *, api_key: str, base_url: str = "https://api.together.xyz/v1", - model: str = "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", + model: Optional[str] = None, + settings: Optional[OpenAILLMSettings] = None, **kwargs, ): """Initialize Together.ai LLM service. @@ -32,9 +37,24 @@ class TogetherLLMService(OpenAILLMService): api_key: The API key for accessing Together.ai's API. base_url: The base URL for Together.ai API. Defaults to "https://api.together.xyz/v1". model: The model identifier to use. Defaults to "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo". + + .. deprecated:: 1.0 + Use ``settings=OpenAILLMSettings(model=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) + if model is not None: + _warn_deprecated_param("model", "OpenAILLMSettings", "model") + + default_settings = OpenAILLMSettings( + model=model or "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo" + ) + if settings is not None: + default_settings.apply_update(settings) + + super().__init__(api_key=api_key, base_url=base_url, settings=default_settings, **kwargs) def create_client(self, api_key=None, base_url=None, **kwargs): """Create OpenAI-compatible client for Together.ai API endpoint. diff --git a/src/pipecat/services/ultravox/llm.py b/src/pipecat/services/ultravox/llm.py index 07c3c34fe..933930152 100644 --- a/src/pipecat/services/ultravox/llm.py +++ b/src/pipecat/services/ultravox/llm.py @@ -172,32 +172,38 @@ class UltravoxRealtimeLLMService(LLMService): self, *, params: Union[AgentInputParams, OneShotInputParams, JoinUrlInputParams], + settings: Optional[UltravoxRealtimeLLMSettings] = None, one_shot_selected_tools: Optional[ToolsSchema] = None, **kwargs, ): """Initialize the Ultravox Realtime LLM service. Args: - api_key: Ultravox API key for authentication. params: Configuration parameters for the model. + settings: Ultravox Realtime LLM settings. If provided, the ``settings`` + values take precedence over default values. one_shot_selected_tools: ToolsSchema for tools to use with this call. May only be set with OneShotInputParams. **kwargs: Additional arguments passed to parent LLMService. """ + default_settings = UltravoxRealtimeLLMSettings( + model=None, + temperature=None, + max_tokens=None, + top_p=None, + top_k=None, + frequency_penalty=None, + presence_penalty=None, + seed=None, + filter_incomplete_user_turns=False, + user_turn_completion_config=None, + output_medium=None, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( - settings=UltravoxRealtimeLLMSettings( - model=None, - temperature=None, - max_tokens=None, - top_p=None, - top_k=None, - frequency_penalty=None, - presence_penalty=None, - seed=None, - filter_incomplete_user_turns=False, - user_turn_completion_config=None, - output_medium=None, - ), + settings=default_settings, **kwargs, ) self._params = params diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index 08310831c..32dd382e8 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -18,7 +18,7 @@ from openai import AsyncOpenAI from openai.types.audio import Transcription from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import WHISPER_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -129,14 +129,15 @@ class BaseWhisperSTTService(SegmentedSTTService): def __init__( self, *, - model: str, + model: Optional[str] = None, api_key: Optional[str] = None, base_url: Optional[str] = None, - language: Optional[Language] = Language.EN, + language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, include_prob_metrics: bool = False, push_empty_transcripts: bool = False, + settings: Optional[BaseWhisperSTTSettings] = None, ttfs_p99_latency: Optional[float] = WHISPER_TTFS_P99, **kwargs, ): @@ -144,11 +145,27 @@ class BaseWhisperSTTService(SegmentedSTTService): Args: model: Name of the Whisper model to use. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(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. Defaults to English. + language: Language of the audio input. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. + prompt: Optional text to guide the model's style or continue a previous segment. - temperature: Sampling temperature between 0 and 1. Defaults to 0.0. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. + + temperature: Sampling temperature between 0 and 1. + + .. deprecated:: 1.0 + Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. + include_prob_metrics: If True, enables probability metrics in API response. Each service implements this differently (see child classes). Defaults to False. @@ -158,25 +175,44 @@ class BaseWhisperSTTService(SegmentedSTTService): useful to know that nothing was transcribed so that the agent can resume speaking, instead of waiting longer for a transcription. Defaults to False. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService. """ + if model is not None: + _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") + if language is not None: + _warn_deprecated_param("language", "BaseWhisperSTTSettings", "language") + if prompt is not None: + _warn_deprecated_param("prompt", "BaseWhisperSTTSettings", "prompt") + if temperature is not None: + _warn_deprecated_param("temperature", "BaseWhisperSTTSettings", "temperature") + + _language = language or Language.EN + + default_settings = BaseWhisperSTTSettings( + model=model, + language=self.language_to_service_language(_language), + base_url=base_url, + prompt=prompt, + temperature=temperature, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( ttfs_p99_latency=ttfs_p99_latency, - settings=BaseWhisperSTTSettings( - model=model, - language=self.language_to_service_language(language or Language.EN), - base_url=base_url, - prompt=prompt, - temperature=temperature, - ), + settings=default_settings, **kwargs, ) self._client = self._create_client(api_key, base_url) self._language = self._settings.language - self._prompt = prompt - self._temperature = temperature + self._prompt = self._settings.prompt if self._settings.prompt else prompt + self._temperature = ( + self._settings.temperature if self._settings.temperature else temperature + ) self._include_prob_metrics = include_prob_metrics self._push_empty_transcripts = push_empty_transcripts diff --git a/src/pipecat/services/whisper/stt.py b/src/pipecat/services/whisper/stt.py index d386d6ed2..2e0a6156a 100644 --- a/src/pipecat/services/whisper/stt.py +++ b/src/pipecat/services/whisper/stt.py @@ -20,7 +20,7 @@ from loguru import logger from typing_extensions import TYPE_CHECKING, override from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_service import SegmentedSTTService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.time import time_now_iso8601 @@ -216,36 +216,80 @@ class WhisperSTTService(SegmentedSTTService): def __init__( self, *, - model: str | Model = Model.DISTIL_MEDIUM_EN, - device: str = "auto", - compute_type: str = "default", - no_speech_prob: float = 0.4, - language: Language = Language.EN, + model: Optional[str | Model] = None, + device: Optional[str] = None, + compute_type: Optional[str] = None, + no_speech_prob: Optional[float] = None, + language: Optional[Language] = None, + settings: Optional[WhisperSTTSettings] = None, **kwargs, ): """Initialize the Whisper STT service. Args: model: The Whisper model to use for transcription. Can be a Model enum or string. + + .. deprecated:: 1.0 + Use ``settings=WhisperSTTSettings(model=...)`` instead. + device: The device to run inference on ('cpu', 'cuda', or 'auto'). + + .. deprecated:: 1.0 + Use ``settings=WhisperSTTSettings(device=...)`` instead. + compute_type: The compute type for inference ('default', 'int8', 'int8_float16', etc.). + + .. deprecated:: 1.0 + Use ``settings=WhisperSTTSettings(compute_type=...)`` instead. + no_speech_prob: Probability threshold for filtering out non-speech segments. + + .. deprecated:: 1.0 + Use ``settings=WhisperSTTSettings(no_speech_prob=...)`` instead. + language: The default language for transcription. + + .. deprecated:: 1.0 + Use ``settings=WhisperSTTSettings(language=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to SegmentedSTTService. """ + if model is not None: + _warn_deprecated_param("model", "WhisperSTTSettings", "model") + if device is not None: + _warn_deprecated_param("device", "WhisperSTTSettings", "device") + if compute_type is not None: + _warn_deprecated_param("compute_type", "WhisperSTTSettings", "compute_type") + if no_speech_prob is not None: + _warn_deprecated_param("no_speech_prob", "WhisperSTTSettings", "no_speech_prob") + if language is not None: + _warn_deprecated_param("language", "WhisperSTTSettings", "language") + + _model = model if model is not None else Model.DISTIL_MEDIUM_EN + _device = device or "auto" + _compute_type = compute_type or "default" + _no_speech_prob = no_speech_prob if no_speech_prob is not None else 0.4 + _language = language or Language.EN + + default_settings = WhisperSTTSettings( + model=_model if isinstance(_model, str) else _model.value, + language=_language, + device=_device, + compute_type=_compute_type, + no_speech_prob=_no_speech_prob, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( - settings=WhisperSTTSettings( - model=model if isinstance(model, str) else model.value, - language=language, - device=device, - compute_type=compute_type, - no_speech_prob=no_speech_prob, - ), + settings=default_settings, **kwargs, ) - self._device: str = device - self._compute_type = compute_type - self._no_speech_prob = no_speech_prob + self._device: str = self._settings.device + self._compute_type = self._settings.compute_type + self._no_speech_prob = self._settings.no_speech_prob self._model: Optional[WhisperModel] = None self._load() @@ -352,36 +396,73 @@ class WhisperSTTServiceMLX(WhisperSTTService): def __init__( self, *, - model: str | MLXModel = MLXModel.TINY, - no_speech_prob: float = 0.6, - language: Language = Language.EN, - temperature: float = 0.0, + model: Optional[str | MLXModel] = None, + no_speech_prob: Optional[float] = None, + language: Optional[Language] = None, + temperature: Optional[float] = None, + settings: Optional[WhisperMLXSTTSettings] = None, **kwargs, ): """Initialize the MLX Whisper STT service. Args: model: The MLX Whisper model to use for transcription. Can be an MLXModel enum or string. + + .. deprecated:: 1.0 + Use ``settings=WhisperMLXSTTSettings(model=...)`` instead. + no_speech_prob: Probability threshold for filtering out non-speech segments. + + .. deprecated:: 1.0 + Use ``settings=WhisperMLXSTTSettings(no_speech_prob=...)`` instead. + language: The default language for transcription. + + .. deprecated:: 1.0 + Use ``settings=WhisperMLXSTTSettings(language=...)`` instead. + temperature: Temperature for sampling. Can be a float or tuple of floats. + + .. deprecated:: 1.0 + Use ``settings=WhisperMLXSTTSettings(temperature=...)`` instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to SegmentedSTTService. """ + if model is not None: + _warn_deprecated_param("model", "WhisperMLXSTTSettings", "model") + if no_speech_prob is not None: + _warn_deprecated_param("no_speech_prob", "WhisperMLXSTTSettings", "no_speech_prob") + if language is not None: + _warn_deprecated_param("language", "WhisperMLXSTTSettings", "language") + if temperature is not None: + _warn_deprecated_param("temperature", "WhisperMLXSTTSettings", "temperature") + + _model = model if model is not None else MLXModel.TINY + _no_speech_prob = no_speech_prob if no_speech_prob is not None else 0.6 + _language = language or Language.EN + _temperature = temperature if temperature is not None else 0.0 + + default_settings = WhisperMLXSTTSettings( + model=_model if isinstance(_model, str) else _model.value, + language=_language, + no_speech_prob=_no_speech_prob, + temperature=_temperature, + engine="mlx", + ) + if settings is not None: + default_settings.apply_update(settings) + # Skip WhisperSTTService.__init__ and call its parent directly SegmentedSTTService.__init__( self, - settings=WhisperMLXSTTSettings( - model=model if isinstance(model, str) else model.value, - language=language, - no_speech_prob=no_speech_prob, - temperature=temperature, - engine="mlx", - ), + settings=default_settings, **kwargs, ) - self._no_speech_prob = no_speech_prob - self._temperature = temperature + self._no_speech_prob = self._settings.no_speech_prob + self._temperature = self._settings.temperature # No need to call _load() as MLX Whisper loads models on demand diff --git a/src/pipecat/services/xtts/tts.py b/src/pipecat/services/xtts/tts.py index 8817c09b5..bba95a400 100644 --- a/src/pipecat/services/xtts/tts.py +++ b/src/pipecat/services/xtts/tts.py @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -94,31 +94,45 @@ class XTTSService(TTSService): def __init__( self, *, - voice_id: str, + voice_id: Optional[str] = None, base_url: str, aiohttp_session: aiohttp.ClientSession, language: Language = Language.EN, sample_rate: Optional[int] = None, + settings: Optional[XTTSTTSSettings] = None, **kwargs, ): """Initialize the XTTS service. Args: voice_id: ID of the voice/speaker to use for synthesis. + + .. deprecated:: 1.0 + Use ``settings=XTTSTTSSettings(voice=...)`` instead. + base_url: Base URL of the XTTS streaming server. aiohttp_session: HTTP session for making requests to the server. language: Language for synthesis. Defaults to English. sample_rate: Audio sample rate. If None, uses default. + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ + if voice_id is not None: + _warn_deprecated_param("voice_id", "XTTSTTSSettings", "voice") + + default_settings = XTTSTTSSettings( + model=None, + voice=voice_id, + language=self.language_to_service_language(language), + base_url=base_url, + ) + if settings is not None: + default_settings.apply_update(settings) + super().__init__( sample_rate=sample_rate, - settings=XTTSTTSSettings( - model=None, - voice=voice_id, - language=self.language_to_service_language(language), - base_url=base_url, - ), + settings=default_settings, **kwargs, ) self._studio_speakers: Optional[Dict[str, Any]] = None From bc2843e30ae2031766d3af665e34df915e65e90e Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 3 Mar 2026 14:33:16 -0500 Subject: [PATCH 02/17] Fix deprecation version --- src/pipecat/services/asyncai/tts.py | 16 ++++++------- src/pipecat/services/aws/stt.py | 4 ++-- src/pipecat/services/aws/tts.py | 6 ++--- src/pipecat/services/azure/image.py | 2 +- src/pipecat/services/azure/llm.py | 2 +- src/pipecat/services/azure/stt.py | 2 +- src/pipecat/services/azure/tts.py | 10 ++++---- src/pipecat/services/camb/tts.py | 8 +++---- src/pipecat/services/cartesia/tts.py | 12 +++++----- src/pipecat/services/cerebras/llm.py | 2 +- src/pipecat/services/deepgram/flux/stt.py | 6 ++--- .../services/deepgram/sagemaker/tts.py | 2 +- src/pipecat/services/deepgram/tts.py | 4 ++-- src/pipecat/services/deepseek/llm.py | 2 +- src/pipecat/services/elevenlabs/stt.py | 12 +++++----- src/pipecat/services/elevenlabs/tts.py | 16 ++++++------- src/pipecat/services/fal/image.py | 2 +- src/pipecat/services/fal/stt.py | 4 ++-- src/pipecat/services/fireworks/llm.py | 2 +- src/pipecat/services/fish/tts.py | 8 +++---- src/pipecat/services/gladia/stt.py | 4 ++-- src/pipecat/services/google/image.py | 2 +- src/pipecat/services/google/llm_openai.py | 2 +- src/pipecat/services/google/stt.py | 4 ++-- src/pipecat/services/google/tts.py | 20 ++++++++-------- src/pipecat/services/gradium/stt.py | 4 ++-- src/pipecat/services/gradium/tts.py | 8 +++---- src/pipecat/services/grok/llm.py | 2 +- src/pipecat/services/groq/llm.py | 2 +- src/pipecat/services/groq/stt.py | 8 +++---- src/pipecat/services/groq/tts.py | 8 +++---- src/pipecat/services/hume/tts.py | 6 ++--- src/pipecat/services/inworld/tts.py | 16 ++++++------- src/pipecat/services/kokoro/tts.py | 6 ++--- src/pipecat/services/lmnt/tts.py | 4 ++-- src/pipecat/services/minimax/tts.py | 8 +++---- src/pipecat/services/mistral/llm.py | 2 +- src/pipecat/services/moondream/vision.py | 2 +- src/pipecat/services/neuphonic/tts.py | 12 +++++----- src/pipecat/services/nvidia/llm.py | 2 +- src/pipecat/services/nvidia/stt.py | 8 +++---- src/pipecat/services/nvidia/tts.py | 6 ++--- src/pipecat/services/ollama/llm.py | 2 +- src/pipecat/services/openai/base_llm.py | 6 ++--- src/pipecat/services/openai/image.py | 2 +- src/pipecat/services/openai/llm.py | 4 ++-- src/pipecat/services/openai/stt.py | 4 ++-- src/pipecat/services/openai/tts.py | 12 +++++----- src/pipecat/services/openpipe/llm.py | 2 +- src/pipecat/services/openrouter/llm.py | 2 +- src/pipecat/services/perplexity/llm.py | 2 +- src/pipecat/services/piper/tts.py | 4 ++-- src/pipecat/services/qwen/llm.py | 2 +- src/pipecat/services/resembleai/tts.py | 2 +- src/pipecat/services/rime/tts.py | 24 +++++++++---------- src/pipecat/services/sambanova/llm.py | 2 +- src/pipecat/services/sambanova/stt.py | 8 +++---- src/pipecat/services/sarvam/stt.py | 6 ++--- src/pipecat/services/sarvam/tts.py | 16 ++++++------- src/pipecat/services/soniox/stt.py | 6 ++--- src/pipecat/services/speechmatics/stt.py | 2 +- src/pipecat/services/speechmatics/tts.py | 6 ++--- src/pipecat/services/together/llm.py | 2 +- src/pipecat/services/whisper/base_stt.py | 8 +++---- src/pipecat/services/whisper/stt.py | 18 +++++++------- src/pipecat/services/xtts/tts.py | 2 +- 66 files changed, 201 insertions(+), 201 deletions(-) diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index 245253ac8..b7ddec2e1 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -110,7 +110,7 @@ class AsyncAITTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for Async TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -143,14 +143,14 @@ class AsyncAITTSService(AudioContextTTSService): voice_id: UUID of the voice to use for synthesis. See docs for a full list: https://docs.async.com/list-voices-16699698e0 - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AsyncAITTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AsyncAITTSSettings(model=...)`` instead. sample_rate: Audio sample rate. @@ -158,7 +158,7 @@ class AsyncAITTSService(AudioContextTTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AsyncAITTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -500,7 +500,7 @@ class AsyncAIHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Async API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -531,13 +531,13 @@ class AsyncAIHttpTTSService(TTSService): api_key: Async API key. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AsyncAITTSSettings(voice=...)`` instead. aiohttp_session: An aiohttp session for making HTTP requests. model: TTS model to use (e.g., "async_flash_v1.0"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AsyncAITTSSettings(model=...)`` instead. url: Base URL for Async API. @@ -547,7 +547,7 @@ class AsyncAIHttpTTSService(TTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AsyncAITTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index 1cbfa7329..061b17889 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -96,12 +96,12 @@ class AWSTranscribeSTTService(WebsocketSTTService): region: AWS region for the service. sample_rate: Audio sample rate in Hz. Must be 8000 or 16000. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AWSTranscribeSTTSettings(sample_rate=...)`` instead. language: Language for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AWSTranscribeSTTSettings(language=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/aws/tts.py b/src/pipecat/services/aws/tts.py index 8e11cb3cd..83ef4125c 100644 --- a/src/pipecat/services/aws/tts.py +++ b/src/pipecat/services/aws/tts.py @@ -155,7 +155,7 @@ class AWSPollyTTSService(TTSService): class InputParams(BaseModel): """Input parameters for AWS Polly TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``AWSPollyTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -196,13 +196,13 @@ class AWSPollyTTSService(TTSService): region: AWS region for Polly service. Defaults to 'us-east-1'. voice_id: Voice ID to use for synthesis. Defaults to 'Joanna'. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AWSPollyTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses service default. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AWSPollyTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/azure/image.py b/src/pipecat/services/azure/image.py index e64e5c7d8..9f5d48c33 100644 --- a/src/pipecat/services/azure/image.py +++ b/src/pipecat/services/azure/image.py @@ -59,7 +59,7 @@ class AzureImageGenServiceREST(ImageGenService): endpoint: Azure OpenAI endpoint URL. model: The image generation model to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureImageGenSettings(model=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. diff --git a/src/pipecat/services/azure/llm.py b/src/pipecat/services/azure/llm.py index b828f0e4e..3c28e190e 100644 --- a/src/pipecat/services/azure/llm.py +++ b/src/pipecat/services/azure/llm.py @@ -40,7 +40,7 @@ class AzureLLMService(OpenAILLMService): endpoint: The Azure endpoint URL. model: The model identifier to use. Defaults to "gpt-4o". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. api_version: Azure API version. Defaults to "2024-09-01-preview". diff --git a/src/pipecat/services/azure/stt.py b/src/pipecat/services/azure/stt.py index 5ab88c8dd..02a7ca8ed 100644 --- a/src/pipecat/services/azure/stt.py +++ b/src/pipecat/services/azure/stt.py @@ -94,7 +94,7 @@ class AzureSTTService(STTService): region: Azure region for the Speech service (e.g., 'eastus'). language: Language for speech recognition. Defaults to English (US). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureSTTSettings(language=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index d37874825..7e5791f03 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -115,7 +115,7 @@ class AzureBaseTTSService: class InputParams(BaseModel): """Input parameters for Azure TTS voice configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureTTSSettings(...)`` instead. Parameters: @@ -271,13 +271,13 @@ class AzureTTSService(TTSService, AzureBaseTTSService): region: Azure region identifier (e.g., "eastus", "westus2"). voice: Voice name to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -766,13 +766,13 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): region: Azure region identifier (e.g., "eastus", "westus2"). voice: Voice name to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=AzureTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/camb/tts.py b/src/pipecat/services/camb/tts.py index 4ee2d5171..de8b16ab8 100644 --- a/src/pipecat/services/camb/tts.py +++ b/src/pipecat/services/camb/tts.py @@ -175,7 +175,7 @@ class CambTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Camb.ai TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CambTTSSettings(...)`` instead. Parameters: @@ -210,12 +210,12 @@ class CambTTSService(TTSService): api_key: Camb.ai API key for authentication. voice_id: Voice ID to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CambTTSSettings(voice=...)`` instead. model: TTS model to use. Options: "mars-flash" (fast), "mars-pro" (high quality). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CambTTSSettings(model=...)`` instead. timeout: Request timeout in seconds. Defaults to 60.0 (minimum recommended @@ -223,7 +223,7 @@ class CambTTSService(TTSService): sample_rate: Audio sample rate in Hz. If None, uses model-specific default. params: Additional voice parameters. If None, uses defaults. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CambTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index bc8b04dfd..c2227d00b 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -279,14 +279,14 @@ class CartesiaTTSService(AudioContextTTSService): api_key: Cartesia API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CartesiaTTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CartesiaTTSSettings(model=...)`` instead. sample_rate: Audio sample rate. If None, uses default. @@ -294,7 +294,7 @@ class CartesiaTTSService(AudioContextTTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CartesiaTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -757,12 +757,12 @@ class CartesiaHttpTTSService(TTSService): api_key: Cartesia API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CartesiaTTSSettings(voice=...)`` instead. model: TTS model to use (e.g., "sonic-3"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CartesiaTTSSettings(model=...)`` instead. base_url: Base URL for Cartesia HTTP API. @@ -774,7 +774,7 @@ class CartesiaHttpTTSService(TTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=CartesiaTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index ec3c3f09b..053594083 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -39,7 +39,7 @@ class CerebrasLLMService(OpenAILLMService): base_url: The base URL for Cerebras API. Defaults to "https://api.cerebras.ai/v1". model: The model identifier to use. Defaults to "gpt-oss-120b". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index fdfd65613..04c2f1da3 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -124,7 +124,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for Deepgram Flux API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=DeepgramFluxSTTSettings(...)`` instead. Parameters: @@ -173,14 +173,14 @@ class DeepgramFluxSTTService(WebsocketSTTService): sample_rate: Audio sample rate in Hz. If None, uses the rate from params or 16000. model: Deepgram Flux model to use for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=DeepgramFluxSTTSettings(model=...)`` instead. flux_encoding: Audio encoding format required by Flux API. Must be "linear16". Raw signed little-endian 16-bit PCM encoding. params: InputParams instance containing detailed API configuration options. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=DeepgramFluxSTTSettings(...)`` instead. should_interrupt: Determine whether the bot should be interrupted when Flux detects that the user is speaking. diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index 0c141bac0..8d03f6eac 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -92,7 +92,7 @@ class DeepgramSageMakerTTSService(TTSService): region: AWS region where the endpoint is deployed (e.g., "us-east-2"). voice: Voice model to use for synthesis. Defaults to "aura-2-helena-en". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=DeepgramSageMakerTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses the value from StartFrame. diff --git a/src/pipecat/services/deepgram/tts.py b/src/pipecat/services/deepgram/tts.py index 4524d17b6..7c391490d 100644 --- a/src/pipecat/services/deepgram/tts.py +++ b/src/pipecat/services/deepgram/tts.py @@ -85,7 +85,7 @@ class DeepgramTTSService(WebsocketTTSService): api_key: Deepgram API key for authentication. voice: Voice model to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=DeepgramTTSSettings(voice=...)`` instead. base_url: WebSocket base URL for Deepgram API. Defaults to "wss://api.deepgram.com". @@ -403,7 +403,7 @@ class DeepgramHttpTTSService(TTSService): api_key: Deepgram API key for authentication. voice: Voice model to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=DeepgramTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests with connection pooling. diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index 2ebc2e6eb..8cc9ac56e 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -39,7 +39,7 @@ class DeepSeekLLMService(OpenAILLMService): base_url: The base URL for DeepSeek API. Defaults to "https://api.deepseek.com/v1". model: The model identifier to use. Defaults to "deepseek-chat". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/elevenlabs/stt.py b/src/pipecat/services/elevenlabs/stt.py index d5897b5c5..1eebcffde 100644 --- a/src/pipecat/services/elevenlabs/stt.py +++ b/src/pipecat/services/elevenlabs/stt.py @@ -228,7 +228,7 @@ class ElevenLabsSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for ElevenLabs STT API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsSTTSettings(...)`` instead. Parameters: @@ -260,13 +260,13 @@ class ElevenLabsSTTService(SegmentedSTTService): base_url: Base URL for ElevenLabs API. model: Model ID for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsSTTSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -452,7 +452,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for ElevenLabs Realtime STT API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. Parameters: @@ -500,13 +500,13 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): base_url: Base URL for ElevenLabs WebSocket API. model: Model ID for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsRealtimeSTTSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index b98ce6e1b..15c2dbb2e 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -331,7 +331,7 @@ class ElevenLabsTTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for ElevenLabs TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsTTSSettings(...)`` instead. Parameters: @@ -381,12 +381,12 @@ class ElevenLabsTTSService(AudioContextTTSService): api_key: ElevenLabs API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsTTSSettings(voice=...)`` instead. model: TTS model to use (e.g., "eleven_turbo_v2_5"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsTTSSettings(model=...)`` instead. url: WebSocket URL for ElevenLabs TTS API. @@ -395,7 +395,7 @@ class ElevenLabsTTSService(AudioContextTTSService): locators to use. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -907,7 +907,7 @@ class ElevenLabsHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for ElevenLabs HTTP TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. Parameters: @@ -954,13 +954,13 @@ class ElevenLabsHttpTTSService(TTSService): api_key: ElevenLabs API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsHttpTTSSettings(voice=...)`` instead. aiohttp_session: aiohttp ClientSession for HTTP requests. model: TTS model to use (e.g., "eleven_turbo_v2_5"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsHttpTTSSettings(model=...)`` instead. base_url: Base URL for ElevenLabs HTTP API. @@ -969,7 +969,7 @@ class ElevenLabsHttpTTSService(TTSService): locators to use. params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/fal/image.py b/src/pipecat/services/fal/image.py index 8847e3f24..6fd953f13 100644 --- a/src/pipecat/services/fal/image.py +++ b/src/pipecat/services/fal/image.py @@ -80,7 +80,7 @@ class FalImageGenService(ImageGenService): 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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FalImageGenSettings(model=...)`` instead. key: Optional API key for Fal.ai. If provided, sets FAL_KEY environment variable. diff --git a/src/pipecat/services/fal/stt.py b/src/pipecat/services/fal/stt.py index d2c1441d0..d80f73a98 100644 --- a/src/pipecat/services/fal/stt.py +++ b/src/pipecat/services/fal/stt.py @@ -169,7 +169,7 @@ class FalSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for Fal's Wizper API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FalSTTSettings(...)`` instead. Parameters: @@ -204,7 +204,7 @@ class FalSTTService(SegmentedSTTService): sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate. params: Configuration parameters for the Wizper API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FalSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index 9fa9e44bd..33d7d22e2 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -38,7 +38,7 @@ class FireworksLLMService(OpenAILLMService): api_key: The API key for accessing Fireworks AI. model: The model identifier to use. Defaults to "accounts/fireworks/models/firefunction-v2". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for Fireworks API. Defaults to "https://api.fireworks.ai/inference/v1". diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index e95cceebd..431b51729 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -95,7 +95,7 @@ class FishAudioTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Input parameters for Fish Audio TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FishAudioTTSSettings(...)`` instead. Parameters: @@ -131,7 +131,7 @@ class FishAudioTTSService(InterruptibleTTSService): api_key: Fish Audio API key for authentication. reference_id: Reference ID of the voice model to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FishAudioTTSSettings(voice=...)`` instead. model: Deprecated. Reference ID of the voice model to use for synthesis. @@ -142,14 +142,14 @@ class FishAudioTTSService(InterruptibleTTSService): model_id: Specify which Fish Audio TTS model to use (e.g. "s1"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FishAudioTTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=FishAudioTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index f2376d93e..e1e0d9276 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -272,12 +272,12 @@ class GladiaSTTService(WebsocketSTTService): sample_rate: Audio sample rate in Hz. If None, uses service default. model: Model to use for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GladiaSTTSettings(model=...)`` instead. params: Additional configuration parameters for Gladia service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GladiaSTTSettings(...)`` instead. max_buffer_size: Maximum size of audio buffer in bytes. Defaults to 20MB. diff --git a/src/pipecat/services/google/image.py b/src/pipecat/services/google/image.py index 3d7cf8c94..ce29c0276 100644 --- a/src/pipecat/services/google/image.py +++ b/src/pipecat/services/google/image.py @@ -82,7 +82,7 @@ class GoogleImageGenService(ImageGenService): api_key: Google AI API key for authentication. params: Configuration parameters for image generation. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleImageGenSettings(model=...)`` instead. http_options: HTTP options for the client. diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index 22703ae55..aa8794469 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -66,7 +66,7 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): base_url: Base URL for Google's OpenAI-compatible API. model: Google model name to use (e.g., "gemini-2.0-flash"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/google/stt.py b/src/pipecat/services/google/stt.py index 818df0214..23a586b96 100644 --- a/src/pipecat/services/google/stt.py +++ b/src/pipecat/services/google/stt.py @@ -425,7 +425,7 @@ class GoogleSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for Google Speech-to-Text. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleSTTSettings(...)`` instead. Parameters: @@ -500,7 +500,7 @@ class GoogleSTTService(STTService): sample_rate: Audio sample rate in Hertz. params: Configuration parameters for the service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index 86ec845a5..78719f8fa 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -566,7 +566,7 @@ class GoogleHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Google HTTP TTS voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``GoogleHttpTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -609,13 +609,13 @@ class GoogleHttpTTSService(TTSService): location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Google TTS voice identifier (e.g., "en-US-Standard-A"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleHttpTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses default. params: Voice customization parameters including pitch, rate, volume, etc. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleHttpTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -1016,7 +1016,7 @@ class GoogleTTSService(GoogleBaseTTSService): class InputParams(BaseModel): """Input parameters for Google streaming TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``GoogleStreamTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -1048,14 +1048,14 @@ class GoogleTTSService(GoogleBaseTTSService): location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Google TTS voice identifier (e.g., "en-US-Chirp3-HD-Charon"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleStreamTTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GoogleStreamTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -1222,7 +1222,7 @@ class GeminiTTSService(GoogleBaseTTSService): class InputParams(BaseModel): """Input parameters for Gemini TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``GeminiTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -1263,7 +1263,7 @@ class GeminiTTSService(GoogleBaseTTSService): model: Gemini TTS model to use. Must be a TTS model like "gemini-2.5-flash-tts" or "gemini-2.5-pro-tts". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GeminiTTSSettings(model=...)`` instead. credentials: JSON string containing Google Cloud service account credentials. @@ -1271,13 +1271,13 @@ class GeminiTTSService(GoogleBaseTTSService): location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Voice name from the available Gemini voices. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GeminiTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses Google's default 24kHz. params: TTS configuration parameters. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GeminiTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index e1d2b74d4..5974133c0 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -91,7 +91,7 @@ class GradiumSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for Gradium STT API. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GradiumSTTSettings(...)`` instead. Parameters: @@ -125,7 +125,7 @@ class GradiumSTTService(WebsocketSTTService): api_endpoint_base_url: WebSocket endpoint URL. Defaults to Gradium's streaming endpoint. params: Configuration parameters for language and delay settings. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GradiumSTTSettings(...)`` instead. json_config: Optional JSON configuration string for additional model settings. diff --git a/src/pipecat/services/gradium/tts.py b/src/pipecat/services/gradium/tts.py index 75455cf54..6f076f933 100644 --- a/src/pipecat/services/gradium/tts.py +++ b/src/pipecat/services/gradium/tts.py @@ -57,7 +57,7 @@ class GradiumTTSService(AudioContextTTSService): class InputParams(BaseModel): """Configuration parameters for Gradium TTS service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``GradiumTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -84,19 +84,19 @@ class GradiumTTSService(AudioContextTTSService): api_key: Gradium API key for authentication. voice_id: the voice identifier. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GradiumTTSSettings(voice=...)`` instead. url: Gradium websocket API endpoint. model: Model ID to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GradiumTTSSettings(model=...)`` instead. json_config: Optional JSON configuration string for additional model settings. params: Additional configuration parameters. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GradiumTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index 0ef6d36f2..2e6a93c4e 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -95,7 +95,7 @@ class GrokLLMService(OpenAILLMService): base_url: The base URL for Grok API. Defaults to "https://api.x.ai/v1". model: The model identifier to use. Defaults to "grok-3-beta". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index 23cce68a2..0ea3b3f50 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -38,7 +38,7 @@ class GroqLLMService(OpenAILLMService): base_url: The base URL for Groq API. Defaults to "https://api.groq.com/openai/v1". model: The model identifier to use. Defaults to "llama-3.3-70b-versatile". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/groq/stt.py b/src/pipecat/services/groq/stt.py index 8018ec702..e6ea42fd8 100644 --- a/src/pipecat/services/groq/stt.py +++ b/src/pipecat/services/groq/stt.py @@ -43,24 +43,24 @@ class GroqSTTService(BaseWhisperSTTService): Args: model: Whisper model to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/groq/tts.py b/src/pipecat/services/groq/tts.py index c6cc46e23..d16964d8c 100644 --- a/src/pipecat/services/groq/tts.py +++ b/src/pipecat/services/groq/tts.py @@ -64,7 +64,7 @@ class GroqTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Groq TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GroqTTSSettings(...)`` instead. Parameters: @@ -96,17 +96,17 @@ class GroqTTSService(TTSService): output_format: Audio output format. Defaults to "wav". params: Additional input parameters for voice customization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GroqTTSSettings(...)`` instead. model_name: TTS model to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GroqTTSSettings(model=...)`` instead. voice_id: Voice identifier to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=GroqTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate. Must be 48000 Hz for Groq TTS. diff --git a/src/pipecat/services/hume/tts.py b/src/pipecat/services/hume/tts.py index 35b6fbbc4..5b7300816 100644 --- a/src/pipecat/services/hume/tts.py +++ b/src/pipecat/services/hume/tts.py @@ -84,7 +84,7 @@ class HumeTTSService(TTSService): class InputParams(BaseModel): """Optional synthesis parameters for Hume TTS. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=HumeTTSSettings(...)`` instead. Parameters: @@ -113,12 +113,12 @@ class HumeTTSService(TTSService): api_key: Hume API key. If omitted, reads the ``HUME_API_KEY`` environment variable. voice_id: ID of the voice to use. Only voice IDs are supported; voice names are not. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=HumeTTSSettings(voice=...)`` instead. params: Optional synthesis controls (acting instructions, speed, trailing silence). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=HumeTTSSettings(...)`` instead. sample_rate: Output sample rate for emitted PCM frames. Defaults to 48_000 (Hume). diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index 23c3b36e4..f1797ad55 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -114,7 +114,7 @@ class InworldHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Inworld TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -148,12 +148,12 @@ class InworldHttpTTSService(TTSService): aiohttp_session: aiohttp ClientSession for HTTP requests. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=InworldTTSSettings(voice=...)`` instead. model: ID of the model to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=InworldTTSSettings(model=...)`` instead. streaming: Whether to use streaming mode. @@ -161,7 +161,7 @@ class InworldHttpTTSService(TTSService): encoding: Audio encoding format. params: Input parameters for Inworld TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=InworldTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -506,7 +506,7 @@ class InworldTTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for Inworld WebSocket TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -553,12 +553,12 @@ class InworldTTSService(AudioContextTTSService): api_key: Inworld API key. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=InworldTTSSettings(voice=...)`` instead. model: ID of the model to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=InworldTTSSettings(model=...)`` instead. url: URL of the Inworld WebSocket API. @@ -566,7 +566,7 @@ class InworldTTSService(AudioContextTTSService): encoding: Audio encoding format. params: Input parameters for Inworld WebSocket TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=InworldTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/kokoro/tts.py b/src/pipecat/services/kokoro/tts.py index fed53049c..8bab78f93 100644 --- a/src/pipecat/services/kokoro/tts.py +++ b/src/pipecat/services/kokoro/tts.py @@ -112,7 +112,7 @@ class KokoroTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Kokoro TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``KokoroTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -136,14 +136,14 @@ class KokoroTTSService(TTSService): Args: voice_id: Voice identifier to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=KokoroTTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=KokoroTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/lmnt/tts.py b/src/pipecat/services/lmnt/tts.py index 1e7cff994..a8ccec358 100644 --- a/src/pipecat/services/lmnt/tts.py +++ b/src/pipecat/services/lmnt/tts.py @@ -111,14 +111,14 @@ class LmntTTSService(InterruptibleTTSService): api_key: LMNT API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=LmntTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses default. language: Language for synthesis. Defaults to English. model: TTS model to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=LmntTTSSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/minimax/tts.py b/src/pipecat/services/minimax/tts.py index 602654e2f..9e520f763 100644 --- a/src/pipecat/services/minimax/tts.py +++ b/src/pipecat/services/minimax/tts.py @@ -166,7 +166,7 @@ class MiniMaxHttpTTSService(TTSService): class InputParams(BaseModel): """Configuration parameters for MiniMax TTS. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``MiniMaxTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -226,19 +226,19 @@ class MiniMaxHttpTTSService(TTSService): "speech-02-hd", "speech-02-turbo", "speech-01-hd", "speech-01-turbo". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=MiniMaxTTSSettings(model=...)`` instead. voice_id: Voice identifier. Defaults to "Calm_Woman". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=MiniMaxTTSSettings(voice=...)`` instead. aiohttp_session: aiohttp.ClientSession for API communication. sample_rate: Output audio sample rate in Hz. If None, uses pipeline default. params: Additional configuration parameters. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=MiniMaxTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index e4249741e..da1f612c9 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -41,7 +41,7 @@ class MistralLLMService(OpenAILLMService): base_url: The base URL for Mistral API. Defaults to "https://api.mistral.ai/v1". model: The model identifier to use. Defaults to "mistral-small-latest". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/moondream/vision.py b/src/pipecat/services/moondream/vision.py index db449d7ed..b80928a43 100644 --- a/src/pipecat/services/moondream/vision.py +++ b/src/pipecat/services/moondream/vision.py @@ -93,7 +93,7 @@ class MoondreamService(VisionService): Args: model: Hugging Face model identifier for the Moondream model. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=MoondreamSettings(model=...)`` instead. revision: Specific model revision to use. diff --git a/src/pipecat/services/neuphonic/tts.py b/src/pipecat/services/neuphonic/tts.py index 21c7b57dd..e1efee96b 100644 --- a/src/pipecat/services/neuphonic/tts.py +++ b/src/pipecat/services/neuphonic/tts.py @@ -102,7 +102,7 @@ class NeuphonicTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Input parameters for Neuphonic TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NeuphonicTTSSettings(...)`` instead. Parameters: @@ -133,7 +133,7 @@ class NeuphonicTTSService(InterruptibleTTSService): api_key: Neuphonic API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. url: WebSocket URL for the Neuphonic API. @@ -141,7 +141,7 @@ class NeuphonicTTSService(InterruptibleTTSService): encoding: Audio encoding format. Defaults to "pcm_linear". params: Additional input parameters for TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NeuphonicTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -441,7 +441,7 @@ class NeuphonicHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Neuphonic HTTP TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NeuphonicTTSSettings(...)`` instead. Parameters: @@ -471,7 +471,7 @@ class NeuphonicHttpTTSService(TTSService): api_key: Neuphonic API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. @@ -480,7 +480,7 @@ class NeuphonicHttpTTSService(TTSService): encoding: Audio encoding format. Defaults to "pcm_linear". params: Additional input parameters for TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NeuphonicTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index ef4afe848..1667457b9 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -45,7 +45,7 @@ class NvidiaLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index 7f9c28f8f..63e901005 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -130,7 +130,7 @@ class NvidiaSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva STT service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NvidiaSTTSettings(...)`` instead. Parameters: @@ -164,7 +164,7 @@ class NvidiaSTTService(STTService): sample_rate: Audio sample rate in Hz. If None, uses pipeline default. params: Additional configuration parameters for NVIDIA Riva. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NvidiaSTTSettings(...)`` instead. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. @@ -438,7 +438,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva segmented STT service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. Parameters: @@ -482,7 +482,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate params: Additional configuration parameters for NVIDIA Riva - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. diff --git a/src/pipecat/services/nvidia/tts.py b/src/pipecat/services/nvidia/tts.py index 0f7491645..75caa27e4 100644 --- a/src/pipecat/services/nvidia/tts.py +++ b/src/pipecat/services/nvidia/tts.py @@ -68,7 +68,7 @@ class NvidiaTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Riva TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``NvidiaTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -102,14 +102,14 @@ class NvidiaTTSService(TTSService): server: gRPC server endpoint. Defaults to NVIDIA's cloud endpoint. voice_id: Voice model identifier. Defaults to multilingual Aria voice. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NvidiaTTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=NvidiaTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index ecae3fc95..8fc94985d 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -35,7 +35,7 @@ class OLLamaLLMService(OpenAILLMService): Args: model: The OLLama model to use. Defaults to "llama2". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for the OLLama API endpoint. diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 9ff3af0ab..0b4c3dec7 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -75,7 +75,7 @@ class BaseOpenAILLMService(LLMService): class InputParams(BaseModel): """Input parameters for OpenAI model configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(...)`` instead of ``params=InputParams(...)``. @@ -130,7 +130,7 @@ class BaseOpenAILLMService(LLMService): Args: model: The OpenAI model name to use (e.g., "gpt-4.1", "gpt-4o"). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. api_key: OpenAI API key. If None, uses environment variable. @@ -140,7 +140,7 @@ class BaseOpenAILLMService(LLMService): default_headers: Additional HTTP headers to include in requests. params: Input parameters for model configuration and behavior. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openai/image.py b/src/pipecat/services/openai/image.py index 2dc66876c..a145df6e5 100644 --- a/src/pipecat/services/openai/image.py +++ b/src/pipecat/services/openai/image.py @@ -64,7 +64,7 @@ class OpenAIImageGenService(ImageGenService): image_size: Target size for generated images. model: DALL-E model to use for generation. Defaults to "dall-e-3". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAIImageGenSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index c259987a8..a8ab760c4 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -83,12 +83,12 @@ class OpenAILLMService(BaseOpenAILLMService): Args: model: The OpenAI model name to use. Defaults to "gpt-4.1". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. params: Input parameters for model configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index be933cd9a..5c31d3f02 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -80,7 +80,7 @@ class OpenAISTTService(BaseWhisperSTTService): Args: model: Model to use — either gpt-4o or Whisper. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(model=...)`` instead. api_key: OpenAI API key. Defaults to None. @@ -210,7 +210,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): model: Transcription model. Supported values are ``"gpt-4o-transcribe"`` and ``"gpt-4o-mini-transcribe"``. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAIRealtimeSTTSettings(model=...)`` instead. base_url: WebSocket base URL for the Realtime API. diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index 965b8faf7..42c963808 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -90,7 +90,7 @@ class OpenAITTSService(TTSService): class InputParams(BaseModel): """Input parameters for OpenAI TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAITTSSettings(...)`` instead. Parameters: @@ -122,28 +122,28 @@ class OpenAITTSService(TTSService): base_url: Custom base URL for OpenAI API. If None, uses default. voice: Voice ID to use for synthesis. Defaults to "alloy". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAITTSSettings(voice=...)`` instead. model: TTS model to use. Defaults to "gpt-4o-mini-tts". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAITTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAITTSSettings(instructions=...)`` instead. speed: Voice speed control (0.25 to 4.0, default 1.0). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAITTSSettings(speed=...)`` instead. params: Optional synthesis controls (acting instructions, speed, ...). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAITTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index 524eff860..7fb4ebd2d 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -52,7 +52,7 @@ class OpenPipeLLMService(OpenAILLMService): Args: model: The model name to use. Defaults to "gpt-4.1". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. api_key: OpenAI API key for authentication. If None, reads from environment. diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index 9b202c04d..ea307aaee 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -42,7 +42,7 @@ class OpenRouterLLMService(OpenAILLMService): to read from environment variables. model: The model identifier to use. Defaults to "openai/gpt-4o-2024-11-20". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for OpenRouter API. Defaults to "https://openrouter.ai/api/v1". diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index b00f9e974..1fbf763f3 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -46,7 +46,7 @@ class PerplexityLLMService(OpenAILLMService): base_url: The base URL for Perplexity's API. Defaults to "https://api.perplexity.ai". model: The model identifier to use. Defaults to "sonar". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/piper/tts.py b/src/pipecat/services/piper/tts.py index 559824b49..73c555c9d 100644 --- a/src/pipecat/services/piper/tts.py +++ b/src/pipecat/services/piper/tts.py @@ -65,7 +65,7 @@ class PiperTTSService(TTSService): Args: voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=PiperTTSSettings(voice=...)`` instead. download_dir: Directory for storing voice model files. Defaults to @@ -215,7 +215,7 @@ class PiperHttpTTSService(TTSService): aiohttp_session: aiohttp ClientSession for making HTTP requests. voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=PiperHttpTTSSettings(voice=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index 132924662..db407f880 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -38,7 +38,7 @@ class QwenLLMService(OpenAILLMService): base_url: Base URL for Qwen API. Defaults to "https://dashscope-intl.aliyuncs.com/compatible-mode/v1". model: The model identifier to use. Defaults to "qwen-plus". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/resembleai/tts.py b/src/pipecat/services/resembleai/tts.py index 148dacde2..ade4361e0 100644 --- a/src/pipecat/services/resembleai/tts.py +++ b/src/pipecat/services/resembleai/tts.py @@ -84,7 +84,7 @@ class ResembleAITTSService(AudioContextTTSService): api_key: Resemble AI API key for authentication. voice_id: Voice UUID to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=ResembleAITTSSettings(voice=...)`` instead. url: WebSocket URL for Resemble AI TTS API. diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index a44b738d1..c607a2e06 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -144,7 +144,7 @@ class RimeTTSService(AudioContextTTSService): class InputParams(BaseModel): """Configuration parameters for Rime TTS service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(...)`` instead. Parameters: @@ -196,19 +196,19 @@ class RimeTTSService(AudioContextTTSService): api_key: Rime API key for authentication. voice_id: ID of the voice to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(voice=...)`` instead. url: Rime websocket API endpoint. model: Model ID to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(model=...)`` instead. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -657,7 +657,7 @@ class RimeHttpTTSService(TTSService): class InputParams(BaseModel): """Configuration parameters for Rime HTTP TTS service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(...)`` instead. Parameters: @@ -694,19 +694,19 @@ class RimeHttpTTSService(TTSService): api_key: Rime API key for authentication. voice_id: ID of the voice to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. model: Model ID to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(model=...)`` instead. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -868,7 +868,7 @@ class RimeNonJsonTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Configuration parameters for Rime Non-JSON WebSocket TTS service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeNonJsonTTSSettings(...)`` instead. Args: @@ -908,20 +908,20 @@ class RimeNonJsonTTSService(InterruptibleTTSService): api_key: Rime API key for authentication. voice_id: ID of the voice to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeNonJsonTTSSettings(voice=...)`` instead. url: Rime websocket API endpoint. model: Model ID to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeNonJsonTTSSettings(model=...)`` instead. audio_format: Audio format to use. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=RimeNonJsonTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index 23d415598..5114297a8 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -49,7 +49,7 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore api_key: The API key for accessing SambaNova API. model: The model identifier to use. Defaults to "Llama-4-Maverick-17B-128E-Instruct". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for SambaNova API. Defaults to "https://api.sambanova.ai/v1". diff --git a/src/pipecat/services/sambanova/stt.py b/src/pipecat/services/sambanova/stt.py index 4e3c9e01d..4ca156b88 100644 --- a/src/pipecat/services/sambanova/stt.py +++ b/src/pipecat/services/sambanova/stt.py @@ -45,24 +45,24 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore Args: model: Whisper model to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/sarvam/stt.py b/src/pipecat/services/sarvam/stt.py index b3ac41470..97c8d1ccc 100644 --- a/src/pipecat/services/sarvam/stt.py +++ b/src/pipecat/services/sarvam/stt.py @@ -177,7 +177,7 @@ class SarvamSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for Sarvam STT service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamSTTSettings(...)`` instead. Parameters: @@ -219,14 +219,14 @@ class SarvamSTTService(STTService): api_key: Sarvam API key for authentication. model: Sarvam model to use for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamSTTSettings(model=...)`` instead. sample_rate: Audio sample rate. Defaults to 16000 if not specified. input_audio_codec: Audio codec/format of the input file. Defaults to "wav". params: Configuration parameters for Sarvam STT service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 4d125dfc9..14386d743 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -376,7 +376,7 @@ class SarvamHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Sarvam TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``SarvamHttpTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -445,14 +445,14 @@ class SarvamHttpTTSService(TTSService): aiohttp_session: Shared aiohttp session for making requests. voice_id: Speaker voice ID. If None, uses model-appropriate default. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamHttpTTSSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamHttpTTSSettings(model=...)`` instead. base_url: Sarvam AI API base URL. Defaults to "https://api.sarvam.ai". @@ -460,7 +460,7 @@ class SarvamHttpTTSService(TTSService): If None, uses model-specific default. params: Additional voice and preprocessing parameters. If None, uses defaults. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamHttpTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -724,7 +724,7 @@ class SarvamTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Configuration parameters for Sarvam TTS WebSocket service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``SarvamTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -830,12 +830,12 @@ class SarvamTTSService(InterruptibleTTSService): - "bulbul:v2" (default): Standard model with pitch/loudness support - "bulbul:v3-beta": Advanced model with temperature control - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamTTSSettings(model=...)`` instead. voice_id: Speaker voice ID. If None, uses model-appropriate default. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamTTSSettings(voice=...)`` instead. url: WebSocket URL for the TTS backend (default production URL). @@ -849,7 +849,7 @@ class SarvamTTSService(InterruptibleTTSService): If None, uses model-specific default. params: Optional input parameters to override defaults. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SarvamTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index 84c437f36..c9b3fb7c9 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -79,7 +79,7 @@ class SonioxContextObject(BaseModel): class SonioxInputParams(BaseModel): """Real-time transcription settings. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SonioxSTTSettings(...)`` instead. See Soniox WebSocket API documentation for more details: @@ -201,13 +201,13 @@ class SonioxSTTService(WebsocketSTTService): sample_rate: Audio sample rate. model: Soniox model to use for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SonioxSTTSettings(model=...)`` instead. params: Additional configuration parameters, such as language hints, context and speaker diarization. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SonioxSTTSettings(...)`` instead. vad_force_turn_endpoint: Listen to `VADUserStoppedSpeakingFrame` to send finalize message to Soniox. diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index a0ca19f74..2d3e90896 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -395,7 +395,7 @@ class SpeechmaticsSTTService(STTService): sample_rate: Optional audio sample rate in Hz. params: Input parameters for the service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SpeechmaticsSTTSettings(...)`` instead. should_interrupt: Determine whether the bot should be interrupted when Speechmatics turn_detection_mode is configured to detect user speech. diff --git a/src/pipecat/services/speechmatics/tts.py b/src/pipecat/services/speechmatics/tts.py index e1260fbe2..8ce6ae2ef 100644 --- a/src/pipecat/services/speechmatics/tts.py +++ b/src/pipecat/services/speechmatics/tts.py @@ -62,7 +62,7 @@ class SpeechmaticsTTSService(TTSService): class InputParams(BaseModel): """Optional input parameters for Speechmatics TTS configuration. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SpeechmaticsTTSSettings(...)`` instead. Parameters: @@ -90,14 +90,14 @@ class SpeechmaticsTTSService(TTSService): base_url: Base URL for Speechmatics TTS API. voice_id: Voice model to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SpeechmaticsTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. sample_rate: Audio sample rate in Hz. params: Input parameters for the service. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=SpeechmaticsTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index b1cb4ffea..48e15ae5c 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -38,7 +38,7 @@ class TogetherLLMService(OpenAILLMService): base_url: The base URL for Together.ai API. Defaults to "https://api.together.xyz/v1". model: The model identifier to use. Defaults to "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo". - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index 32dd382e8..a54da0c05 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -146,24 +146,24 @@ class BaseWhisperSTTService(SegmentedSTTService): Args: model: Name of the Whisper model to use. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(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:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. temperature: Sampling temperature between 0 and 1. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. include_prob_metrics: If True, enables probability metrics in API response. diff --git a/src/pipecat/services/whisper/stt.py b/src/pipecat/services/whisper/stt.py index 2e0a6156a..38fd287fa 100644 --- a/src/pipecat/services/whisper/stt.py +++ b/src/pipecat/services/whisper/stt.py @@ -229,27 +229,27 @@ class WhisperSTTService(SegmentedSTTService): Args: model: The Whisper model to use for transcription. Can be a Model enum or string. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperSTTSettings(model=...)`` instead. device: The device to run inference on ('cpu', 'cuda', or 'auto'). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperSTTSettings(device=...)`` instead. compute_type: The compute type for inference ('default', 'int8', 'int8_float16', etc.). - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperSTTSettings(compute_type=...)`` instead. no_speech_prob: Probability threshold for filtering out non-speech segments. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperSTTSettings(no_speech_prob=...)`` instead. language: The default language for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperSTTSettings(language=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -408,22 +408,22 @@ class WhisperSTTServiceMLX(WhisperSTTService): Args: model: The MLX Whisper model to use for transcription. Can be an MLXModel enum or string. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperMLXSTTSettings(model=...)`` instead. no_speech_prob: Probability threshold for filtering out non-speech segments. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperMLXSTTSettings(no_speech_prob=...)`` instead. language: The default language for transcription. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperMLXSTTSettings(language=...)`` instead. temperature: Temperature for sampling. Can be a float or tuple of floats. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=WhisperMLXSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/xtts/tts.py b/src/pipecat/services/xtts/tts.py index bba95a400..88137172f 100644 --- a/src/pipecat/services/xtts/tts.py +++ b/src/pipecat/services/xtts/tts.py @@ -107,7 +107,7 @@ class XTTSService(TTSService): Args: voice_id: ID of the voice/speaker to use for synthesis. - .. deprecated:: 1.0 + .. deprecated:: 1.0.0 Use ``settings=XTTSTTSSettings(voice=...)`` instead. base_url: Base URL of the XTTS streaming server. From 07f1d0cd966ceafabb875664149eebfa1b7021fe Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 3 Mar 2026 19:52:09 -0500 Subject: [PATCH 03/17] Change `_warn_deprecated_param` to accept type references instead of strings Update all ~192 call sites across 84 service files to pass class references (e.g. `CartesiaTTSSettings`) instead of string names (`"CartesiaTTSSettings"`) to `_warn_deprecated_param()`. This enables better IDE refactoring support. Also fix `from_mapping` return type annotations in 5 settings subclasses to use `typing.Self` instead of forward reference strings. --- src/pipecat/services/anthropic/llm.py | 74 ++--- src/pipecat/services/assemblyai/stt.py | 39 ++- src/pipecat/services/asyncai/tts.py | 76 +++--- src/pipecat/services/aws/llm.py | 52 ++-- src/pipecat/services/aws/nova_sonic/llm.py | 55 ++-- src/pipecat/services/aws/stt.py | 29 +- src/pipecat/services/aws/tts.py | 46 ++-- src/pipecat/services/azure/image.py | 2 +- src/pipecat/services/azure/llm.py | 11 +- src/pipecat/services/azure/stt.py | 15 +- src/pipecat/services/azure/tts.py | 104 ++++--- src/pipecat/services/camb/tts.py | 49 ++-- src/pipecat/services/cartesia/stt.py | 38 +-- src/pipecat/services/cartesia/tts.py | 93 ++++--- src/pipecat/services/cerebras/llm.py | 11 +- src/pipecat/services/deepgram/flux/stt.py | 41 ++- .../services/deepgram/sagemaker/stt.py | 36 ++- .../services/deepgram/sagemaker/tts.py | 2 +- src/pipecat/services/deepgram/stt.py | 28 +- src/pipecat/services/deepgram/tts.py | 32 ++- src/pipecat/services/deepseek/llm.py | 11 +- src/pipecat/services/elevenlabs/stt.py | 82 ++++-- src/pipecat/services/elevenlabs/tts.py | 131 +++++---- src/pipecat/services/fal/image.py | 11 +- src/pipecat/services/fal/stt.py | 31 ++- src/pipecat/services/fireworks/llm.py | 13 +- src/pipecat/services/fish/tts.py | 52 ++-- src/pipecat/services/gladia/stt.py | 91 ++++--- .../services/google/gemini_live/llm.py | 77 ++++-- .../services/google/gemini_live/llm_vertex.py | 77 ++++-- src/pipecat/services/google/image.py | 14 +- src/pipecat/services/google/llm.py | 41 ++- src/pipecat/services/google/llm_openai.py | 11 +- src/pipecat/services/google/llm_vertex.py | 46 ++-- src/pipecat/services/google/stt.py | 50 ++-- src/pipecat/services/google/tts.py | 131 +++++---- src/pipecat/services/gradium/stt.py | 21 +- src/pipecat/services/gradium/tts.py | 27 +- src/pipecat/services/grok/llm.py | 11 +- src/pipecat/services/grok/realtime/llm.py | 17 +- src/pipecat/services/groq/llm.py | 11 +- src/pipecat/services/groq/stt.py | 39 +-- src/pipecat/services/groq/tts.py | 35 ++- src/pipecat/services/hume/tts.py | 31 ++- src/pipecat/services/inworld/tts.py | 117 +++++--- src/pipecat/services/kokoro/tts.py | 37 ++- src/pipecat/services/lmnt/tts.py | 22 +- src/pipecat/services/minimax/tts.py | 132 ++++----- src/pipecat/services/mistral/llm.py | 11 +- src/pipecat/services/moondream/vision.py | 11 +- src/pipecat/services/neuphonic/tts.py | 62 +++-- src/pipecat/services/nvidia/llm.py | 13 +- src/pipecat/services/nvidia/stt.py | 54 ++-- src/pipecat/services/nvidia/tts.py | 30 ++- src/pipecat/services/ollama/llm.py | 11 +- src/pipecat/services/openai/base_llm.py | 41 ++- src/pipecat/services/openai/image.py | 11 +- src/pipecat/services/openai/llm.py | 51 ++-- src/pipecat/services/openai/realtime/llm.py | 23 +- src/pipecat/services/openai/stt.py | 49 ++-- src/pipecat/services/openai/tts.py | 47 ++-- .../services/openai_realtime_beta/openai.py | 24 +- src/pipecat/services/openpipe/llm.py | 11 +- src/pipecat/services/openrouter/llm.py | 11 +- src/pipecat/services/perplexity/llm.py | 11 +- src/pipecat/services/piper/tts.py | 34 ++- src/pipecat/services/qwen/llm.py | 11 +- src/pipecat/services/resembleai/tts.py | 27 +- src/pipecat/services/rime/tts.py | 176 +++++++----- src/pipecat/services/sambanova/llm.py | 11 +- src/pipecat/services/sambanova/stt.py | 39 +-- src/pipecat/services/sarvam/stt.py | 66 +++-- src/pipecat/services/sarvam/tts.py | 255 ++++++++++-------- src/pipecat/services/settings.py | 5 +- src/pipecat/services/soniox/stt.py | 49 ++-- src/pipecat/services/speechmatics/stt.py | 109 +++++--- src/pipecat/services/speechmatics/tts.py | 24 +- src/pipecat/services/together/llm.py | 13 +- src/pipecat/services/ultravox/llm.py | 5 + src/pipecat/services/whisper/base_stt.py | 42 +-- src/pipecat/services/whisper/stt.py | 90 ++++--- src/pipecat/services/xtts/tts.py | 13 +- 82 files changed, 2321 insertions(+), 1321 deletions(-) diff --git a/src/pipecat/services/anthropic/llm.py b/src/pipecat/services/anthropic/llm.py index d2a4c300d..170c7e425 100644 --- a/src/pipecat/services/anthropic/llm.py +++ b/src/pipecat/services/anthropic/llm.py @@ -249,43 +249,57 @@ class AnthropicLLMService(LLMService): system_instruction: Optional system instruction to use as the system prompt. **kwargs: Additional arguments passed to parent LLMService. """ - if model is not None: - _warn_deprecated_param("model", "AnthropicLLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "AnthropicLLMSettings") - - _params = params or AnthropicLLMService.InputParams() - - # Handle existing enable_prompt_caching_beta deprecation - enable_prompt_caching = _params.enable_prompt_caching - if _params.enable_prompt_caching_beta is not None: - import warnings - - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - "enable_prompt_caching_beta is deprecated. Use enable_prompt_caching instead.", - DeprecationWarning, - stacklevel=2, - ) - if enable_prompt_caching is None: - enable_prompt_caching = _params.enable_prompt_caching_beta - + # 1. Initialize default_settings with hardcoded defaults default_settings = AnthropicLLMSettings( - model=model or "claude-sonnet-4-6", - max_tokens=_params.max_tokens, - enable_prompt_caching=enable_prompt_caching or False, - temperature=_params.temperature, - top_k=_params.top_k, - top_p=_params.top_p, + model="claude-sonnet-4-6", + max_tokens=4096, + enable_prompt_caching=False, + temperature=NOT_GIVEN, + top_k=NOT_GIVEN, + top_p=NOT_GIVEN, frequency_penalty=None, presence_penalty=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - thinking=_params.thinking, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + thinking=NOT_GIVEN, + extra={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", AnthropicLLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AnthropicLLMSettings) + if not settings: + default_settings.max_tokens = params.max_tokens + default_settings.temperature = params.temperature + default_settings.top_k = params.top_k + default_settings.top_p = params.top_p + default_settings.thinking = params.thinking + if isinstance(params.extra, dict): + default_settings.extra = params.extra + # Handle enable_prompt_caching / enable_prompt_caching_beta + enable_prompt_caching = params.enable_prompt_caching + if params.enable_prompt_caching_beta is not None: + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "enable_prompt_caching_beta is deprecated. " + "Use enable_prompt_caching instead.", + DeprecationWarning, + stacklevel=2, + ) + if enable_prompt_caching is None: + enable_prompt_caching = params.enable_prompt_caching_beta + default_settings.enable_prompt_caching = enable_prompt_caching or False + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/assemblyai/stt.py b/src/pipecat/services/assemblyai/stt.py index 85d4029b7..e140f7543 100644 --- a/src/pipecat/services/assemblyai/stt.py +++ b/src/pipecat/services/assemblyai/stt.py @@ -32,7 +32,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import ASSEMBLYAI_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language @@ -108,9 +108,9 @@ class AssemblyAISTTService(WebsocketSTTService): self, *, api_key: str, - language: Language = Language.EN, # AssemblyAI only supports English + language: Optional[Language] = None, api_endpoint_base_url: str = "wss://streaming.assemblyai.com/v3/ws", - connection_params: AssemblyAIConnectionParams = AssemblyAIConnectionParams(), + connection_params: Optional[AssemblyAIConnectionParams] = None, vad_force_turn_endpoint: bool = True, should_interrupt: bool = True, speaker_format: Optional[str] = None, @@ -151,20 +151,23 @@ class AssemblyAISTTService(WebsocketSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService class. """ + # Resolve connection_params early — needed for validation and turn mode config + _connection_params = connection_params or AssemblyAIConnectionParams() + # AssemblyAI turn detection mode (vad_force_turn_endpoint=False) requires the # SpeechStarted event for reliable barge-in. Only u3-rt-pro supports # this. Other models must use Pipecat turn detection. - is_u3_pro = connection_params.speech_model == "u3-rt-pro" + is_u3_pro = _connection_params.speech_model == "u3-rt-pro" if not vad_force_turn_endpoint and not is_u3_pro: raise ValueError( f"AssemblyAI turn detection mode (vad_force_turn_endpoint=False) requires " f"u3-rt-pro for SpeechStarted support. Either set " - f"vad_force_turn_endpoint=True for {connection_params.speech_model}, " + f"vad_force_turn_endpoint=True for {_connection_params.speech_model}, " f"or use speech_model='u3-rt-pro'." ) # Validate that prompt and keyterms_prompt are not both set - if connection_params.prompt is not None and connection_params.keyterms_prompt is not None: + if _connection_params.prompt is not None and _connection_params.keyterms_prompt is not None: raise ValueError( "The prompt and keyterms_prompt parameters cannot be used in the same request. " "Please choose either one or the other based on your use case. When you use " @@ -174,7 +177,7 @@ class AssemblyAISTTService(WebsocketSTTService): ) # Warn if user sets a custom prompt (recommend testing without one first) - if connection_params.prompt is not None: + if _connection_params.prompt is not None: logger.warning( "Custom prompt detected. Prompting is a beta feature. We recommend testing " "with no prompt first, as this will use our optimized default prompt for " @@ -186,18 +189,32 @@ class AssemblyAISTTService(WebsocketSTTService): # When vad_force_turn_endpoint is enabled, configure connection params # for Pipecat turn detection mode (fast finals for smart turn analyzer) if vad_force_turn_endpoint: - connection_params = self._configure_pipecat_turn_mode(connection_params, is_u3_pro) + _connection_params = self._configure_pipecat_turn_mode(_connection_params, is_u3_pro) + # 1. Initialize default_settings with hardcoded defaults default_settings = AssemblyAISTTSettings( model=None, - language=language, - connection_params=connection_params, + language=Language.EN, + connection_params=AssemblyAIConnectionParams(), ) + + # 2. Apply direct init arg overrides (deprecated) + if language is not None: + _warn_deprecated_param("language", AssemblyAISTTSettings, "language") + default_settings.language = language + + # 3. Apply connection_params overrides — only if settings not provided + if connection_params is not None: + _warn_deprecated_param("connection_params", AssemblyAISTTSettings) + if not settings: + default_settings.connection_params = _connection_params + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) super().__init__( - sample_rate=connection_params.sample_rate, + sample_rate=_connection_params.sample_rate, ttfs_p99_latency=ttfs_p99_latency, settings=default_settings, **kwargs, diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index b7ddec2e1..ef5c95bfe 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -10,7 +10,7 @@ import asyncio import base64 import json from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, Mapping, Optional +from typing import Any, AsyncGenerator, Mapping, Optional, Self import aiohttp from loguru import logger @@ -88,7 +88,7 @@ class AsyncAITTSSettings(TTSSettings): output_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> "AsyncAITTSSettings": + def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested ``output_format``.""" flat = dict(settings) nested = flat.pop("output_format", None) @@ -171,25 +171,33 @@ class AsyncAITTSService(AudioContextTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to the parent service. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "AsyncAITTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "AsyncAITTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "AsyncAITTSSettings") - - _params = params or AsyncAITTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AsyncAITTSSettings( - model=model or "async_flash_v1.0", - voice=voice_id, + model="async_flash_v1.0", + voice=None, + language=None, output_container=container, output_encoding=encoding, output_sample_rate=0, - language=self.language_to_service_language(_params.language) - if _params.language - else None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", AsyncAITTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", AsyncAITTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AsyncAITTSSettings) + if not settings: + default_settings.language = ( + self.language_to_service_language(params.language) if params.language else None + ) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -554,25 +562,33 @@ class AsyncAIHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "AsyncAITTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "AsyncAITTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "AsyncAITTSSettings") - - _params = params or AsyncAIHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AsyncAITTSSettings( - model=model or "async_flash_v1.0", - voice=voice_id, + model="async_flash_v1.0", + voice=None, + language=None, output_container=container, output_encoding=encoding, output_sample_rate=0, - language=self.language_to_service_language(_params.language) - if _params.language - else None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", AsyncAITTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", AsyncAITTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AsyncAITTSSettings) + if not settings: + default_settings.language = ( + self.language_to_service_language(params.language) if params.language else None + ) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index b8a92eccb..d688b6114 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -816,37 +816,53 @@ class AWSBedrockLLMService(LLMService): system_instruction: Optional system instruction to use as the system prompt. **kwargs: Additional arguments passed to parent LLMService. """ - if model is not None: - _warn_deprecated_param("model", "AWSBedrockLLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "AWSBedrockLLMSettings") - - _params = params or AWSBedrockLLMService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AWSBedrockLLMSettings( - model=model or "us.amazon.nova-lite-v1:0", - max_tokens=_params.max_tokens, - temperature=_params.temperature, - top_p=_params.top_p, + model="us.amazon.nova-lite-v1:0", + max_tokens=None, + temperature=None, + top_p=None, top_k=None, frequency_penalty=None, presence_penalty=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - latency=_params.latency, - additional_model_request_fields=_params.additional_model_request_fields - if isinstance(_params.additional_model_request_fields, dict) - else {}, + latency=None, + additional_model_request_fields={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", AWSBedrockLLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AWSBedrockLLMSettings) + if not settings: + default_settings.max_tokens = params.max_tokens + default_settings.temperature = params.temperature + default_settings.top_p = params.top_p + default_settings.latency = params.latency + if isinstance(params.additional_model_request_fields, dict): + default_settings.additional_model_request_fields = ( + params.additional_model_request_fields + ) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) super().__init__(settings=default_settings, **kwargs) - self._stop_sequences = ( - stop_sequences if stop_sequences is not None else (_params.stop_sequences or []) - ) + # Handle stop_sequences (not a settings field) + if stop_sequences is not None: + self._stop_sequences = stop_sequences + elif params is not None: + self._stop_sequences = params.stop_sequences or [] + else: + self._stop_sequences = [] # Initialize the AWS Bedrock client if not client_config: diff --git a/src/pipecat/services/aws/nova_sonic/llm.py b/src/pipecat/services/aws/nova_sonic/llm.py index 887c3f46c..7fec1c73c 100644 --- a/src/pipecat/services/aws/nova_sonic/llm.py +++ b/src/pipecat/services/aws/nova_sonic/llm.py @@ -270,30 +270,40 @@ class AWSNovaSonicLLMService(LLMService): **kwargs: Additional arguments passed to the parent LLMService. """ - # Check for deprecated parameter usage - if model != "amazon.nova-2-sonic-v1:0": - _warn_deprecated_param("model", "AWSNovaSonicLLMSettings", "model") - if voice_id != "matthew": - _warn_deprecated_param("voice_id", "AWSNovaSonicLLMSettings", "voice_id") - if params is not None: - _warn_deprecated_param("params", "AWSNovaSonicLLMSettings") - - _params = params or Params() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AWSNovaSonicLLMSettings( - model=model, - voice_id=voice_id, - temperature=_params.temperature, - max_tokens=_params.max_tokens, - top_p=_params.top_p, + model="amazon.nova-2-sonic-v1:0", + voice_id="matthew", + temperature=0.7, + max_tokens=1024, + top_p=0.9, top_k=None, frequency_penalty=None, presence_penalty=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - endpointing_sensitivity=_params.endpointing_sensitivity, + endpointing_sensitivity=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if model != "amazon.nova-2-sonic-v1:0": + _warn_deprecated_param("model", AWSNovaSonicLLMSettings, "model") + default_settings.model = model + if voice_id != "matthew": + _warn_deprecated_param("voice_id", AWSNovaSonicLLMSettings, "voice_id") + default_settings.voice_id = voice_id + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AWSNovaSonicLLMSettings) + if not settings: + default_settings.temperature = params.temperature + default_settings.max_tokens = params.max_tokens + default_settings.top_p = params.top_p + default_settings.endpointing_sensitivity = params.endpointing_sensitivity + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -308,12 +318,13 @@ class AWSNovaSonicLLMService(LLMService): self._client: Optional[BedrockRuntimeClient] = None # Audio I/O config (hardware settings, not runtime-tunable) - self._input_sample_rate = _params.input_sample_rate - self._input_sample_size = _params.input_sample_size - self._input_channel_count = _params.input_channel_count - self._output_sample_rate = _params.output_sample_rate - self._output_sample_size = _params.output_sample_size - self._output_channel_count = _params.output_channel_count + _audio_params = params or Params() + self._input_sample_rate = _audio_params.input_sample_rate + self._input_sample_size = _audio_params.input_sample_size + self._input_channel_count = _audio_params.input_channel_count + self._output_sample_rate = _audio_params.output_sample_rate + self._output_sample_size = _audio_params.output_sample_size + self._output_channel_count = _audio_params.output_channel_count self._system_instruction = system_instruction self._tools = tools diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index 061b17889..950624fbf 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -110,22 +110,27 @@ class AWSTranscribeSTTService(WebsocketSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService class. """ - if sample_rate is not None: - _warn_deprecated_param("sample_rate", "AWSTranscribeSTTSettings", "sample_rate") - if language is not None: - _warn_deprecated_param("language", "AWSTranscribeSTTSettings", "language") - - _sample_rate = sample_rate or 16000 - _language = language or Language.EN - + # 1. Initialize default_settings with hardcoded defaults default_settings = AWSTranscribeSTTSettings( - language=self.language_to_service_language(_language) or "en-US", - sample_rate=_sample_rate, + language=self.language_to_service_language(Language.EN) or "en-US", + sample_rate=16000, media_encoding="linear16", number_of_channels=1, show_speaker_label=False, enable_channel_identification=False, ) + + # 2. Apply direct init arg overrides (deprecated) + if sample_rate is not None: + _warn_deprecated_param("sample_rate", AWSTranscribeSTTSettings, "sample_rate") + default_settings.sample_rate = sample_rate + if language is not None: + _warn_deprecated_param("language", AWSTranscribeSTTSettings, "language") + default_settings.language = self.language_to_service_language(language) or "en-US" + + # 3. No params to apply + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -136,9 +141,9 @@ class AWSTranscribeSTTService(WebsocketSTTService): ) # Validate sample rate - AWS Transcribe only supports 8000 Hz or 16000 Hz - if _sample_rate not in [8000, 16000]: + if default_settings.sample_rate not in [8000, 16000]: logger.warning( - f"AWS Transcribe only supports 8000 Hz or 16000 Hz sample rates. Converting from {_sample_rate} Hz to 16000 Hz." + f"AWS Transcribe only supports 8000 Hz or 16000 Hz sample rates. Converting from {default_settings.sample_rate} Hz to 16000 Hz." ) self._settings.sample_rate = 16000 diff --git a/src/pipecat/services/aws/tts.py b/src/pipecat/services/aws/tts.py index 83ef4125c..f248db27a 100644 --- a/src/pipecat/services/aws/tts.py +++ b/src/pipecat/services/aws/tts.py @@ -209,25 +209,39 @@ class AWSPollyTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "AWSPollyTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "AWSPollyTTSSettings") - - _params = params or AWSPollyTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AWSPollyTTSSettings( model=None, - voice=voice_id or "Joanna", - engine=_params.engine, - language=self.language_to_service_language(_params.language) - if _params.language - else "en-US", - pitch=_params.pitch, - rate=_params.rate, - volume=_params.volume, - lexicon_names=_params.lexicon_names, + voice="Joanna", + language="en-US", + engine=None, + pitch=None, + rate=None, + volume=None, + lexicon_names=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", AWSPollyTTSSettings, "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) + if not settings: + default_settings.engine = params.engine + default_settings.language = ( + self.language_to_service_language(params.language) + if params.language + else "en-US" + ) + default_settings.pitch = params.pitch + default_settings.rate = params.rate + default_settings.volume = params.volume + default_settings.lexicon_names = params.lexicon_names + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/azure/image.py b/src/pipecat/services/azure/image.py index 9f5d48c33..ca58644f2 100644 --- a/src/pipecat/services/azure/image.py +++ b/src/pipecat/services/azure/image.py @@ -68,7 +68,7 @@ class AzureImageGenServiceREST(ImageGenService): parameters, ``settings`` values take precedence. """ if model is not None: - _warn_deprecated_param("model", "AzureImageGenSettings", "model") + _warn_deprecated_param("model", AzureImageGenSettings, "model") default_settings = AzureImageGenSettings(model=model) if settings is not None: diff --git a/src/pipecat/services/azure/llm.py b/src/pipecat/services/azure/llm.py index 3c28e190e..734a0bacf 100644 --- a/src/pipecat/services/azure/llm.py +++ b/src/pipecat/services/azure/llm.py @@ -48,10 +48,15 @@ class AzureLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="gpt-4o") - default_settings = OpenAILLMSettings(model=model or "gpt-4o") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/azure/stt.py b/src/pipecat/services/azure/stt.py index 02a7ca8ed..66f871ad3 100644 --- a/src/pipecat/services/azure/stt.py +++ b/src/pipecat/services/azure/stt.py @@ -107,15 +107,22 @@ class AzureSTTService(STTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService. """ - if language != Language.EN_US: - _warn_deprecated_param("language", "AzureSTTSettings", "language") - + # 1. Initialize default_settings with hardcoded defaults default_settings = AzureSTTSettings( model=None, region=region, - language=language_to_azure_language(language) if language else None, + language=language_to_azure_language(Language.EN_US), sample_rate=sample_rate, ) + + # 2. Apply direct init arg overrides (deprecated) + if language is not None and language != Language.EN_US: + _warn_deprecated_param("language", AzureSTTSettings, "language") + default_settings.language = language_to_azure_language(language) + + # 3. No params to apply + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index 7e5791f03..3a67cb2ff 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -290,27 +290,43 @@ class AzureTTSService(TTSService, AzureBaseTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to parent WordTTSService. """ - if voice is not None: - _warn_deprecated_param("voice", "AzureTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "AzureTTSSettings") - - _params = params or AzureBaseTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AzureTTSSettings( model=None, - emphasis=_params.emphasis, - language=self.language_to_service_language(_params.language) - if _params.language - else "en-US", - pitch=_params.pitch, - rate=_params.rate, - role=_params.role, - style=_params.style, - style_degree=_params.style_degree, - voice=voice or "en-US-SaraNeural", - volume=_params.volume, + voice="en-US-SaraNeural", + language="en-US", + emphasis=None, + pitch=None, + rate=None, + role=None, + style=None, + style_degree=None, + volume=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice is not None: + _warn_deprecated_param("voice", AzureTTSSettings, "voice") + default_settings.voice = voice + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AzureTTSSettings) + if not settings: + default_settings.emphasis = params.emphasis + default_settings.language = ( + self.language_to_service_language(params.language) + if params.language + else "en-US" + ) + default_settings.pitch = params.pitch + default_settings.rate = params.rate + default_settings.role = params.role + default_settings.style = params.style + default_settings.style_degree = params.style_degree + default_settings.volume = params.volume + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -779,27 +795,43 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice is not None: - _warn_deprecated_param("voice", "AzureTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "AzureTTSSettings") - - _params = params or AzureBaseTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = AzureTTSSettings( model=None, - emphasis=_params.emphasis, - language=self.language_to_service_language(_params.language) - if _params.language - else "en-US", - pitch=_params.pitch, - rate=_params.rate, - role=_params.role, - style=_params.style, - style_degree=_params.style_degree, - voice=voice or "en-US-SaraNeural", - volume=_params.volume, + voice="en-US-SaraNeural", + language="en-US", + emphasis=None, + pitch=None, + rate=None, + role=None, + style=None, + style_degree=None, + volume=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice is not None: + _warn_deprecated_param("voice", AzureTTSSettings, "voice") + default_settings.voice = voice + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", AzureTTSSettings) + if not settings: + default_settings.emphasis = params.emphasis + default_settings.language = ( + self.language_to_service_language(params.language) + if params.language + else "en-US" + ) + default_settings.pitch = params.pitch + default_settings.rate = params.rate + default_settings.role = params.role + default_settings.style = params.style + default_settings.style_degree = params.style_degree + default_settings.volume = params.volume + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/camb/tts.py b/src/pipecat/services/camb/tts.py index de8b16ab8..9a1b753a6 100644 --- a/src/pipecat/services/camb/tts.py +++ b/src/pipecat/services/camb/tts.py @@ -230,34 +230,45 @@ class CambTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "CambTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "CambTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "CambTTSSettings") + # 1. Initialize default_settings with hardcoded defaults + default_settings = CambTTSSettings( + model="mars-flash", + voice=147320, + language="en-us", + user_instructions=None, + ) - _params = params or CambTTSService.InputParams() - _model = model or "mars-flash" + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", CambTTSSettings, "model") + default_settings.model = model + if voice_id is not None: + _warn_deprecated_param("voice_id", CambTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = ( + self.language_to_service_language(params.language) or "en-us" + ) + if params.user_instructions is not None: + default_settings.user_instructions = params.user_instructions + + # 4. Apply settings delta (canonical API, always wins) + if settings is not None: + default_settings.apply_update(settings) # Warn if sample rate doesn't match model's supported rate + _model = default_settings.model if sample_rate and sample_rate != MODEL_SAMPLE_RATES.get(_model): logger.warning( f"Camb.ai's {_model} model only supports {MODEL_SAMPLE_RATES.get(_model)}Hz " f"sample rate. Current rate of {sample_rate}Hz may cause issues." ) - default_settings = CambTTSSettings( - model=_model, - voice=voice_id or 147320, - language=( - self.language_to_service_language(_params.language) if _params.language else "en-us" - ), - user_instructions=_params.user_instructions, - ) - if settings is not None: - default_settings.apply_update(settings) - super().__init__( sample_rate=sample_rate, settings=default_settings, diff --git a/src/pipecat/services/cartesia/stt.py b/src/pipecat/services/cartesia/stt.py index 530f6a4d1..aa66b102e 100644 --- a/src/pipecat/services/cartesia/stt.py +++ b/src/pipecat/services/cartesia/stt.py @@ -28,7 +28,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import CARTESIA_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language @@ -177,26 +177,34 @@ class CartesiaSTTService(WebsocketSTTService): """ sample_rate = sample_rate or (live_options.sample_rate if live_options else None) - default_options = CartesiaLiveOptions( + # 1. Initialize default_settings with hardcoded defaults + default_settings = CartesiaSTTSettings( model="ink-whisper", language=Language.EN.value, encoding="pcm_s16le", - sample_rate=sample_rate, ) - merged_options = default_options.to_dict() - if live_options: - merged_options.update(live_options.to_dict()) - # Filter out "None" string values - merged_options = { - k: v for k, v in merged_options.items() if not isinstance(v, str) or v != "None" - } + # 2. (no deprecated direct args for this service) - default_settings = CartesiaSTTSettings( - model=merged_options["model"], - language=merged_options.get("language"), - encoding=merged_options.get("encoding", "pcm_s16le"), - ) + # 3. Apply live_options overrides — only if settings not provided + if live_options is not None: + _warn_deprecated_param("live_options", CartesiaSTTSettings) + if not settings: + lo_dict = live_options.to_dict() + # Filter out "None" string values + lo_dict = { + k: v + for k, v in lo_dict.items() + if (not isinstance(v, str) or v != "None") and k != "sample_rate" + } + if "model" in lo_dict: + default_settings.model = lo_dict["model"] + if "language" in lo_dict: + default_settings.language = lo_dict["language"] + if "encoding" in lo_dict: + default_settings.encoding = lo_dict["encoding"] + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index c2227d00b..2aeeefda2 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -11,7 +11,7 @@ import json import warnings from dataclasses import dataclass, field from enum import Enum -from typing import Any, AsyncGenerator, List, Literal, Mapping, Optional +from typing import Any, AsyncGenerator, List, Literal, Mapping, Optional, Self import aiohttp from loguru import logger @@ -212,7 +212,7 @@ class CartesiaTTSSettings(TTSSettings): pronunciation_dict_id: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> "CartesiaTTSSettings": + def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested ``output_format``.""" flat = dict(settings) nested = flat.pop("output_format", None) @@ -312,13 +312,6 @@ class CartesiaTTSService(AudioContextTTSService): **kwargs: Additional arguments passed to the parent service. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "CartesiaTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "CartesiaTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "CartesiaTTSSettings") - # By default, we aggregate sentences before sending to TTS. This adds # ~200-300ms of latency per sentence (waiting for the sentence-ending # punctuation token from the LLM). Setting @@ -332,22 +325,39 @@ class CartesiaTTSService(AudioContextTTSService): # if we're interrupted. Cartesia gives us word-by-word timestamps. We # can use those to generate text frames ourselves aligned with the # playout timing of the audio! - _params = params or CartesiaTTSService.InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaTTSSettings( - model=model or "sonic-3", - voice=voice_id, + model="sonic-3", output_container=container, output_encoding=encoding, output_sample_rate=0, - language=( - self.language_to_service_language(_params.language) if _params.language else None - ), - speed=_params.speed, - emotion=_params.emotion, - generation_config=_params.generation_config, - pronunciation_dict_id=_params.pronunciation_dict_id, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", CartesiaTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", CartesiaTTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", CartesiaTTSSettings) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.speed is not None: + default_settings.speed = params.speed + if params.emotion is not None: + default_settings.emotion = params.emotion + if params.generation_config is not None: + default_settings.generation_config = params.generation_config + if params.pronunciation_dict_id is not None: + default_settings.pronunciation_dict_id = params.pronunciation_dict_id + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -781,29 +791,38 @@ class CartesiaHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "CartesiaTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "CartesiaTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "CartesiaTTSSettings") - - _params = params or CartesiaHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaTTSSettings( - model=model or "sonic-3", - voice=voice_id, + model="sonic-3", output_container=container, output_encoding=encoding, output_sample_rate=0, - language=( - self.language_to_service_language(_params.language) if _params.language else None - ), - speed=_params.speed, - emotion=_params.emotion, - generation_config=_params.generation_config, - pronunciation_dict_id=_params.pronunciation_dict_id, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", CartesiaTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", CartesiaTTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", CartesiaTTSSettings) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.speed is not None: + default_settings.speed = params.speed + if params.emotion is not None: + default_settings.emotion = params.emotion + if params.generation_config is not None: + default_settings.generation_config = params.generation_config + if params.pronunciation_dict_id is not None: + default_settings.pronunciation_dict_id = params.pronunciation_dict_id + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index 053594083..98fbfe0e3 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -46,10 +46,15 @@ class CerebrasLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="gpt-oss-120b") - default_settings = OpenAILLMSettings(model=model or "gpt-oss-120b") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index 04c2f1da3..8ddd2ef0d 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -206,10 +206,6 @@ class DeepgramFluxSTTService(WebsocketSTTService): ), ) """ - if model is not None: - _warn_deprecated_param("model", "DeepgramFluxSTTSettings", "model") - if params is not None: - _warn_deprecated_param("params", "DeepgramFluxSTTSettings") # Note: For DeepgramFluxSTTService, differently from other processes, we need to create # the _receive_task inside _connect_websocket, because the websocket should only be # considered connected and ready to send audio once we receive from Flux the message @@ -220,20 +216,39 @@ class DeepgramFluxSTTService(WebsocketSTTService): # was never destroyed. # So we can keep it here as false, because inside the method send_with_retry, it will # already try to reconnect if needed. - _params = params or DeepgramFluxSTTService.InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramFluxSTTSettings( - model=model or "flux-general-en", + model="flux-general-en", language=Language.EN, encoding=flux_encoding, - eager_eot_threshold=_params.eager_eot_threshold, - eot_threshold=_params.eot_threshold, - eot_timeout_ms=_params.eot_timeout_ms, - keyterm=_params.keyterm or [], - mip_opt_out=_params.mip_opt_out, - tag=_params.tag or [], - min_confidence=_params.min_confidence, + eager_eot_threshold=None, + eot_threshold=None, + eot_timeout_ms=None, + keyterm=[], + mip_opt_out=None, + tag=[], + min_confidence=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", DeepgramFluxSTTSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", DeepgramFluxSTTSettings) + if not settings: + default_settings.eager_eot_threshold = params.eager_eot_threshold + default_settings.eot_threshold = params.eot_threshold + default_settings.eot_timeout_ms = params.eot_timeout_ms + default_settings.keyterm = params.keyterm or [] + default_settings.mip_opt_out = params.mip_opt_out + default_settings.tag = params.tag or [] + default_settings.min_confidence = params.min_confidence + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/deepgram/sagemaker/stt.py b/src/pipecat/services/deepgram/sagemaker/stt.py index 6d813157d..d7a867e38 100644 --- a/src/pipecat/services/deepgram/sagemaker/stt.py +++ b/src/pipecat/services/deepgram/sagemaker/stt.py @@ -14,7 +14,7 @@ languages, and various Deepgram features. import asyncio import json -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -32,8 +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 -from pipecat.services.settings import STTSettings +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import DEEPGRAM_SAGEMAKER_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language @@ -51,13 +50,14 @@ except ModuleNotFoundError as e: @dataclass -class DeepgramSageMakerSTTSettings(_DeepgramSTTSettingsBase): +class DeepgramSageMakerSTTSettings(STTSettings): """Settings for the Deepgram SageMaker STT service. - See ``_DeepgramSTTSettingsBase`` for full documentation. + Parameters: + live_options: Deepgram LiveOptions for the SageMaker connection. """ - pass + live_options: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class DeepgramSageMakerSTTService(STTService): @@ -130,13 +130,29 @@ class DeepgramSageMakerSTTService(STTService): punctuate=True, ) + # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramSageMakerSTTSettings( - model=default_options.model, - language=default_options.language, + model="nova-3", + language=Language.EN, live_options=default_options, ) - if live_options: - default_settings._merge_live_options_delta(live_options) + + # 2. (no deprecated direct args like model= for this service) + + # 3. Apply live_options overrides — only if settings not provided + if live_options is not None: + _warn_deprecated_param("live_options", DeepgramSageMakerSTTSettings) + if not settings: + # Merge user live_options onto defaults + merged_dict = {**default_options.to_dict(), **live_options.to_dict()} + merged_live_options = LiveOptions(**merged_dict) + default_settings.live_options = merged_live_options + if hasattr(live_options, "model") and live_options.model is not None: + default_settings.model = live_options.model + if hasattr(live_options, "language") and live_options.language is not None: + default_settings.language = live_options.language + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index 8d03f6eac..62cd25188 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -102,7 +102,7 @@ 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", DeepgramSageMakerTTSSettings, "voice") voice = voice or "aura-2-helena-en" diff --git a/src/pipecat/services/deepgram/stt.py b/src/pipecat/services/deepgram/stt.py index fe3add7cf..f311567aa 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -25,7 +25,14 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import _S, NOT_GIVEN, STTSettings, _NotGiven, is_given +from pipecat.services.settings import ( + _S, + NOT_GIVEN, + STTSettings, + _NotGiven, + _warn_deprecated_param, + is_given, +) from pipecat.services.stt_latency import DEEPGRAM_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language @@ -303,6 +310,7 @@ class DeepgramSTTService(STTService): ) base_url = url + # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramSTTSettings( model="nova-3-general", language=Language.EN, @@ -317,13 +325,19 @@ class DeepgramSTTService(STTService): endpointing=None, ) - if live_options: - lo_dict = live_options.to_dict() - delta = DeepgramSTTSettings.from_mapping( - {k: v for k, v in lo_dict.items() if k != "sample_rate"} - ) - default_settings.apply_update(delta) + # 2. (no deprecated direct args like model= for this service) + # 3. Apply live_options overrides — only if settings not provided + if live_options is not None: + _warn_deprecated_param("live_options", DeepgramSTTSettings) + if not settings: + lo_dict = live_options.to_dict() + delta = DeepgramSTTSettings.from_mapping( + {k: v for k, v in lo_dict.items() if k != "sample_rate"} + ) + default_settings.apply_update(delta) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/deepgram/tts.py b/src/pipecat/services/deepgram/tts.py index 7c391490d..98a615f9b 100644 --- a/src/pipecat/services/deepgram/tts.py +++ b/src/pipecat/services/deepgram/tts.py @@ -98,20 +98,26 @@ class DeepgramTTSService(WebsocketTTSService): Raises: ValueError: If encoding is not in SUPPORTED_ENCODINGS. """ - if voice is not None: - _warn_deprecated_param("voice", "DeepgramTTSSettings", "voice") - if encoding.lower() not in self.SUPPORTED_ENCODINGS: raise ValueError( f"Unsupported encoding '{encoding}'. Must be one of {', '.join(self.SUPPORTED_ENCODINGS)} for WebSocket TTS." ) + # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramTTSSettings( - model=voice or "aura-2-helena-en", - voice=voice or "aura-2-helena-en", + model="aura-2-helena-en", + voice="aura-2-helena-en", language=None, encoding=encoding, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice is not None: + _warn_deprecated_param("voice", DeepgramTTSSettings, "voice") + default_settings.model = voice + default_settings.voice = voice + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -414,15 +420,21 @@ class DeepgramHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ - if voice is not None: - _warn_deprecated_param("voice", "DeepgramTTSSettings", "voice") - + # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramTTSSettings( - model=voice or "aura-2-helena-en", - voice=voice or "aura-2-helena-en", + model="aura-2-helena-en", + voice="aura-2-helena-en", language=None, encoding=encoding, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice is not None: + _warn_deprecated_param("voice", DeepgramTTSSettings, "voice") + default_settings.model = voice + default_settings.voice = voice + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index 8cc9ac56e..c383f5609 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -46,10 +46,15 @@ class DeepSeekLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="deepseek-chat") - default_settings = OpenAILLMSettings(model=model or "deepseek-chat") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/elevenlabs/stt.py b/src/pipecat/services/elevenlabs/stt.py index 1eebcffde..d93f95332 100644 --- a/src/pipecat/services/elevenlabs/stt.py +++ b/src/pipecat/services/elevenlabs/stt.py @@ -275,20 +275,29 @@ class ElevenLabsSTTService(SegmentedSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService. """ - if model is not None: - _warn_deprecated_param("model", "ElevenLabsSTTSettings", "model") - if params is not None: - _warn_deprecated_param("params", "ElevenLabsSTTSettings") - - _params = params or ElevenLabsSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = ElevenLabsSTTSettings( - model=model or "scribe_v2", - language=self.language_to_service_language(_params.language) - if _params.language - else "eng", - tag_audio_events=_params.tag_audio_events, + model="scribe_v2", + language="eng", + tag_audio_events=True, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", ElevenLabsSTTSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", ElevenLabsSTTSettings) + if not settings: + if params.language is not None: + default_settings.language = ( + self.language_to_service_language(params.language) or "eng" + ) + default_settings.tag_audio_events = params.tag_audio_events + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -515,25 +524,40 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to WebsocketSTTService. """ - if model is not None: - _warn_deprecated_param("model", "ElevenLabsRealtimeSTTSettings", "model") - if params is not None: - _warn_deprecated_param("params", "ElevenLabsRealtimeSTTSettings") - - _params = params or ElevenLabsRealtimeSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = ElevenLabsRealtimeSTTSettings( - model=model or "scribe_v2_realtime", - language=_params.language_code, - commit_strategy=_params.commit_strategy, - vad_silence_threshold_secs=_params.vad_silence_threshold_secs, - vad_threshold=_params.vad_threshold, - min_speech_duration_ms=_params.min_speech_duration_ms, - min_silence_duration_ms=_params.min_silence_duration_ms, - include_timestamps=_params.include_timestamps, - enable_logging=_params.enable_logging, - include_language_detection=_params.include_language_detection, + model="scribe_v2_realtime", + language=None, + commit_strategy=CommitStrategy.MANUAL, + vad_silence_threshold_secs=None, + vad_threshold=None, + min_speech_duration_ms=None, + min_silence_duration_ms=None, + include_timestamps=False, + enable_logging=False, + include_language_detection=False, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", ElevenLabsRealtimeSTTSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", ElevenLabsRealtimeSTTSettings) + if not settings: + default_settings.language = params.language_code + default_settings.commit_strategy = params.commit_strategy + default_settings.vad_silence_threshold_secs = params.vad_silence_threshold_secs + default_settings.vad_threshold = params.vad_threshold + default_settings.min_speech_duration_ms = params.min_speech_duration_ms + default_settings.min_silence_duration_ms = params.min_silence_duration_ms + default_settings.include_timestamps = params.include_timestamps + default_settings.enable_logging = params.enable_logging + default_settings.include_language_detection = params.include_language_detection + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 15c2dbb2e..3cec12431 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -408,13 +408,6 @@ class ElevenLabsTTSService(AudioContextTTSService): **kwargs: Additional arguments passed to the parent service. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "ElevenLabsTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "ElevenLabsTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "ElevenLabsTTSSettings") - # By default, we aggregate sentences before sending to TTS. This adds # ~200-300ms of latency per sentence (waiting for the sentence-ending # punctuation token from the LLM). Setting @@ -431,24 +424,49 @@ class ElevenLabsTTSService(AudioContextTTSService): # Finally, ElevenLabs doesn't provide information on when the bot stops # speaking for a while, so we want the parent class to send TTSStopFrame # after a short period not receiving any audio. - _params = params or ElevenLabsTTSService.InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = ElevenLabsTTSSettings( - model=model or "eleven_turbo_v2_5", - voice=voice_id, - language=( - self.language_to_service_language(_params.language) if _params.language else None - ), - stability=_params.stability, - similarity_boost=_params.similarity_boost, - style=_params.style, - use_speaker_boost=_params.use_speaker_boost, - speed=_params.speed, - auto_mode=str(_params.auto_mode).lower(), - enable_ssml_parsing=_params.enable_ssml_parsing, - enable_logging=_params.enable_logging, - apply_text_normalization=_params.apply_text_normalization, + model="eleven_turbo_v2_5", ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", ElevenLabsTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", ElevenLabsTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.stability is not None: + default_settings.stability = params.stability + if params.similarity_boost is not None: + default_settings.similarity_boost = params.similarity_boost + if params.style is not None: + default_settings.style = params.style + if params.use_speaker_boost is not None: + default_settings.use_speaker_boost = params.use_speaker_boost + if params.speed is not None: + default_settings.speed = params.speed + if params.auto_mode is not None: + default_settings.auto_mode = str(params.auto_mode).lower() + if params.enable_ssml_parsing is not None: + default_settings.enable_ssml_parsing = params.enable_ssml_parsing + if params.enable_logging is not None: + default_settings.enable_logging = params.enable_logging + if params.apply_text_normalization is not None: + default_settings.apply_text_normalization = params.apply_text_normalization + if _pronunciation_dictionary_locators is None: + _pronunciation_dictionary_locators = params.pronunciation_dictionary_locators + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -469,11 +487,7 @@ class ElevenLabsTTSService(AudioContextTTSService): self._output_format = "" # initialized in start() self._voice_settings = self._set_voice_settings() - self._pronunciation_dictionary_locators = ( - pronunciation_dictionary_locators - if pronunciation_dictionary_locators is not None - else _params.pronunciation_dictionary_locators - ) + self._pronunciation_dictionary_locators = _pronunciation_dictionary_locators self._cumulative_time = 0 # Track partial words that span across alignment chunks @@ -982,29 +996,44 @@ class ElevenLabsHttpTTSService(TTSService): **kwargs: Additional arguments passed to the parent service. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "ElevenLabsHttpTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "ElevenLabsHttpTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "ElevenLabsHttpTTSSettings") - - _params = params or ElevenLabsHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = ElevenLabsHttpTTSSettings( - model=model or "eleven_turbo_v2_5", - voice=voice_id, - language=( - self.language_to_service_language(_params.language) if _params.language else None - ), - optimize_streaming_latency=_params.optimize_streaming_latency, - stability=_params.stability, - similarity_boost=_params.similarity_boost, - style=_params.style, - use_speaker_boost=_params.use_speaker_boost, - speed=_params.speed, - apply_text_normalization=_params.apply_text_normalization, + model="eleven_turbo_v2_5", ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", ElevenLabsHttpTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", ElevenLabsHttpTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.optimize_streaming_latency is not None: + default_settings.optimize_streaming_latency = params.optimize_streaming_latency + if params.stability is not None: + default_settings.stability = params.stability + if params.similarity_boost is not None: + default_settings.similarity_boost = params.similarity_boost + if params.style is not None: + default_settings.style = params.style + if params.use_speaker_boost is not None: + default_settings.use_speaker_boost = params.use_speaker_boost + if params.speed is not None: + default_settings.speed = params.speed + if params.apply_text_normalization is not None: + default_settings.apply_text_normalization = params.apply_text_normalization + if _pronunciation_dictionary_locators is None: + _pronunciation_dictionary_locators = params.pronunciation_dictionary_locators + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -1025,11 +1054,7 @@ class ElevenLabsHttpTTSService(TTSService): self._output_format = "" # initialized in start() self._voice_settings = self._set_voice_settings() - self._pronunciation_dictionary_locators = ( - pronunciation_dictionary_locators - if pronunciation_dictionary_locators is not None - else _params.pronunciation_dictionary_locators - ) + self._pronunciation_dictionary_locators = _pronunciation_dictionary_locators # Track cumulative time to properly sequence word timestamps across utterances self._cumulative_time = 0 diff --git a/src/pipecat/services/fal/image.py b/src/pipecat/services/fal/image.py index 6fd953f13..2c36c2208 100644 --- a/src/pipecat/services/fal/image.py +++ b/src/pipecat/services/fal/image.py @@ -88,10 +88,15 @@ class FalImageGenService(ImageGenService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent ImageGenService. """ - if model is not None: - _warn_deprecated_param("model", "FalImageGenSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = FalImageGenSettings(model="fal-ai/fast-sdxl") - default_settings = FalImageGenSettings(model=model or "fal-ai/fast-sdxl") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", FalImageGenSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/fal/stt.py b/src/pipecat/services/fal/stt.py index d80f73a98..ea9f69a18 100644 --- a/src/pipecat/services/fal/stt.py +++ b/src/pipecat/services/fal/stt.py @@ -213,20 +213,29 @@ class FalSTTService(SegmentedSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService. """ - if params is not None: - _warn_deprecated_param("params", "FalSTTSettings") - - _params = params or FalSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = FalSTTSettings( model=None, - language=self.language_to_service_language(_params.language) - if _params.language - else "en", - task=_params.task, - chunk_level=_params.chunk_level, - version=_params.version, + language=language_to_fal_language(Language.EN) or "en", + task="transcribe", + chunk_level="segment", + version="3", ) + + # 2. (no deprecated direct args for this service) + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", FalSTTSettings) + if not settings: + default_settings.language = ( + language_to_fal_language(params.language) if params.language else "en" + ) + default_settings.task = params.task + default_settings.chunk_level = params.chunk_level + default_settings.version = params.version + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index 33d7d22e2..cb5a0cf39 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -46,12 +46,15 @@ class FireworksLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="accounts/fireworks/models/firefunction-v2") - default_settings = OpenAILLMSettings( - model=model or "accounts/fireworks/models/firefunction-v2" - ) + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index 431b51729..3d4412186 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -12,7 +12,7 @@ for streaming text-to-speech synthesis with customizable voice parameters. import uuid from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, ClassVar, Dict, Literal, Mapping, Optional +from typing import Any, AsyncGenerator, ClassVar, Dict, Literal, Mapping, Optional, Self from loguru import logger from pydantic import BaseModel @@ -72,7 +72,7 @@ class FishAudioTTSSettings(TTSSettings): _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice", "sample_rate": "fish_sample_rate"} @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> "FishAudioTTSSettings": + def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested ``prosody``.""" flat = dict(settings) nested = flat.pop("prosody", None) @@ -156,15 +156,6 @@ class FishAudioTTSService(InterruptibleTTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent service. """ - if reference_id is not None: - _warn_deprecated_param("reference_id", "FishAudioTTSSettings", "voice") - if model_id is not None: - _warn_deprecated_param("model_id", "FishAudioTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "FishAudioTTSSettings") - - _params = params or FishAudioTTSService.InputParams() - # Validation for model and reference_id parameters if model and reference_id: raise ValueError( @@ -184,17 +175,42 @@ class FishAudioTTSService(InterruptibleTTSService): ) reference_id = model + # 1. Initialize default_settings with hardcoded defaults default_settings = FishAudioTTSSettings( - model=model_id or "s1", - voice=reference_id, + model="s1", + voice=None, fish_sample_rate=0, - latency=_params.latency, + latency="normal", format=output_format, - normalize=_params.normalize, - prosody_speed=_params.prosody_speed, - prosody_volume=_params.prosody_volume, - reference_id=reference_id, + normalize=True, + prosody_speed=1.0, + prosody_volume=0, + reference_id=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if reference_id is not None: + _warn_deprecated_param("reference_id", FishAudioTTSSettings, "voice") + default_settings.voice = reference_id + default_settings.reference_id = reference_id + if model_id is not None: + _warn_deprecated_param("model_id", FishAudioTTSSettings, "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) + if not settings: + if params.latency is not None: + default_settings.latency = params.latency + if params.normalize is not None: + default_settings.normalize = params.normalize + if params.prosody_speed is not None: + default_settings.prosody_speed = params.prosody_speed + if params.prosody_volume is not None: + default_settings.prosody_volume = params.prosody_volume + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index e1e0d9276..a12829b0d 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -289,23 +289,6 @@ class GladiaSTTService(WebsocketSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the STTService parent class. """ - if model is not None: - _warn_deprecated_param("model", "GladiaSTTSettings", "model") - if params is not None: - _warn_deprecated_param("params", "GladiaSTTSettings") - - params = params or GladiaInputParams() - - if params.language is not None: - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - "The 'language' parameter is deprecated and will be removed in a future version. " - "Use 'language_config' instead.", - DeprecationWarning, - stacklevel=2, - ) - if confidence: with warnings.catch_warnings(): warnings.simplefilter("always") @@ -316,28 +299,64 @@ class GladiaSTTService(WebsocketSTTService): stacklevel=2, ) - # Resolve deprecated language → language_config at init time - language_config = params.language_config - if not language_config and params.language: - language_code = self.language_to_service_language(params.language) - if language_code: - language_config = LanguageConfig(languages=[language_code], code_switching=False) - + # 1. Initialize default_settings with hardcoded defaults default_settings = GladiaSTTSettings( - model=model or "solaria-1", + model="solaria-1", language=None, - encoding=params.encoding, - bit_depth=params.bit_depth, - channels=params.channels, - custom_metadata=params.custom_metadata, - endpointing=params.endpointing, - maximum_duration_without_endpointing=params.maximum_duration_without_endpointing, - language_config=language_config, - pre_processing=params.pre_processing, - realtime_processing=params.realtime_processing, - messages_config=params.messages_config, - enable_vad=params.enable_vad, + encoding="wav/pcm", + bit_depth=16, + channels=1, + custom_metadata=None, + endpointing=None, + maximum_duration_without_endpointing=5, + language_config=None, + pre_processing=None, + realtime_processing=None, + messages_config=None, + enable_vad=False, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GladiaSTTSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GladiaSTTSettings) + if params.language is not None: + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "The 'language' parameter is deprecated and will be removed in a future " + "version. Use 'language_config' instead.", + DeprecationWarning, + stacklevel=2, + ) + if not settings: + default_settings.encoding = params.encoding + default_settings.bit_depth = params.bit_depth + default_settings.channels = params.channels + default_settings.custom_metadata = params.custom_metadata + default_settings.endpointing = params.endpointing + default_settings.maximum_duration_without_endpointing = ( + params.maximum_duration_without_endpointing + ) + default_settings.pre_processing = params.pre_processing + default_settings.realtime_processing = params.realtime_processing + default_settings.messages_config = params.messages_config + default_settings.enable_vad = params.enable_vad + # Resolve deprecated language → language_config at init time + language_config = params.language_config + if not language_config and params.language: + language_code = self.language_to_service_language(params.language) + if language_code: + language_config = LanguageConfig( + languages=[language_code], code_switching=False + ) + default_settings.language_config = language_config + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index 518684dfb..6e7a8f8a1 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -708,36 +708,63 @@ class GeminiLiveLLMService(LLMService): DeprecationWarning, stacklevel=2, ) - if model is not None: - _warn_deprecated_param("model", "GeminiLiveLLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "GeminiLiveLLMSettings") - - _params = params or InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = GeminiLiveLLMSettings( - model=model or "models/gemini-2.5-flash-native-audio-preview-12-2025", - frequency_penalty=_params.frequency_penalty, - max_tokens=_params.max_tokens, - presence_penalty=_params.presence_penalty, - temperature=_params.temperature, - top_k=_params.top_k, - top_p=_params.top_p, + model="models/gemini-2.5-flash-native-audio-preview-12-2025", + frequency_penalty=None, + max_tokens=4096, + presence_penalty=None, + temperature=None, + top_k=None, + top_p=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - modalities=_params.modalities, - language=language_to_gemini_language(_params.language) if _params.language else "en-US", - media_resolution=_params.media_resolution, - vad=_params.vad, - context_window_compression=_params.context_window_compression.model_dump() - if _params.context_window_compression - else {}, - thinking=_params.thinking or {}, - enable_affective_dialog=_params.enable_affective_dialog or False, - proactivity=_params.proactivity or {}, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + modalities=GeminiModalities.AUDIO, + language="en-US", + media_resolution=GeminiMediaResolution.UNSPECIFIED, + vad=None, + context_window_compression={}, + thinking={}, + enable_affective_dialog=False, + proactivity={}, + extra={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GeminiLiveLLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GeminiLiveLLMSettings) + if not settings: + default_settings.frequency_penalty = params.frequency_penalty + default_settings.max_tokens = params.max_tokens + default_settings.presence_penalty = params.presence_penalty + default_settings.temperature = params.temperature + default_settings.top_k = params.top_k + default_settings.top_p = params.top_p + default_settings.modalities = params.modalities + default_settings.language = ( + language_to_gemini_language(params.language) if params.language else "en-US" + ) + default_settings.media_resolution = params.media_resolution + default_settings.vad = params.vad + default_settings.context_window_compression = ( + params.context_window_compression.model_dump() + if params.context_window_compression + else {} + ) + default_settings.thinking = params.thinking or {} + default_settings.enable_affective_dialog = params.enable_affective_dialog or False + default_settings.proactivity = params.proactivity or {} + if isinstance(params.extra, dict): + default_settings.extra = params.extra + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -750,7 +777,7 @@ class GeminiLiveLLMService(LLMService): self._last_sent_time = 0 self._base_url = base_url self._voice_id = voice_id - self._language_code = _params.language + self._language_code = params.language if params is not None else Language.EN_US self._system_instruction_from_init = system_instruction self._tools_from_init = tools diff --git a/src/pipecat/services/google/gemini_live/llm_vertex.py b/src/pipecat/services/google/gemini_live/llm_vertex.py index eadcb66d1..5d63251d9 100644 --- a/src/pipecat/services/google/gemini_live/llm_vertex.py +++ b/src/pipecat/services/google/gemini_live/llm_vertex.py @@ -20,6 +20,8 @@ from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.services.google.gemini_live.llm import ( GeminiLiveLLMService, GeminiLiveLLMSettings, + GeminiMediaResolution, + GeminiModalities, HttpOptions, InputParams, language_to_gemini_language, @@ -109,11 +111,6 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): "Invalid parameter 'api_key'. Use 'credentials' or 'credentials_path' for Vertex AI authentication." ) - if model is not None: - _warn_deprecated_param("model", "GeminiLiveLLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "GeminiLiveLLMSettings") - # These need to be set before calling super().__init__() because # super().__init__() invokes create_client(), which needs these. self._credentials = self._get_credentials(credentials, credentials_path) @@ -123,31 +120,63 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # Build default_settings from deprecated args, then apply settings delta. # We pass settings= to super() instead of model=/params= to avoid # double deprecation warnings from the parent. - _params = params or InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = GeminiLiveLLMSettings( - model=model or "google/gemini-live-2.5-flash-native-audio", - frequency_penalty=_params.frequency_penalty, - max_tokens=_params.max_tokens, - presence_penalty=_params.presence_penalty, - temperature=_params.temperature, - top_k=_params.top_k, - top_p=_params.top_p, + model="google/gemini-live-2.5-flash-native-audio", + frequency_penalty=None, + max_tokens=4096, + presence_penalty=None, + temperature=None, + top_k=None, + top_p=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - modalities=_params.modalities, - language=language_to_gemini_language(_params.language) if _params.language else "en-US", - media_resolution=_params.media_resolution, - vad=_params.vad, - context_window_compression=_params.context_window_compression.model_dump() - if _params.context_window_compression - else {}, - thinking=_params.thinking or {}, - enable_affective_dialog=_params.enable_affective_dialog or False, - proactivity=_params.proactivity or {}, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + modalities=GeminiModalities.AUDIO, + language="en-US", + media_resolution=GeminiMediaResolution.UNSPECIFIED, + vad=None, + context_window_compression={}, + thinking={}, + enable_affective_dialog=False, + proactivity={}, + extra={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GeminiLiveLLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GeminiLiveLLMSettings) + if not settings: + default_settings.frequency_penalty = params.frequency_penalty + default_settings.max_tokens = params.max_tokens + default_settings.presence_penalty = params.presence_penalty + default_settings.temperature = params.temperature + default_settings.top_k = params.top_k + default_settings.top_p = params.top_p + default_settings.modalities = params.modalities + default_settings.language = ( + language_to_gemini_language(params.language) if params.language else "en-US" + ) + default_settings.media_resolution = params.media_resolution + default_settings.vad = params.vad + default_settings.context_window_compression = ( + params.context_window_compression.model_dump() + if params.context_window_compression + else {} + ) + default_settings.thinking = params.thinking or {} + default_settings.enable_affective_dialog = params.enable_affective_dialog or False + default_settings.proactivity = params.proactivity or {} + if isinstance(params.extra, dict): + default_settings.extra = params.extra + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/google/image.py b/src/pipecat/services/google/image.py index ce29c0276..09ec61554 100644 --- a/src/pipecat/services/google/image.py +++ b/src/pipecat/services/google/image.py @@ -90,17 +90,21 @@ class GoogleImageGenService(ImageGenService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent ImageGenService. """ + # 1. Initialize default_settings with hardcoded defaults + default_settings = GoogleImageGenSettings(model="imagen-3.0-generate-002") + + # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", "GoogleImageGenSettings") + _warn_deprecated_param("params", GoogleImageGenSettings) + if not settings: + default_settings.model = params.model - params = params or GoogleImageGenService.InputParams() - - default_settings = GoogleImageGenSettings(model=params.model) + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) super().__init__(settings=default_settings, **kwargs) - self._params = params + self._params = params or GoogleImageGenService.InputParams() # Add client header http_options = update_google_client_http_options(http_options) diff --git a/src/pipecat/services/google/llm.py b/src/pipecat/services/google/llm.py index 5d5a87188..49e6d2366 100644 --- a/src/pipecat/services/google/llm.py +++ b/src/pipecat/services/google/llm.py @@ -814,27 +814,40 @@ class GoogleLLMService(LLMService): http_options: HTTP options for the client. **kwargs: Additional arguments passed to parent class. """ - if model is not None: - _warn_deprecated_param("model", "GoogleLLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "GoogleLLMSettings") - - _params = params or GoogleLLMService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleLLMSettings( - model=model or "gemini-2.5-flash", - max_tokens=_params.max_tokens, - temperature=_params.temperature, - top_k=_params.top_k, - top_p=_params.top_p, + model="gemini-2.5-flash", + max_tokens=4096, + temperature=None, + top_k=None, + top_p=None, frequency_penalty=None, presence_penalty=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - thinking=_params.thinking, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + thinking=None, + extra={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GoogleLLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GoogleLLMSettings) + if not settings: + default_settings.max_tokens = params.max_tokens + default_settings.temperature = params.temperature + default_settings.top_k = params.top_k + default_settings.top_p = params.top_p + default_settings.thinking = params.thinking + if isinstance(params.extra, dict): + default_settings.extra = params.extra + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index aa8794469..4705e8f68 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -84,10 +84,15 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): stacklevel=2, ) - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="gemini-2.0-flash") - default_settings = OpenAILLMSettings(model=model or "gemini-2.0-flash") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/google/llm_vertex.py b/src/pipecat/services/google/llm_vertex.py index 9258a4d67..b1a9de584 100644 --- a/src/pipecat/services/google/llm_vertex.py +++ b/src/pipecat/services/google/llm_vertex.py @@ -148,15 +148,9 @@ class GoogleVertexLLMService(GoogleLLMService): "Invalid parameter 'api_key'. Use 'credentials' or 'credentials_path' for Vertex AI authentication." ) - if model is not None: - _warn_deprecated_param("model", "GoogleLLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "GoogleLLMSettings") - - # Handle deprecated InputParams fields + # Handle deprecated InputParams fields (location/project_id extraction + # must happen before validation, regardless of settings) if params and isinstance(params, GoogleVertexLLMService.InputParams): - # Extract location and project_id from params if not provided - # directly, for backward compatibility if project_id is None: project_id = params.project_id if location is None: @@ -188,22 +182,40 @@ class GoogleVertexLLMService(GoogleLLMService): self._project_id = project_id self._location = location - # Build default_settings from deprecated args - _params = params or GoogleLLMService.InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleLLMSettings( - model=model or "gemini-2.5-flash", - max_tokens=_params.max_tokens, - temperature=_params.temperature, - top_k=_params.top_k, - top_p=_params.top_p, + model="gemini-2.5-flash", + max_tokens=4096, + temperature=None, + top_k=None, + top_p=None, frequency_penalty=None, presence_penalty=None, seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - thinking=_params.thinking, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + thinking=None, + extra={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GoogleLLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GoogleLLMSettings) + if not settings: + default_settings.max_tokens = params.max_tokens + default_settings.temperature = params.temperature + default_settings.top_k = params.top_k + default_settings.top_p = params.top_p + default_settings.thinking = params.thinking + if isinstance(params.extra, dict): + default_settings.extra = params.extra + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/google/stt.py b/src/pipecat/services/google/stt.py index 23a586b96..5415a5403 100644 --- a/src/pipecat/services/google/stt.py +++ b/src/pipecat/services/google/stt.py @@ -509,26 +509,44 @@ class GoogleSTTService(STTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to STTService. """ - if params is not None: - _warn_deprecated_param("params", "GoogleSTTSettings") - - _params = params or GoogleSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleSTTSettings( language=None, - languages=list(_params.language_list), + languages=[Language.EN_US], language_codes=None, - model=_params.model, - use_separate_recognition_per_channel=_params.use_separate_recognition_per_channel, - enable_automatic_punctuation=_params.enable_automatic_punctuation, - enable_spoken_punctuation=_params.enable_spoken_punctuation, - enable_spoken_emojis=_params.enable_spoken_emojis, - profanity_filter=_params.profanity_filter, - enable_word_time_offsets=_params.enable_word_time_offsets, - enable_word_confidence=_params.enable_word_confidence, - enable_interim_results=_params.enable_interim_results, - enable_voice_activity_events=_params.enable_voice_activity_events, + model="latest_long", + use_separate_recognition_per_channel=False, + enable_automatic_punctuation=True, + enable_spoken_punctuation=False, + enable_spoken_emojis=False, + profanity_filter=False, + enable_word_time_offsets=False, + enable_word_confidence=False, + enable_interim_results=True, + enable_voice_activity_events=False, ) + + # 2. No direct init arg overrides + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GoogleSTTSettings) + if not settings: + default_settings.languages = list(params.language_list) + default_settings.model = params.model + default_settings.use_separate_recognition_per_channel = ( + params.use_separate_recognition_per_channel + ) + default_settings.enable_automatic_punctuation = params.enable_automatic_punctuation + default_settings.enable_spoken_punctuation = params.enable_spoken_punctuation + default_settings.enable_spoken_emojis = params.enable_spoken_emojis + default_settings.profanity_filter = params.profanity_filter + default_settings.enable_word_time_offsets = params.enable_word_time_offsets + default_settings.enable_word_confidence = params.enable_word_confidence + default_settings.enable_interim_results = params.enable_interim_results + default_settings.enable_voice_activity_events = params.enable_voice_activity_events + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index 78719f8fa..6b17caed5 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -622,27 +622,40 @@ class GoogleHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "GoogleHttpTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "GoogleHttpTTSSettings") - - _params = params or GoogleHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleHttpTTSSettings( model=None, - pitch=_params.pitch, - rate=_params.rate, - speaking_rate=_params.speaking_rate, - volume=_params.volume, - emphasis=_params.emphasis, - language=self.language_to_service_language(_params.language) - if _params.language - else "en-US", - gender=_params.gender, - google_style=_params.google_style, - voice=voice_id or "en-US-Chirp3-HD-Charon", + voice="en-US-Chirp3-HD-Charon", + language="en-US", ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", GoogleHttpTTSSettings, "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) + if not settings: + if params.pitch is not None: + default_settings.pitch = params.pitch + if params.rate is not None: + default_settings.rate = params.rate + if params.speaking_rate is not None: + default_settings.speaking_rate = params.speaking_rate + if params.volume is not None: + default_settings.volume = params.volume + if params.emphasis is not None: + default_settings.emphasis = params.emphasis + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.gender is not None: + default_settings.gender = params.gender + if params.google_style is not None: + default_settings.google_style = params.google_style + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -1062,21 +1075,28 @@ class GoogleTTSService(GoogleBaseTTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "GoogleStreamTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "GoogleStreamTTSSettings") - - _params = params or GoogleTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleStreamTTSSettings( model=None, - language=self.language_to_service_language(_params.language) - if _params.language - else "en-US", - speaking_rate=_params.speaking_rate, - voice=voice_id or "en-US-Chirp3-HD-Charon", + voice="en-US-Chirp3-HD-Charon", + language="en-US", ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", GoogleStreamTTSSettings, "voice") + default_settings.voice = voice_id + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GoogleStreamTTSSettings) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.speaking_rate is not None: + default_settings.speaking_rate = params.speaking_rate + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -1292,34 +1312,47 @@ class GeminiTTSService(GoogleBaseTTSService): DeprecationWarning, stacklevel=2, ) - if model is not None: - _warn_deprecated_param("model", "GeminiTTSSettings", "model") - if voice_id is not None: - _warn_deprecated_param("voice_id", "GeminiTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "GeminiTTSSettings") if sample_rate and sample_rate != self.GOOGLE_SAMPLE_RATE: logger.warning( f"Google TTS only supports {self.GOOGLE_SAMPLE_RATE}Hz sample rate. " f"Current rate of {sample_rate}Hz may cause issues." ) - _params = params or GeminiTTSService.InputParams() - - voice_id = voice_id or "Kore" - if voice_id not in self.AVAILABLE_VOICES: - logger.warning(f"Voice '{voice_id}' not in known voices list. Using anyway.") + # 1. Initialize default_settings with hardcoded defaults default_settings = GeminiTTSSettings( - model=model or "gemini-2.5-flash-tts", - language=self.language_to_service_language(_params.language) - if _params.language - else "en-US", - prompt=_params.prompt, - multi_speaker=_params.multi_speaker, - speaker_configs=_params.speaker_configs, - voice=voice_id, + model="gemini-2.5-flash-tts", + voice="Kore", + language="en-US", ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GeminiTTSSettings, "model") + default_settings.model = model + if voice_id is not None: + _warn_deprecated_param("voice_id", GeminiTTSSettings, "voice") + default_settings.voice = voice_id + + if default_settings.voice not in self.AVAILABLE_VOICES: + logger.warning( + f"Voice '{default_settings.voice}' not in known voices list. Using anyway." + ) + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GeminiTTSSettings) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.prompt is not None: + default_settings.prompt = params.prompt + if params.multi_speaker is not None: + default_settings.multi_speaker = params.multi_speaker + if params.speaker_configs is not None: + default_settings.speaker_configs = params.speaker_configs + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index 5974133c0..51ac8a7cd 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -148,16 +148,23 @@ class GradiumSTTService(WebsocketSTTService): stacklevel=2, ) - if params is not None: - _warn_deprecated_param("params", "GradiumSTTSettings") - - _params = params or GradiumSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = GradiumSTTSettings( model=None, - language=_params.language, - delay_in_frames=_params.delay_in_frames or None, + language=None, + delay_in_frames=None, ) + + # 2. (no deprecated direct args for this service) + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", GradiumSTTSettings) + if not settings: + default_settings.language = params.language + default_settings.delay_in_frames = params.delay_in_frames + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/gradium/tts.py b/src/pipecat/services/gradium/tts.py index 6f076f933..b3b9b50ca 100644 --- a/src/pipecat/services/gradium/tts.py +++ b/src/pipecat/services/gradium/tts.py @@ -103,19 +103,28 @@ class GradiumTTSService(AudioContextTTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "GradiumTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "GradiumTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "GradiumTTSSettings") - + # 1. Initialize default_settings with hardcoded defaults default_settings = GradiumTTSSettings( - model=model or "default", - voice=voice_id or "YTpq7expH9539ERJ", + model="default", + voice="YTpq7expH9539ERJ", language=None, output_format="pcm", ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", GradiumTTSSettings, "model") + default_settings.model = model + if voice_id is not None: + _warn_deprecated_param("voice_id", GradiumTTSSettings, "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) + # Note: params.temp has no corresponding settings field + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index 2e6a93c4e..f552f059a 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -102,10 +102,15 @@ class GrokLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="grok-3-beta") - default_settings = OpenAILLMSettings(model=model or "grok-3-beta") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/grok/realtime/llm.py b/src/pipecat/services/grok/realtime/llm.py index 87f5eaaaa..2f2df1b45 100644 --- a/src/pipecat/services/grok/realtime/llm.py +++ b/src/pipecat/services/grok/realtime/llm.py @@ -153,11 +153,7 @@ class GrokRealtimeLLMService(LLMService): start_audio_paused: Whether to start with audio input paused. Defaults to False. **kwargs: Additional arguments passed to parent LLMService. """ - if session_properties is not None: - _warn_deprecated_param( - "session_properties", "GrokRealtimeLLMSettings", "session_properties" - ) - + # 1. Initialize default_settings with hardcoded defaults default_settings = GrokRealtimeLLMSettings( model=None, temperature=None, @@ -169,8 +165,17 @@ class GrokRealtimeLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - session_properties=session_properties or events.SessionProperties(), + session_properties=events.SessionProperties(), ) + + # 2. Apply direct init arg overrides (deprecated) + if session_properties is not None: + _warn_deprecated_param( + "session_properties", GrokRealtimeLLMSettings, "session_properties" + ) + default_settings.session_properties = session_properties + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index 0ea3b3f50..f88d5a877 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -45,10 +45,15 @@ class GroqLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="llama-3.3-70b-versatile") - default_settings = OpenAILLMSettings(model=model or "llama-3.3-70b-versatile") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/groq/stt.py b/src/pipecat/services/groq/stt.py index e6ea42fd8..ac6a4325c 100644 --- a/src/pipecat/services/groq/stt.py +++ b/src/pipecat/services/groq/stt.py @@ -69,27 +69,30 @@ class GroqSTTService(BaseWhisperSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to BaseWhisperSTTService. """ - if model is not None: - _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") - if language is not None: - _warn_deprecated_param("language", "BaseWhisperSTTSettings", "language") - if prompt is not None: - _warn_deprecated_param("prompt", "BaseWhisperSTTSettings", "prompt") - if temperature is not None: - _warn_deprecated_param("temperature", "BaseWhisperSTTSettings", "temperature") - - model = model or "whisper-large-v3-turbo" - language = language or Language.EN - - # Build settings from deprecated params and pass via settings= - # to avoid double deprecation warnings in BaseWhisperSTTService. + # --- 1. Hardcoded defaults --- default_settings = BaseWhisperSTTSettings( - model=model, - language=self.language_to_service_language(language), + model="whisper-large-v3-turbo", + language=self.language_to_service_language(Language.EN), base_url=base_url, - prompt=prompt, - temperature=temperature, ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + default_settings.model = model + if language is not None: + _warn_deprecated_param("language", BaseWhisperSTTSettings, "language") + default_settings.language = self.language_to_service_language(language) + if prompt is not None: + _warn_deprecated_param("prompt", BaseWhisperSTTSettings, "prompt") + default_settings.prompt = prompt + if temperature is not None: + _warn_deprecated_param("temperature", BaseWhisperSTTSettings, "temperature") + default_settings.temperature = temperature + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/groq/tts.py b/src/pipecat/services/groq/tts.py index d16964d8c..b1c546713 100644 --- a/src/pipecat/services/groq/tts.py +++ b/src/pipecat/services/groq/tts.py @@ -114,26 +114,35 @@ class GroqTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService class. """ - if model_name is not None: - _warn_deprecated_param("model_name", "GroqTTSSettings", "model") - if voice_id is not None: - _warn_deprecated_param("voice_id", "GroqTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "GroqTTSSettings") - if sample_rate != self.GROQ_SAMPLE_RATE: logger.warning(f"Groq TTS only supports {self.GROQ_SAMPLE_RATE}Hz sample rate. ") - _params = params or GroqTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = GroqTTSSettings( - model=model_name or "canopylabs/orpheus-v1-english", - voice=voice_id or "autumn", - language=str(_params.language) if _params.language else "en", + model="canopylabs/orpheus-v1-english", + voice="autumn", + language="en", output_format=output_format, - speed=_params.speed, + speed=1.0, groq_sample_rate=sample_rate, ) + + # 2. Apply direct init arg overrides (deprecated) + if model_name is not None: + _warn_deprecated_param("model_name", GroqTTSSettings, "model") + default_settings.model = model_name + if voice_id is not None: + _warn_deprecated_param("voice_id", GroqTTSSettings, "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) + if not settings: + default_settings.language = str(params.language) if params.language else "en" + default_settings.speed = params.speed + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/hume/tts.py b/src/pipecat/services/hume/tts.py index 5b7300816..7b0ecd0c8 100644 --- a/src/pipecat/services/hume/tts.py +++ b/src/pipecat/services/hume/tts.py @@ -126,11 +126,6 @@ class HumeTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "HumeTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "HumeTTSSettings") - api_key = api_key or os.getenv("HUME_API_KEY") if not api_key: raise ValueError("HumeTTSService requires an API key (env HUME_API_KEY or api_key=)") @@ -140,16 +135,30 @@ class HumeTTSService(TTSService): f"Hume TTS streams at {HUME_SAMPLE_RATE} Hz; configured sample_rate={sample_rate}" ) - _params = params or HumeTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = HumeTTSSettings( model=None, - voice=voice_id, + voice=None, language=None, # Not applicable here - description=_params.description, - speed=_params.speed, - trailing_silence=_params.trailing_silence, + description=None, + speed=None, + trailing_silence=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", HumeTTSSettings, "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) + if not settings: + default_settings.description = params.description + default_settings.speed = params.speed + default_settings.trailing_silence = params.trailing_silence + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index f1797ad55..688ba542a 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -18,7 +18,18 @@ import base64 import json import uuid from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, ClassVar, Dict, List, Literal, Mapping, Optional, Tuple +from typing import ( + Any, + AsyncGenerator, + ClassVar, + Dict, + List, + Literal, + Mapping, + Optional, + Self, + Tuple, +) import aiohttp import websockets @@ -91,7 +102,7 @@ class InworldTTSSettings(TTSSettings): } @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> "InworldTTSSettings": + def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested ``audioConfig``.""" flat = dict(settings) nested = flat.pop("audioConfig", None) @@ -168,27 +179,42 @@ class InworldHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "InworldTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "InworldTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "InworldTTSSettings") - - _params = params or InworldHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = InworldTTSSettings( - model=model or "inworld-tts-1.5-max", - voice=voice_id or "Ashley", + model="inworld-tts-1.5-max", + voice="Ashley", language=None, audio_encoding=encoding, audio_sample_rate=0, - speaking_rate=_params.speaking_rate, - temperature=_params.temperature, - timestamp_transport_strategy=_params.timestamp_transport_strategy, + speaking_rate=None, + temperature=None, + timestamp_transport_strategy="ASYNC", auto_mode=None, # Not applicable for HTTP TTS apply_text_normalization=None, # Not applicable for HTTP TTS ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", InworldTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", InworldTTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", InworldTTSSettings) + if not settings: + if params.speaking_rate is not None: + default_settings.speaking_rate = params.speaking_rate + if params.temperature is not None: + default_settings.temperature = params.temperature + if params.timestamp_transport_strategy is not None: + default_settings.timestamp_transport_strategy = ( + params.timestamp_transport_strategy + ) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -580,27 +606,50 @@ class InworldTTSService(AudioContextTTSService): append_trailing_space: Whether to append a trailing space to text before sending to TTS. **kwargs: Additional arguments passed to the parent class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "InworldTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "InworldTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "InworldTTSSettings") - - _params = params or InworldTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = InworldTTSSettings( - model=model or "inworld-tts-1.5-max", - voice=voice_id or "Ashley", + model="inworld-tts-1.5-max", + voice="Ashley", language=None, audio_encoding=encoding, audio_sample_rate=0, - speaking_rate=_params.speaking_rate, - temperature=_params.temperature, - apply_text_normalization=_params.apply_text_normalization, - timestamp_transport_strategy=_params.timestamp_transport_strategy, - auto_mode=_params.auto_mode if _params.auto_mode is not None else aggregate_sentences, + speaking_rate=None, + temperature=None, + apply_text_normalization=None, + timestamp_transport_strategy="ASYNC", + auto_mode=True if aggregate_sentences is None else aggregate_sentences, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", InworldTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", InworldTTSSettings, "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) + if not settings: + if params.speaking_rate is not None: + default_settings.speaking_rate = params.speaking_rate + if params.temperature is not None: + default_settings.temperature = params.temperature + if params.apply_text_normalization is not None: + default_settings.apply_text_normalization = params.apply_text_normalization + if params.timestamp_transport_strategy is not None: + default_settings.timestamp_transport_strategy = ( + params.timestamp_transport_strategy + ) + if params.auto_mode is not None: + default_settings.auto_mode = params.auto_mode + _buffer_max_delay_ms = params.max_buffer_delay_ms + _buffer_char_threshold = params.buffer_char_threshold + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -622,8 +671,8 @@ class InworldTTSService(AudioContextTTSService): self._timestamp_type = "WORD" self._buffer_settings = { - "maxBufferDelayMs": _params.max_buffer_delay_ms, - "bufferCharThreshold": _params.buffer_char_threshold, + "maxBufferDelayMs": _buffer_max_delay_ms, + "bufferCharThreshold": _buffer_char_threshold, } self._receive_task = None diff --git a/src/pipecat/services/kokoro/tts.py b/src/pipecat/services/kokoro/tts.py index 8bab78f93..7e53060da 100644 --- a/src/pipecat/services/kokoro/tts.py +++ b/src/pipecat/services/kokoro/tts.py @@ -151,19 +151,28 @@ class KokoroTTSService(TTSService): **kwargs: Additional arguments passed to parent `TTSService`. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "KokoroTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "KokoroTTSSettings") - - _params = params or KokoroTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = KokoroTTSSettings( model=None, - voice=voice_id, - language=language_to_kokoro_language(_params.language), - lang_code=language_to_kokoro_language(_params.language), + voice=None, + language=language_to_kokoro_language(Language.EN), + lang_code=language_to_kokoro_language(Language.EN), ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", KokoroTTSSettings, "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) + if not settings: + lang_code = language_to_kokoro_language(params.language) + default_settings.language = lang_code + default_settings.lang_code = lang_code + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -172,14 +181,14 @@ class KokoroTTSService(TTSService): **kwargs, ) - self._lang_code = language_to_kokoro_language(_params.language) + self._lang_code = default_settings.lang_code - model = Path(model_path) if model_path else KOKORO_CACHE_DIR / "kokoro-v1.0.onnx" + model_file = Path(model_path) if model_path else KOKORO_CACHE_DIR / "kokoro-v1.0.onnx" voices = Path(voices_path) if voices_path else KOKORO_CACHE_DIR / "voices-v1.0.bin" - _ensure_model_files(model, voices) + _ensure_model_files(model_file, voices) - self._kokoro = Kokoro(str(model), str(voices)) + self._kokoro = Kokoro(str(model_file), str(voices)) self._resampler = create_stream_resampler() diff --git a/src/pipecat/services/lmnt/tts.py b/src/pipecat/services/lmnt/tts.py index a8ccec358..c69eadfef 100644 --- a/src/pipecat/services/lmnt/tts.py +++ b/src/pipecat/services/lmnt/tts.py @@ -125,17 +125,25 @@ class LmntTTSService(InterruptibleTTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent InterruptibleTTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "LmntTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "LmntTTSSettings", "model") - + # 1. Initialize default_settings with hardcoded defaults default_settings = LmntTTSSettings( - model=model or "blizzard", - voice=voice_id, + model="blizzard", + voice=None, language=self.language_to_service_language(language), format="raw", ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", LmntTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", LmntTTSSettings, "model") + default_settings.model = model + + # 3. No params for this service + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/minimax/tts.py b/src/pipecat/services/minimax/tts.py index 9e520f763..2d9f49636 100644 --- a/src/pipecat/services/minimax/tts.py +++ b/src/pipecat/services/minimax/tts.py @@ -12,7 +12,7 @@ for streaming text-to-speech synthesis. import json from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, ClassVar, Dict, Mapping, Optional +from typing import Any, AsyncGenerator, ClassVar, Dict, Mapping, Optional, Self import aiohttp from loguru import logger @@ -123,7 +123,7 @@ class MiniMaxTTSSettings(TTSSettings): _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice"} @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> "MiniMaxTTSSettings": + def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested dicts. Handles ``voice_setting`` (with ``vol`` → ``volume`` rename) and @@ -245,74 +245,82 @@ class MiniMaxHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if model is not None: - _warn_deprecated_param("model", "MiniMaxTTSSettings", "model") - if voice_id is not None: - _warn_deprecated_param("voice_id", "MiniMaxTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "MiniMaxTTSSettings") - - _params = params or MiniMaxHttpTTSService.InputParams() - - # Resolve language boost - language_boost = None - if _params.language: - service_lang = self.language_to_service_language(_params.language) - if service_lang: - language_boost = service_lang - - # Resolve emotion - emotion = None - if _params.emotion: - supported_emotions = [ - "happy", - "sad", - "angry", - "fearful", - "disgusted", - "surprised", - "neutral", - "fluent", - ] - if _params.emotion in supported_emotions: - emotion = _params.emotion - else: - logger.warning( - f"Unsupported emotion: {_params.emotion}. Supported emotions: {supported_emotions}" - ) - - # Resolve text_normalization - text_normalization = None - if _params.english_normalization is not None: - import warnings - - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - "Parameter `english_normalization` is deprecated and will be removed in a future version. Use `text_normalization` instead.", - DeprecationWarning, - ) - text_normalization = _params.english_normalization - if _params.text_normalization is not None: - text_normalization = _params.text_normalization - + # 1. Initialize default_settings with hardcoded defaults default_settings = MiniMaxTTSSettings( - model=model or "speech-02-turbo", - voice=voice_id or "Calm_Woman", + model="speech-02-turbo", + voice="Calm_Woman", language=None, stream=True, - speed=_params.speed, - volume=_params.volume, - pitch=_params.pitch, - language_boost=language_boost, - emotion=emotion, - text_normalization=text_normalization, - latex_read=_params.latex_read, + speed=1.0, + volume=1.0, + pitch=0, + language_boost=None, + emotion=None, + text_normalization=None, + latex_read=None, audio_bitrate=128000, audio_format="pcm", audio_channel=1, audio_sample_rate=0, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", MiniMaxTTSSettings, "model") + default_settings.model = model + if voice_id is not None: + _warn_deprecated_param("voice_id", MiniMaxTTSSettings, "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) + if not settings: + default_settings.speed = params.speed + default_settings.volume = params.volume + default_settings.pitch = params.pitch + default_settings.latex_read = params.latex_read + + # Resolve language boost + if params.language: + service_lang = self.language_to_service_language(params.language) + if service_lang: + default_settings.language_boost = service_lang + + # Resolve emotion + if params.emotion: + supported_emotions = [ + "happy", + "sad", + "angry", + "fearful", + "disgusted", + "surprised", + "neutral", + "fluent", + ] + if params.emotion in supported_emotions: + default_settings.emotion = params.emotion + else: + logger.warning( + f"Unsupported emotion: {params.emotion}. Supported emotions: {supported_emotions}" + ) + + # Resolve text_normalization + if params.english_normalization is not None: + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "Parameter `english_normalization` is deprecated and will be removed in a future version. Use `text_normalization` instead.", + DeprecationWarning, + ) + default_settings.text_normalization = params.english_normalization + if params.text_normalization is not None: + default_settings.text_normalization = params.text_normalization + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index da1f612c9..ca72cde37 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -48,10 +48,15 @@ class MistralLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="mistral-small-latest") - default_settings = OpenAILLMSettings(model=model or "mistral-small-latest") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/moondream/vision.py b/src/pipecat/services/moondream/vision.py index b80928a43..3f0701c80 100644 --- a/src/pipecat/services/moondream/vision.py +++ b/src/pipecat/services/moondream/vision.py @@ -102,10 +102,15 @@ class MoondreamService(VisionService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent VisionService. """ - if model is not None: - _warn_deprecated_param("model", "MoondreamSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = MoondreamSettings(model="vikhyatk/moondream2") - default_settings = MoondreamSettings(model=model or "vikhyatk/moondream2") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", MoondreamSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/neuphonic/tts.py b/src/pipecat/services/neuphonic/tts.py index e1efee96b..ae85c3ab5 100644 --- a/src/pipecat/services/neuphonic/tts.py +++ b/src/pipecat/services/neuphonic/tts.py @@ -154,21 +154,31 @@ class NeuphonicTTSService(InterruptibleTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to parent InterruptibleTTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "NeuphonicTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "NeuphonicTTSSettings") - - _params = params or NeuphonicTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = NeuphonicTTSSettings( model=None, - language=self.language_to_service_language(_params.language), - speed=_params.speed, + voice=None, + language=self.language_to_service_language(Language.EN), + speed=1.0, encoding=encoding, sampling_rate=sample_rate, - voice=voice_id, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", NeuphonicTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = self.language_to_service_language(params.language) + if params.speed is not None: + default_settings.speed = params.speed + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -487,21 +497,33 @@ class NeuphonicHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "NeuphonicTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "NeuphonicTTSSettings") - - _params = params or NeuphonicHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = NeuphonicTTSSettings( model=None, - voice=voice_id, - language=self.language_to_service_language(_params.language) or "en", - speed=_params.speed, + voice=None, + language=self.language_to_service_language(Language.EN) or "en", + speed=1.0, encoding=encoding, sampling_rate=sample_rate, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", NeuphonicTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = ( + self.language_to_service_language(params.language) or "en" + ) + if params.speed is not None: + default_settings.speed = params.speed + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index 1667457b9..f09db54fa 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -52,12 +52,15 @@ class NvidiaLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="nvidia/llama-3.1-nemotron-70b-instruct") - default_settings = OpenAILLMSettings( - model=model or "nvidia/llama-3.1-nemotron-70b-instruct" - ) + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index 63e901005..3ceaf45fa 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -174,15 +174,21 @@ class NvidiaSTTService(STTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to STTService. """ - if params is not None: - _warn_deprecated_param("params", "NvidiaSTTSettings") - - _params = params or NvidiaSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = NvidiaSTTSettings( model=model_function_map.get("model_name"), - language=_params.language, + language=Language.EN_US, ) + + # 2. (no deprecated direct args for this service) + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", NvidiaSTTSettings) + if not settings: + default_settings.language = params.language + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -492,21 +498,33 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService """ - if params is not None: - _warn_deprecated_param("params", "NvidiaSegmentedSTTSettings") - - _params = params or NvidiaSegmentedSTTService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = NvidiaSegmentedSTTSettings( model=model_function_map.get("model_name"), - language=self.language_to_service_language(_params.language or Language.EN_US) - or "en-US", - profanity_filter=_params.profanity_filter, - automatic_punctuation=_params.automatic_punctuation, - verbatim_transcripts=_params.verbatim_transcripts, - boosted_lm_words=_params.boosted_lm_words, - boosted_lm_score=_params.boosted_lm_score, + language=language_to_nvidia_riva_language(Language.EN_US) or "en-US", + profanity_filter=False, + automatic_punctuation=True, + verbatim_transcripts=False, + boosted_lm_words=None, + boosted_lm_score=4.0, ) + + # 2. (no deprecated direct args for this service) + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", NvidiaSegmentedSTTSettings) + if not settings: + default_settings.language = ( + language_to_nvidia_riva_language(params.language or Language.EN_US) or "en-US" + ) + default_settings.profanity_filter = params.profanity_filter + default_settings.automatic_punctuation = params.automatic_punctuation + default_settings.verbatim_transcripts = params.verbatim_transcripts + default_settings.boosted_lm_words = params.boosted_lm_words + default_settings.boosted_lm_score = params.boosted_lm_score + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/nvidia/tts.py b/src/pipecat/services/nvidia/tts.py index 75caa27e4..be0b90071 100644 --- a/src/pipecat/services/nvidia/tts.py +++ b/src/pipecat/services/nvidia/tts.py @@ -117,19 +117,29 @@ class NvidiaTTSService(TTSService): use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "NvidiaTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "NvidiaTTSSettings") - - _params = params or NvidiaTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = NvidiaTTSSettings( model=model_function_map.get("model_name"), - voice=voice_id or "Magpie-Multilingual.EN-US.Aria", - language=_params.language, - quality=_params.quality, + voice="Magpie-Multilingual.EN-US.Aria", + language=Language.EN_US, + quality=20, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", NvidiaTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = params.language + if params.quality is not None: + default_settings.quality = params.quality + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index 8fc94985d..2a4a3e78f 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -44,10 +44,15 @@ class OLLamaLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="llama2") - default_settings = OpenAILLMSettings(model=model or "llama2") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 0b4c3dec7..6c27fbe37 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -150,24 +150,41 @@ class BaseOpenAILLMService(LLMService): system_instruction: Optional system instruction to prepend to messages. **kwargs: Additional arguments passed to the parent LLMService. """ - _params = params or BaseOpenAILLMService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAILLMSettings( - model=model or "gpt-4o", - frequency_penalty=_params.frequency_penalty, - presence_penalty=_params.presence_penalty, - seed=_params.seed, - temperature=_params.temperature, - top_p=_params.top_p, + model="gpt-4o", + frequency_penalty=NOT_GIVEN, + presence_penalty=NOT_GIVEN, + seed=NOT_GIVEN, + temperature=NOT_GIVEN, + top_p=NOT_GIVEN, top_k=None, - max_tokens=_params.max_tokens, - max_completion_tokens=_params.max_completion_tokens, - service_tier=_params.service_tier, + max_tokens=NOT_GIVEN, + max_completion_tokens=NOT_GIVEN, + service_tier=NOT_GIVEN, filter_incomplete_user_turns=False, user_turn_completion_config=None, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + extra={}, ) + # 2. Apply direct init arg overrides (no warnings in base class) + if model is not None: + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None and not settings: + default_settings.frequency_penalty = params.frequency_penalty + default_settings.presence_penalty = params.presence_penalty + default_settings.seed = params.seed + default_settings.temperature = params.temperature + default_settings.top_p = params.top_p + default_settings.max_tokens = params.max_tokens + default_settings.max_completion_tokens = params.max_completion_tokens + default_settings.service_tier = params.service_tier + if isinstance(params.extra, dict): + default_settings.extra = params.extra + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openai/image.py b/src/pipecat/services/openai/image.py index a145df6e5..fd9bd0ba8 100644 --- a/src/pipecat/services/openai/image.py +++ b/src/pipecat/services/openai/image.py @@ -70,10 +70,15 @@ class OpenAIImageGenService(ImageGenService): settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. """ - if model is not None: - _warn_deprecated_param("model", "OpenAIImageGenSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAIImageGenSettings(model="dall-e-3") - default_settings = OpenAIImageGenSettings(model=model or "dall-e-3") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAIImageGenSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index a8ab760c4..56515ce89 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -10,6 +10,8 @@ import json from dataclasses import dataclass from typing import Any, Optional +from openai import NOT_GIVEN + from pipecat.frames.frames import ( FunctionCallCancelFrame, FunctionCallInProgressFrame, @@ -95,27 +97,44 @@ class OpenAILLMService(BaseOpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent BaseOpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") - if params is not None: - _warn_deprecated_param("params", "OpenAILLMSettings") - - _params = params or BaseOpenAILLMService.InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAILLMSettings( - model=model or "gpt-4.1", - frequency_penalty=_params.frequency_penalty, - presence_penalty=_params.presence_penalty, - seed=_params.seed, - temperature=_params.temperature, - top_p=_params.top_p, + model="gpt-4.1", + frequency_penalty=NOT_GIVEN, + presence_penalty=NOT_GIVEN, + seed=NOT_GIVEN, + temperature=NOT_GIVEN, + top_p=NOT_GIVEN, top_k=None, - max_tokens=_params.max_tokens, - max_completion_tokens=_params.max_completion_tokens, - service_tier=_params.service_tier, + max_tokens=NOT_GIVEN, + max_completion_tokens=NOT_GIVEN, + service_tier=NOT_GIVEN, filter_incomplete_user_turns=False, user_turn_completion_config=None, - extra=_params.extra if isinstance(_params.extra, dict) else {}, + extra={}, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", OpenAILLMSettings) + if not settings: + default_settings.frequency_penalty = params.frequency_penalty + default_settings.presence_penalty = params.presence_penalty + default_settings.seed = params.seed + default_settings.temperature = params.temperature + default_settings.top_p = params.top_p + default_settings.max_tokens = params.max_tokens + default_settings.max_completion_tokens = params.max_completion_tokens + default_settings.service_tier = params.service_tier + if isinstance(params.extra, dict): + default_settings.extra = params.extra + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openai/realtime/llm.py b/src/pipecat/services/openai/realtime/llm.py index d6e7a71bd..1230ed2db 100644 --- a/src/pipecat/services/openai/realtime/llm.py +++ b/src/pipecat/services/openai/realtime/llm.py @@ -168,12 +168,6 @@ class OpenAIRealtimeLLMService(LLMService): **kwargs: Additional arguments passed to parent LLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAIRealtimeLLMSettings", "model") - if session_properties is not None: - _warn_deprecated_param( - "session_properties", "OpenAIRealtimeLLMSettings", "session_properties" - ) if send_transcription_frames is not None: import warnings @@ -186,8 +180,9 @@ class OpenAIRealtimeLLMService(LLMService): stacklevel=2, ) + # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAIRealtimeLLMSettings( - model=model or "gpt-realtime-1.5", + model="gpt-realtime-1.5", temperature=None, max_tokens=None, top_p=None, @@ -197,8 +192,20 @@ class OpenAIRealtimeLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - session_properties=session_properties or events.SessionProperties(), + session_properties=events.SessionProperties(), ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAIRealtimeLLMSettings, "model") + default_settings.model = model + if session_properties is not None: + _warn_deprecated_param( + "session_properties", OpenAIRealtimeLLMSettings, "session_properties" + ) + default_settings.session_properties = session_properties + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index 5c31d3f02..ea2814619 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -94,23 +94,35 @@ class OpenAISTTService(BaseWhisperSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to BaseWhisperSTTService. """ - if model is not None: - _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") - - super().__init__( - model=model or "gpt-4o-transcribe", - api_key=api_key, + # --- 1. Hardcoded defaults --- + _language = language or Language.EN + default_settings = BaseWhisperSTTSettings( + model="gpt-4o-transcribe", + language=self.language_to_service_language(_language), base_url=base_url, - language=language, prompt=prompt, temperature=temperature, + ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + default_settings.model = model + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- + if settings is not None: + default_settings.apply_update(settings) + + super().__init__( + api_key=api_key, + base_url=base_url, + settings=default_settings, ttfs_p99_latency=ttfs_p99_latency, **kwargs, ) - if settings is not None: - self._settings.apply_update(settings) - async def _transcribe(self, audio: bytes) -> Transcription: assert self._language is not None # Assigned in the BaseWhisperSTTService class @@ -242,14 +254,21 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): "Install it with: pip install pipecat-ai[openai]" ) - if model is not None: - _warn_deprecated_param("model", "OpenAIRealtimeSTTSettings", "model") - + # --- 1. Hardcoded defaults --- default_settings = OpenAIRealtimeSTTSettings( - model=model or "gpt-4o-transcribe", + model="gpt-4o-transcribe", language=language, prompt=prompt, ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", OpenAIRealtimeSTTSettings, "model") + default_settings.model = model + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) @@ -262,7 +281,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): self._api_key = api_key self._base_url = base_url - self._prompt = prompt + self._prompt = self._settings.prompt self._turn_detection = turn_detection self._noise_reduction = noise_reduction self._should_interrupt = should_interrupt diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index 42c963808..a119c3d14 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -150,34 +150,43 @@ class OpenAITTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to TTSService. """ - if voice is not None: - _warn_deprecated_param("voice", "OpenAITTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "OpenAITTSSettings", "model") - if instructions is not None: - _warn_deprecated_param("instructions", "OpenAITTSSettings", "instructions") - if speed is not None: - _warn_deprecated_param("speed", "OpenAITTSSettings", "speed") - if params is not None: - _warn_deprecated_param("params", "OpenAITTSSettings") - if sample_rate and sample_rate != self.OPENAI_SAMPLE_RATE: logger.warning( f"OpenAI TTS only supports {self.OPENAI_SAMPLE_RATE}Hz sample rate. " f"Current rate of {sample_rate}Hz may cause issues." ) - _params = params or OpenAITTSService.InputParams() - _instructions = instructions if instructions is not None else _params.instructions - _speed = speed if speed is not None else _params.speed - + # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAITTSSettings( - model=model or "gpt-4o-mini-tts", - voice=voice or "alloy", + model="gpt-4o-mini-tts", + voice="alloy", language=None, - instructions=_instructions, - speed=_speed, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice is not None: + _warn_deprecated_param("voice", OpenAITTSSettings, "voice") + default_settings.voice = voice + if model is not None: + _warn_deprecated_param("model", OpenAITTSSettings, "model") + default_settings.model = model + if instructions is not None: + _warn_deprecated_param("instructions", OpenAITTSSettings, "instructions") + default_settings.instructions = instructions + if speed is not None: + _warn_deprecated_param("speed", OpenAITTSSettings, "speed") + default_settings.speed = speed + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", OpenAITTSSettings) + if not settings: + if params.instructions is not None: + default_settings.instructions = params.instructions + if params.speed is not None: + default_settings.speed = params.speed + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index cb660ce72..11b60c3b9 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -167,15 +167,9 @@ class OpenAIRealtimeBetaLLMService(LLMService): stacklevel=2, ) - if model is not None: - _warn_deprecated_param("model", "OpenAIRealtimeBetaLLMSettings", "model") - if session_properties is not None: - _warn_deprecated_param( - "session_properties", "OpenAIRealtimeBetaLLMSettings", "session_properties" - ) - + # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAIRealtimeBetaLLMSettings( - model=model or "gpt-4o-realtime-preview-2025-06-03", + model="gpt-4o-realtime-preview-2025-06-03", temperature=None, max_tokens=None, top_p=None, @@ -185,8 +179,20 @@ class OpenAIRealtimeBetaLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - session_properties=session_properties or events.SessionProperties(), + session_properties=events.SessionProperties(), ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAIRealtimeBetaLLMSettings, "model") + default_settings.model = model + if session_properties is not None: + _warn_deprecated_param( + "session_properties", OpenAIRealtimeBetaLLMSettings, "session_properties" + ) + default_settings.session_properties = session_properties + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index 7fb4ebd2d..9724c0a3f 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -64,10 +64,15 @@ class OpenPipeLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="gpt-4.1") - default_settings = OpenAILLMSettings(model=model or "gpt-4.1") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index ea307aaee..42f01c77d 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -50,10 +50,15 @@ class OpenRouterLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="openai/gpt-4o-2024-11-20") - default_settings = OpenAILLMSettings(model=model or "openai/gpt-4o-2024-11-20") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index 1fbf763f3..2d350b736 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -53,10 +53,15 @@ class PerplexityLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="sonar") - default_settings = OpenAILLMSettings(model=model or "sonar") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/piper/tts.py b/src/pipecat/services/piper/tts.py index 73c555c9d..fd6b0bf16 100644 --- a/src/pipecat/services/piper/tts.py +++ b/src/pipecat/services/piper/tts.py @@ -76,10 +76,17 @@ class PiperTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent `TTSService`. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "PiperTTSSettings", "voice") + # 1. Initialize default_settings with hardcoded defaults + default_settings = PiperTTSSettings(model=None, voice=None, language=None) - default_settings = PiperTTSSettings(model=None, voice=voice_id, language=None) + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", PiperTTSSettings, "voice") + default_settings.voice = voice_id + + # 3. No params for this service + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -92,15 +99,15 @@ class PiperTTSService(TTSService): _voice = self._settings.voice model_file = f"{_voice}.onnx" - model_path = Path(download_dir) / model_file + model_path_resolved = Path(download_dir) / model_file - if not model_path.exists(): + if not model_path_resolved.exists(): logger.debug(f"Downloading Piper '{_voice}' model") download_voice(_voice, download_dir, force_redownload=force_redownload) - logger.debug(f"Loading Piper '{_voice}' model from {model_path}") + logger.debug(f"Loading Piper '{_voice}' model from {model_path_resolved}") - self._voice = PiperVoice.load(model_path, use_cuda=use_cuda) + self._voice = PiperVoice.load(model_path_resolved, use_cuda=use_cuda) logger.debug(f"Loaded Piper '{_voice}' model") @@ -222,10 +229,17 @@ class PiperHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "PiperHttpTTSSettings", "voice") + # 1. Initialize default_settings with hardcoded defaults + default_settings = PiperHttpTTSSettings(model=None, voice=None, language=None) - default_settings = PiperHttpTTSSettings(model=None, voice=voice_id, language=None) + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", PiperHttpTTSSettings, "voice") + default_settings.voice = voice_id + + # 3. No params for this service + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index db407f880..92d24fa76 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -45,10 +45,15 @@ class QwenLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="qwen-plus") - default_settings = OpenAILLMSettings(model=model or "qwen-plus") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/resembleai/tts.py b/src/pipecat/services/resembleai/tts.py index ade4361e0..28ec8a522 100644 --- a/src/pipecat/services/resembleai/tts.py +++ b/src/pipecat/services/resembleai/tts.py @@ -95,17 +95,30 @@ class ResembleAITTSService(AudioContextTTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to the parent service. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "ResembleAITTSSettings", "voice") - + # 1. Initialize default_settings with hardcoded defaults default_settings = ResembleAITTSSettings( model=None, - voice=voice_id, + voice=None, language=None, - precision=precision, - output_format=output_format, - resemble_sample_rate=sample_rate, + precision="PCM_16", + output_format="wav", + resemble_sample_rate=22050, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", ResembleAITTSSettings, "voice") + default_settings.voice = voice_id + if precision is not None: + default_settings.precision = precision + if output_format is not None: + default_settings.output_format = output_format + if sample_rate is not None: + default_settings.resemble_sample_rate = sample_rate + + # 3. No params for this service + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index c607a2e06..1de4087de 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -226,38 +226,57 @@ class RimeTTSService(AudioContextTTSService): **kwargs: Additional arguments passed to parent class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "RimeTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "RimeTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "RimeTTSSettings") - - # Initialize with parent class settings for proper frame handling - _params = params or RimeTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = RimeTTSSettings( - model=model or "arcana", - voice=voice_id, + model="arcana", + voice=None, audioFormat="pcm", samplingRate=0, # updated in start() - language=self.language_to_service_language(_params.language) - if _params.language - else None, - segment=_params.segment, - inlineSpeedAlpha=None, # Not applicable here - speedAlpha=_params.speed_alpha, + language=None, + segment=None, + inlineSpeedAlpha=None, + speedAlpha=None, # Arcana params - repetition_penalty=_params.repetition_penalty, - temperature=_params.temperature, - top_p=_params.top_p, + repetition_penalty=None, + temperature=None, + top_p=None, # Mistv2 params - reduceLatency=_params.reduce_latency, - pauseBetweenBrackets=_params.pause_between_brackets, - phonemizeBetweenBrackets=_params.phonemize_between_brackets, - noTextNormalization=_params.no_text_normalization, - saveOovs=_params.save_oovs, + reduceLatency=None, + pauseBetweenBrackets=None, + phonemizeBetweenBrackets=None, + noTextNormalization=None, + saveOovs=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", RimeTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", RimeTTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", RimeTTSSettings) + if not settings: + default_settings.language = ( + self.language_to_service_language(params.language) if params.language else None + ) + default_settings.segment = params.segment + default_settings.speedAlpha = params.speed_alpha + # Arcana params + default_settings.repetition_penalty = params.repetition_penalty + default_settings.temperature = params.temperature + default_settings.top_p = params.top_p + # Mistv2 params + default_settings.reduceLatency = params.reduce_latency + default_settings.pauseBetweenBrackets = params.pause_between_brackets + default_settings.phonemizeBetweenBrackets = params.phonemize_between_brackets + default_settings.noTextNormalization = params.no_text_normalization + default_settings.saveOovs = params.save_oovs + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -713,35 +732,50 @@ class RimeHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "RimeTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "RimeTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "RimeTTSSettings") - - _params = params or RimeHttpTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = RimeTTSSettings( - model=model or "mistv2", - language=self.language_to_service_language(_params.language) - if _params.language - else "eng", + model="mistv2", + voice=None, + language="eng", audioFormat="pcm", samplingRate=0, segment=None, - speedAlpha=_params.speed_alpha, - reduceLatency=_params.reduce_latency, - pauseBetweenBrackets=_params.pause_between_brackets, - phonemizeBetweenBrackets=_params.phonemize_between_brackets, + speedAlpha=None, + reduceLatency=None, + pauseBetweenBrackets=None, + phonemizeBetweenBrackets=None, noTextNormalization=None, saveOovs=None, - inlineSpeedAlpha=_params.inline_speed_alpha if _params.inline_speed_alpha else None, + inlineSpeedAlpha=None, repetition_penalty=None, temperature=None, top_p=None, - voice=voice_id, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", RimeTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", RimeTTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", RimeTTSSettings) + if not settings: + default_settings.language = ( + self.language_to_service_language(params.language) if params.language else "eng" + ) + default_settings.speedAlpha = params.speed_alpha + default_settings.reduceLatency = params.reduce_latency + default_settings.pauseBetweenBrackets = params.pause_between_brackets + default_settings.phonemizeBetweenBrackets = params.phonemize_between_brackets + default_settings.inlineSpeedAlpha = ( + params.inline_speed_alpha if params.inline_speed_alpha else None + ) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -936,28 +970,40 @@ class RimeNonJsonTTSService(InterruptibleTTSService): text_aggregation_mode: How to aggregate text before synthesis. **kwargs: Additional arguments passed to parent class. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "RimeNonJsonTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "RimeNonJsonTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "RimeNonJsonTTSSettings") - - _params = params or RimeNonJsonTTSService.InputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = RimeNonJsonTTSSettings( - voice=voice_id, - model=model or "arcana", + voice=None, + model="arcana", audioFormat=audio_format, samplingRate=sample_rate, - language=self.language_to_service_language(_params.language) - if _params.language - else None, - segment=_params.segment, - repetition_penalty=_params.repetition_penalty, - temperature=_params.temperature, - top_p=_params.top_p, + language=None, + segment=None, + repetition_penalty=None, + temperature=None, + top_p=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", RimeNonJsonTTSSettings, "voice") + default_settings.voice = voice_id + if model is not None: + _warn_deprecated_param("model", RimeNonJsonTTSSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", RimeNonJsonTTSSettings) + if not settings: + default_settings.language = ( + self.language_to_service_language(params.language) if params.language else None + ) + default_settings.segment = params.segment + default_settings.repetition_penalty = params.repetition_penalty + default_settings.temperature = params.temperature + default_settings.top_p = params.top_p + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -974,8 +1020,8 @@ class RimeNonJsonTTSService(InterruptibleTTSService): self._api_key = api_key self._url = url # Add any extra parameters for future compatibility - if _params.extra: - self._settings.extra.update(_params.extra) + if params and params.extra: + self._settings.extra.update(params.extra) self._receive_task = None self._context_id: Optional[str] = None diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index 5114297a8..f9b7b1380 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -57,10 +57,15 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="Llama-4-Maverick-17B-128E-Instruct") - default_settings = OpenAILLMSettings(model=model or "Llama-4-Maverick-17B-128E-Instruct") + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/sambanova/stt.py b/src/pipecat/services/sambanova/stt.py index 4ca156b88..0c2d77e36 100644 --- a/src/pipecat/services/sambanova/stt.py +++ b/src/pipecat/services/sambanova/stt.py @@ -71,27 +71,30 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to `pipecat.services.whisper.base_stt.BaseWhisperSTTService`. """ - if model is not None: - _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") - if language is not None: - _warn_deprecated_param("language", "BaseWhisperSTTSettings", "language") - if prompt is not None: - _warn_deprecated_param("prompt", "BaseWhisperSTTSettings", "prompt") - if temperature is not None: - _warn_deprecated_param("temperature", "BaseWhisperSTTSettings", "temperature") - - model = model or "Whisper-Large-v3" - language = language or Language.EN - - # Build settings from deprecated params and pass via settings= - # to avoid double deprecation warnings in BaseWhisperSTTService. + # --- 1. Hardcoded defaults --- default_settings = BaseWhisperSTTSettings( - model=model, - language=self.language_to_service_language(language), + model="Whisper-Large-v3", + language=self.language_to_service_language(Language.EN), base_url=base_url, - prompt=prompt, - temperature=temperature, ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + default_settings.model = model + if language is not None: + _warn_deprecated_param("language", BaseWhisperSTTSettings, "language") + default_settings.language = self.language_to_service_language(language) + if prompt is not None: + _warn_deprecated_param("prompt", BaseWhisperSTTSettings, "prompt") + default_settings.prompt = prompt + if temperature is not None: + _warn_deprecated_param("temperature", BaseWhisperSTTSettings, "temperature") + default_settings.temperature = temperature + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/sarvam/stt.py b/src/pipecat/services/sarvam/stt.py index 97c8d1ccc..fd9a55f14 100644 --- a/src/pipecat/services/sarvam/stt.py +++ b/src/pipecat/services/sarvam/stt.py @@ -238,44 +238,56 @@ class SarvamSTTService(STTService): keepalive_interval: Seconds between idle checks when keepalive is enabled. **kwargs: Additional arguments passed to the parent STTService. """ + # 1. Initialize default_settings with hardcoded defaults + default_settings = SarvamSTTSettings( + model="saarika:v2.5", + language=None, + prompt=None, + mode=None, + vad_signals=None, + high_vad_sensitivity=None, + ) + + # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", "SarvamSTTSettings", "model") + _warn_deprecated_param("model", SarvamSTTSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", "SarvamSTTSettings") + _warn_deprecated_param("params", SarvamSTTSettings) + if not settings: + default_settings.language = params.language + default_settings.prompt = params.prompt + default_settings.mode = params.mode + default_settings.vad_signals = params.vad_signals + default_settings.high_vad_sensitivity = params.high_vad_sensitivity - model = model or "saarika:v2.5" - _params = params or SarvamSTTService.InputParams() + # 4. Apply settings delta (canonical API, always wins) + if settings is not None: + default_settings.apply_update(settings) - # Get model configuration (validates model exists) - if model not in MODEL_CONFIGS: + # Resolve model config and validate (after all overrides) + resolved_model = default_settings.model + if resolved_model not in MODEL_CONFIGS: allowed = ", ".join(sorted(MODEL_CONFIGS.keys())) - raise ValueError(f"Unsupported model '{model}'. Allowed values: {allowed}.") + raise ValueError(f"Unsupported model '{resolved_model}'. Allowed values: {allowed}.") - self._config = MODEL_CONFIGS[model] + self._config = MODEL_CONFIGS[resolved_model] # Validate parameters against model capabilities - if _params.prompt is not None and not self._config.supports_prompt: - raise ValueError(f"Model '{model}' does not support prompt parameter.") - if _params.mode is not None and not self._config.supports_mode: - raise ValueError(f"Model '{model}' does not support mode parameter.") - if _params.language is not None and not self._config.supports_language: + if default_settings.prompt is not None and not self._config.supports_prompt: + raise ValueError(f"Model '{resolved_model}' does not support prompt parameter.") + if default_settings.mode is not None and not self._config.supports_mode: + raise ValueError(f"Model '{resolved_model}' does not support mode parameter.") + if default_settings.language is not None and not self._config.supports_language: raise ValueError( - f"Model '{model}' does not support language parameter (auto-detects language)." + f"Model '{resolved_model}' does not support language parameter (auto-detects language)." ) # Resolve mode default from model config - mode = _params.mode if _params.mode is not None else self._config.default_mode - - default_settings = SarvamSTTSettings( - model=model, - language=_params.language, - prompt=_params.prompt, - mode=mode, - vad_signals=_params.vad_signals, - high_vad_sensitivity=_params.high_vad_sensitivity, - ) - if settings is not None: - default_settings.apply_update(settings) + if default_settings.mode is None: + default_settings.mode = self._config.default_mode super().__init__( sample_rate=sample_rate, @@ -301,7 +313,7 @@ class SarvamSTTService(STTService): self._socket_client = None self._receive_task = None - if _params.vad_signals: + if default_settings.vad_signals: self._register_event_handler("on_speech_started") self._register_event_handler("on_speech_stopped") self._register_event_handler("on_utterance_end") diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 14386d743..8c76e0ec9 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -467,55 +467,89 @@ class SarvamHttpTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "SarvamHttpTTSSettings", "voice") - if model is not None: - _warn_deprecated_param("model", "SarvamHttpTTSSettings", "model") - if params is not None: - _warn_deprecated_param("params", "SarvamHttpTTSSettings") + # 1. Initialize default_settings with hardcoded defaults + default_settings = SarvamHttpTTSSettings( + model="bulbul:v2", + voice="anushka", + language="en-IN", + enable_preprocessing=False, + pace=1.0, + pitch=None, + loudness=None, + temperature=None, + ) - model = model or "bulbul:v2" + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", SarvamHttpTTSSettings, "model") + default_settings.model = model + if voice_id is not None: + _warn_deprecated_param("voice_id", SarvamHttpTTSSettings, "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) + if not settings: + if params.language is not None: + default_settings.language = ( + self.language_to_service_language(params.language) or "en-IN" + ) + if params.enable_preprocessing is not None: + default_settings.enable_preprocessing = params.enable_preprocessing + if params.pace is not None: + default_settings.pace = params.pace + if params.pitch is not None: + default_settings.pitch = params.pitch + if params.loudness is not None: + default_settings.loudness = params.loudness + if params.temperature is not None: + default_settings.temperature = params.temperature + + # 4. Apply settings delta (canonical API, always wins) + if settings is not None: + default_settings.apply_update(settings) # Get model configuration (validates model exists) - if model not in TTS_MODEL_CONFIGS: + resolved_model = default_settings.model + if resolved_model not in TTS_MODEL_CONFIGS: allowed = ", ".join(sorted(TTS_MODEL_CONFIGS.keys())) - raise ValueError(f"Unsupported model '{model}'. Allowed values: {allowed}.") + raise ValueError(f"Unsupported model '{resolved_model}'. Allowed values: {allowed}.") - self._config = TTS_MODEL_CONFIGS[model] + self._config = TTS_MODEL_CONFIGS[resolved_model] # Set default sample rate based on model if not specified if sample_rate is None: sample_rate = self._config.default_sample_rate - _params = params or SarvamHttpTTSService.InputParams() - - # Set default voice based on model if not specified - if voice_id is None: - voice_id = self._config.default_speaker + # Set default voice based on model if not specified via any mechanism + if voice_id is None and (settings is None or settings.voice is NOT_GIVEN): + default_settings.voice = self._config.default_speaker # Validate and clamp pace to model's valid range - pace = _params.pace + pace = default_settings.pace pace_min, pace_max = self._config.pace_range if pace is not None and (pace < pace_min or pace > pace_max): logger.warning(f"Pace {pace} is outside model range ({pace_min}-{pace_max}). Clamping.") - pace = max(pace_min, min(pace_max, pace)) + default_settings.pace = max(pace_min, min(pace_max, pace)) - default_settings = SarvamHttpTTSSettings( - language=( - self.language_to_service_language(_params.language) if _params.language else "en-IN" - ), - enable_preprocessing=( - True if self._config.preprocessing_always_enabled else _params.enable_preprocessing - ), - pace=pace, - pitch=None, - loudness=None, - temperature=None, - model=model, - voice=voice_id, - ) - if settings is not None: - default_settings.apply_update(settings) + # Force preprocessing for models that require it + if self._config.preprocessing_always_enabled: + default_settings.enable_preprocessing = True + + # Warn about unsupported model-specific parameters + if not self._config.supports_pitch and default_settings.pitch not in (None, 0.0): + logger.warning(f"pitch parameter is ignored for {resolved_model}") + default_settings.pitch = None + if not self._config.supports_loudness and default_settings.loudness not in (None, 1.0): + logger.warning(f"loudness parameter is ignored for {resolved_model}") + default_settings.loudness = None + if not self._config.supports_temperature and default_settings.temperature not in ( + None, + 0.6, + ): + logger.warning(f"temperature parameter is ignored for {resolved_model}") + default_settings.temperature = None super().__init__( sample_rate=sample_rate, @@ -527,22 +561,6 @@ class SarvamHttpTTSService(TTSService): self._base_url = base_url self._session = aiohttp_session - # Add parameters based on model support - if self._config.supports_pitch: - self._settings.pitch = _params.pitch - elif _params.pitch != 0.0: - logger.warning(f"pitch parameter is ignored for {model}") - - if self._config.supports_loudness: - self._settings.loudness = _params.loudness - elif _params.loudness != 1.0: - logger.warning(f"loudness parameter is ignored for {model}") - - if self._config.supports_temperature: - self._settings.temperature = _params.temperature - elif _params.temperature != 0.6: - logger.warning(f"temperature parameter is ignored for {model}") - def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -858,62 +876,105 @@ class SarvamTTSService(InterruptibleTTSService): See https://docs.sarvam.ai/api-reference-docs/text-to-speech/stream """ - if model is not None: - _warn_deprecated_param("model", "SarvamTTSSettings", "model") - if voice_id is not None: - _warn_deprecated_param("voice_id", "SarvamTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "SarvamTTSSettings") + # 1. Initialize default_settings with hardcoded defaults + default_settings = SarvamTTSSettings( + model="bulbul:v2", + voice="anushka", + language="en-IN", + speech_sample_rate="22050", + enable_preprocessing=False, + min_buffer_size=50, + max_chunk_length=150, + output_audio_codec="linear16", + output_audio_bitrate="128k", + pace=1.0, + pitch=None, + loudness=None, + temperature=None, + ) - model = model or "bulbul:v2" + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", SarvamTTSSettings, "model") + default_settings.model = model + if voice_id is not None: + _warn_deprecated_param("voice_id", SarvamTTSSettings, "voice") + default_settings.voice = voice_id + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", SarvamTTSSettings) + if not settings: + if params.language is not None: + default_settings.language = ( + self.language_to_service_language(params.language) or "en-IN" + ) + if params.enable_preprocessing is not None: + default_settings.enable_preprocessing = params.enable_preprocessing + if params.min_buffer_size is not None: + default_settings.min_buffer_size = params.min_buffer_size + if params.max_chunk_length is not None: + default_settings.max_chunk_length = params.max_chunk_length + if params.output_audio_codec is not None: + default_settings.output_audio_codec = params.output_audio_codec + if params.output_audio_bitrate is not None: + default_settings.output_audio_bitrate = params.output_audio_bitrate + if params.pace is not None: + default_settings.pace = params.pace + if params.pitch is not None: + default_settings.pitch = params.pitch + if params.loudness is not None: + default_settings.loudness = params.loudness + if params.temperature is not None: + default_settings.temperature = params.temperature + + # 4. Apply settings delta (canonical API, always wins) + if settings is not None: + default_settings.apply_update(settings) # Get model configuration (validates model exists) - if model not in TTS_MODEL_CONFIGS: + resolved_model = default_settings.model + if resolved_model not in TTS_MODEL_CONFIGS: allowed = ", ".join(sorted(TTS_MODEL_CONFIGS.keys())) - raise ValueError(f"Unsupported model '{model}'. Allowed values: {allowed}.") + raise ValueError(f"Unsupported model '{resolved_model}'. Allowed values: {allowed}.") - self._config = TTS_MODEL_CONFIGS[model] + self._config = TTS_MODEL_CONFIGS[resolved_model] # Set default sample rate based on model if not specified if sample_rate is None: sample_rate = self._config.default_sample_rate + default_settings.speech_sample_rate = str(sample_rate) - # Set default voice based on model if not specified - if voice_id is None: - voice_id = self._config.default_speaker - - _params = params or SarvamTTSService.InputParams() + # Set default voice based on model if not specified via any mechanism + if voice_id is None and (settings is None or settings.voice is NOT_GIVEN): + default_settings.voice = self._config.default_speaker # Validate and clamp pace to model's valid range - pace = _params.pace + pace = default_settings.pace pace_min, pace_max = self._config.pace_range if pace is not None and (pace < pace_min or pace > pace_max): logger.warning(f"Pace {pace} is outside model range ({pace_min}-{pace_max}). Clamping.") - pace = max(pace_min, min(pace_max, pace)) + default_settings.pace = max(pace_min, min(pace_max, pace)) - default_settings = SarvamTTSSettings( - language=( - self.language_to_service_language(_params.language) if _params.language else "en-IN" - ), - speech_sample_rate=str(sample_rate), - enable_preprocessing=( - True if self._config.preprocessing_always_enabled else _params.enable_preprocessing - ), - min_buffer_size=_params.min_buffer_size, - max_chunk_length=_params.max_chunk_length, - output_audio_codec=_params.output_audio_codec, - output_audio_bitrate=_params.output_audio_bitrate, - pace=pace, - pitch=None, - loudness=None, - temperature=None, - model=model, - voice=voice_id, - ) - if settings is not None: - default_settings.apply_update(settings) + # Force preprocessing for models that require it + if self._config.preprocessing_always_enabled: + default_settings.enable_preprocessing = True - # Initialize parent class first + # Warn about unsupported model-specific parameters + if not self._config.supports_pitch and default_settings.pitch not in (None, 0.0): + logger.warning(f"pitch parameter is ignored for {resolved_model}") + default_settings.pitch = None + if not self._config.supports_loudness and default_settings.loudness not in (None, 1.0): + logger.warning(f"loudness parameter is ignored for {resolved_model}") + default_settings.loudness = None + if not self._config.supports_temperature and default_settings.temperature not in ( + None, + 0.6, + ): + logger.warning(f"temperature parameter is ignored for {resolved_model}") + default_settings.temperature = None + + # Initialize parent class super().__init__( aggregate_sentences=aggregate_sentences, text_aggregation_mode=text_aggregation_mode, @@ -926,25 +987,9 @@ class SarvamTTSService(InterruptibleTTSService): ) # WebSocket endpoint URL with model query parameter - self._websocket_url = f"{url}?model={model}" + self._websocket_url = f"{url}?model={resolved_model}" self._api_key = api_key - # Add parameters based on model support - if self._config.supports_pitch: - self._settings.pitch = _params.pitch - elif _params.pitch != 0.0: - logger.warning(f"pitch parameter is ignored for {model}") - - if self._config.supports_loudness: - self._settings.loudness = _params.loudness - elif _params.loudness != 1.0: - logger.warning(f"loudness parameter is ignored for {model}") - - if self._config.supports_temperature: - self._settings.temperature = _params.temperature - elif _params.temperature != 0.6: - logger.warning(f"temperature parameter is ignored for {model}") - self._receive_task = None self._keepalive_task = None self._context_id: Optional[str] = None diff --git a/src/pipecat/services/settings.py b/src/pipecat/services/settings.py index 546104b9a..d9ec5bc7b 100644 --- a/src/pipecat/services/settings.py +++ b/src/pipecat/services/settings.py @@ -56,7 +56,7 @@ if TYPE_CHECKING: def _warn_deprecated_param( param_name: str, - settings_class_name: str, + settings_class: type, settings_field: str | None = None, stacklevel: int = 3, ): @@ -64,12 +64,13 @@ def _warn_deprecated_param( Args: param_name: Name of the deprecated parameter. - settings_class_name: Name of the settings class to use instead. + settings_class: The settings class to use instead. settings_field: Specific field on the settings class, if different from *param_name*. stacklevel: Stack depth for the warning. Default ``3`` targets the caller's caller (i.e. user code that instantiated the service). """ + settings_class_name = settings_class.__name__ if settings_field: msg = ( f"The `{param_name}` parameter is deprecated. " diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index c9b3fb7c9..b37a76b0f 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -218,25 +218,42 @@ class SonioxSTTService(WebsocketSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the STTService. """ - if model is not None: - _warn_deprecated_param("model", "SonioxSTTSettings", "model") - if params is not None: - _warn_deprecated_param("params", "SonioxSTTSettings") - - _params = params or SonioxInputParams() - + # 1. Initialize default_settings with hardcoded defaults default_settings = SonioxSTTSettings( - model=model or _params.model, + model="stt-rt-v4", language=None, - audio_format=_params.audio_format, - num_channels=_params.num_channels, - language_hints=_params.language_hints, - language_hints_strict=_params.language_hints_strict, - context=_params.context, - enable_speaker_diarization=_params.enable_speaker_diarization, - enable_language_identification=_params.enable_language_identification, - client_reference_id=_params.client_reference_id, + audio_format="pcm_s16le", + num_channels=1, + language_hints=None, + language_hints_strict=None, + context=None, + enable_speaker_diarization=False, + enable_language_identification=False, + client_reference_id=None, ) + + # 2. Apply direct init arg overrides (deprecated) + if model is not None: + _warn_deprecated_param("model", SonioxSTTSettings, "model") + default_settings.model = model + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", SonioxSTTSettings) + if not settings: + default_settings.model = params.model + default_settings.audio_format = params.audio_format + default_settings.num_channels = params.num_channels + default_settings.language_hints = params.language_hints + default_settings.language_hints_strict = params.language_hints_strict + default_settings.context = params.context + default_settings.enable_speaker_diarization = params.enable_speaker_diarization + default_settings.enable_language_identification = ( + params.enable_language_identification + ) + default_settings.client_reference_id = params.client_reference_id + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index 2d3e90896..620646d31 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -417,57 +417,86 @@ class SpeechmaticsSTTService(STTService): if not self._base_url: raise ValueError("Missing Speechmatics base URL") - if params is not None: - _warn_deprecated_param("params", "SpeechmaticsSTTSettings") - - # Default params - params = params or SpeechmaticsSTTService.InputParams() self._should_interrupt = should_interrupt - # Deprecation check - self._check_deprecated_args(kwargs, params) + # Deprecation check (mutates params in-place for legacy kwargs migration) + _params = params or SpeechmaticsSTTService.InputParams() + self._check_deprecated_args(kwargs, _params) - # Output formatting defaults - speaker_active_format = params.speaker_active_format - if speaker_active_format is None: - speaker_active_format = ( - "@{speaker_id}: {text}" if params.enable_diarization else "{text}" - ) - speaker_passive_format = params.speaker_passive_format or speaker_active_format - - # Settings — seeded from InputParams + # 1. Initialize default_settings with hardcoded defaults default_settings = SpeechmaticsSTTSettings( model=None, # Will be resolved from operating_point after config is built - language=params.language, - domain=params.domain, - turn_detection_mode=params.turn_detection_mode, - speaker_active_format=speaker_active_format, - speaker_passive_format=speaker_passive_format, - focus_speakers=params.focus_speakers, - ignore_speakers=params.ignore_speakers, - focus_mode=params.focus_mode, - known_speakers=params.known_speakers, - additional_vocab=params.additional_vocab, - audio_encoding=params.audio_encoding, - operating_point=params.operating_point, - max_delay=params.max_delay, - end_of_utterance_silence_trigger=params.end_of_utterance_silence_trigger, - end_of_utterance_max_delay=params.end_of_utterance_max_delay, - punctuation_overrides=params.punctuation_overrides, - include_partials=params.include_partials, - split_sentences=params.split_sentences, - enable_diarization=params.enable_diarization, - speaker_sensitivity=params.speaker_sensitivity, - max_speakers=params.max_speakers, - prefer_current_speaker=params.prefer_current_speaker, - extra_params=params.extra_params, + language=Language.EN, + domain=None, + turn_detection_mode=TurnDetectionMode.EXTERNAL, + speaker_active_format="{text}", + speaker_passive_format="{text}", + focus_speakers=[], + ignore_speakers=[], + focus_mode=SpeakerFocusMode.RETAIN, + known_speakers=[], + additional_vocab=[], + audio_encoding=AudioEncoding.PCM_S16LE, + operating_point=None, + max_delay=None, + end_of_utterance_silence_trigger=None, + end_of_utterance_max_delay=None, + punctuation_overrides=None, + include_partials=None, + split_sentences=None, + enable_diarization=None, + speaker_sensitivity=None, + max_speakers=None, + prefer_current_speaker=None, + extra_params=None, ) + # 2. No direct init arg overrides + + # 3. Apply params overrides — only if settings not provided + if params is not None: + _warn_deprecated_param("params", SpeechmaticsSTTSettings) + if not settings: + default_settings.language = _params.language + default_settings.domain = _params.domain + default_settings.turn_detection_mode = _params.turn_detection_mode + # Output formatting defaults + speaker_active_format = _params.speaker_active_format + if speaker_active_format is None: + speaker_active_format = ( + "@{speaker_id}: {text}" if _params.enable_diarization else "{text}" + ) + default_settings.speaker_active_format = speaker_active_format + default_settings.speaker_passive_format = ( + _params.speaker_passive_format or speaker_active_format + ) + default_settings.focus_speakers = _params.focus_speakers + default_settings.ignore_speakers = _params.ignore_speakers + default_settings.focus_mode = _params.focus_mode + default_settings.known_speakers = _params.known_speakers + default_settings.additional_vocab = _params.additional_vocab + default_settings.audio_encoding = _params.audio_encoding + default_settings.operating_point = _params.operating_point + default_settings.max_delay = _params.max_delay + default_settings.end_of_utterance_silence_trigger = ( + _params.end_of_utterance_silence_trigger + ) + default_settings.end_of_utterance_max_delay = _params.end_of_utterance_max_delay + default_settings.punctuation_overrides = _params.punctuation_overrides + default_settings.include_partials = _params.include_partials + default_settings.split_sentences = _params.split_sentences + default_settings.enable_diarization = _params.enable_diarization + default_settings.speaker_sensitivity = _params.speaker_sensitivity + default_settings.max_speakers = _params.max_speakers + default_settings.prefer_current_speaker = _params.prefer_current_speaker + default_settings.extra_params = _params.extra_params + # Build SDK config from settings, then resolve model from operating_point self._client: VoiceAgentClient | None = None self._config: VoiceAgentConfig = self._build_config(default_settings) default_settings.model = self._config.operating_point.value + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -496,7 +525,7 @@ class SpeechmaticsSTTService(STTService): self._bot_speaking: bool = False # Event handlers - if params.enable_diarization: + if default_settings.enable_diarization: self._register_event_handler("on_speakers_result") # ============================================================================ diff --git a/src/pipecat/services/speechmatics/tts.py b/src/pipecat/services/speechmatics/tts.py index 8ce6ae2ef..dff3e5f0f 100644 --- a/src/pipecat/services/speechmatics/tts.py +++ b/src/pipecat/services/speechmatics/tts.py @@ -104,24 +104,32 @@ class SpeechmaticsTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "SpeechmaticsTTSSettings", "voice") - if params is not None: - _warn_deprecated_param("params", "SpeechmaticsTTSSettings") - if sample_rate and sample_rate != self.SPEECHMATICS_SAMPLE_RATE: logger.warning( f"Speechmatics TTS only supports {self.SPEECHMATICS_SAMPLE_RATE}Hz sample rate. " f"Current rate of {sample_rate}Hz may cause issues." ) - _params = params or SpeechmaticsTTSService.InputParams() + # 1. Initialize default_settings with hardcoded defaults default_settings = SpeechmaticsTTSSettings( model=None, - voice=voice_id or "sarah", + voice="sarah", language=None, - max_retries=_params.max_retries, + max_retries=5, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", SpeechmaticsTTSSettings, "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) + if not settings: + default_settings.max_retries = params.max_retries + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index 48e15ae5c..0fd8b637b 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -45,12 +45,15 @@ class TogetherLLMService(OpenAILLMService): parameters, ``settings`` values take precedence. **kwargs: Additional keyword arguments passed to OpenAILLMService. """ - if model is not None: - _warn_deprecated_param("model", "OpenAILLMSettings", "model") + # 1. Initialize default_settings with hardcoded defaults + default_settings = OpenAILLMSettings(model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo") - default_settings = OpenAILLMSettings( - model=model or "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", OpenAILLMSettings, "model") + default_settings.model = model + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/ultravox/llm.py b/src/pipecat/services/ultravox/llm.py index 933930152..094d22827 100644 --- a/src/pipecat/services/ultravox/llm.py +++ b/src/pipecat/services/ultravox/llm.py @@ -186,6 +186,7 @@ class UltravoxRealtimeLLMService(LLMService): May only be set with OneShotInputParams. **kwargs: Additional arguments passed to parent LLMService. """ + # 1. Initialize default_settings with hardcoded defaults default_settings = UltravoxRealtimeLLMSettings( model=None, temperature=None, @@ -199,6 +200,10 @@ class UltravoxRealtimeLLMService(LLMService): user_turn_completion_config=None, output_medium=None, ) + + # (No step 2/3 — params is required and not deprecated) + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index a54da0c05..b6c19ab5a 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -181,24 +181,30 @@ class BaseWhisperSTTService(SegmentedSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to SegmentedSTTService. """ - if model is not None: - _warn_deprecated_param("model", "BaseWhisperSTTSettings", "model") - if language is not None: - _warn_deprecated_param("language", "BaseWhisperSTTSettings", "language") - if prompt is not None: - _warn_deprecated_param("prompt", "BaseWhisperSTTSettings", "prompt") - if temperature is not None: - _warn_deprecated_param("temperature", "BaseWhisperSTTSettings", "temperature") - - _language = language or Language.EN - + # --- 1. Hardcoded defaults --- default_settings = BaseWhisperSTTSettings( - model=model, - language=self.language_to_service_language(_language), + model=None, + language=None, base_url=base_url, - prompt=prompt, - temperature=temperature, ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + default_settings.model = model + if language is not None: + _warn_deprecated_param("language", BaseWhisperSTTSettings, "language") + default_settings.language = self.language_to_service_language(language) + if prompt is not None: + _warn_deprecated_param("prompt", BaseWhisperSTTSettings, "prompt") + default_settings.prompt = prompt + if temperature is not None: + _warn_deprecated_param("temperature", BaseWhisperSTTSettings, "temperature") + default_settings.temperature = temperature + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) @@ -209,10 +215,8 @@ class BaseWhisperSTTService(SegmentedSTTService): ) self._client = self._create_client(api_key, base_url) self._language = self._settings.language - self._prompt = self._settings.prompt if self._settings.prompt else prompt - self._temperature = ( - self._settings.temperature if self._settings.temperature else temperature - ) + self._prompt = self._settings.prompt + self._temperature = self._settings.temperature self._include_prob_metrics = include_prob_metrics self._push_empty_transcripts = push_empty_transcripts diff --git a/src/pipecat/services/whisper/stt.py b/src/pipecat/services/whisper/stt.py index 38fd287fa..17fe24c2d 100644 --- a/src/pipecat/services/whisper/stt.py +++ b/src/pipecat/services/whisper/stt.py @@ -256,30 +256,35 @@ class WhisperSTTService(SegmentedSTTService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to SegmentedSTTService. """ - if model is not None: - _warn_deprecated_param("model", "WhisperSTTSettings", "model") - if device is not None: - _warn_deprecated_param("device", "WhisperSTTSettings", "device") - if compute_type is not None: - _warn_deprecated_param("compute_type", "WhisperSTTSettings", "compute_type") - if no_speech_prob is not None: - _warn_deprecated_param("no_speech_prob", "WhisperSTTSettings", "no_speech_prob") - if language is not None: - _warn_deprecated_param("language", "WhisperSTTSettings", "language") - - _model = model if model is not None else Model.DISTIL_MEDIUM_EN - _device = device or "auto" - _compute_type = compute_type or "default" - _no_speech_prob = no_speech_prob if no_speech_prob is not None else 0.4 - _language = language or Language.EN - + # --- 1. Hardcoded defaults --- default_settings = WhisperSTTSettings( - model=_model if isinstance(_model, str) else _model.value, - language=_language, - device=_device, - compute_type=_compute_type, - no_speech_prob=_no_speech_prob, + model=Model.DISTIL_MEDIUM_EN.value, + language=Language.EN, + device="auto", + compute_type="default", + no_speech_prob=0.4, ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", WhisperSTTSettings, "model") + default_settings.model = model if isinstance(model, str) else model.value + if device is not None: + _warn_deprecated_param("device", WhisperSTTSettings, "device") + default_settings.device = device + if compute_type is not None: + _warn_deprecated_param("compute_type", WhisperSTTSettings, "compute_type") + default_settings.compute_type = compute_type + if no_speech_prob is not None: + _warn_deprecated_param("no_speech_prob", WhisperSTTSettings, "no_speech_prob") + default_settings.no_speech_prob = no_speech_prob + if language is not None: + _warn_deprecated_param("language", WhisperSTTSettings, "language") + default_settings.language = language + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) @@ -430,27 +435,32 @@ class WhisperSTTServiceMLX(WhisperSTTService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to SegmentedSTTService. """ - if model is not None: - _warn_deprecated_param("model", "WhisperMLXSTTSettings", "model") - if no_speech_prob is not None: - _warn_deprecated_param("no_speech_prob", "WhisperMLXSTTSettings", "no_speech_prob") - if language is not None: - _warn_deprecated_param("language", "WhisperMLXSTTSettings", "language") - if temperature is not None: - _warn_deprecated_param("temperature", "WhisperMLXSTTSettings", "temperature") - - _model = model if model is not None else MLXModel.TINY - _no_speech_prob = no_speech_prob if no_speech_prob is not None else 0.6 - _language = language or Language.EN - _temperature = temperature if temperature is not None else 0.0 - + # --- 1. Hardcoded defaults --- default_settings = WhisperMLXSTTSettings( - model=_model if isinstance(_model, str) else _model.value, - language=_language, - no_speech_prob=_no_speech_prob, - temperature=_temperature, + model=MLXModel.TINY.value, + language=Language.EN, + no_speech_prob=0.6, + temperature=0.0, engine="mlx", ) + + # --- 2. Deprecated direct-arg overrides --- + if model is not None: + _warn_deprecated_param("model", WhisperMLXSTTSettings, "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") + default_settings.no_speech_prob = no_speech_prob + if language is not None: + _warn_deprecated_param("language", WhisperMLXSTTSettings, "language") + default_settings.language = language + if temperature is not None: + _warn_deprecated_param("temperature", WhisperMLXSTTSettings, "temperature") + default_settings.temperature = temperature + + # --- 3. (no params object for this service) --- + + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) diff --git a/src/pipecat/services/xtts/tts.py b/src/pipecat/services/xtts/tts.py index 88137172f..c5bfe629e 100644 --- a/src/pipecat/services/xtts/tts.py +++ b/src/pipecat/services/xtts/tts.py @@ -118,15 +118,20 @@ class XTTSService(TTSService): parameters, ``settings`` values take precedence. **kwargs: Additional arguments passed to parent TTSService. """ - if voice_id is not None: - _warn_deprecated_param("voice_id", "XTTSTTSSettings", "voice") - + # 1. Initialize default_settings with hardcoded defaults default_settings = XTTSTTSSettings( model=None, - voice=voice_id, + voice=None, language=self.language_to_service_language(language), base_url=base_url, ) + + # 2. Apply direct init arg overrides (deprecated) + if voice_id is not None: + _warn_deprecated_param("voice_id", XTTSTTSSettings, "voice") + default_settings.voice = voice_id + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) From f31bfcf4ece659a1be7267250ccd6d41c396a51a Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 3 Mar 2026 20:29:35 -0500 Subject: [PATCH 04/17] Clean up CartesiaTTSSettings: separate init-only vs runtime-updatable fields Move output_container, output_encoding, output_sample_rate out of CartesiaTTSSettings into plain instance attributes since they cannot change at runtime without breaking the audio pipeline. Remove deprecated speed/emotion fields and their dead references in _build_msg() and run_tts(). Remove the from_mapping override that only existed to destructure those now-removed output format fields. --- src/pipecat/services/cartesia/tts.py | 135 ++++++++------------------- 1 file changed, 37 insertions(+), 98 deletions(-) diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index 2aeeefda2..71017074b 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -8,14 +8,13 @@ import base64 import json -import warnings from dataclasses import dataclass, field from enum import Enum -from typing import Any, AsyncGenerator, List, Literal, Mapping, Optional, Self +from typing import AsyncGenerator, List, Optional import aiohttp from loguru import logger -from pydantic import BaseModel, Field +from pydantic import BaseModel from pipecat.frames.frames import ( CancelFrame, @@ -192,35 +191,16 @@ class CartesiaTTSSettings(TTSSettings): """Settings for Cartesia TTS services. Parameters: - output_container: Audio container format (e.g. "raw"). - output_encoding: Audio encoding format (e.g. "pcm_s16le"). - output_sample_rate: Audio sample rate in Hz. - speed: Voice speed control for non-Sonic-3 models (literal values). - emotion: List of emotion controls for non-Sonic-3 models. generation_config: Generation configuration for Sonic-3 models. Includes volume, speed (numeric), and emotion (string) parameters. pronunciation_dict_id: The ID of the pronunciation dictionary to use for custom pronunciations. """ - output_container: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - speed: Literal["slow", "normal", "fast"] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - emotion: List[str] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - generation_config: GenerationConfig | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pronunciation_dict_id: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - - @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> Self: - """Construct settings from a plain dict, destructuring legacy nested ``output_format``.""" - flat = dict(settings) - nested = flat.pop("output_format", None) - if isinstance(nested, dict): - flat.setdefault("output_container", nested.get("container")) - flat.setdefault("output_encoding", nested.get("encoding")) - flat.setdefault("output_sample_rate", nested.get("sample_rate")) - return super().from_mapping(flat) + generation_config: GenerationConfig | None | _NotGiven = field( + default_factory=lambda: NOT_GIVEN + ) + pronunciation_dict_id: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class CartesiaTTSService(AudioContextTTSService): @@ -228,7 +208,7 @@ class CartesiaTTSService(AudioContextTTSService): Provides text-to-speech using Cartesia's streaming WebSocket API. Supports word-level timestamps, audio context management, and various voice - customization options including speed and emotion controls. + customization options including generation configuration. """ _settings: CartesiaTTSSettings @@ -238,20 +218,12 @@ class CartesiaTTSService(AudioContextTTSService): Parameters: language: Language to use for synthesis. - speed: Voice speed control for non-Sonic-3 models (literal values). - emotion: List of emotion controls for non-Sonic-3 models. - - .. deprecated:: 0.0.68 - The `emotion` parameter is deprecated and will be removed in a future version. - generation_config: Generation configuration for Sonic-3 models. Includes volume, speed (numeric), and emotion (string) parameters. pronunciation_dict_id: The ID of the pronunciation dictionary to use for custom pronunciations. """ language: Optional[Language] = Language.EN - speed: Optional[Literal["slow", "normal", "fast"]] = None - emotion: Optional[List[str]] = [] generation_config: Optional[GenerationConfig] = None pronunciation_dict_id: Optional[str] = None @@ -279,14 +251,14 @@ class CartesiaTTSService(AudioContextTTSService): api_key: Cartesia API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CartesiaTTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CartesiaTTSSettings(model=...)`` instead. sample_rate: Audio sample rate. If None, uses default. @@ -294,7 +266,7 @@ class CartesiaTTSService(AudioContextTTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CartesiaTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -329,9 +301,9 @@ class CartesiaTTSService(AudioContextTTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaTTSSettings( model="sonic-3", - output_container=container, - output_encoding=encoding, - output_sample_rate=0, + language=language_to_cartesia_language(Language.EN), + generation_config=None, + pronunciation_dict_id=None, ) # 2. Apply direct init arg overrides (deprecated) @@ -348,10 +320,6 @@ class CartesiaTTSService(AudioContextTTSService): if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) - if params.speed is not None: - default_settings.speed = params.speed - if params.emotion is not None: - default_settings.emotion = params.emotion if params.generation_config is not None: default_settings.generation_config = params.generation_config if params.pronunciation_dict_id is not None: @@ -387,6 +355,11 @@ class CartesiaTTSService(AudioContextTTSService): self._cartesia_version = cartesia_version self._url = url + # Audio output format — init-only, not runtime-updatable + self._output_container = container + self._output_encoding = encoding + self._output_sample_rate = 0 # Set in start() from self.sample_rate + self._receive_task = None def can_generate_metrics(self) -> bool: @@ -484,17 +457,6 @@ class CartesiaTTSService(AudioContextTTSService): voice_config["mode"] = "id" voice_config["id"] = self._settings.voice - if self._settings.emotion: - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - "The 'emotion' parameter in __experimental_controls is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) - voice_config["__experimental_controls"] = {} - voice_config["__experimental_controls"]["emotion"] = self._settings.emotion - msg = { "transcript": text, "continue": continue_transcript, @@ -502,9 +464,9 @@ class CartesiaTTSService(AudioContextTTSService): "model_id": self._settings.model, "voice": voice_config, "output_format": { - "container": self._settings.output_container, - "encoding": self._settings.output_encoding, - "sample_rate": self._settings.output_sample_rate, + "container": self._output_container, + "encoding": self._output_encoding, + "sample_rate": self._output_sample_rate, }, "add_timestamps": add_timestamps, "use_original_timestamps": False if self._settings.model == "sonic" else True, @@ -513,9 +475,6 @@ class CartesiaTTSService(AudioContextTTSService): if self._settings.language: msg["language"] = self._settings.language - if self._settings.speed: - msg["speed"] = self._settings.speed - if self._settings.generation_config: msg["generation_config"] = self._settings.generation_config.model_dump( exclude_none=True @@ -533,7 +492,7 @@ class CartesiaTTSService(AudioContextTTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.output_sample_rate = self.sample_rate + self._output_sample_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): @@ -728,20 +687,12 @@ class CartesiaHttpTTSService(TTSService): Parameters: language: Language to use for synthesis. - speed: Voice speed control for non-Sonic-3 models (literal values). - emotion: List of emotion controls for non-Sonic-3 models. - - .. deprecated:: 0.0.68 - The `emotion` parameter is deprecated and will be removed in a future version. - generation_config: Generation configuration for Sonic-3 models. Includes volume, speed (numeric), and emotion (string) parameters. pronunciation_dict_id: The ID of the pronunciation dictionary to use for custom pronunciations. """ language: Optional[Language] = Language.EN - speed: Optional[Literal["slow", "normal", "fast"]] = None - emotion: Optional[List[str]] = Field(default_factory=list) generation_config: Optional[GenerationConfig] = None pronunciation_dict_id: Optional[str] = None @@ -767,12 +718,12 @@ class CartesiaHttpTTSService(TTSService): api_key: Cartesia API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CartesiaTTSSettings(voice=...)`` instead. model: TTS model to use (e.g., "sonic-3"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CartesiaTTSSettings(model=...)`` instead. base_url: Base URL for Cartesia HTTP API. @@ -784,7 +735,7 @@ class CartesiaHttpTTSService(TTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CartesiaTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -794,9 +745,9 @@ class CartesiaHttpTTSService(TTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaTTSSettings( model="sonic-3", - output_container=container, - output_encoding=encoding, - output_sample_rate=0, + language=language_to_cartesia_language(Language.EN), + generation_config=None, + pronunciation_dict_id=None, ) # 2. Apply direct init arg overrides (deprecated) @@ -813,10 +764,6 @@ class CartesiaHttpTTSService(TTSService): if not settings: if params.language is not None: default_settings.language = self.language_to_service_language(params.language) - if params.speed is not None: - default_settings.speed = params.speed - if params.emotion is not None: - default_settings.emotion = params.emotion if params.generation_config is not None: default_settings.generation_config = params.generation_config if params.pronunciation_dict_id is not None: @@ -836,6 +783,11 @@ class CartesiaHttpTTSService(TTSService): self._base_url = base_url self._cartesia_version = cartesia_version + # Audio output format — init-only, not runtime-updatable + self._output_container = container + self._output_encoding = encoding + self._output_sample_rate = 0 # Set in start() from self.sample_rate + self._session: aiohttp.ClientSession | None = aiohttp_session self._owns_session = aiohttp_session is None @@ -865,7 +817,7 @@ class CartesiaHttpTTSService(TTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.output_sample_rate = self.sample_rate + self._output_sample_rate = self.sample_rate if self._owns_session: self._session = aiohttp.ClientSession() @@ -909,22 +861,12 @@ class CartesiaHttpTTSService(TTSService): try: voice_config = {"mode": "id", "id": self._settings.voice} - if self._settings.emotion: - with warnings.catch_warnings(): - warnings.simplefilter("always") - warnings.warn( - "The 'emotion' parameter in voice.__experimental_controls is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) - voice_config["__experimental_controls"] = {"emotion": self._settings.emotion} - await self.start_ttfb_metrics() output_format = { - "container": self._settings.output_container, - "encoding": self._settings.output_encoding, - "sample_rate": self._settings.output_sample_rate, + "container": self._output_container, + "encoding": self._output_encoding, + "sample_rate": self._output_sample_rate, } payload = { @@ -937,9 +879,6 @@ class CartesiaHttpTTSService(TTSService): if self._settings.language: payload["language"] = self._settings.language - if self._settings.speed: - payload["speed"] = self._settings.speed - if self._settings.generation_config: payload["generation_config"] = self._settings.generation_config.model_dump( exclude_none=True From 1274bb2c5588f35dc69871cb21153a889d365227 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 3 Mar 2026 20:31:08 -0500 Subject: [PATCH 05/17] Update deprecation version to 0.0.105 --- examples/foundational/07-interruptible.py | 9 ++++--- src/pipecat/services/asyncai/tts.py | 16 ++++++------- src/pipecat/services/aws/stt.py | 4 ++-- src/pipecat/services/aws/tts.py | 6 ++--- src/pipecat/services/azure/image.py | 2 +- src/pipecat/services/azure/llm.py | 2 +- src/pipecat/services/azure/stt.py | 2 +- src/pipecat/services/azure/tts.py | 10 ++++---- src/pipecat/services/camb/tts.py | 8 +++---- src/pipecat/services/cerebras/llm.py | 2 +- src/pipecat/services/deepgram/flux/stt.py | 6 ++--- .../services/deepgram/sagemaker/tts.py | 2 +- src/pipecat/services/deepgram/tts.py | 4 ++-- src/pipecat/services/deepseek/llm.py | 2 +- src/pipecat/services/elevenlabs/stt.py | 12 +++++----- src/pipecat/services/elevenlabs/tts.py | 16 ++++++------- src/pipecat/services/fal/image.py | 2 +- src/pipecat/services/fal/stt.py | 4 ++-- src/pipecat/services/fireworks/llm.py | 2 +- src/pipecat/services/fish/tts.py | 8 +++---- src/pipecat/services/gladia/stt.py | 4 ++-- src/pipecat/services/google/image.py | 2 +- src/pipecat/services/google/llm_openai.py | 2 +- src/pipecat/services/google/stt.py | 4 ++-- src/pipecat/services/google/tts.py | 20 ++++++++-------- src/pipecat/services/gradium/stt.py | 4 ++-- src/pipecat/services/gradium/tts.py | 8 +++---- src/pipecat/services/grok/llm.py | 2 +- src/pipecat/services/groq/llm.py | 2 +- src/pipecat/services/groq/stt.py | 8 +++---- src/pipecat/services/groq/tts.py | 8 +++---- src/pipecat/services/hume/tts.py | 6 ++--- src/pipecat/services/inworld/tts.py | 16 ++++++------- src/pipecat/services/kokoro/tts.py | 6 ++--- src/pipecat/services/lmnt/tts.py | 4 ++-- src/pipecat/services/minimax/tts.py | 8 +++---- src/pipecat/services/mistral/llm.py | 2 +- src/pipecat/services/moondream/vision.py | 2 +- src/pipecat/services/neuphonic/tts.py | 12 +++++----- src/pipecat/services/nvidia/llm.py | 2 +- src/pipecat/services/nvidia/stt.py | 8 +++---- src/pipecat/services/nvidia/tts.py | 6 ++--- src/pipecat/services/ollama/llm.py | 2 +- src/pipecat/services/openai/base_llm.py | 6 ++--- src/pipecat/services/openai/image.py | 2 +- src/pipecat/services/openai/llm.py | 4 ++-- src/pipecat/services/openai/stt.py | 4 ++-- src/pipecat/services/openai/tts.py | 12 +++++----- src/pipecat/services/openpipe/llm.py | 2 +- src/pipecat/services/openrouter/llm.py | 2 +- src/pipecat/services/perplexity/llm.py | 2 +- src/pipecat/services/piper/tts.py | 4 ++-- src/pipecat/services/qwen/llm.py | 2 +- src/pipecat/services/resembleai/tts.py | 2 +- src/pipecat/services/rime/tts.py | 24 +++++++++---------- src/pipecat/services/sambanova/llm.py | 2 +- src/pipecat/services/sambanova/stt.py | 8 +++---- src/pipecat/services/sarvam/stt.py | 6 ++--- src/pipecat/services/sarvam/tts.py | 16 ++++++------- src/pipecat/services/soniox/stt.py | 6 ++--- src/pipecat/services/speechmatics/stt.py | 2 +- src/pipecat/services/speechmatics/tts.py | 6 ++--- src/pipecat/services/together/llm.py | 2 +- src/pipecat/services/whisper/base_stt.py | 8 +++---- src/pipecat/services/whisper/stt.py | 18 +++++++------- src/pipecat/services/xtts/tts.py | 2 +- 66 files changed, 199 insertions(+), 200 deletions(-) diff --git a/examples/foundational/07-interruptible.py b/examples/foundational/07-interruptible.py index 3f97e5028..b8a334ec0 100644 --- a/examples/foundational/07-interruptible.py +++ b/examples/foundational/07-interruptible.py @@ -21,7 +21,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.tts_service import TextAggregationMode @@ -56,10 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady - # Alternatively, you can use TextAggregationMode.TOKEN to stream tokens instead of - # sentencesfor faster response times. - # text_aggregation_mode=TextAggregationMode.TOKEN, + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index ef5c95bfe..d4e2eabdc 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -110,7 +110,7 @@ class AsyncAITTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for Async TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -143,14 +143,14 @@ class AsyncAITTSService(AudioContextTTSService): voice_id: UUID of the voice to use for synthesis. See docs for a full list: https://docs.async.com/list-voices-16699698e0 - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AsyncAITTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AsyncAITTSSettings(model=...)`` instead. sample_rate: Audio sample rate. @@ -158,7 +158,7 @@ class AsyncAITTSService(AudioContextTTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AsyncAITTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -508,7 +508,7 @@ class AsyncAIHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Async API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``AsyncAITTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -539,13 +539,13 @@ class AsyncAIHttpTTSService(TTSService): api_key: Async API key. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AsyncAITTSSettings(voice=...)`` instead. aiohttp_session: An aiohttp session for making HTTP requests. model: TTS model to use (e.g., "async_flash_v1.0"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AsyncAITTSSettings(model=...)`` instead. url: Base URL for Async API. @@ -555,7 +555,7 @@ class AsyncAIHttpTTSService(TTSService): container: Audio container format. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AsyncAITTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index 950624fbf..451c8a695 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -96,12 +96,12 @@ class AWSTranscribeSTTService(WebsocketSTTService): region: AWS region for the service. sample_rate: Audio sample rate in Hz. Must be 8000 or 16000. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AWSTranscribeSTTSettings(sample_rate=...)`` instead. language: Language for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AWSTranscribeSTTSettings(language=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/aws/tts.py b/src/pipecat/services/aws/tts.py index f248db27a..043fc264e 100644 --- a/src/pipecat/services/aws/tts.py +++ b/src/pipecat/services/aws/tts.py @@ -155,7 +155,7 @@ class AWSPollyTTSService(TTSService): class InputParams(BaseModel): """Input parameters for AWS Polly TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``AWSPollyTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -196,13 +196,13 @@ class AWSPollyTTSService(TTSService): region: AWS region for Polly service. Defaults to 'us-east-1'. voice_id: Voice ID to use for synthesis. Defaults to 'Joanna'. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AWSPollyTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses service default. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AWSPollyTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/azure/image.py b/src/pipecat/services/azure/image.py index ca58644f2..2a1286c78 100644 --- a/src/pipecat/services/azure/image.py +++ b/src/pipecat/services/azure/image.py @@ -59,7 +59,7 @@ class AzureImageGenServiceREST(ImageGenService): endpoint: Azure OpenAI endpoint URL. model: The image generation model to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureImageGenSettings(model=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. diff --git a/src/pipecat/services/azure/llm.py b/src/pipecat/services/azure/llm.py index 734a0bacf..19a31320e 100644 --- a/src/pipecat/services/azure/llm.py +++ b/src/pipecat/services/azure/llm.py @@ -40,7 +40,7 @@ class AzureLLMService(OpenAILLMService): endpoint: The Azure endpoint URL. model: The model identifier to use. Defaults to "gpt-4o". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. api_version: Azure API version. Defaults to "2024-09-01-preview". diff --git a/src/pipecat/services/azure/stt.py b/src/pipecat/services/azure/stt.py index 66f871ad3..2527f0bb0 100644 --- a/src/pipecat/services/azure/stt.py +++ b/src/pipecat/services/azure/stt.py @@ -94,7 +94,7 @@ class AzureSTTService(STTService): region: Azure region for the Speech service (e.g., 'eastus'). language: Language for speech recognition. Defaults to English (US). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureSTTSettings(language=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index 3a67cb2ff..f4aa85dbc 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -115,7 +115,7 @@ class AzureBaseTTSService: class InputParams(BaseModel): """Input parameters for Azure TTS voice configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureTTSSettings(...)`` instead. Parameters: @@ -271,13 +271,13 @@ class AzureTTSService(TTSService, AzureBaseTTSService): region: Azure region identifier (e.g., "eastus", "westus2"). voice: Voice name to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -782,13 +782,13 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): region: Azure region identifier (e.g., "eastus", "westus2"). voice: Voice name to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses service default. params: Voice and synthesis parameters configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=AzureTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/camb/tts.py b/src/pipecat/services/camb/tts.py index 9a1b753a6..ef007181e 100644 --- a/src/pipecat/services/camb/tts.py +++ b/src/pipecat/services/camb/tts.py @@ -175,7 +175,7 @@ class CambTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Camb.ai TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CambTTSSettings(...)`` instead. Parameters: @@ -210,12 +210,12 @@ class CambTTSService(TTSService): api_key: Camb.ai API key for authentication. voice_id: Voice ID to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CambTTSSettings(voice=...)`` instead. model: TTS model to use. Options: "mars-flash" (fast), "mars-pro" (high quality). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CambTTSSettings(model=...)`` instead. timeout: Request timeout in seconds. Defaults to 60.0 (minimum recommended @@ -223,7 +223,7 @@ class CambTTSService(TTSService): sample_rate: Audio sample rate in Hz. If None, uses model-specific default. params: Additional voice parameters. If None, uses defaults. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=CambTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index 98fbfe0e3..c952b9552 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -39,7 +39,7 @@ class CerebrasLLMService(OpenAILLMService): base_url: The base URL for Cerebras API. Defaults to "https://api.cerebras.ai/v1". model: The model identifier to use. Defaults to "gpt-oss-120b". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index 8ddd2ef0d..ae5364f60 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -124,7 +124,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for Deepgram Flux API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=DeepgramFluxSTTSettings(...)`` instead. Parameters: @@ -173,14 +173,14 @@ class DeepgramFluxSTTService(WebsocketSTTService): sample_rate: Audio sample rate in Hz. If None, uses the rate from params or 16000. model: Deepgram Flux model to use for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=DeepgramFluxSTTSettings(model=...)`` instead. flux_encoding: Audio encoding format required by Flux API. Must be "linear16". Raw signed little-endian 16-bit PCM encoding. params: InputParams instance containing detailed API configuration options. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=DeepgramFluxSTTSettings(...)`` instead. should_interrupt: Determine whether the bot should be interrupted when Flux detects that the user is speaking. diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index 62cd25188..9457cc1db 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -92,7 +92,7 @@ class DeepgramSageMakerTTSService(TTSService): region: AWS region where the endpoint is deployed (e.g., "us-east-2"). voice: Voice model to use for synthesis. Defaults to "aura-2-helena-en". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=DeepgramSageMakerTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses the value from StartFrame. diff --git a/src/pipecat/services/deepgram/tts.py b/src/pipecat/services/deepgram/tts.py index 98a615f9b..b54cd23dc 100644 --- a/src/pipecat/services/deepgram/tts.py +++ b/src/pipecat/services/deepgram/tts.py @@ -85,7 +85,7 @@ class DeepgramTTSService(WebsocketTTSService): api_key: Deepgram API key for authentication. voice: Voice model to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=DeepgramTTSSettings(voice=...)`` instead. base_url: WebSocket base URL for Deepgram API. Defaults to "wss://api.deepgram.com". @@ -409,7 +409,7 @@ class DeepgramHttpTTSService(TTSService): api_key: Deepgram API key for authentication. voice: Voice model to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=DeepgramTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests with connection pooling. diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index c383f5609..3d7c67e2a 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -39,7 +39,7 @@ class DeepSeekLLMService(OpenAILLMService): base_url: The base URL for DeepSeek API. Defaults to "https://api.deepseek.com/v1". model: The model identifier to use. Defaults to "deepseek-chat". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/elevenlabs/stt.py b/src/pipecat/services/elevenlabs/stt.py index d93f95332..2d75abff9 100644 --- a/src/pipecat/services/elevenlabs/stt.py +++ b/src/pipecat/services/elevenlabs/stt.py @@ -228,7 +228,7 @@ class ElevenLabsSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for ElevenLabs STT API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsSTTSettings(...)`` instead. Parameters: @@ -260,13 +260,13 @@ class ElevenLabsSTTService(SegmentedSTTService): base_url: Base URL for ElevenLabs API. model: Model ID for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsSTTSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -461,7 +461,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for ElevenLabs Realtime STT API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. Parameters: @@ -509,13 +509,13 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): base_url: Base URL for ElevenLabs WebSocket API. model: Model ID for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsRealtimeSTTSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsRealtimeSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 3cec12431..2447427ab 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -331,7 +331,7 @@ class ElevenLabsTTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for ElevenLabs TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsTTSSettings(...)`` instead. Parameters: @@ -381,12 +381,12 @@ class ElevenLabsTTSService(AudioContextTTSService): api_key: ElevenLabs API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsTTSSettings(voice=...)`` instead. model: TTS model to use (e.g., "eleven_turbo_v2_5"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsTTSSettings(model=...)`` instead. url: WebSocket URL for ElevenLabs TTS API. @@ -395,7 +395,7 @@ class ElevenLabsTTSService(AudioContextTTSService): locators to use. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -921,7 +921,7 @@ class ElevenLabsHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for ElevenLabs HTTP TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. Parameters: @@ -968,13 +968,13 @@ class ElevenLabsHttpTTSService(TTSService): api_key: ElevenLabs API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsHttpTTSSettings(voice=...)`` instead. aiohttp_session: aiohttp ClientSession for HTTP requests. model: TTS model to use (e.g., "eleven_turbo_v2_5"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsHttpTTSSettings(model=...)`` instead. base_url: Base URL for ElevenLabs HTTP API. @@ -983,7 +983,7 @@ class ElevenLabsHttpTTSService(TTSService): locators to use. params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ElevenLabsHttpTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/fal/image.py b/src/pipecat/services/fal/image.py index 2c36c2208..342aaa4a9 100644 --- a/src/pipecat/services/fal/image.py +++ b/src/pipecat/services/fal/image.py @@ -80,7 +80,7 @@ class FalImageGenService(ImageGenService): 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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FalImageGenSettings(model=...)`` instead. key: Optional API key for Fal.ai. If provided, sets FAL_KEY environment variable. diff --git a/src/pipecat/services/fal/stt.py b/src/pipecat/services/fal/stt.py index ea9f69a18..4428599b1 100644 --- a/src/pipecat/services/fal/stt.py +++ b/src/pipecat/services/fal/stt.py @@ -169,7 +169,7 @@ class FalSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for Fal's Wizper API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FalSTTSettings(...)`` instead. Parameters: @@ -204,7 +204,7 @@ class FalSTTService(SegmentedSTTService): sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate. params: Configuration parameters for the Wizper API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FalSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index cb5a0cf39..e7866c55d 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -38,7 +38,7 @@ class FireworksLLMService(OpenAILLMService): api_key: The API key for accessing Fireworks AI. model: The model identifier to use. Defaults to "accounts/fireworks/models/firefunction-v2". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for Fireworks API. Defaults to "https://api.fireworks.ai/inference/v1". diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index 3d4412186..af02b4e99 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -95,7 +95,7 @@ class FishAudioTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Input parameters for Fish Audio TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FishAudioTTSSettings(...)`` instead. Parameters: @@ -131,7 +131,7 @@ class FishAudioTTSService(InterruptibleTTSService): api_key: Fish Audio API key for authentication. reference_id: Reference ID of the voice model to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FishAudioTTSSettings(voice=...)`` instead. model: Deprecated. Reference ID of the voice model to use for synthesis. @@ -142,14 +142,14 @@ class FishAudioTTSService(InterruptibleTTSService): model_id: Specify which Fish Audio TTS model to use (e.g. "s1"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FishAudioTTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=FishAudioTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index a12829b0d..44e5bbd9c 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -272,12 +272,12 @@ class GladiaSTTService(WebsocketSTTService): sample_rate: Audio sample rate in Hz. If None, uses service default. model: Model to use for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GladiaSTTSettings(model=...)`` instead. params: Additional configuration parameters for Gladia service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GladiaSTTSettings(...)`` instead. max_buffer_size: Maximum size of audio buffer in bytes. Defaults to 20MB. diff --git a/src/pipecat/services/google/image.py b/src/pipecat/services/google/image.py index 09ec61554..d15d5d0ed 100644 --- a/src/pipecat/services/google/image.py +++ b/src/pipecat/services/google/image.py @@ -82,7 +82,7 @@ class GoogleImageGenService(ImageGenService): api_key: Google AI API key for authentication. params: Configuration parameters for image generation. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleImageGenSettings(model=...)`` instead. http_options: HTTP options for the client. diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index 4705e8f68..b33eefd9a 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -66,7 +66,7 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): base_url: Base URL for Google's OpenAI-compatible API. model: Google model name to use (e.g., "gemini-2.0-flash"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/google/stt.py b/src/pipecat/services/google/stt.py index 5415a5403..376e74a6d 100644 --- a/src/pipecat/services/google/stt.py +++ b/src/pipecat/services/google/stt.py @@ -425,7 +425,7 @@ class GoogleSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for Google Speech-to-Text. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleSTTSettings(...)`` instead. Parameters: @@ -500,7 +500,7 @@ class GoogleSTTService(STTService): sample_rate: Audio sample rate in Hertz. params: Configuration parameters for the service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index 6b17caed5..22ba47821 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -566,7 +566,7 @@ class GoogleHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Google HTTP TTS voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``GoogleHttpTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -609,13 +609,13 @@ class GoogleHttpTTSService(TTSService): location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Google TTS voice identifier (e.g., "en-US-Standard-A"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleHttpTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses default. params: Voice customization parameters including pitch, rate, volume, etc. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleHttpTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -1029,7 +1029,7 @@ class GoogleTTSService(GoogleBaseTTSService): class InputParams(BaseModel): """Input parameters for Google streaming TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``GoogleStreamTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -1061,14 +1061,14 @@ class GoogleTTSService(GoogleBaseTTSService): location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Google TTS voice identifier (e.g., "en-US-Chirp3-HD-Charon"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleStreamTTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GoogleStreamTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -1242,7 +1242,7 @@ class GeminiTTSService(GoogleBaseTTSService): class InputParams(BaseModel): """Input parameters for Gemini TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``GeminiTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -1283,7 +1283,7 @@ class GeminiTTSService(GoogleBaseTTSService): model: Gemini TTS model to use. Must be a TTS model like "gemini-2.5-flash-tts" or "gemini-2.5-pro-tts". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GeminiTTSSettings(model=...)`` instead. credentials: JSON string containing Google Cloud service account credentials. @@ -1291,13 +1291,13 @@ class GeminiTTSService(GoogleBaseTTSService): location: Google Cloud location for regional endpoint (e.g., "us-central1"). voice_id: Voice name from the available Gemini voices. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GeminiTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate in Hz. If None, uses Google's default 24kHz. params: TTS configuration parameters. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GeminiTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index 51ac8a7cd..fff58d87a 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -91,7 +91,7 @@ class GradiumSTTService(WebsocketSTTService): class InputParams(BaseModel): """Configuration parameters for Gradium STT API. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GradiumSTTSettings(...)`` instead. Parameters: @@ -125,7 +125,7 @@ class GradiumSTTService(WebsocketSTTService): api_endpoint_base_url: WebSocket endpoint URL. Defaults to Gradium's streaming endpoint. params: Configuration parameters for language and delay settings. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GradiumSTTSettings(...)`` instead. json_config: Optional JSON configuration string for additional model settings. diff --git a/src/pipecat/services/gradium/tts.py b/src/pipecat/services/gradium/tts.py index b3b9b50ca..3befb4505 100644 --- a/src/pipecat/services/gradium/tts.py +++ b/src/pipecat/services/gradium/tts.py @@ -57,7 +57,7 @@ class GradiumTTSService(AudioContextTTSService): class InputParams(BaseModel): """Configuration parameters for Gradium TTS service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``GradiumTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -84,19 +84,19 @@ class GradiumTTSService(AudioContextTTSService): api_key: Gradium API key for authentication. voice_id: the voice identifier. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GradiumTTSSettings(voice=...)`` instead. url: Gradium websocket API endpoint. model: Model ID to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GradiumTTSSettings(model=...)`` instead. json_config: Optional JSON configuration string for additional model settings. params: Additional configuration parameters. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GradiumTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index f552f059a..98c925ac5 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -95,7 +95,7 @@ class GrokLLMService(OpenAILLMService): base_url: The base URL for Grok API. Defaults to "https://api.x.ai/v1". model: The model identifier to use. Defaults to "grok-3-beta". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index f88d5a877..c69776ad0 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -38,7 +38,7 @@ class GroqLLMService(OpenAILLMService): base_url: The base URL for Groq API. Defaults to "https://api.groq.com/openai/v1". model: The model identifier to use. Defaults to "llama-3.3-70b-versatile". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/groq/stt.py b/src/pipecat/services/groq/stt.py index ac6a4325c..b875f63d4 100644 --- a/src/pipecat/services/groq/stt.py +++ b/src/pipecat/services/groq/stt.py @@ -43,24 +43,24 @@ class GroqSTTService(BaseWhisperSTTService): Args: model: Whisper model to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/groq/tts.py b/src/pipecat/services/groq/tts.py index b1c546713..6f9a610e2 100644 --- a/src/pipecat/services/groq/tts.py +++ b/src/pipecat/services/groq/tts.py @@ -64,7 +64,7 @@ class GroqTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Groq TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GroqTTSSettings(...)`` instead. Parameters: @@ -96,17 +96,17 @@ class GroqTTSService(TTSService): output_format: Audio output format. Defaults to "wav". params: Additional input parameters for voice customization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GroqTTSSettings(...)`` instead. model_name: TTS model to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GroqTTSSettings(model=...)`` instead. voice_id: Voice identifier to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=GroqTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate. Must be 48000 Hz for Groq TTS. diff --git a/src/pipecat/services/hume/tts.py b/src/pipecat/services/hume/tts.py index 7b0ecd0c8..052d1cd0a 100644 --- a/src/pipecat/services/hume/tts.py +++ b/src/pipecat/services/hume/tts.py @@ -84,7 +84,7 @@ class HumeTTSService(TTSService): class InputParams(BaseModel): """Optional synthesis parameters for Hume TTS. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=HumeTTSSettings(...)`` instead. Parameters: @@ -113,12 +113,12 @@ class HumeTTSService(TTSService): api_key: Hume API key. If omitted, reads the ``HUME_API_KEY`` environment variable. voice_id: ID of the voice to use. Only voice IDs are supported; voice names are not. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=HumeTTSSettings(voice=...)`` instead. params: Optional synthesis controls (acting instructions, speed, trailing silence). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=HumeTTSSettings(...)`` instead. sample_rate: Output sample rate for emitted PCM frames. Defaults to 48_000 (Hume). diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index 688ba542a..f650ce620 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -125,7 +125,7 @@ class InworldHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Inworld TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -159,12 +159,12 @@ class InworldHttpTTSService(TTSService): aiohttp_session: aiohttp ClientSession for HTTP requests. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=InworldTTSSettings(voice=...)`` instead. model: ID of the model to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=InworldTTSSettings(model=...)`` instead. streaming: Whether to use streaming mode. @@ -172,7 +172,7 @@ class InworldHttpTTSService(TTSService): encoding: Audio encoding format. params: Input parameters for Inworld TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=InworldTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -532,7 +532,7 @@ class InworldTTSService(AudioContextTTSService): class InputParams(BaseModel): """Input parameters for Inworld WebSocket TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``InworldTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -579,12 +579,12 @@ class InworldTTSService(AudioContextTTSService): api_key: Inworld API key. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=InworldTTSSettings(voice=...)`` instead. model: ID of the model to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=InworldTTSSettings(model=...)`` instead. url: URL of the Inworld WebSocket API. @@ -592,7 +592,7 @@ class InworldTTSService(AudioContextTTSService): encoding: Audio encoding format. params: Input parameters for Inworld WebSocket TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=InworldTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/kokoro/tts.py b/src/pipecat/services/kokoro/tts.py index 7e53060da..60dfb65ce 100644 --- a/src/pipecat/services/kokoro/tts.py +++ b/src/pipecat/services/kokoro/tts.py @@ -112,7 +112,7 @@ class KokoroTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Kokoro TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``KokoroTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -136,14 +136,14 @@ class KokoroTTSService(TTSService): Args: voice_id: Voice identifier to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=KokoroTTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=KokoroTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/lmnt/tts.py b/src/pipecat/services/lmnt/tts.py index c69eadfef..58468bc00 100644 --- a/src/pipecat/services/lmnt/tts.py +++ b/src/pipecat/services/lmnt/tts.py @@ -111,14 +111,14 @@ class LmntTTSService(InterruptibleTTSService): api_key: LMNT API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=LmntTTSSettings(voice=...)`` instead. sample_rate: Audio sample rate. If None, uses default. language: Language for synthesis. Defaults to English. model: TTS model to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=LmntTTSSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/minimax/tts.py b/src/pipecat/services/minimax/tts.py index 2d9f49636..2be25aef9 100644 --- a/src/pipecat/services/minimax/tts.py +++ b/src/pipecat/services/minimax/tts.py @@ -166,7 +166,7 @@ class MiniMaxHttpTTSService(TTSService): class InputParams(BaseModel): """Configuration parameters for MiniMax TTS. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``MiniMaxTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -226,19 +226,19 @@ class MiniMaxHttpTTSService(TTSService): "speech-02-hd", "speech-02-turbo", "speech-01-hd", "speech-01-turbo". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=MiniMaxTTSSettings(model=...)`` instead. voice_id: Voice identifier. Defaults to "Calm_Woman". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=MiniMaxTTSSettings(voice=...)`` instead. aiohttp_session: aiohttp.ClientSession for API communication. sample_rate: Output audio sample rate in Hz. If None, uses pipeline default. params: Additional configuration parameters. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=MiniMaxTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index ca72cde37..57ab45d6f 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -41,7 +41,7 @@ class MistralLLMService(OpenAILLMService): base_url: The base URL for Mistral API. Defaults to "https://api.mistral.ai/v1". model: The model identifier to use. Defaults to "mistral-small-latest". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/moondream/vision.py b/src/pipecat/services/moondream/vision.py index 3f0701c80..32b592061 100644 --- a/src/pipecat/services/moondream/vision.py +++ b/src/pipecat/services/moondream/vision.py @@ -93,7 +93,7 @@ class MoondreamService(VisionService): Args: model: Hugging Face model identifier for the Moondream model. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=MoondreamSettings(model=...)`` instead. revision: Specific model revision to use. diff --git a/src/pipecat/services/neuphonic/tts.py b/src/pipecat/services/neuphonic/tts.py index ae85c3ab5..f6cc6bf68 100644 --- a/src/pipecat/services/neuphonic/tts.py +++ b/src/pipecat/services/neuphonic/tts.py @@ -102,7 +102,7 @@ class NeuphonicTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Input parameters for Neuphonic TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NeuphonicTTSSettings(...)`` instead. Parameters: @@ -133,7 +133,7 @@ class NeuphonicTTSService(InterruptibleTTSService): api_key: Neuphonic API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. url: WebSocket URL for the Neuphonic API. @@ -141,7 +141,7 @@ class NeuphonicTTSService(InterruptibleTTSService): encoding: Audio encoding format. Defaults to "pcm_linear". params: Additional input parameters for TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NeuphonicTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -451,7 +451,7 @@ class NeuphonicHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Neuphonic HTTP TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NeuphonicTTSSettings(...)`` instead. Parameters: @@ -481,7 +481,7 @@ class NeuphonicHttpTTSService(TTSService): api_key: Neuphonic API key for authentication. voice_id: ID of the voice to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NeuphonicTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. @@ -490,7 +490,7 @@ class NeuphonicHttpTTSService(TTSService): encoding: Audio encoding format. Defaults to "pcm_linear". params: Additional input parameters for TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NeuphonicTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index f09db54fa..88245464e 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -45,7 +45,7 @@ class NvidiaLLMService(OpenAILLMService): model: The model identifier to use. Defaults to "nvidia/llama-3.1-nemotron-70b-instruct". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index 3ceaf45fa..df785e25c 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -130,7 +130,7 @@ class NvidiaSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva STT service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NvidiaSTTSettings(...)`` instead. Parameters: @@ -164,7 +164,7 @@ class NvidiaSTTService(STTService): sample_rate: Audio sample rate in Hz. If None, uses pipeline default. params: Additional configuration parameters for NVIDIA Riva. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NvidiaSTTSettings(...)`` instead. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. @@ -444,7 +444,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): class InputParams(BaseModel): """Configuration parameters for NVIDIA Riva segmented STT service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. Parameters: @@ -488,7 +488,7 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate params: Additional configuration parameters for NVIDIA Riva - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NvidiaSegmentedSTTSettings(...)`` instead. use_ssl: Whether to use SSL for the NVIDIA Riva server. Defaults to True. diff --git a/src/pipecat/services/nvidia/tts.py b/src/pipecat/services/nvidia/tts.py index be0b90071..6e3298a75 100644 --- a/src/pipecat/services/nvidia/tts.py +++ b/src/pipecat/services/nvidia/tts.py @@ -68,7 +68,7 @@ class NvidiaTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Riva TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``NvidiaTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -102,14 +102,14 @@ class NvidiaTTSService(TTSService): server: gRPC server endpoint. Defaults to NVIDIA's cloud endpoint. voice_id: Voice model identifier. Defaults to multilingual Aria voice. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NvidiaTTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=NvidiaTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index 2a4a3e78f..477a80b5f 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -35,7 +35,7 @@ class OLLamaLLMService(OpenAILLMService): Args: model: The OLLama model to use. Defaults to "llama2". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for the OLLama API endpoint. diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 6c27fbe37..d44fbcf41 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -75,7 +75,7 @@ class BaseOpenAILLMService(LLMService): class InputParams(BaseModel): """Input parameters for OpenAI model configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(...)`` instead of ``params=InputParams(...)``. @@ -130,7 +130,7 @@ class BaseOpenAILLMService(LLMService): Args: model: The OpenAI model name to use (e.g., "gpt-4.1", "gpt-4o"). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. api_key: OpenAI API key. If None, uses environment variable. @@ -140,7 +140,7 @@ class BaseOpenAILLMService(LLMService): default_headers: Additional HTTP headers to include in requests. params: Input parameters for model configuration and behavior. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openai/image.py b/src/pipecat/services/openai/image.py index fd9bd0ba8..4120db8c6 100644 --- a/src/pipecat/services/openai/image.py +++ b/src/pipecat/services/openai/image.py @@ -64,7 +64,7 @@ class OpenAIImageGenService(ImageGenService): image_size: Target size for generated images. model: DALL-E model to use for generation. Defaults to "dall-e-3". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAIImageGenSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index 56515ce89..a81d3dc29 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -85,12 +85,12 @@ class OpenAILLMService(BaseOpenAILLMService): Args: model: The OpenAI model name to use. Defaults to "gpt-4.1". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. params: Input parameters for model configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index ea2814619..7692deee5 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -80,7 +80,7 @@ class OpenAISTTService(BaseWhisperSTTService): Args: model: Model to use — either gpt-4o or Whisper. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(model=...)`` instead. api_key: OpenAI API key. Defaults to None. @@ -222,7 +222,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): model: Transcription model. Supported values are ``"gpt-4o-transcribe"`` and ``"gpt-4o-mini-transcribe"``. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAIRealtimeSTTSettings(model=...)`` instead. base_url: WebSocket base URL for the Realtime API. diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index a119c3d14..feb6453c7 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -90,7 +90,7 @@ class OpenAITTSService(TTSService): class InputParams(BaseModel): """Input parameters for OpenAI TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAITTSSettings(...)`` instead. Parameters: @@ -122,28 +122,28 @@ class OpenAITTSService(TTSService): base_url: Custom base URL for OpenAI API. If None, uses default. voice: Voice ID to use for synthesis. Defaults to "alloy". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAITTSSettings(voice=...)`` instead. model: TTS model to use. Defaults to "gpt-4o-mini-tts". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAITTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAITTSSettings(instructions=...)`` instead. speed: Voice speed control (0.25 to 4.0, default 1.0). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAITTSSettings(speed=...)`` instead. params: Optional synthesis controls (acting instructions, speed, ...). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAITTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index 9724c0a3f..431de832d 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -52,7 +52,7 @@ class OpenPipeLLMService(OpenAILLMService): Args: model: The model name to use. Defaults to "gpt-4.1". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. api_key: OpenAI API key for authentication. If None, reads from environment. diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index 42f01c77d..8c42069d8 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -42,7 +42,7 @@ class OpenRouterLLMService(OpenAILLMService): to read from environment variables. model: The model identifier to use. Defaults to "openai/gpt-4o-2024-11-20". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for OpenRouter API. Defaults to "https://openrouter.ai/api/v1". diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index 2d350b736..8195dd50e 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -46,7 +46,7 @@ class PerplexityLLMService(OpenAILLMService): base_url: The base URL for Perplexity's API. Defaults to "https://api.perplexity.ai". model: The model identifier to use. Defaults to "sonar". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/piper/tts.py b/src/pipecat/services/piper/tts.py index fd6b0bf16..46bf98cd1 100644 --- a/src/pipecat/services/piper/tts.py +++ b/src/pipecat/services/piper/tts.py @@ -65,7 +65,7 @@ class PiperTTSService(TTSService): Args: voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=PiperTTSSettings(voice=...)`` instead. download_dir: Directory for storing voice model files. Defaults to @@ -222,7 +222,7 @@ class PiperHttpTTSService(TTSService): aiohttp_session: aiohttp ClientSession for making HTTP requests. voice_id: Piper voice model identifier (e.g. `en_US-ryan-high`). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=PiperHttpTTSSettings(voice=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index 92d24fa76..b983e00cd 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -38,7 +38,7 @@ class QwenLLMService(OpenAILLMService): base_url: Base URL for Qwen API. Defaults to "https://dashscope-intl.aliyuncs.com/compatible-mode/v1". model: The model identifier to use. Defaults to "qwen-plus". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/resembleai/tts.py b/src/pipecat/services/resembleai/tts.py index 28ec8a522..f0a8a988a 100644 --- a/src/pipecat/services/resembleai/tts.py +++ b/src/pipecat/services/resembleai/tts.py @@ -84,7 +84,7 @@ class ResembleAITTSService(AudioContextTTSService): api_key: Resemble AI API key for authentication. voice_id: Voice UUID to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=ResembleAITTSSettings(voice=...)`` instead. url: WebSocket URL for Resemble AI TTS API. diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index 1de4087de..613d58f3a 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -144,7 +144,7 @@ class RimeTTSService(AudioContextTTSService): class InputParams(BaseModel): """Configuration parameters for Rime TTS service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(...)`` instead. Parameters: @@ -196,19 +196,19 @@ class RimeTTSService(AudioContextTTSService): api_key: Rime API key for authentication. voice_id: ID of the voice to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(voice=...)`` instead. url: Rime websocket API endpoint. model: Model ID to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(model=...)`` instead. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -676,7 +676,7 @@ class RimeHttpTTSService(TTSService): class InputParams(BaseModel): """Configuration parameters for Rime HTTP TTS service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(...)`` instead. Parameters: @@ -713,19 +713,19 @@ class RimeHttpTTSService(TTSService): api_key: Rime API key for authentication. voice_id: ID of the voice to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. model: Model ID to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(model=...)`` instead. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -902,7 +902,7 @@ class RimeNonJsonTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Configuration parameters for Rime Non-JSON WebSocket TTS service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeNonJsonTTSSettings(...)`` instead. Args: @@ -942,20 +942,20 @@ class RimeNonJsonTTSService(InterruptibleTTSService): api_key: Rime API key for authentication. voice_id: ID of the voice to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeNonJsonTTSSettings(voice=...)`` instead. url: Rime websocket API endpoint. model: Model ID to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeNonJsonTTSSettings(model=...)`` instead. audio_format: Audio format to use. sample_rate: Audio sample rate in Hz. params: Additional configuration parameters. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=RimeNonJsonTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index f9b7b1380..2468dad13 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -49,7 +49,7 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore api_key: The API key for accessing SambaNova API. model: The model identifier to use. Defaults to "Llama-4-Maverick-17B-128E-Instruct". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. base_url: The base URL for SambaNova API. Defaults to "https://api.sambanova.ai/v1". diff --git a/src/pipecat/services/sambanova/stt.py b/src/pipecat/services/sambanova/stt.py index 0c2d77e36..60f638897 100644 --- a/src/pipecat/services/sambanova/stt.py +++ b/src/pipecat/services/sambanova/stt.py @@ -45,24 +45,24 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore Args: model: Whisper model to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/sarvam/stt.py b/src/pipecat/services/sarvam/stt.py index fd9a55f14..f255619bb 100644 --- a/src/pipecat/services/sarvam/stt.py +++ b/src/pipecat/services/sarvam/stt.py @@ -177,7 +177,7 @@ class SarvamSTTService(STTService): class InputParams(BaseModel): """Configuration parameters for Sarvam STT service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamSTTSettings(...)`` instead. Parameters: @@ -219,14 +219,14 @@ class SarvamSTTService(STTService): api_key: Sarvam API key for authentication. model: Sarvam model to use for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamSTTSettings(model=...)`` instead. sample_rate: Audio sample rate. Defaults to 16000 if not specified. input_audio_codec: Audio codec/format of the input file. Defaults to "wav". params: Configuration parameters for Sarvam STT service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamSTTSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 8c76e0ec9..cf00dd8c7 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -376,7 +376,7 @@ class SarvamHttpTTSService(TTSService): class InputParams(BaseModel): """Input parameters for Sarvam TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``SarvamHttpTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -445,14 +445,14 @@ class SarvamHttpTTSService(TTSService): aiohttp_session: Shared aiohttp session for making requests. voice_id: Speaker voice ID. If None, uses model-appropriate default. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamHttpTTSSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamHttpTTSSettings(model=...)`` instead. base_url: Sarvam AI API base URL. Defaults to "https://api.sarvam.ai". @@ -460,7 +460,7 @@ class SarvamHttpTTSService(TTSService): If None, uses model-specific default. params: Additional voice and preprocessing parameters. If None, uses defaults. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamHttpTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -742,7 +742,7 @@ class SarvamTTSService(InterruptibleTTSService): class InputParams(BaseModel): """Configuration parameters for Sarvam TTS WebSocket service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``SarvamTTSSettings`` directly via the ``settings`` parameter instead. Parameters: @@ -848,12 +848,12 @@ class SarvamTTSService(InterruptibleTTSService): - "bulbul:v2" (default): Standard model with pitch/loudness support - "bulbul:v3-beta": Advanced model with temperature control - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamTTSSettings(model=...)`` instead. voice_id: Speaker voice ID. If None, uses model-appropriate default. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamTTSSettings(voice=...)`` instead. url: WebSocket URL for the TTS backend (default production URL). @@ -867,7 +867,7 @@ class SarvamTTSService(InterruptibleTTSService): If None, uses model-specific default. params: Optional input parameters to override defaults. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SarvamTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index b37a76b0f..beadabf1b 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -79,7 +79,7 @@ class SonioxContextObject(BaseModel): class SonioxInputParams(BaseModel): """Real-time transcription settings. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SonioxSTTSettings(...)`` instead. See Soniox WebSocket API documentation for more details: @@ -201,13 +201,13 @@ class SonioxSTTService(WebsocketSTTService): sample_rate: Audio sample rate. model: Soniox model to use for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SonioxSTTSettings(model=...)`` instead. params: Additional configuration parameters, such as language hints, context and speaker diarization. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SonioxSTTSettings(...)`` instead. vad_force_turn_endpoint: Listen to `VADUserStoppedSpeakingFrame` to send finalize message to Soniox. diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index 620646d31..a0a5c8b64 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -395,7 +395,7 @@ class SpeechmaticsSTTService(STTService): sample_rate: Optional audio sample rate in Hz. params: Input parameters for the service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SpeechmaticsSTTSettings(...)`` instead. should_interrupt: Determine whether the bot should be interrupted when Speechmatics turn_detection_mode is configured to detect user speech. diff --git a/src/pipecat/services/speechmatics/tts.py b/src/pipecat/services/speechmatics/tts.py index dff3e5f0f..55ded437e 100644 --- a/src/pipecat/services/speechmatics/tts.py +++ b/src/pipecat/services/speechmatics/tts.py @@ -62,7 +62,7 @@ class SpeechmaticsTTSService(TTSService): class InputParams(BaseModel): """Optional input parameters for Speechmatics TTS configuration. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SpeechmaticsTTSSettings(...)`` instead. Parameters: @@ -90,14 +90,14 @@ class SpeechmaticsTTSService(TTSService): base_url: Base URL for Speechmatics TTS API. voice_id: Voice model to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SpeechmaticsTTSSettings(voice=...)`` instead. aiohttp_session: Shared aiohttp session for HTTP requests. sample_rate: Audio sample rate in Hz. params: Input parameters for the service. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=SpeechmaticsTTSSettings(...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index 0fd8b637b..9ec8e9fc2 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -38,7 +38,7 @@ class TogetherLLMService(OpenAILLMService): base_url: The base URL for Together.ai API. Defaults to "https://api.together.xyz/v1". model: The model identifier to use. Defaults to "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo". - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index b6c19ab5a..c2dde8acc 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -146,24 +146,24 @@ class BaseWhisperSTTService(SegmentedSTTService): Args: model: Name of the Whisper model to use. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(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:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(language=...)`` instead. prompt: Optional text to guide the model's style or continue a previous segment. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(prompt=...)`` instead. temperature: Sampling temperature between 0 and 1. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. include_prob_metrics: If True, enables probability metrics in API response. diff --git a/src/pipecat/services/whisper/stt.py b/src/pipecat/services/whisper/stt.py index 17fe24c2d..f3ac0c948 100644 --- a/src/pipecat/services/whisper/stt.py +++ b/src/pipecat/services/whisper/stt.py @@ -229,27 +229,27 @@ class WhisperSTTService(SegmentedSTTService): Args: model: The Whisper model to use for transcription. Can be a Model enum or string. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperSTTSettings(model=...)`` instead. device: The device to run inference on ('cpu', 'cuda', or 'auto'). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperSTTSettings(device=...)`` instead. compute_type: The compute type for inference ('default', 'int8', 'int8_float16', etc.). - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperSTTSettings(compute_type=...)`` instead. no_speech_prob: Probability threshold for filtering out non-speech segments. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperSTTSettings(no_speech_prob=...)`` instead. language: The default language for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperSTTSettings(language=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated @@ -413,22 +413,22 @@ class WhisperSTTServiceMLX(WhisperSTTService): Args: model: The MLX Whisper model to use for transcription. Can be an MLXModel enum or string. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperMLXSTTSettings(model=...)`` instead. no_speech_prob: Probability threshold for filtering out non-speech segments. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperMLXSTTSettings(no_speech_prob=...)`` instead. language: The default language for transcription. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperMLXSTTSettings(language=...)`` instead. temperature: Temperature for sampling. Can be a float or tuple of floats. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=WhisperMLXSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated diff --git a/src/pipecat/services/xtts/tts.py b/src/pipecat/services/xtts/tts.py index c5bfe629e..adf11da6a 100644 --- a/src/pipecat/services/xtts/tts.py +++ b/src/pipecat/services/xtts/tts.py @@ -107,7 +107,7 @@ class XTTSService(TTSService): Args: voice_id: ID of the voice/speaker to use for synthesis. - .. deprecated:: 1.0.0 + .. deprecated:: 0.0.105 Use ``settings=XTTSTTSSettings(voice=...)`` instead. base_url: Base URL of the XTTS streaming server. From 3cb792a80167beabf54c32cf008c705846149ef3 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Tue, 3 Mar 2026 23:02:55 -0500 Subject: [PATCH 06/17] Update TTS service settings --- src/pipecat/services/asyncai/tts.py | 61 +++++++------------ src/pipecat/services/azure/tts.py | 8 +-- .../services/deepgram/sagemaker/tts.py | 16 ++--- src/pipecat/services/deepgram/tts.py | 24 +++----- src/pipecat/services/elevenlabs/tts.py | 51 ++++++---------- src/pipecat/services/fish/tts.py | 18 +++--- src/pipecat/services/google/tts.py | 6 -- src/pipecat/services/gradium/tts.py | 13 ++-- src/pipecat/services/groq/tts.py | 10 +-- src/pipecat/services/inworld/tts.py | 31 +++++----- src/pipecat/services/kokoro/tts.py | 32 +++++----- src/pipecat/services/lmnt/tts.py | 17 ++---- src/pipecat/services/minimax/tts.py | 39 ++++-------- src/pipecat/services/neuphonic/tts.py | 17 ++---- src/pipecat/services/resembleai/tts.py | 45 +++++--------- src/pipecat/services/rime/tts.py | 38 ++++++------ src/pipecat/services/sarvam/tts.py | 40 +++++------- src/pipecat/services/xtts/tts.py | 21 +++---- 18 files changed, 184 insertions(+), 303 deletions(-) diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index d4e2eabdc..3b1296752 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -9,8 +9,8 @@ import asyncio import base64 import json -from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, Mapping, Optional, Self +from dataclasses import dataclass +from typing import Any, AsyncGenerator, Optional import aiohttp from loguru import logger @@ -27,7 +27,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService, TextAggregationMode, TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -75,28 +75,9 @@ def language_to_async_language(language: Language) -> Optional[str]: @dataclass class AsyncAITTSSettings(TTSSettings): - """Settings for Async AI TTS services. + """Settings for Async AI TTS services.""" - Parameters: - output_container: Audio container format (e.g. "raw"). - output_encoding: Audio encoding format (e.g. "pcm_s16le"). - output_sample_rate: Audio sample rate in Hz. - """ - - output_container: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - - @classmethod - def from_mapping(cls, settings: Mapping[str, Any]) -> Self: - """Construct settings from a plain dict, destructuring legacy nested ``output_format``.""" - flat = dict(settings) - nested = flat.pop("output_format", None) - if isinstance(nested, dict): - flat.setdefault("output_container", nested.get("container")) - flat.setdefault("output_encoding", nested.get("encoding")) - flat.setdefault("output_sample_rate", nested.get("sample_rate")) - return super().from_mapping(flat) + pass class AsyncAITTSService(AudioContextTTSService): @@ -176,9 +157,6 @@ class AsyncAITTSService(AudioContextTTSService): model="async_flash_v1.0", voice=None, language=None, - output_container=container, - output_encoding=encoding, - output_sample_rate=0, ) # 2. Apply direct init arg overrides (deprecated) @@ -215,6 +193,11 @@ class AsyncAITTSService(AudioContextTTSService): self._api_version = version self._url = url + # Init-only audio format config (not runtime-updatable). + self._output_container = container + self._output_encoding = encoding + self._output_sample_rate = 0 # Set in start() + self._receive_task = None self._keepalive_task = None @@ -262,7 +245,7 @@ class AsyncAITTSService(AudioContextTTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.output_sample_rate = self.sample_rate + self._output_sample_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): @@ -319,9 +302,9 @@ class AsyncAITTSService(AudioContextTTSService): "model_id": self._settings.model, "voice": {"mode": "id", "id": self._settings.voice}, "output_format": { - "container": self._settings.output_container, - "encoding": self._settings.output_encoding, - "sample_rate": self._settings.output_sample_rate, + "container": self._output_container, + "encoding": self._output_encoding, + "sample_rate": self._output_sample_rate, }, "language": self._settings.language, } @@ -567,9 +550,6 @@ class AsyncAIHttpTTSService(TTSService): model="async_flash_v1.0", voice=None, language=None, - output_container=container, - output_encoding=encoding, - output_sample_rate=0, ) # 2. Apply direct init arg overrides (deprecated) @@ -602,6 +582,11 @@ class AsyncAIHttpTTSService(TTSService): self._base_url = url self._api_version = version + # Init-only audio format config (not runtime-updatable). + self._output_container = container + self._output_encoding = encoding + self._output_sample_rate = 0 # Set in start() + self._session = aiohttp_session def can_generate_metrics(self) -> bool: @@ -630,7 +615,7 @@ class AsyncAIHttpTTSService(TTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.output_sample_rate = self.sample_rate + self._output_sample_rate = self.sample_rate @traced_tts async def run_tts(self, text: str, context_id: str) -> AsyncGenerator[Frame, None]: @@ -653,9 +638,9 @@ class AsyncAIHttpTTSService(TTSService): "transcript": text, "voice": voice_config, "output_format": { - "container": self._settings.output_container, - "encoding": self._settings.output_encoding, - "sample_rate": self._settings.output_sample_rate, + "container": self._output_container, + "encoding": self._output_encoding, + "sample_rate": self._output_sample_rate, }, "language": self._settings.language, } diff --git a/src/pipecat/services/azure/tts.py b/src/pipecat/services/azure/tts.py index f4aa85dbc..112459c5a 100644 --- a/src/pipecat/services/azure/tts.py +++ b/src/pipecat/services/azure/tts.py @@ -73,7 +73,6 @@ class AzureTTSSettings(TTSSettings): Parameters: emphasis: Emphasis level for speech ("strong", "moderate", "reduced"). - language: Language for synthesis. Defaults to English (US). pitch: Voice pitch adjustment (e.g., "+10%", "-5Hz", "high"). rate: Speech rate adjustment (e.g., "1.0", "1.25", "slow", "fast"). role: Voice role for expression (e.g., "YoungAdultFemale"). @@ -83,7 +82,6 @@ class AzureTTSSettings(TTSSettings): """ emphasis: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - language: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) pitch: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) rate: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) role: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -143,7 +141,6 @@ class AzureBaseTTSService: *, api_key: str, region: str, - voice: str = "en-US-SaraNeural", ): """Initialize Azure-specific configuration. @@ -152,7 +149,6 @@ class AzureBaseTTSService: Args: api_key: Azure Cognitive Services subscription key. region: Azure region identifier (e.g., "eastus", "westus2"). - voice: Voice name to use for synthesis. Defaults to "en-US-SaraNeural". """ self._api_key = api_key self._region = region @@ -343,7 +339,7 @@ class AzureTTSService(TTSService, AzureBaseTTSService): ) # Initialize Azure-specific functionality from mixin - self._init_azure_base(api_key=api_key, region=region, voice=default_settings.voice) + self._init_azure_base(api_key=api_key, region=region) self._speech_config = None self._speech_synthesizer = None @@ -842,7 +838,7 @@ class AzureHttpTTSService(TTSService, AzureBaseTTSService): ) # Initialize Azure-specific functionality from mixin - self._init_azure_base(api_key=api_key, region=region, voice=default_settings.voice) + self._init_azure_base(api_key=api_key, region=region) self._speech_config = None self._speech_synthesizer = None diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index 9457cc1db..0129abedb 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -14,7 +14,7 @@ streaming audio output. import asyncio import json -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -33,20 +33,16 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.aws.sagemaker.bidi_client import SageMakerBidiClient -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.utils.tracing.service_decorators import traced_tts @dataclass class DeepgramSageMakerTTSSettings(TTSSettings): - """Settings for Deepgram SageMaker TTS service. + """Settings for Deepgram SageMaker TTS service.""" - Parameters: - encoding: Audio encoding format (e.g. "linear16"). - """ - - encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class DeepgramSageMakerTTSService(TTSService): @@ -107,10 +103,9 @@ class DeepgramSageMakerTTSService(TTSService): voice = voice or "aura-2-helena-en" default_settings = DeepgramSageMakerTTSSettings( - model=voice, + model=None, voice=voice, language=None, - encoding=encoding, ) if settings is not None: default_settings.apply_update(settings) @@ -126,6 +121,7 @@ class DeepgramSageMakerTTSService(TTSService): self._endpoint_name = endpoint_name self._region = region + self._encoding = encoding self._client: Optional[SageMakerBidiClient] = None self._response_task: Optional[asyncio.Task] = None diff --git a/src/pipecat/services/deepgram/tts.py b/src/pipecat/services/deepgram/tts.py index b54cd23dc..95db998e2 100644 --- a/src/pipecat/services/deepgram/tts.py +++ b/src/pipecat/services/deepgram/tts.py @@ -11,7 +11,7 @@ for generating speech from text using various voice models. """ import json -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional import aiohttp @@ -30,7 +30,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import TTSService, WebsocketTTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -47,13 +47,9 @@ except ModuleNotFoundError as e: @dataclass class DeepgramTTSSettings(TTSSettings): - """Settings for Deepgram TTS service. + """Settings for Deepgram TTS service.""" - Parameters: - encoding: Audio encoding format (linear16, mulaw, alaw). - """ - - encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class DeepgramTTSService(WebsocketTTSService): @@ -105,10 +101,9 @@ class DeepgramTTSService(WebsocketTTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramTTSSettings( - model="aura-2-helena-en", + model=None, voice="aura-2-helena-en", language=None, - encoding=encoding, ) # 2. Apply direct init arg overrides (deprecated) @@ -132,6 +127,7 @@ class DeepgramTTSService(WebsocketTTSService): self._api_key = api_key self._base_url = base_url + self._encoding = encoding self._receive_task = None self._context_id: Optional[str] = None @@ -236,7 +232,7 @@ class DeepgramTTSService(WebsocketTTSService): # Build WebSocket URL with query parameters params = [] params.append(f"model={self._settings.voice}") - params.append(f"encoding={self._settings.encoding}") + params.append(f"encoding={self._encoding}") params.append(f"sample_rate={self.sample_rate}") url = f"{self._base_url}/v1/speak?{'&'.join(params)}" @@ -422,10 +418,9 @@ class DeepgramHttpTTSService(TTSService): """ # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramTTSSettings( - model="aura-2-helena-en", + model=None, voice="aura-2-helena-en", language=None, - encoding=encoding, ) # 2. Apply direct init arg overrides (deprecated) @@ -447,6 +442,7 @@ class DeepgramHttpTTSService(TTSService): self._api_key = api_key self._session = aiohttp_session self._base_url = base_url + self._encoding = encoding def can_generate_metrics(self) -> bool: """Check if the service can generate metrics. @@ -476,7 +472,7 @@ class DeepgramHttpTTSService(TTSService): params = { "model": self._settings.voice, - "encoding": self._settings.encoding, + "encoding": self._encoding, "sample_rate": self.sample_rate, "container": "none", } diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 2447427ab..c22455e7a 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -201,9 +201,6 @@ class ElevenLabsTTSSettings(TTSSettings): style: Style control for voice expression (0.0 to 1.0). use_speaker_boost: Whether to use speaker boost enhancement. speed: Voice speed control (0.7 to 1.2). - auto_mode: Whether to enable automatic mode optimization. - enable_ssml_parsing: Whether to parse SSML tags in text. - enable_logging: Whether to enable ElevenLabs logging. apply_text_normalization: Text normalization mode ("auto", "on", "off"). """ @@ -212,9 +209,6 @@ class ElevenLabsTTSSettings(TTSSettings): style: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) use_speaker_boost: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speed: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - auto_mode: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - enable_ssml_parsing: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - enable_logging: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) apply_text_normalization: Literal["auto", "on", "off"] | None | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) @@ -228,8 +222,6 @@ class ElevenLabsTTSSettings(TTSSettings): {"stability", "similarity_boost", "style", "use_speaker_boost", "speed"} ) - _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice"} - @dataclass class ElevenLabsHttpTTSSettings(TTSSettings): @@ -255,8 +247,6 @@ class ElevenLabsHttpTTSSettings(TTSSettings): default_factory=lambda: NOT_GIVEN ) - _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice"} - def calculate_word_times( alignment_info: Mapping[str, Any], @@ -430,6 +420,11 @@ class ElevenLabsTTSService(AudioContextTTSService): model="eleven_turbo_v2_5", ) + # Track init-only URL params through the override chain + _auto_mode = True + _enable_ssml_parsing = None + _enable_logging = None + # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: _warn_deprecated_param("voice_id", ElevenLabsTTSSettings, "voice") @@ -456,11 +451,11 @@ class ElevenLabsTTSService(AudioContextTTSService): if params.speed is not None: default_settings.speed = params.speed if params.auto_mode is not None: - default_settings.auto_mode = str(params.auto_mode).lower() + _auto_mode = str(params.auto_mode).lower() if params.enable_ssml_parsing is not None: - default_settings.enable_ssml_parsing = params.enable_ssml_parsing + _enable_ssml_parsing = params.enable_ssml_parsing if params.enable_logging is not None: - default_settings.enable_logging = params.enable_logging + _enable_logging = params.enable_logging if params.apply_text_normalization is not None: default_settings.apply_text_normalization = params.apply_text_normalization if _pronunciation_dictionary_locators is None: @@ -485,6 +480,11 @@ class ElevenLabsTTSService(AudioContextTTSService): self._api_key = api_key self._url = url + # Init-only WebSocket URL params (not runtime-updatable). + self._auto_mode = _auto_mode + self._enable_ssml_parsing = _enable_ssml_parsing + self._enable_logging = _enable_logging + self._output_format = "" # initialized in start() self._voice_settings = self._set_voice_settings() self._pronunciation_dictionary_locators = _pronunciation_dictionary_locators @@ -518,20 +518,7 @@ class ElevenLabsTTSService(AudioContextTTSService): return language_to_elevenlabs_language(language) def _set_voice_settings(self): - ts = self._settings - voice_setting_keys = [ - "stability", - "similarity_boost", - "style", - "use_speaker_boost", - "speed", - ] - voice_settings = {} - for key in voice_setting_keys: - val = getattr(ts, key, None) - if val is not None: - voice_settings[key] = val - return voice_settings or None + return build_elevenlabs_voice_settings(self._settings) async def _update_settings(self, delta: TTSSettings) -> dict[str, Any]: """Apply a settings delta, reconnecting as needed. @@ -670,13 +657,13 @@ class ElevenLabsTTSService(AudioContextTTSService): voice_id = self._settings.voice model = self._settings.model output_format = self._output_format - url = f"{self._url}/v1/text-to-speech/{voice_id}/multi-stream-input?model_id={model}&output_format={output_format}&auto_mode={self._settings.auto_mode}" + url = f"{self._url}/v1/text-to-speech/{voice_id}/multi-stream-input?model_id={model}&output_format={output_format}&auto_mode={self._auto_mode}" - if self._settings.enable_ssml_parsing: - url += f"&enable_ssml_parsing={self._settings.enable_ssml_parsing}" + if self._enable_ssml_parsing: + url += f"&enable_ssml_parsing={self._enable_ssml_parsing}" - if self._settings.enable_logging: - url += f"&enable_logging={self._settings.enable_logging}" + if self._enable_logging: + url += f"&enable_logging={self._enable_logging}" if self._settings.apply_text_normalization is not None: url += f"&apply_text_normalization={self._settings.apply_text_normalization}" diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index af02b4e99..78b021c51 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -52,25 +52,19 @@ class FishAudioTTSSettings(TTSSettings): """Settings for Fish Audio TTS service. Parameters: - fish_sample_rate: Audio sample rate sent to the API. latency: Latency mode ("normal" or "balanced"). Defaults to "normal". - format: Audio output format. normalize: Whether to normalize audio output. Defaults to True. prosody_speed: Speech speed multiplier (0.5-2.0). Defaults to 1.0. prosody_volume: Volume adjustment in dB. Defaults to 0. reference_id: Reference ID of the voice model. """ - fish_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) latency: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) normalize: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) prosody_speed: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) prosody_volume: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) reference_id: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice", "sample_rate": "fish_sample_rate"} - @classmethod def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested ``prosody``.""" @@ -179,9 +173,7 @@ class FishAudioTTSService(InterruptibleTTSService): default_settings = FishAudioTTSSettings( model="s1", voice=None, - fish_sample_rate=0, latency="normal", - format=output_format, normalize=True, prosody_speed=1.0, prosody_volume=0, @@ -228,6 +220,10 @@ class FishAudioTTSService(InterruptibleTTSService): self._receive_task = None self._request_id = None + # Init-only audio format config (not runtime-updatable). + self._fish_sample_rate = 0 # Set in start() + self._output_format = output_format + def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -262,7 +258,7 @@ class FishAudioTTSService(InterruptibleTTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.fish_sample_rate = self.sample_rate + self._fish_sample_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): @@ -312,9 +308,9 @@ class FishAudioTTSService(InterruptibleTTSService): # Send initial start message with ormsgpack request_settings = { - "sample_rate": self._settings.fish_sample_rate, + "sample_rate": self._fish_sample_rate, "latency": self._settings.latency, - "format": self._settings.format, + "format": self._output_format, "normalize": self._settings.normalize, "prosody": { "speed": self._settings.prosody_speed, diff --git a/src/pipecat/services/google/tts.py b/src/pipecat/services/google/tts.py index 22ba47821..7cf2ee996 100644 --- a/src/pipecat/services/google/tts.py +++ b/src/pipecat/services/google/tts.py @@ -494,7 +494,6 @@ class GoogleHttpTTSSettings(TTSSettings): Range [0.25, 2.0]. volume: Volume adjustment (e.g., "loud", "soft", "+6dB"). emphasis: Emphasis level for the text. - language: Language for synthesis. Defaults to English. gender: Voice gender preference. google_style: Google-specific voice style. """ @@ -506,7 +505,6 @@ class GoogleHttpTTSSettings(TTSSettings): emphasis: Literal["strong", "moderate", "reduced", "none"] | None | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) - language: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) gender: Literal["male", "female", "neutral"] | None | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) @@ -520,11 +518,9 @@ class GoogleStreamTTSSettings(TTSSettings): """Settings for Google streaming TTS service. Parameters: - language: Language for synthesis. Defaults to English. speaking_rate: The speaking rate, in the range [0.25, 2.0]. """ - language: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speaking_rate: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -533,13 +529,11 @@ class GeminiTTSSettings(TTSSettings): """Settings for Gemini TTS service. Parameters: - language: Language for synthesis. Defaults to English. prompt: Optional style instructions for how to synthesize the content. multi_speaker: Whether to enable multi-speaker support. speaker_configs: List of speaker configurations for multi-speaker mode. """ - language: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) multi_speaker: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speaker_configs: list[dict[str, Any]] | None | _NotGiven = field( diff --git a/src/pipecat/services/gradium/tts.py b/src/pipecat/services/gradium/tts.py index 3befb4505..2ade14367 100644 --- a/src/pipecat/services/gradium/tts.py +++ b/src/pipecat/services/gradium/tts.py @@ -6,7 +6,7 @@ import base64 import json -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -22,7 +22,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -40,13 +40,9 @@ SAMPLE_RATE = 48000 @dataclass class GradiumTTSSettings(TTSSettings): - """Settings for the Gradium TTS service. + """Settings for the Gradium TTS service.""" - Parameters: - output_format: Audio output format. - """ - - output_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class GradiumTTSService(AudioContextTTSService): @@ -108,7 +104,6 @@ class GradiumTTSService(AudioContextTTSService): model="default", voice="YTpq7expH9539ERJ", language=None, - output_format="pcm", ) # 2. Apply direct init arg overrides (deprecated) diff --git a/src/pipecat/services/groq/tts.py b/src/pipecat/services/groq/tts.py index 6f9a610e2..18b623fc8 100644 --- a/src/pipecat/services/groq/tts.py +++ b/src/pipecat/services/groq/tts.py @@ -9,7 +9,7 @@ import io import wave from dataclasses import dataclass, field -from typing import AsyncGenerator, ClassVar, Dict, Optional +from typing import AsyncGenerator, Optional from loguru import logger from pydantic import BaseModel @@ -39,16 +39,10 @@ class GroqTTSSettings(TTSSettings): """Settings for the Groq TTS service. Parameters: - output_format: Audio output format. speed: Speech speed multiplier. Defaults to 1.0. - groq_sample_rate: Audio sample rate. """ - output_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speed: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - groq_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - - _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice", "sample_rate": "groq_sample_rate"} class GroqTTSService(TTSService): @@ -122,9 +116,7 @@ class GroqTTSService(TTSService): model="canopylabs/orpheus-v1-english", voice="autumn", language="en", - output_format=output_format, speed=1.0, - groq_sample_rate=sample_rate, ) # 2. Apply direct init arg overrides (deprecated) diff --git a/src/pipecat/services/inworld/tts.py b/src/pipecat/services/inworld/tts.py index f650ce620..a1421b2ab 100644 --- a/src/pipecat/services/inworld/tts.py +++ b/src/pipecat/services/inworld/tts.py @@ -71,8 +71,6 @@ class InworldTTSSettings(TTSSettings): """Settings for Inworld TTS services. Parameters: - audio_encoding: Audio encoding format (e.g. LINEAR16). - audio_sample_rate: Audio sample rate in Hz. speaking_rate: Speaking rate for speech synthesis. temperature: Temperature for speech synthesis. auto_mode: Whether to use auto mode. Recommended when texts are sent @@ -84,8 +82,6 @@ class InworldTTSSettings(TTSSettings): timestamp_transport_strategy: Strategy for timestamp transport ("ASYNC" or "SYNC"). """ - audio_encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - audio_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speaking_rate: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) temperature: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) auto_mode: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -93,7 +89,6 @@ class InworldTTSSettings(TTSSettings): timestamp_transport_strategy: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) _aliases: ClassVar[Dict[str, str]] = { - "voice_id": "voice", "voiceId": "voice", "modelId": "model", "applyTextNormalization": "apply_text_normalization", @@ -107,8 +102,6 @@ class InworldTTSSettings(TTSSettings): flat = dict(settings) nested = flat.pop("audioConfig", None) if isinstance(nested, dict): - flat.setdefault("audio_encoding", nested.get("audioEncoding")) - flat.setdefault("audio_sample_rate", nested.get("sampleRateHertz")) flat.setdefault("speaking_rate", nested.get("speakingRate")) return super().from_mapping(flat) @@ -184,8 +177,6 @@ class InworldHttpTTSService(TTSService): model="inworld-tts-1.5-max", voice="Ashley", language=None, - audio_encoding=encoding, - audio_sample_rate=0, speaking_rate=None, temperature=None, timestamp_transport_strategy="ASYNC", @@ -239,6 +230,10 @@ class InworldHttpTTSService(TTSService): self._cumulative_time = 0.0 + # Init-only audio format config (not runtime-updatable). + self._audio_encoding = encoding + self._audio_sample_rate = 0 # Set in start() + def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -254,7 +249,7 @@ class InworldHttpTTSService(TTSService): frame: The start frame. """ await super().start(frame) - self._settings.audio_sample_rate = self.sample_rate + self._audio_sample_rate = self.sample_rate async def stop(self, frame: EndFrame): """Stop the Inworld TTS service. @@ -334,8 +329,8 @@ class InworldHttpTTSService(TTSService): logger.debug(f"{self}: Generating TTS [{text}] (streaming={self._streaming})") audio_config = { - "audioEncoding": self._settings.audio_encoding, - "sampleRateHertz": self._settings.audio_sample_rate, + "audioEncoding": self._audio_encoding, + "sampleRateHertz": self._audio_sample_rate, } if self._settings.speaking_rate is not None: audio_config["speakingRate"] = self._settings.speaking_rate @@ -611,8 +606,6 @@ class InworldTTSService(AudioContextTTSService): model="inworld-tts-1.5-max", voice="Ashley", language=None, - audio_encoding=encoding, - audio_sample_rate=0, speaking_rate=None, temperature=None, apply_text_normalization=None, @@ -686,6 +679,10 @@ class InworldTTSService(AudioContextTTSService): # Track the end time of the last word in the current generation self._generation_end_time = 0.0 + # Init-only audio format config (not runtime-updatable). + self._audio_encoding = encoding + self._audio_sample_rate = 0 # Set in start() + def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -701,7 +698,7 @@ class InworldTTSService(AudioContextTTSService): frame: The start frame. """ await super().start(frame) - self._settings.audio_sample_rate = self.sample_rate + self._audio_sample_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): @@ -1051,8 +1048,8 @@ class InworldTTSService(AudioContextTTSService): context_id: The context ID. """ audio_config = { - "audioEncoding": self._settings.audio_encoding, - "sampleRateHertz": self._settings.audio_sample_rate, + "audioEncoding": self._audio_encoding, + "sampleRateHertz": self._audio_sample_rate, } if self._settings.speaking_rate is not None: audio_config["speakingRate"] = self._settings.speaking_rate diff --git a/src/pipecat/services/kokoro/tts.py b/src/pipecat/services/kokoro/tts.py index 60dfb65ce..0646923f3 100644 --- a/src/pipecat/services/kokoro/tts.py +++ b/src/pipecat/services/kokoro/tts.py @@ -7,7 +7,7 @@ """Kokoro TTS service implementation using kokoro-onnx.""" import os -from dataclasses import dataclass, field +from dataclasses import dataclass from pathlib import Path from typing import AsyncGenerator, Optional @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -91,13 +91,9 @@ def language_to_kokoro_language(language: Language) -> str: @dataclass class KokoroTTSSettings(TTSSettings): - """Settings for the Kokoro TTS service. + """Settings for the Kokoro TTS service.""" - Parameters: - lang_code: Kokoro language code for synthesis. - """ - - lang_code: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class KokoroTTSService(TTSService): @@ -156,7 +152,6 @@ class KokoroTTSService(TTSService): model=None, voice=None, language=language_to_kokoro_language(Language.EN), - lang_code=language_to_kokoro_language(Language.EN), ) # 2. Apply direct init arg overrides (deprecated) @@ -168,9 +163,7 @@ class KokoroTTSService(TTSService): if params is not None: _warn_deprecated_param("params", KokoroTTSSettings) if not settings: - lang_code = language_to_kokoro_language(params.language) - default_settings.language = lang_code - default_settings.lang_code = lang_code + default_settings.language = language_to_kokoro_language(params.language) # 4. Apply settings delta (canonical API, always wins) if settings is not None: @@ -181,8 +174,6 @@ class KokoroTTSService(TTSService): **kwargs, ) - self._lang_code = default_settings.lang_code - model_file = Path(model_path) if model_path else KOKORO_CACHE_DIR / "kokoro-v1.0.onnx" voices = Path(voices_path) if voices_path else KOKORO_CACHE_DIR / "voices-v1.0.bin" @@ -196,6 +187,17 @@ class KokoroTTSService(TTSService): """Indicate that this service supports TTFB and usage metrics.""" return True + def language_to_service_language(self, language: Language) -> str: + """Convert a Language enum to kokoro-onnx language format. + + Args: + language: The language to convert. + + Returns: + The kokoro-onnx language code. + """ + return language_to_kokoro_language(language) + @traced_tts async def run_tts(self, text: str, context_id: str) -> AsyncGenerator[Frame, None]: """Synthesize speech from text using kokoro-onnx. @@ -215,7 +217,7 @@ class KokoroTTSService(TTSService): yield TTSStartedFrame(context_id=context_id) stream = self._kokoro.create_stream( - text, voice=self._settings.voice, lang=self._lang_code, speed=1.0 + text, voice=self._settings.voice, lang=self._settings.language, speed=1.0 ) async for samples, sample_rate in stream: diff --git a/src/pipecat/services/lmnt/tts.py b/src/pipecat/services/lmnt/tts.py index 58468bc00..9ee6d8d60 100644 --- a/src/pipecat/services/lmnt/tts.py +++ b/src/pipecat/services/lmnt/tts.py @@ -7,7 +7,7 @@ """LMNT text-to-speech service implementation.""" import json -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -17,14 +17,13 @@ from pipecat.frames.frames import ( EndFrame, ErrorFrame, Frame, - InterruptionFrame, StartFrame, TTSAudioRawFrame, TTSStartedFrame, TTSStoppedFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import InterruptibleTTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -75,13 +74,9 @@ def language_to_lmnt_language(language: Language) -> Optional[str]: @dataclass class LmntTTSSettings(TTSSettings): - """Settings for LMNT TTS service. + """Settings for LMNT TTS service.""" - Parameters: - format: Audio output format. Defaults to "raw". - """ - - format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class LmntTTSService(InterruptibleTTSService): @@ -130,7 +125,6 @@ class LmntTTSService(InterruptibleTTSService): model="blizzard", voice=None, language=self.language_to_service_language(language), - format="raw", ) # 2. Apply direct init arg overrides (deprecated) @@ -156,6 +150,7 @@ class LmntTTSService(InterruptibleTTSService): ) self._api_key = api_key + self._output_format = "raw" self._receive_task = None self._context_id: Optional[str] = None @@ -262,7 +257,7 @@ class LmntTTSService(InterruptibleTTSService): init_msg = { "X-API-Key": self._api_key, "voice": self._settings.voice, - "format": self._settings.format, + "format": self._output_format, "sample_rate": self.sample_rate, "language": self._settings.language, "model": self._settings.model, diff --git a/src/pipecat/services/minimax/tts.py b/src/pipecat/services/minimax/tts.py index 2be25aef9..efe8c1fd9 100644 --- a/src/pipecat/services/minimax/tts.py +++ b/src/pipecat/services/minimax/tts.py @@ -12,7 +12,7 @@ for streaming text-to-speech synthesis. import json from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, ClassVar, Dict, Mapping, Optional, Self +from typing import Any, AsyncGenerator, Mapping, Optional, Self import aiohttp from loguru import logger @@ -100,10 +100,6 @@ class MiniMaxTTSSettings(TTSSettings): "disgusted", "surprised", "calm", "fluent"). text_normalization: Enable text normalization (Chinese/English). latex_read: Enable LaTeX formula reading. - audio_bitrate: Audio bitrate in bps. - audio_format: Audio output format. - audio_channel: Number of audio channels. - audio_sample_rate: Audio sample rate in Hz. language_boost: Language boost string for multilingual support. """ @@ -114,14 +110,8 @@ class MiniMaxTTSSettings(TTSSettings): emotion: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) text_normalization: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) latex_read: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - audio_bitrate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - audio_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - audio_channel: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - audio_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) language_boost: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - _aliases: ClassVar[Dict[str, str]] = {"voice_id": "voice"} - @classmethod def from_mapping(cls, settings: Mapping[str, Any]) -> Self: """Construct settings from a plain dict, destructuring legacy nested dicts. @@ -140,13 +130,6 @@ class MiniMaxTTSSettings(TTSSettings): flat.setdefault("text_normalization", voice.get("text_normalization")) flat.setdefault("latex_read", voice.get("latex_read")) - audio = flat.pop("audio_setting", None) - if isinstance(audio, dict): - flat.setdefault("audio_bitrate", audio.get("bitrate")) - flat.setdefault("audio_format", audio.get("format")) - flat.setdefault("audio_channel", audio.get("channel")) - flat.setdefault("audio_sample_rate", audio.get("sample_rate")) - return super().from_mapping(flat) @@ -258,10 +241,6 @@ class MiniMaxHttpTTSService(TTSService): emotion=None, text_normalization=None, latex_read=None, - audio_bitrate=128000, - audio_format="pcm", - audio_channel=1, - audio_sample_rate=0, ) # 2. Apply direct init arg overrides (deprecated) @@ -335,6 +314,12 @@ class MiniMaxHttpTTSService(TTSService): self._base_url = f"{base_url}?GroupId={group_id}" self._session = aiohttp_session + # Init-only audio format config + self._audio_bitrate = 128000 + self._audio_format = "pcm" + self._audio_channel = 1 + self._audio_sample_rate = 0 # Set in start() + def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -361,7 +346,7 @@ class MiniMaxHttpTTSService(TTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.audio_sample_rate = self.sample_rate + self._audio_sample_rate = self.sample_rate logger.debug(f"MiniMax TTS initialized with sample_rate: {self.sample_rate}") @traced_tts @@ -399,10 +384,10 @@ class MiniMaxHttpTTSService(TTSService): # Build audio_setting dict for API audio_setting = { - "bitrate": self._settings.audio_bitrate, - "format": self._settings.audio_format, - "channel": self._settings.audio_channel, - "sample_rate": self._settings.audio_sample_rate, + "bitrate": self._audio_bitrate, + "format": self._audio_format, + "channel": self._audio_channel, + "sample_rate": self._audio_sample_rate, } # Create payload from settings diff --git a/src/pipecat/services/neuphonic/tts.py b/src/pipecat/services/neuphonic/tts.py index f6cc6bf68..da14ec2e5 100644 --- a/src/pipecat/services/neuphonic/tts.py +++ b/src/pipecat/services/neuphonic/tts.py @@ -80,13 +80,9 @@ class NeuphonicTTSSettings(TTSSettings): Parameters: speed: Speech speed multiplier. Defaults to 1.0. - encoding: Audio encoding format. - sampling_rate: Audio sample rate. """ speed: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - sampling_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class NeuphonicTTSService(InterruptibleTTSService): @@ -160,8 +156,6 @@ class NeuphonicTTSService(InterruptibleTTSService): voice=None, language=self.language_to_service_language(Language.EN), speed=1.0, - encoding=encoding, - sampling_rate=sample_rate, ) # 2. Apply direct init arg overrides (deprecated) @@ -200,6 +194,8 @@ class NeuphonicTTSService(InterruptibleTTSService): self._receive_task = None self._keepalive_task = None self._context_id: Optional[str] = None + self._encoding = encoding + self._sampling_rate = sample_rate def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -327,8 +323,8 @@ class NeuphonicTTSService(InterruptibleTTSService): tts_config = { "lang_code": self._settings.language, "speed": self._settings.speed, - "encoding": self._settings.encoding, - "sampling_rate": self._settings.sampling_rate, + "encoding": self._encoding, + "sampling_rate": self._sampling_rate, "voice_id": self._settings.voice, } @@ -503,8 +499,6 @@ class NeuphonicHttpTTSService(TTSService): voice=None, language=self.language_to_service_language(Language.EN) or "en", speed=1.0, - encoding=encoding, - sampling_rate=sample_rate, ) # 2. Apply direct init arg overrides (deprecated) @@ -536,6 +530,7 @@ class NeuphonicHttpTTSService(TTSService): self._api_key = api_key self._session = aiohttp_session self._base_url = url.rstrip("/") + self._encoding = encoding def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -629,7 +624,7 @@ class NeuphonicHttpTTSService(TTSService): payload = { "text": text, "lang_code": self._settings.language, - "encoding": self._settings.encoding, + "encoding": self._encoding, "sampling_rate": self.sample_rate, "speed": self._settings.speed, } diff --git a/src/pipecat/services/resembleai/tts.py b/src/pipecat/services/resembleai/tts.py index f0a8a988a..e1c1cf68a 100644 --- a/src/pipecat/services/resembleai/tts.py +++ b/src/pipecat/services/resembleai/tts.py @@ -8,8 +8,8 @@ import base64 import json -from dataclasses import dataclass, field -from typing import AsyncGenerator, ClassVar, Dict, Optional +from dataclasses import dataclass +from typing import AsyncGenerator, Optional from loguru import logger @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import AudioContextTTSService from pipecat.utils.tracing.service_decorators import traced_tts @@ -38,22 +38,9 @@ except ModuleNotFoundError as e: @dataclass class ResembleAITTSSettings(TTSSettings): - """Settings for Resemble AI TTS service. + """Settings for Resemble AI TTS service.""" - Parameters: - precision: PCM bit depth (PCM_32, PCM_24, PCM_16, or MULAW). - output_format: Audio format (wav or mp3). - resemble_sample_rate: Audio sample rate sent to the API. - """ - - precision: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_format: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - resemble_sample_rate: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - - _aliases: ClassVar[Dict[str, str]] = { - "voice_id": "voice", - "sample_rate": "resemble_sample_rate", - } + pass class ResembleAITTSService(AudioContextTTSService): @@ -100,21 +87,12 @@ class ResembleAITTSService(AudioContextTTSService): model=None, voice=None, language=None, - precision="PCM_16", - output_format="wav", - resemble_sample_rate=22050, ) # 2. Apply direct init arg overrides (deprecated) if voice_id is not None: _warn_deprecated_param("voice_id", ResembleAITTSSettings, "voice") default_settings.voice = voice_id - if precision is not None: - default_settings.precision = precision - if output_format is not None: - default_settings.output_format = output_format - if sample_rate is not None: - default_settings.resemble_sample_rate = sample_rate # 3. No params for this service @@ -133,6 +111,11 @@ class ResembleAITTSService(AudioContextTTSService): self._api_key = api_key self._url = url + # Init-only audio format config (not runtime-updatable). + self._precision = precision or "PCM_16" + self._output_format = output_format or "wav" + self._resemble_sample_rate = 0 # Set in start() + self._websocket = None self._request_id_counter = 0 self._receive_task = None @@ -174,9 +157,9 @@ class ResembleAITTSService(AudioContextTTSService): "data": text, "binary_response": False, # Use JSON frames to get timestamps "request_id": self._request_id_counter, # ResembleAI only accepts number - "output_format": self._settings.output_format, - "sample_rate": self._settings.resemble_sample_rate, - "precision": self._settings.precision, + "output_format": self._output_format, + "sample_rate": self._resemble_sample_rate, + "precision": self._precision, "no_audio_header": True, } @@ -190,7 +173,7 @@ class ResembleAITTSService(AudioContextTTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.resemble_sample_rate = self.sample_rate + self._resemble_sample_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): diff --git a/src/pipecat/services/rime/tts.py b/src/pipecat/services/rime/tts.py index 613d58f3a..04ebcd5fc 100644 --- a/src/pipecat/services/rime/tts.py +++ b/src/pipecat/services/rime/tts.py @@ -76,8 +76,6 @@ class RimeTTSSettings(TTSSettings): """Settings for Rime WS JSON and HTTP TTS services. Parameters: - audioFormat: Audio output format. - samplingRate: Audio sample rate. segment: Text segmentation mode ("immediate", "bySentence", "never"). speedAlpha: Speech speed multiplier (mistv2 only). reduceLatency: Whether to reduce latency at potential quality cost (mistv2 only). @@ -91,8 +89,6 @@ class RimeTTSSettings(TTSSettings): top_p: Cumulative probability threshold (arcana only, 0.0-1.0). """ - audioFormat: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - samplingRate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) segment: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) speedAlpha: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) reduceLatency: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -113,16 +109,12 @@ class RimeNonJsonTTSSettings(TTSSettings): """Settings for Rime non-JSON WS TTS service. Parameters: - audioFormat: Audio output format. - samplingRate: Audio sample rate. segment: Text segmentation mode ("immediate", "bySentence", "never"). repetition_penalty: Token repetition penalty (1.0-2.0). temperature: Sampling temperature (0.0-1.0). top_p: Cumulative probability threshold (0.0-1.0). """ - audioFormat: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - samplingRate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) segment: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) repetition_penalty: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -230,8 +222,6 @@ class RimeTTSService(AudioContextTTSService): default_settings = RimeTTSSettings( model="arcana", voice=None, - audioFormat="pcm", - samplingRate=0, # updated in start() language=None, segment=None, inlineSpeedAlpha=None, @@ -293,6 +283,10 @@ class RimeTTSService(AudioContextTTSService): **kwargs, ) + # Init-only audio format fields (not runtime-updatable) + self._audio_format = "pcm" + self._sampling_rate = 0 # updated in start() + if not text_aggregator: # Always skip tags added for spelled-out text # Note: This is primarily to support backwards compatibility. @@ -342,8 +336,8 @@ class RimeTTSService(AudioContextTTSService): params: dict[str, Any] = { "speaker": self._settings.voice, "modelId": self._settings.model, - "audioFormat": self._settings.audioFormat, - "samplingRate": self._settings.samplingRate, + "audioFormat": self._audio_format, + "samplingRate": self._sampling_rate, } if self._settings.language is not None: params["lang"] = self._settings.language @@ -437,7 +431,7 @@ class RimeTTSService(AudioContextTTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.samplingRate = self.sample_rate + self._sampling_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): @@ -737,8 +731,6 @@ class RimeHttpTTSService(TTSService): model="mistv2", voice=None, language="eng", - audioFormat="pcm", - samplingRate=0, segment=None, speedAlpha=None, reduceLatency=None, @@ -789,6 +781,9 @@ class RimeHttpTTSService(TTSService): self._session = aiohttp_session self._base_url = "https://users.rime.ai/v1/rime-tts" + # Init-only audio format fields (not runtime-updatable) + self._audio_format = "pcm" + def can_generate_metrics(self) -> bool: """Check if this service can generate processing metrics. @@ -974,8 +969,6 @@ class RimeNonJsonTTSService(InterruptibleTTSService): default_settings = RimeNonJsonTTSSettings( voice=None, model="arcana", - audioFormat=audio_format, - samplingRate=sample_rate, language=None, segment=None, repetition_penalty=None, @@ -1017,6 +1010,11 @@ class RimeNonJsonTTSService(InterruptibleTTSService): settings=default_settings, **kwargs, ) + + # Init-only audio format fields (not runtime-updatable) + self._audio_format = audio_format + self._sampling_rate = sample_rate + self._api_key = api_key self._url = url # Add any extra parameters for future compatibility @@ -1053,7 +1051,7 @@ class RimeNonJsonTTSService(InterruptibleTTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.samplingRate = self.sample_rate + self._sampling_rate = self.sample_rate await self._connect() async def stop(self, frame: EndFrame): @@ -1101,8 +1099,8 @@ class RimeNonJsonTTSService(InterruptibleTTSService): settings_dict = { "speaker": self._settings.voice, "modelId": self._settings.model, - "audioFormat": self._settings.audioFormat, - "samplingRate": self._settings.samplingRate, + "audioFormat": self._audio_format, + "samplingRate": self._sampling_rate, } if self._settings.language is not None: settings_dict["lang"] = self._settings.language diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index cf00dd8c7..659a58bdd 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -250,7 +250,6 @@ class SarvamHttpTTSSettings(TTSSettings): """Settings for Sarvam HTTP TTS service. Parameters: - language: Sarvam language code. enable_preprocessing: Whether to enable text preprocessing. Defaults to False. **Note:** Always enabled for bulbul:v3-beta (cannot be disabled). pace: Speech pace multiplier. Defaults to 1.0. @@ -263,16 +262,13 @@ class SarvamHttpTTSSettings(TTSSettings): temperature: Controls output randomness for bulbul:v3-beta (0.01 to 1.0). Lower values = more deterministic, higher = more random. Defaults to 0.6. **Note:** Only supported for bulbul:v3-beta. Ignored for v2. - sample_rate: Audio sample rate. """ - language: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) enable_preprocessing: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) pace: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) pitch: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) loudness: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - sarvam_sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @dataclass @@ -280,19 +276,12 @@ class SarvamTTSSettings(TTSSettings): """Settings for Sarvam WebSocket TTS service. Parameters: - language: Sarvam language code (e.g. ``"hi-IN"``). Uses the standard - ``TTSSettings.language`` field. - speech_sample_rate: Audio sample rate as string. enable_preprocessing: Enable text preprocessing. Defaults to False. **Note:** Always enabled for bulbul:v3-beta. min_buffer_size: Minimum characters to buffer before generating audio. Lower values reduce latency but may affect quality. Defaults to 50. max_chunk_length: Maximum characters processed in a single chunk. Controls memory usage and processing efficiency. Defaults to 150. - output_audio_codec: Audio codec format. Options: linear16, mulaw, alaw, - opus, flac, aac, wav, mp3. Defaults to "linear16". - output_audio_bitrate: Audio bitrate (32k, 64k, 96k, 128k, 192k). - Defaults to "128k". pace: Speech pace multiplier. Defaults to 1.0. - bulbul:v2: Range 0.3 to 3.0 - bulbul:v3-beta: Range 0.5 to 2.0 @@ -307,12 +296,9 @@ class SarvamTTSSettings(TTSSettings): _aliases: ClassVar[Dict[str, str]] = {"target_language_code": "language"} - speech_sample_rate: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) enable_preprocessing: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) min_buffer_size: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) max_chunk_length: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_audio_codec: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - output_audio_bitrate: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) pace: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) pitch: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) loudness: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -587,7 +573,6 @@ class SarvamHttpTTSService(TTSService): frame: The start frame containing initialization parameters. """ await super().start(frame) - self._settings.sarvam_sample_rate = self.sample_rate @traced_tts async def run_tts(self, text: str, context_id: str) -> AsyncGenerator[Frame, None]: @@ -881,12 +866,9 @@ class SarvamTTSService(InterruptibleTTSService): model="bulbul:v2", voice="anushka", language="en-IN", - speech_sample_rate="22050", enable_preprocessing=False, min_buffer_size=50, max_chunk_length=150, - output_audio_codec="linear16", - output_audio_bitrate="128k", pace=1.0, pitch=None, loudness=None, @@ -901,6 +883,10 @@ class SarvamTTSService(InterruptibleTTSService): _warn_deprecated_param("voice_id", SarvamTTSSettings, "voice") default_settings.voice = voice_id + # Init-only audio format fields (not runtime-updatable) + output_audio_codec = "linear16" + output_audio_bitrate = "128k" + # 3. Apply params overrides — only if settings not provided if params is not None: _warn_deprecated_param("params", SarvamTTSSettings) @@ -916,9 +902,9 @@ class SarvamTTSService(InterruptibleTTSService): if params.max_chunk_length is not None: default_settings.max_chunk_length = params.max_chunk_length if params.output_audio_codec is not None: - default_settings.output_audio_codec = params.output_audio_codec + output_audio_codec = params.output_audio_codec if params.output_audio_bitrate is not None: - default_settings.output_audio_bitrate = params.output_audio_bitrate + output_audio_bitrate = params.output_audio_bitrate if params.pace is not None: default_settings.pace = params.pace if params.pitch is not None: @@ -943,7 +929,6 @@ class SarvamTTSService(InterruptibleTTSService): # Set default sample rate based on model if not specified if sample_rate is None: sample_rate = self._config.default_sample_rate - default_settings.speech_sample_rate = str(sample_rate) # Set default voice based on model if not specified via any mechanism if voice_id is None and (settings is None or settings.voice is NOT_GIVEN): @@ -986,6 +971,11 @@ class SarvamTTSService(InterruptibleTTSService): **kwargs, ) + # Init-only audio format fields (not runtime-updatable) + self._speech_sample_rate = str(sample_rate) + self._output_audio_codec = output_audio_codec + self._output_audio_bitrate = output_audio_bitrate + # WebSocket endpoint URL with model query parameter self._websocket_url = f"{url}?model={resolved_model}" self._api_key = api_key @@ -1022,7 +1012,7 @@ class SarvamTTSService(InterruptibleTTSService): await super().start(frame) # WebSocket API expects sample rate as string - self._settings.speech_sample_rate = str(self.sample_rate) + self._speech_sample_rate = str(self.sample_rate) await self._connect() async def stop(self, frame: EndFrame): @@ -1140,12 +1130,12 @@ class SarvamTTSService(InterruptibleTTSService): config_data = { "target_language_code": self._settings.language, "speaker": self._settings.voice, - "speech_sample_rate": self._settings.speech_sample_rate, + "speech_sample_rate": self._speech_sample_rate, "enable_preprocessing": self._settings.enable_preprocessing, "min_buffer_size": self._settings.min_buffer_size, "max_chunk_length": self._settings.max_chunk_length, - "output_audio_codec": self._settings.output_audio_codec, - "output_audio_bitrate": self._settings.output_audio_bitrate, + "output_audio_codec": self._output_audio_codec, + "output_audio_bitrate": self._output_audio_bitrate, "pace": self._settings.pace, "model": self._settings.model, } diff --git a/src/pipecat/services/xtts/tts.py b/src/pipecat/services/xtts/tts.py index adf11da6a..ea7cb0b8b 100644 --- a/src/pipecat/services/xtts/tts.py +++ b/src/pipecat/services/xtts/tts.py @@ -10,7 +10,7 @@ This module provides integration with Coqui XTTS streaming server for text-to-speech synthesis using local Docker deployment. """ -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import AsyncGenerator, Dict, Optional import aiohttp @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( TTSStartedFrame, TTSStoppedFrame, ) -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import TTSSettings, _warn_deprecated_param from pipecat.services.tts_service import TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -72,13 +72,9 @@ def language_to_xtts_language(language: Language) -> Optional[str]: @dataclass class XTTSTTSSettings(TTSSettings): - """Settings for XTTS TTS service. + """Settings for XTTS TTS service.""" - Parameters: - base_url: Base URL of the XTTS streaming server. - """ - - base_url: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class XTTSService(TTSService): @@ -123,7 +119,6 @@ class XTTSService(TTSService): model=None, voice=None, language=self.language_to_service_language(language), - base_url=base_url, ) # 2. Apply direct init arg overrides (deprecated) @@ -140,6 +135,10 @@ class XTTSService(TTSService): settings=default_settings, **kwargs, ) + + # Init-only fields (not runtime-updatable) + self._base_url = base_url + self._studio_speakers: Optional[Dict[str, Any]] = None self._aiohttp_session = aiohttp_session @@ -175,7 +174,7 @@ class XTTSService(TTSService): if self._studio_speakers: return - async with self._aiohttp_session.get(self._settings.base_url + "/studio_speakers") as r: + async with self._aiohttp_session.get(self._base_url + "/studio_speakers") as r: if r.status != 200: text = await r.text() await self.push_error( @@ -203,7 +202,7 @@ class XTTSService(TTSService): embeddings = self._studio_speakers[self._settings.voice] - url = self._settings.base_url + "/tts_stream" + url = self._base_url + "/tts_stream" payload = { "text": text.replace(".", "").replace("*", ""), From 034e81ff1840a980085f6ed2856dafa6ad8100ef Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 16:09:10 -0500 Subject: [PATCH 07/17] Update STT service settings --- .../07c-interruptible-deepgram-sagemaker.py | 17 +- .../07g-interruptible-openai-http.py | 17 +- src/pipecat/services/assemblyai/models.py | 3 + src/pipecat/services/assemblyai/stt.py | 308 +++++++++--------- src/pipecat/services/aws/stt.py | 67 ++-- src/pipecat/services/azure/stt.py | 16 +- src/pipecat/services/cartesia/stt.py | 69 ++-- src/pipecat/services/deepgram/flux/stt.py | 23 +- .../services/deepgram/sagemaker/stt.py | 178 ++++++---- .../services/deepgram/sagemaker/tts.py | 3 +- src/pipecat/services/deepgram/stt.py | 156 +++++++-- src/pipecat/services/elevenlabs/stt.py | 26 +- src/pipecat/services/fal/stt.py | 53 +-- src/pipecat/services/gladia/config.py | 4 + src/pipecat/services/gladia/stt.py | 61 ++-- src/pipecat/services/gradium/stt.py | 26 +- src/pipecat/services/groq/stt.py | 49 ++- src/pipecat/services/nvidia/stt.py | 27 +- src/pipecat/services/openai/stt.py | 82 +++-- src/pipecat/services/openai/tts.py | 2 + src/pipecat/services/sambanova/stt.py | 43 ++- src/pipecat/services/sarvam/stt.py | 72 ++-- src/pipecat/services/soniox/stt.py | 32 +- src/pipecat/services/speechmatics/stt.py | 25 +- src/pipecat/services/whisper/base_stt.py | 35 +- src/pipecat/services/whisper/stt.py | 45 +-- tests/test_settings.py | 49 ++- 27 files changed, 829 insertions(+), 659 deletions(-) diff --git a/examples/foundational/07c-interruptible-deepgram-sagemaker.py b/examples/foundational/07c-interruptible-deepgram-sagemaker.py index 406f95445..2f51bda8d 100644 --- a/examples/foundational/07c-interruptible-deepgram-sagemaker.py +++ b/examples/foundational/07c-interruptible-deepgram-sagemaker.py @@ -22,9 +22,12 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.llm import AWSBedrockLLMService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings from pipecat.services.deepgram.sagemaker.stt import DeepgramSageMakerSTTService -from pipecat.services.deepgram.sagemaker.tts import DeepgramSageMakerTTSService +from pipecat.services.deepgram.sagemaker.tts import ( + DeepgramSageMakerTTSService, + DeepgramSageMakerTTSSettings, +) from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -69,14 +72,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = DeepgramSageMakerTTSService( endpoint_name=os.getenv("SAGEMAKER_TTS_ENDPOINT_NAME"), region=os.getenv("AWS_REGION"), - voice="aura-2-andromeda-en", + settings=DeepgramSageMakerTTSSettings( + voice="aura-2-andromeda-en", + ), ) llm = AWSBedrockLLMService( aws_region=os.getenv("AWS_REGION"), - model="us.amazon.nova-pro-v1:0", - params=AWSBedrockLLMService.InputParams(temperature=0.8), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AWSBedrockLLMSettings( + model="us.amazon.nova-pro-v1:0", + temperature=0.8, + ), ) context = LLMContext() diff --git a/examples/foundational/07g-interruptible-openai-http.py b/examples/foundational/07g-interruptible-openai-http.py index 05c98ca59..721d1795f 100644 --- a/examples/foundational/07g-interruptible-openai-http.py +++ b/examples/foundational/07g-interruptible-openai-http.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.openai.stt import OpenAISTTService -from pipecat.services.openai.tts import OpenAITTSService +from pipecat.services.openai.stt import OpenAISTTService, OpenAISTTSettings +from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,11 +54,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAISTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related to dogs, such as breed names.", + settings=OpenAISTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related to dogs, such as breed names.", + ), ) - tts = OpenAITTSService(api_key=os.getenv("OPENAI_API_KEY"), voice="ballad") + tts = OpenAITTSService( + api_key=os.getenv("OPENAI_API_KEY"), + settings=OpenAITTSSettings( + voice="ballad", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/src/pipecat/services/assemblyai/models.py b/src/pipecat/services/assemblyai/models.py index 2c6b3a1dc..efc13d482 100644 --- a/src/pipecat/services/assemblyai/models.py +++ b/src/pipecat/services/assemblyai/models.py @@ -124,6 +124,9 @@ AnyMessage = BeginMessage | TurnMessage | SpeechStartedMessage | TerminationMess class AssemblyAIConnectionParams(BaseModel): """Configuration parameters for AssemblyAI WebSocket connection. + .. deprecated:: 0.0.105 + Use ``settings=AssemblyAISTTSettings(foo=...)`` instead. + Parameters: sample_rate: Audio sample rate in Hz. Defaults to 16000. encoding: Audio encoding format. Defaults to "pcm_s16le". diff --git a/src/pipecat/services/assemblyai/stt.py b/src/pipecat/services/assemblyai/stt.py index e140f7543..ec4130ea5 100644 --- a/src/pipecat/services/assemblyai/stt.py +++ b/src/pipecat/services/assemblyai/stt.py @@ -13,7 +13,7 @@ WebSocket API for streaming audio transcription. import asyncio import json from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, Dict, Optional +from typing import Any, AsyncGenerator, Dict, List, Optional from urllib.parse import urlencode from loguru import logger @@ -83,15 +83,38 @@ def map_language_from_assemblyai(language_code: str) -> Language: class AssemblyAISTTSettings(STTSettings): """Settings for the AssemblyAI STT service. - See :class:`AssemblyAIConnectionParams` for detailed parameter descriptions. - Parameters: - connection_params: Connection configuration parameters. + formatted_finals: Whether to enable transcript formatting. + word_finalization_max_wait_time: Maximum time to wait for word + finalization in milliseconds. + end_of_turn_confidence_threshold: Confidence threshold for + end-of-turn detection. + min_turn_silence: Minimum silence duration when confident about + end-of-turn. + max_turn_silence: Maximum silence duration before forcing + end-of-turn. + keyterms_prompt: List of key terms to guide transcription. + prompt: Optional text prompt to guide the transcription. Only + used when model is "u3-rt-pro". + language_detection: Enable automatic language detection. + format_turns: Whether to format transcript turns. + speaker_labels: Enable speaker diarization. """ - connection_params: AssemblyAIConnectionParams | _NotGiven = field( + formatted_finals: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + word_finalization_max_wait_time: int | None | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) + end_of_turn_confidence_threshold: float | None | _NotGiven = field( + default_factory=lambda: NOT_GIVEN + ) + min_turn_silence: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + max_turn_silence: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + keyterms_prompt: List[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + language_detection: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + format_turns: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + speaker_labels: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class AssemblyAISTTService(WebsocketSTTService): @@ -110,6 +133,8 @@ class AssemblyAISTTService(WebsocketSTTService): api_key: str, language: Optional[Language] = None, api_endpoint_base_url: str = "wss://streaming.assemblyai.com/v3/ws", + sample_rate: int = 16000, + encoding: str = "pcm_s16le", connection_params: Optional[AssemblyAIConnectionParams] = None, vad_force_turn_endpoint: bool = True, should_interrupt: bool = True, @@ -123,8 +148,18 @@ class AssemblyAISTTService(WebsocketSTTService): Args: api_key: AssemblyAI API key for authentication. language: Language code for transcription. Defaults to English (Language.EN). + + .. deprecated:: 0.0.105 + Use ``settings=AssemblyAISTTSettings(language=...)`` instead. + api_endpoint_base_url: WebSocket endpoint URL. Defaults to AssemblyAI's streaming endpoint. - connection_params: Connection configuration parameters. Defaults to AssemblyAIConnectionParams(). + sample_rate: Audio sample rate in Hz. Defaults to 16000. + encoding: Audio encoding format. Defaults to "pcm_s16le". + connection_params: Connection configuration parameters. + + .. deprecated:: 0.0.105 + Use ``settings=AssemblyAISTTSettings(...)`` instead. + vad_force_turn_endpoint: Controls turn detection mode. When True (Pipecat mode, default): Forces AssemblyAI to return finals ASAP so Pipecat's turn detection (e.g., Smart Turn) decides when the user is done. @@ -135,7 +170,6 @@ class AssemblyAISTTService(WebsocketSTTService): When False (AssemblyAI turn detection mode, u3-rt-pro only): AssemblyAI's model controls turn endings using built-in turn detection. - Uses AssemblyAI API defaults for all parameters (unless user explicitly sets them) - - Respects all user-provided connection_params as-is - Emits UserStarted/StoppedSpeakingFrame from STT - No ForceEndpoint on VAD stop should_interrupt: Whether to interrupt the bot when the user starts speaking @@ -145,39 +179,80 @@ class AssemblyAISTTService(WebsocketSTTService): Use {speaker} for speaker label and {text} for transcript text. Example: "<{speaker}>{text}" or "{speaker}: {text}" If None, transcript text is not modified. Defaults to None. - settings: Runtime-updatable settings. When provided alongside other + settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService class. """ - # Resolve connection_params early — needed for validation and turn mode config - _connection_params = connection_params or AssemblyAIConnectionParams() + # 1. Initialize default_settings with hardcoded defaults + default_settings = AssemblyAISTTSettings( + model="u3-rt-pro", + language=Language.EN, + formatted_finals=True, + word_finalization_max_wait_time=None, + end_of_turn_confidence_threshold=None, + min_turn_silence=None, + max_turn_silence=None, + keyterms_prompt=None, + prompt=None, + language_detection=None, + format_turns=True, + speaker_labels=None, + ) - # AssemblyAI turn detection mode (vad_force_turn_endpoint=False) requires the - # SpeechStarted event for reliable barge-in. Only u3-rt-pro supports - # this. Other models must use Pipecat turn detection. - is_u3_pro = _connection_params.speech_model == "u3-rt-pro" + # 2. Apply direct init arg overrides (deprecated) + if language is not None: + _warn_deprecated_param("language", AssemblyAISTTSettings, "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) + if not settings: + sample_rate = connection_params.sample_rate + encoding = connection_params.encoding + default_settings.model = connection_params.speech_model + default_settings.formatted_finals = connection_params.formatted_finals + default_settings.word_finalization_max_wait_time = ( + connection_params.word_finalization_max_wait_time + ) + default_settings.end_of_turn_confidence_threshold = ( + connection_params.end_of_turn_confidence_threshold + ) + default_settings.min_turn_silence = connection_params.min_turn_silence + default_settings.max_turn_silence = connection_params.max_turn_silence + default_settings.keyterms_prompt = connection_params.keyterms_prompt + default_settings.prompt = connection_params.prompt + default_settings.language_detection = connection_params.language_detection + default_settings.format_turns = connection_params.format_turns + default_settings.speaker_labels = connection_params.speaker_labels + + # 4. Apply settings delta (canonical API, always wins) + if settings is not None: + default_settings.apply_update(settings) + + # 5. Validate final settings + is_u3_pro = default_settings.model == "u3-rt-pro" if not vad_force_turn_endpoint and not is_u3_pro: raise ValueError( f"AssemblyAI turn detection mode (vad_force_turn_endpoint=False) requires " f"u3-rt-pro for SpeechStarted support. Either set " - f"vad_force_turn_endpoint=True for {_connection_params.speech_model}, " - f"or use speech_model='u3-rt-pro'." + f"vad_force_turn_endpoint=True for {default_settings.model}, " + f"or use model='u3-rt-pro'." ) - # Validate that prompt and keyterms_prompt are not both set - if _connection_params.prompt is not None and _connection_params.keyterms_prompt is not None: + if default_settings.prompt is not None and default_settings.keyterms_prompt is not None: raise ValueError( "The prompt and keyterms_prompt parameters cannot be used in the same request. " "Please choose either one or the other based on your use case. When you use " "keyterms_prompt, your boosted words are appended to the default prompt automatically. " - "Or to boost within prompt: + Make sure to boost the words in the audio. " + "Or to boost within prompt: + Make sure to boost the words " + "in the audio. " "For more info go to: https://www.assemblyai.com/docs/streaming/universal-3-pro" ) - # Warn if user sets a custom prompt (recommend testing without one first) - if _connection_params.prompt is not None: + if default_settings.prompt is not None: logger.warning( "Custom prompt detected. Prompting is a beta feature. We recommend testing " "with no prompt first, as this will use our optimized default prompt for " @@ -186,35 +261,12 @@ class AssemblyAISTTService(WebsocketSTTService): "https://www.assemblyai.com/docs/streaming/prompting" ) - # When vad_force_turn_endpoint is enabled, configure connection params - # for Pipecat turn detection mode (fast finals for smart turn analyzer) + # 6. Configure pipecat turn mode (mutates default_settings) if vad_force_turn_endpoint: - _connection_params = self._configure_pipecat_turn_mode(_connection_params, is_u3_pro) - - # 1. Initialize default_settings with hardcoded defaults - default_settings = AssemblyAISTTSettings( - model=None, - language=Language.EN, - connection_params=AssemblyAIConnectionParams(), - ) - - # 2. Apply direct init arg overrides (deprecated) - if language is not None: - _warn_deprecated_param("language", AssemblyAISTTSettings, "language") - default_settings.language = language - - # 3. Apply connection_params overrides — only if settings not provided - if connection_params is not None: - _warn_deprecated_param("connection_params", AssemblyAISTTSettings) - if not settings: - default_settings.connection_params = _connection_params - - # 4. Apply settings delta (canonical API, always wins) - if settings is not None: - default_settings.apply_update(settings) + self._configure_pipecat_turn_mode(default_settings, is_u3_pro) super().__init__( - sample_rate=_connection_params.sample_rate, + sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, settings=default_settings, **kwargs, @@ -226,6 +278,9 @@ class AssemblyAISTTService(WebsocketSTTService): self._should_interrupt = should_interrupt self._speaker_format = speaker_format + # Init-only audio config (not runtime-updatable) + self._encoding = encoding + self._termination_event = asyncio.Event() self._received_termination = False self._connected = False @@ -238,10 +293,8 @@ class AssemblyAISTTService(WebsocketSTTService): self._user_speaking = False - def _configure_pipecat_turn_mode( - self, connection_params: AssemblyAIConnectionParams, is_u3_pro: bool - ) -> AssemblyAIConnectionParams: - """Configure connection params for Pipecat turn detection mode. + def _configure_pipecat_turn_mode(self, settings: AssemblyAISTTSettings, is_u3_pro: bool): + """Configure settings for Pipecat turn detection mode. When vad_force_turn_endpoint is enabled, force AssemblyAI to return finals as fast as possible so Pipecat's smart turn analyzer can decide @@ -260,46 +313,31 @@ class AssemblyAISTTService(WebsocketSTTService): - max_turn_silence: not set (API default) Args: - connection_params: The user-provided connection parameters. + settings: The settings to configure in place. is_u3_pro: Whether using u3-rt-pro model. - - Returns: - Updated connection parameters configured for Pipecat turn mode. """ - updates = {} - if is_u3_pro: # u3-rt-pro: Synchronize max_turn_silence with min_turn_silence - min_silence = connection_params.min_turn_silence + min_silence = settings.min_turn_silence if min_silence is None: min_silence = 100 # Warn if user set max_turn_silence (will be overridden) - if connection_params.max_turn_silence is not None: + if settings.max_turn_silence is not None: logger.warning( - f"Your max_turn_silence value ({connection_params.max_turn_silence}ms) will be " + f"Your max_turn_silence value ({settings.max_turn_silence}ms) will be " f"OVERRIDDEN in Pipecat mode (vad_force_turn_endpoint=True). It will be set to " f"{min_silence}ms (matching min_turn_silence) and SENT to " f"AssemblyAI to avoid double turn detection. To use your max_turn_silence as-is, " f"switch to AssemblyAI turn detection mode (vad_force_turn_endpoint=False)." ) - updates = { - "min_turn_silence": min_silence, - "max_turn_silence": min_silence, - } + settings.min_turn_silence = min_silence + settings.max_turn_silence = min_silence else: # universal-streaming: Different configuration (works differently) - updates = { - "end_of_turn_confidence_threshold": 1.0, - "min_turn_silence": 160, - } - - # Apply updates if any - if updates: - connection_params = connection_params.model_copy(update=updates) - - return connection_params + settings.end_of_turn_confidence_threshold = 1.0 + settings.min_turn_silence = 160 def can_generate_metrics(self) -> bool: """Check if the service can generate metrics. @@ -309,18 +347,11 @@ class AssemblyAISTTService(WebsocketSTTService): """ return True - async def _update_settings(self, delta: STTSettings) -> dict[str, Any]: - """Apply a settings delta and send UpdateConfiguration if connected. - - Stores settings changes and sends UpdateConfiguration message to AssemblyAI - without reconnecting. Supports updating: - - keyterms_prompt: List of terms to boost (can be empty array to clear) - - prompt: Custom prompt text (u3-rt-pro only) - - max_turn_silence: Maximum silence before forcing turn end - - min_turn_silence: Silence before EOT check + async def _update_settings(self, delta: AssemblyAISTTSettings) -> dict[str, Any]: + """Apply a settings delta and reconnect to apply changes. Args: - delta: A :class:`STTSettings` (or ``AssemblyAISTTSettings``) delta. + delta: A settings delta with updated values. Returns: Dict mapping changed field names to their previous values. @@ -330,72 +361,9 @@ class AssemblyAISTTService(WebsocketSTTService): if not changed: return changed - # If websocket is connected, send UpdateConfiguration for supported params - if ( - self._websocket - and self._websocket.state is State.OPEN - and "connection_params" in changed - ): - # Build UpdateConfiguration message - update_config = {"type": "UpdateConfiguration"} - conn_params = self._settings.connection_params - - # Get the old connection_params to see what changed - old_conn_params = changed.get("connection_params") - - # Check each potentially changed parameter - if ( - old_conn_params is None - or conn_params.keyterms_prompt != old_conn_params.keyterms_prompt - ): - if conn_params.keyterms_prompt is not None: - update_config["keyterms_prompt"] = conn_params.keyterms_prompt - logger.info(f"Updating keyterms_prompt to: {conn_params.keyterms_prompt}") - - if old_conn_params is None or conn_params.prompt != old_conn_params.prompt: - if conn_params.prompt is not None: - if conn_params.speech_model != "u3-rt-pro": - logger.warning( - f"prompt parameter is only supported with u3-rt-pro model, " - f"current model is {conn_params.speech_model}" - ) - else: - update_config["prompt"] = conn_params.prompt - logger.info(f"Updating prompt") - - if ( - old_conn_params is None - or conn_params.max_turn_silence != old_conn_params.max_turn_silence - ): - if conn_params.max_turn_silence is not None: - update_config["max_turn_silence"] = conn_params.max_turn_silence - logger.info(f"Updating max_turn_silence to: {conn_params.max_turn_silence}ms") - - if ( - old_conn_params is None - or conn_params.min_turn_silence != old_conn_params.min_turn_silence - ): - if conn_params.min_turn_silence is not None: - update_config["min_turn_silence"] = conn_params.min_turn_silence - logger.info(f"Updating min_turn_silence to: {conn_params.min_turn_silence}ms") - - # Send update if we have parameters to update - if len(update_config) > 1: # More than just "type" - try: - await self._websocket.send(json.dumps(update_config)) - logger.info(f"Sent UpdateConfiguration: {update_config}") - except Exception as e: - logger.error(f"Failed to send UpdateConfiguration: {e}") - elif "connection_params" in changed: - logger.warning( - "Connection params changed but WebSocket not connected. " - "Settings will be applied on next connection." - ) - - # Warn about other settings that can't be changed dynamically - other_changes = {k: v for k, v in changed.items() if k not in ["connection_params"]} - if other_changes: - self._warn_unhandled_updated_settings(other_changes) + # Reconnect to apply updated settings (they become WS query params) + await self._disconnect() + await self._connect() return changed @@ -473,19 +441,41 @@ class AssemblyAISTTService(WebsocketSTTService): def _build_ws_url(self) -> str: """Build WebSocket URL with query parameters using urllib.parse.urlencode.""" - params = {} - for k, v in self._settings.connection_params.model_dump().items(): - # Skip deprecated parameter - it's been migrated to min_turn_silence - if k == "min_end_of_turn_silence_when_confident": - continue + s = self._settings + params: dict[str, Any] = {} + + # Init-only audio config + params["sample_rate"] = self.sample_rate + params["encoding"] = self._encoding + + # Map model → speech_model (AssemblyAI API naming) + if s.model is not None: + params["speech_model"] = s.model + + # Settings fields (skip None values) + optional_fields = { + "formatted_finals": s.formatted_finals, + "word_finalization_max_wait_time": s.word_finalization_max_wait_time, + "end_of_turn_confidence_threshold": s.end_of_turn_confidence_threshold, + "min_turn_silence": s.min_turn_silence, + "max_turn_silence": s.max_turn_silence, + "prompt": s.prompt, + "language_detection": s.language_detection, + "format_turns": s.format_turns, + "speaker_labels": s.speaker_labels, + } + + for k, v in optional_fields.items(): if v is not None: - if k == "keyterms_prompt": - params[k] = json.dumps(v) - elif isinstance(v, bool): + if isinstance(v, bool): params[k] = str(v).lower() else: params[k] = v + # Special handling for keyterms_prompt (needs JSON encoding) + if s.keyterms_prompt is not None: + params["keyterms_prompt"] = json.dumps(s.keyterms_prompt) + if params: query_string = urlencode(params) return f"{self._api_endpoint_base_url}?{query_string}" @@ -717,7 +707,7 @@ class AssemblyAISTTService(WebsocketSTTService): # Determine if this is a final turn from AssemblyAI is_final_turn = message.end_of_turn and ( - not self._settings.connection_params.format_turns or message.turn_is_formatted + not self._settings.format_turns or message.turn_is_formatted ) if self._vad_force_turn_endpoint: diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index 451c8a695..dd2f2f97b 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -14,7 +14,7 @@ import json import os import random import string -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -29,7 +29,7 @@ from pipecat.frames.frames import ( TranscriptionFrame, ) from pipecat.services.aws.utils import build_event_message, decode_event, get_presigned_url -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _warn_deprecated_param from pipecat.services.stt_latency import AWS_TRANSCRIBE_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -47,21 +47,9 @@ except ModuleNotFoundError as e: @dataclass class AWSTranscribeSTTSettings(STTSettings): - """Settings for the AWS Transcribe STT service. + """Settings for the AWS Transcribe STT service.""" - Parameters: - sample_rate: Audio sample rate in Hz (8000 or 16000). - media_encoding: Audio encoding format (e.g. "linear16"). - number_of_channels: Number of audio channels. - show_speaker_label: Whether to show speaker labels. - enable_channel_identification: Whether to enable channel identification. - """ - - sample_rate: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - media_encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - number_of_channels: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - show_speaker_label: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - enable_channel_identification: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class AWSTranscribeSTTService(WebsocketSTTService): @@ -94,11 +82,9 @@ class AWSTranscribeSTTService(WebsocketSTTService): aws_access_key_id: AWS access key ID. If None, uses AWS_ACCESS_KEY_ID environment variable. aws_session_token: AWS session token for temporary credentials. If None, uses AWS_SESSION_TOKEN environment variable. region: AWS region for the service. - sample_rate: Audio sample rate in Hz. Must be 8000 or 16000. - - .. deprecated:: 0.0.105 - Use ``settings=AWSTranscribeSTTSettings(sample_rate=...)`` instead. - + sample_rate: Audio sample rate in Hz. If None, uses the pipeline sample rate. + AWS Transcribe only supports 8000 or 16000 Hz; other values are + clamped to 16000 Hz at connect time. language: Language for transcription. .. deprecated:: 0.0.105 @@ -113,17 +99,9 @@ class AWSTranscribeSTTService(WebsocketSTTService): # 1. Initialize default_settings with hardcoded defaults default_settings = AWSTranscribeSTTSettings( language=self.language_to_service_language(Language.EN) or "en-US", - sample_rate=16000, - media_encoding="linear16", - number_of_channels=1, - show_speaker_label=False, - enable_channel_identification=False, ) # 2. Apply direct init arg overrides (deprecated) - if sample_rate is not None: - _warn_deprecated_param("sample_rate", AWSTranscribeSTTSettings, "sample_rate") - default_settings.sample_rate = sample_rate if language is not None: _warn_deprecated_param("language", AWSTranscribeSTTSettings, "language") default_settings.language = self.language_to_service_language(language) or "en-US" @@ -135,17 +113,17 @@ class AWSTranscribeSTTService(WebsocketSTTService): default_settings.apply_update(settings) super().__init__( + sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, settings=default_settings, **kwargs, ) - # Validate sample rate - AWS Transcribe only supports 8000 Hz or 16000 Hz - if default_settings.sample_rate not in [8000, 16000]: - logger.warning( - f"AWS Transcribe only supports 8000 Hz or 16000 Hz sample rates. Converting from {default_settings.sample_rate} Hz to 16000 Hz." - ) - self._settings.sample_rate = 16000 + # Init-only connection config (not runtime-updatable). + self._media_encoding = "linear16" + self._number_of_channels = 1 + self._show_speaker_label = False + self._enable_channel_identification = False self._credentials = { "aws_access_key_id": aws_access_key_id or os.getenv("AWS_ACCESS_KEY_ID"), @@ -293,6 +271,15 @@ class AWSTranscribeSTTService(WebsocketSTTService): if not language_code: raise ValueError(f"Unsupported language: {language_code}") + # Validate sample rate — AWS Transcribe only supports 8000 or 16000 Hz + connect_sample_rate = self.sample_rate + if connect_sample_rate not in (8000, 16000): + logger.warning( + f"AWS Transcribe only supports 8000 Hz or 16000 Hz sample rates. " + f"Converting from {connect_sample_rate} Hz to 16000 Hz." + ) + connect_sample_rate = 16000 + # Generate random websocket key websocket_key = "".join( random.choices( @@ -318,14 +305,14 @@ class AWSTranscribeSTTService(WebsocketSTTService): }, language_code=language_code, media_encoding=self.get_service_encoding( - self._settings.media_encoding + self._media_encoding ), # Convert to AWS format - sample_rate=self._settings.sample_rate, - number_of_channels=self._settings.number_of_channels, + sample_rate=connect_sample_rate, + number_of_channels=self._number_of_channels, enable_partial_results_stabilization=True, partial_results_stability="high", - show_speaker_label=self._settings.show_speaker_label, - enable_channel_identification=self._settings.enable_channel_identification, + show_speaker_label=self._show_speaker_label, + enable_channel_identification=self._enable_channel_identification, ) logger.debug(f"{self} Connecting to WebSocket with URL: {presigned_url[:100]}...") diff --git a/src/pipecat/services/azure/stt.py b/src/pipecat/services/azure/stt.py index 2527f0bb0..8e6204c5e 100644 --- a/src/pipecat/services/azure/stt.py +++ b/src/pipecat/services/azure/stt.py @@ -11,7 +11,7 @@ Speech SDK for real-time audio transcription. """ import asyncio -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -26,7 +26,7 @@ from pipecat.frames.frames import ( TranscriptionFrame, ) from pipecat.services.azure.common import language_to_azure_language -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _warn_deprecated_param from pipecat.services.stt_latency import AZURE_TTFS_P99 from pipecat.services.stt_service import STTService from pipecat.transcriptions.language import Language @@ -53,15 +53,9 @@ except ModuleNotFoundError as e: @dataclass class AzureSTTSettings(STTSettings): - """Settings for the Azure STT service. + """Settings for the Azure STT service.""" - Parameters: - region: Azure region for the Speech service. - sample_rate: Audio sample rate in Hz. - """ - - region: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - sample_rate: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class AzureSTTService(STTService): @@ -110,9 +104,7 @@ class AzureSTTService(STTService): # 1. Initialize default_settings with hardcoded defaults default_settings = AzureSTTSettings( model=None, - region=region, language=language_to_azure_language(Language.EN_US), - sample_rate=sample_rate, ) # 2. Apply direct init arg overrides (deprecated) diff --git a/src/pipecat/services/cartesia/stt.py b/src/pipecat/services/cartesia/stt.py index aa66b102e..67416016e 100644 --- a/src/pipecat/services/cartesia/stt.py +++ b/src/pipecat/services/cartesia/stt.py @@ -12,7 +12,7 @@ the Cartesia Live transcription API for real-time speech recognition. import json import urllib.parse -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -28,7 +28,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _warn_deprecated_param from pipecat.services.stt_latency import CARTESIA_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language @@ -46,20 +46,17 @@ except ModuleNotFoundError as e: @dataclass class CartesiaSTTSettings(STTSettings): - """Settings for the Cartesia STT service. + """Settings for the Cartesia STT service.""" - Parameters: - encoding: Audio encoding format (e.g. ``"pcm_s16le"``). - """ - - encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class CartesiaLiveOptions: """Configuration options for Cartesia Live STT service. - Manages transcription parameters including model selection, language, - audio encoding format, and sample rate settings. + .. deprecated:: 0.0.105 + Use ``settings=CartesiaSTTSettings(...)`` for model/language and + direct ``__init__`` parameters for encoding/sample_rate instead. """ def __init__( @@ -156,7 +153,8 @@ class CartesiaSTTService(WebsocketSTTService): *, api_key: str, base_url: str = "", - sample_rate: int = 16000, + encoding: str = "pcm_s16le", + sample_rate: Optional[int] = None, live_options: Optional[CartesiaLiveOptions] = None, settings: Optional[CartesiaSTTSettings] = None, ttfs_p99_latency: Optional[float] = CARTESIA_TTFS_P99, @@ -167,44 +165,42 @@ class CartesiaSTTService(WebsocketSTTService): Args: api_key: Authentication key for Cartesia API. base_url: Custom API endpoint URL. If empty, uses default. - sample_rate: Audio sample rate in Hz. Defaults to 16000. + encoding: Audio encoding format. Defaults to "pcm_s16le". + sample_rate: Audio sample rate in Hz. If None, uses the pipeline + sample rate. live_options: Configuration options for transcription service. - settings: Runtime-updatable settings. When provided alongside - ``live_options``, ``settings`` values take precedence. + + .. deprecated:: 0.0.105 + Use ``settings=CartesiaSTTSettings(...)`` for model/language + and direct init parameters for encoding/sample_rate instead. + + settings: Runtime-updatable settings. When provided alongside deprecated + parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to parent STTService. """ - sample_rate = sample_rate or (live_options.sample_rate if live_options else None) - # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaSTTSettings( model="ink-whisper", language=Language.EN.value, - encoding="pcm_s16le", ) - # 2. (no deprecated direct args for this service) - - # 3. Apply live_options overrides — only if settings not provided + # 2. Apply live_options overrides — only if settings not provided if live_options is not None: _warn_deprecated_param("live_options", CartesiaSTTSettings) if not settings: - lo_dict = live_options.to_dict() - # Filter out "None" string values - lo_dict = { - k: v - for k, v in lo_dict.items() - if (not isinstance(v, str) or v != "None") and k != "sample_rate" - } - if "model" in lo_dict: - default_settings.model = lo_dict["model"] - if "language" in lo_dict: - default_settings.language = lo_dict["language"] - if "encoding" in lo_dict: - default_settings.encoding = lo_dict["encoding"] + if live_options.sample_rate and sample_rate is None: + sample_rate = live_options.sample_rate + if live_options.encoding: + encoding = live_options.encoding + if live_options.model: + default_settings.model = live_options.model + if live_options.language: + lang = live_options.language + default_settings.language = lang.value if isinstance(lang, Language) else lang - # 4. Apply settings delta (canonical API, always wins) + # 3. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -221,6 +217,9 @@ class CartesiaSTTService(WebsocketSTTService): self._base_url = base_url or "api.cartesia.ai" self._receive_task = None + # Init-only audio config (not runtime-updatable). + self._encoding = encoding + def can_generate_metrics(self) -> bool: """Check if the service can generate processing metrics. @@ -339,7 +338,7 @@ class CartesiaSTTService(WebsocketSTTService): params = { "model": self._settings.model, "language": self._settings.language, - "encoding": self._settings.encoding, + "encoding": self._encoding, "sample_rate": str(self.sample_rate), } ws_url = f"wss://{self._base_url}/stt/websocket?{urllib.parse.urlencode(params)}" diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index ae5364f60..1e7f135b2 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -81,20 +81,16 @@ class DeepgramFluxSTTSettings(STTSettings): eot_timeout_ms: Time in ms after speech to finish a turn regardless of EOT confidence (default 5000). keyterm: Keyterms to boost recognition accuracy for specialized terminology. - mip_opt_out: Opt out of the Deepgram Model Improvement Program (default False). tag: Tags to label requests for identification during usage reporting. min_confidence: Minimum confidence required to create a TranscriptionFrame. - encoding: Audio encoding format (e.g. ``"linear16"``). """ eager_eot_threshold: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) eot_threshold: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) eot_timeout_ms: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) keyterm: list | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - mip_opt_out: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) tag: list | _NotGiven = field(default_factory=lambda: NOT_GIVEN) min_confidence: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class DeepgramFluxSTTService(WebsocketSTTService): @@ -158,6 +154,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): api_key: str, url: str = "wss://api.deepgram.com/v2/listen", sample_rate: Optional[int] = None, + mip_opt_out: Optional[bool] = None, model: Optional[str] = None, flux_encoding: str = "linear16", params: Optional[InputParams] = None, @@ -170,7 +167,9 @@ class DeepgramFluxSTTService(WebsocketSTTService): Args: api_key: Deepgram API key for authentication. Required for API access. url: WebSocket URL for the Deepgram Flux API. Defaults to the preview endpoint. - sample_rate: Audio sample rate in Hz. If None, uses the rate from params or 16000. + sample_rate: Audio sample rate in Hz. If None, uses the pipeline + sample rate. + mip_opt_out: Opt out of the Deepgram Model Improvement Program. model: Deepgram Flux model to use for transcription. .. deprecated:: 0.0.105 @@ -221,12 +220,10 @@ class DeepgramFluxSTTService(WebsocketSTTService): default_settings = DeepgramFluxSTTSettings( model="flux-general-en", language=Language.EN, - encoding=flux_encoding, eager_eot_threshold=None, eot_threshold=None, eot_timeout_ms=None, keyterm=[], - mip_opt_out=None, tag=[], min_confidence=None, ) @@ -244,9 +241,10 @@ class DeepgramFluxSTTService(WebsocketSTTService): default_settings.eot_threshold = params.eot_threshold default_settings.eot_timeout_ms = params.eot_timeout_ms default_settings.keyterm = params.keyterm or [] - default_settings.mip_opt_out = params.mip_opt_out default_settings.tag = params.tag or [] default_settings.min_confidence = params.min_confidence + if params.mip_opt_out is not None: + mip_opt_out = params.mip_opt_out # 4. Apply settings delta (canonical API, always wins) if settings is not None: @@ -261,8 +259,11 @@ class DeepgramFluxSTTService(WebsocketSTTService): self._api_key = api_key self._url = url self._should_interrupt = should_interrupt + self._encoding = flux_encoding + self._mip_opt_out = mip_opt_out self._websocket_url = None self._receive_task = None + # Flux event handlers self._register_event_handler("on_start_of_turn") self._register_event_handler("on_turn_resumed") @@ -448,7 +449,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): url_params = [ f"model={self._settings.model}", f"sample_rate={self.sample_rate}", - f"encoding={self._settings.encoding}", + f"encoding={self._encoding}", ] if self._settings.eager_eot_threshold is not None: @@ -460,8 +461,8 @@ class DeepgramFluxSTTService(WebsocketSTTService): if self._settings.eot_timeout_ms is not None: url_params.append(f"eot_timeout_ms={self._settings.eot_timeout_ms}") - if self._settings.mip_opt_out is not None: - url_params.append(f"mip_opt_out={str(self._settings.mip_opt_out).lower()}") + if self._mip_opt_out is not None: + url_params.append(f"mip_opt_out={str(self._mip_opt_out).lower()}") # Add keyterm parameters (can have multiple) for keyterm in self._settings.keyterm: diff --git a/src/pipecat/services/deepgram/sagemaker/stt.py b/src/pipecat/services/deepgram/sagemaker/stt.py index d7a867e38..4f29b227f 100644 --- a/src/pipecat/services/deepgram/sagemaker/stt.py +++ b/src/pipecat/services/deepgram/sagemaker/stt.py @@ -14,7 +14,7 @@ languages, and various Deepgram features. import asyncio import json -from dataclasses import dataclass, field +from dataclasses import dataclass, fields from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -32,32 +32,23 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.aws.sagemaker.bidi_client import SageMakerBidiClient -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.deepgram.stt import DeepgramSTTSettings, 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 from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_stt -try: - from deepgram import LiveOptions -except ModuleNotFoundError as e: - logger.error(f"Exception: {e}") - logger.error( - "In order to use DeepgramSageMakerSTTService, you need to `pip install pipecat-ai[deepgram,sagemaker]`." - ) - raise Exception(f"Missing module: {e}") - @dataclass -class DeepgramSageMakerSTTSettings(STTSettings): +class DeepgramSageMakerSTTSettings(DeepgramSTTSettings): """Settings for the Deepgram SageMaker STT service. - Parameters: - live_options: Deepgram LiveOptions for the SageMaker connection. + Inherits all fields from :class:`DeepgramSTTSettings`. """ - live_options: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class DeepgramSageMakerSTTService(STTService): @@ -72,14 +63,13 @@ class DeepgramSageMakerSTTService(STTService): - AWS credentials configured (via environment variables, AWS CLI, or instance metadata) - A deployed SageMaker endpoint with Deepgram model: https://developers.deepgram.com/docs/deploy-amazon-sagemaker - - Deepgram SDK for LiveOptions configuration Example:: stt = DeepgramSageMakerSTTService( endpoint_name="my-deepgram-endpoint", region="us-east-2", - live_options=LiveOptions( + settings=DeepgramSageMakerSTTSettings( model="nova-3", language="en", interim_results=True, @@ -95,7 +85,11 @@ class DeepgramSageMakerSTTService(STTService): *, endpoint_name: str, region: str, + encoding: str = "linear16", + channels: int = 1, + multichannel: bool = False, sample_rate: Optional[int] = None, + mip_opt_out: Optional[bool] = None, live_options: Optional[LiveOptions] = None, settings: Optional[DeepgramSageMakerSTTSettings] = None, ttfs_p99_latency: Optional[float] = DEEPGRAM_SAGEMAKER_TTFS_P99, @@ -107,11 +101,20 @@ class DeepgramSageMakerSTTService(STTService): endpoint_name: Name of the SageMaker endpoint with Deepgram model deployed (e.g., "my-deepgram-nova-3-endpoint"). region: AWS region where the endpoint is deployed (e.g., "us-east-2"). - sample_rate: Audio sample rate in Hz. If None, uses value from - live_options or defaults to the value from StartFrame. - live_options: Deepgram LiveOptions configuration. Treated as a - delta from a set of sensible defaults — only the fields you - set are overridden; all others keep their default values. + encoding: Audio encoding format. Defaults to "linear16". + channels: Number of audio channels. Defaults to 1. + multichannel: Transcribe each audio channel independently. + Defaults to False. + sample_rate: Audio sample rate in Hz. If None, uses the pipeline + sample rate. + mip_opt_out: Opt out of Deepgram model improvement program. + live_options: Legacy configuration options. + + .. deprecated:: 0.0.105 + Use ``settings=DeepgramSageMakerSTTSettings(...)`` for + runtime-updatable fields and direct init parameters for + connection-level config. + settings: Runtime-updatable settings. When provided alongside ``live_options``, ``settings`` values take precedence (applied after the ``live_options`` merge). @@ -119,43 +122,63 @@ class DeepgramSageMakerSTTService(STTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the parent STTService. """ - sample_rate = sample_rate or (live_options.sample_rate if live_options else None) - - default_options = LiveOptions( - encoding="linear16", - language=Language.EN, - model="nova-3", - channels=1, - interim_results=True, - punctuate=True, - ) - # 1. Initialize default_settings with hardcoded defaults default_settings = DeepgramSageMakerSTTSettings( model="nova-3", language=Language.EN, - live_options=default_options, + detect_entities=False, + diarize=False, + dictation=False, + endpointing=None, + interim_results=True, + keyterm=None, + keywords=None, + numerals=False, + profanity_filter=True, + punctuate=True, + redact=None, + replace=None, + search=None, + smart_format=False, + utterance_end_ms=None, + vad_events=False, ) - # 2. (no deprecated direct args like model= for this service) - - # 3. Apply live_options overrides — only if settings not provided + # 2. Apply live_options overrides — only if settings not provided if live_options is not None: _warn_deprecated_param("live_options", DeepgramSageMakerSTTSettings) if not settings: - # Merge user live_options onto defaults - merged_dict = {**default_options.to_dict(), **live_options.to_dict()} - merged_live_options = LiveOptions(**merged_dict) - default_settings.live_options = merged_live_options - if hasattr(live_options, "model") and live_options.model is not None: - default_settings.model = live_options.model - if hasattr(live_options, "language") and live_options.language is not None: - default_settings.language = live_options.language + # Extract init-only fields from live_options + if live_options.sample_rate is not None and sample_rate is None: + sample_rate = live_options.sample_rate + if live_options.encoding is not None: + encoding = live_options.encoding + if live_options.channels is not None: + channels = live_options.channels + if live_options.multichannel is not None: + multichannel = live_options.multichannel + if live_options.mip_opt_out is not None: + mip_opt_out = live_options.mip_opt_out - # 4. Apply settings delta (canonical API, always wins) + # Build settings delta from remaining fields + init_only = { + "sample_rate", + "encoding", + "channels", + "multichannel", + "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) + default_settings.apply_update(delta) + + # 3. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) + # Sync extra to top-level fields so self._settings is unambiguous + default_settings._sync_extra_to_fields() + super().__init__( sample_rate=sample_rate, ttfs_p99_latency=ttfs_p99_latency, @@ -166,6 +189,12 @@ class DeepgramSageMakerSTTService(STTService): self._endpoint_name = endpoint_name self._region = region + # Init-only connection config (not runtime-updatable). + self._encoding = encoding + self._channels = channels + self._multichannel = multichannel + self._mip_opt_out = mip_opt_out + self._client: Optional[SageMakerBidiClient] = None self._response_task: Optional[asyncio.Task] = None self._keepalive_task: Optional[asyncio.Task] = None @@ -185,6 +214,10 @@ class DeepgramSageMakerSTTService(STTService): if not changed: return changed + # Sync extra to fields after the update so self._settings stays unambiguous + if isinstance(self._settings, DeepgramSTTSettings): + self._settings._sync_extra_to_fields() + # TODO: someday we could reconnect here to apply updated settings. # Code might look something like the below: # await self._disconnect() @@ -237,6 +270,43 @@ class DeepgramSageMakerSTTService(STTService): yield ErrorFrame(error=f"Unknown error occurred: {e}") yield None + def _build_query_string(self) -> str: + """Build query string from current settings and init-only connection config.""" + params = {} + s = self._settings + + # Declared Deepgram-specific fields from settings + for f in fields(s): + if f.name in ("model", "language", "extra") or f.name.startswith("_"): + continue + value = getattr(s, f.name) + if not is_given(value) or value is None: + continue + params[f.name] = str(value).lower() if isinstance(value, bool) else str(value) + + # model and language + if is_given(s.model) and s.model is not None: + params["model"] = str(s.model) + if is_given(s.language) and s.language is not None: + params["language"] = str(s.language) + + # Init-only connection config + params["encoding"] = self._encoding + params["channels"] = str(self._channels) + params["multichannel"] = str(self._multichannel).lower() + params["sample_rate"] = str(self.sample_rate) + + if self._mip_opt_out is not None: + params["mip_opt_out"] = str(self._mip_opt_out).lower() + + # Any remaining values in extra + if s.extra: + for key, value in s.extra.items(): + if value is not None: + params[key] = str(value).lower() if isinstance(value, bool) else str(value) + + return "&".join(f"{k}={v}" for k, v in params.items()) + async def _connect(self): """Connect to the SageMaker endpoint and start the BiDi session. @@ -246,21 +316,7 @@ class DeepgramSageMakerSTTService(STTService): """ logger.debug("Connecting to Deepgram on SageMaker...") - live_options = LiveOptions( - **{**self._settings.live_options.to_dict(), "sample_rate": self.sample_rate} - ) - - # Build query string from live_options, converting booleans to strings - query_params = {} - for key, value in live_options.to_dict().items(): - if value is not None: - # Convert boolean values to lowercase strings for Deepgram API - if isinstance(value, bool): - query_params[key] = str(value).lower() - else: - query_params[key] = str(value) - - query_string = "&".join(f"{k}={v}" for k, v in query_params.items()) + query_string = self._build_query_string() # Create BiDi client self._client = SageMakerBidiClient( diff --git a/src/pipecat/services/deepgram/sagemaker/tts.py b/src/pipecat/services/deepgram/sagemaker/tts.py index 0129abedb..3693178a1 100644 --- a/src/pipecat/services/deepgram/sagemaker/tts.py +++ b/src/pipecat/services/deepgram/sagemaker/tts.py @@ -187,8 +187,7 @@ class DeepgramSageMakerTTSService(TTSService): logger.debug("Connecting to Deepgram TTS on SageMaker...") query_string = ( - f"model={self._settings.voice}&encoding={self._settings.encoding}" - f"&sample_rate={self.sample_rate}" + f"model={self._settings.voice}&encoding={self._encoding}&sample_rate={self.sample_rate}" ) self._client = SageMakerBidiClient( diff --git a/src/pipecat/services/deepgram/stt.py b/src/pipecat/services/deepgram/stt.py index f311567aa..d377fe69a 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -8,7 +8,7 @@ import asyncio from dataclasses import dataclass, field, fields -from typing import Any, AsyncGenerator, Dict, Optional +from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -26,7 +26,6 @@ from pipecat.frames.frames import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.settings import ( - _S, NOT_GIVEN, STTSettings, _NotGiven, @@ -57,8 +56,11 @@ class LiveOptions: """Deepgram live transcription options. Compatibility wrapper that mirrors the ``LiveOptions`` class removed in - deepgram-sdk v6. Pass this to :class:`DeepgramSTTService` via the - ``live_options`` constructor argument. + deepgram-sdk v6. + + .. deprecated:: 0.0.105 + Use ``settings=DeepgramSTTSettings(...)`` for runtime-updatable fields + and direct ``__init__`` parameters for connection-level config instead. """ def __init__( @@ -179,29 +181,42 @@ class DeepgramSTTSettings(STTSettings): ``model`` and ``language`` are inherited from ``STTSettings`` / ``ServiceSettings``. Additional Deepgram connection params may - be passed in through extra ``extra`` (also inherited). + be passed in through ``extra`` (also inherited). Parameters: - channels: Number of audio channels. + detect_entities: Enable named entity detection. diarize: Enable speaker diarization. - encoding: Audio encoding (e.g. ``"linear16"``). + dictation: Enable dictation mode (converts commands to punctuation). endpointing: Endpointing sensitivity in ms, or ``False`` to disable. interim_results: Whether to emit interim transcriptions. + keyterm: Keyterms to boost (str or list of str). + keywords: Keywords to boost (str or list of str). + numerals: Convert spoken numbers to numerals. profanity_filter: Filter profanity from transcripts. punctuate: Add punctuation to transcripts. + redact: Redact sensitive information (str or list of redaction types). + replace: Word replacement rules (str or list). + search: Search terms to highlight (str or list of str). smart_format: Apply smart formatting to transcripts. + utterance_end_ms: Silence duration in ms before an utterance-end event. vad_events: Enable Deepgram VAD speech-started / utterance-end events. - extra: Additional Deepgram query parameters not covered by the fields above. """ - channels: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + detect_entities: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) diarize: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - encoding: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + dictation: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) endpointing: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) interim_results: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + keyterm: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + keywords: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + numerals: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) profanity_filter: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) punctuate: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + redact: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + replace: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + search: Any | _NotGiven = field(default_factory=lambda: NOT_GIVEN) smart_format: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + utterance_end_ms: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) vad_events: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) def _sync_extra_to_fields(self) -> None: @@ -259,9 +274,16 @@ class DeepgramSTTService(STTService): api_key: str, url: str = "", base_url: str = "", + encoding: str = "linear16", + channels: int = 1, + multichannel: bool = False, sample_rate: Optional[int] = None, + callback: Optional[str] = None, + callback_method: Optional[str] = None, + tag: Optional[Any] = None, + mip_opt_out: Optional[bool] = None, live_options: Optional[LiveOptions] = None, - addons: Optional[Dict] = None, + addons: Optional[dict] = None, should_interrupt: bool = True, settings: Optional[DeepgramSTTSettings] = None, ttfs_p99_latency: Optional[float] = DEEPGRAM_TTFS_P99, @@ -277,12 +299,25 @@ class DeepgramSTTService(STTService): Parameter `url` is deprecated, use `base_url` instead. base_url: Custom Deepgram API base URL. - sample_rate: Audio sample rate. If None, uses default or live_options value. - live_options: :class: LiveOptions configuration. Treated as a - delta from a set of sensible defaults — only the fields you - set are overridden; all others keep their default values. + encoding: Audio encoding format. Defaults to "linear16". + channels: Number of audio channels. Defaults to 1. + multichannel: Transcribe each audio channel independently. + Defaults to False. + sample_rate: Audio sample rate in Hz. If None, uses the pipeline + sample rate. + callback: Callback URL for async transcription delivery. + callback_method: HTTP method for the callback (``"GET"`` or ``"POST"``). + tag: Custom billing tag. + mip_opt_out: Opt out of Deepgram model improvement program. + live_options: Legacy configuration options. + + .. deprecated:: 0.0.105 + Use ``settings=DeepgramSTTSettings(...)`` for runtime-updatable + fields and direct init parameters for connection-level config. + addons: Additional Deepgram features to enable. - should_interrupt: Determine whether the bot should be interrupted when Deepgram VAD events are enabled and the system detects that the user is speaking. + should_interrupt: Whether to interrupt the bot when Deepgram VAD + detects the user is speaking. .. deprecated:: 0.0.99 This parameter will be removed along with `vad_events` support. @@ -297,8 +332,6 @@ class DeepgramSTTService(STTService): Note: The `vad_events` option in LiveOptions is deprecated as of version 0.0.99 and will be removed in a future version. Please use the Silero VAD instead. """ - sample_rate = sample_rate or (live_options.sample_rate if live_options else None) - if url: import warnings @@ -314,30 +347,62 @@ class DeepgramSTTService(STTService): default_settings = DeepgramSTTSettings( model="nova-3-general", language=Language.EN, - encoding="linear16", - channels=1, - interim_results=True, - smart_format=False, - punctuate=True, - profanity_filter=True, - vad_events=False, + detect_entities=False, diarize=False, + dictation=False, endpointing=None, + interim_results=True, + keyterm=None, + keywords=None, + numerals=False, + profanity_filter=True, + punctuate=True, + redact=None, + replace=None, + search=None, + smart_format=False, + utterance_end_ms=None, + vad_events=False, ) - # 2. (no deprecated direct args like model= for this service) - - # 3. Apply live_options overrides — only if settings not provided + # 2. Apply live_options overrides — only if settings not provided if live_options is not None: _warn_deprecated_param("live_options", DeepgramSTTSettings) if not settings: - lo_dict = live_options.to_dict() - delta = DeepgramSTTSettings.from_mapping( - {k: v for k, v in lo_dict.items() if k != "sample_rate"} - ) + # Extract init-only fields from live_options + if live_options.sample_rate is not None and sample_rate is None: + sample_rate = live_options.sample_rate + if live_options.encoding is not None: + encoding = live_options.encoding + if live_options.channels is not None: + channels = live_options.channels + if live_options.callback is not None: + callback = live_options.callback + if live_options.callback_method is not None: + callback_method = live_options.callback_method + if live_options.tag is not None: + tag = live_options.tag + if live_options.mip_opt_out is not None: + mip_opt_out = live_options.mip_opt_out + if live_options.multichannel is not None: + multichannel = live_options.multichannel + + # Build settings delta from remaining fields + init_only = { + "sample_rate", + "encoding", + "channels", + "multichannel", + "callback", + "callback_method", + "tag", + "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) default_settings.apply_update(delta) - # 4. Apply settings delta (canonical API, always wins) + # 3. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -353,6 +418,13 @@ class DeepgramSTTService(STTService): self._addons = addons self._should_interrupt = should_interrupt + self._encoding = encoding + self._channels = channels + self._multichannel = multichannel + self._callback = callback + self._callback_method = callback_method + self._tag = tag + self._mip_opt_out = mip_opt_out if self._settings.vad_events: import warnings @@ -487,14 +559,26 @@ class DeepgramSTTService(STTService): if is_given(s.language) and s.language is not None: kwargs["language"] = str(s.language) + # Init-only connection config + kwargs["encoding"] = self._encoding + kwargs["channels"] = str(self._channels) + kwargs["multichannel"] = str(self._multichannel).lower() + kwargs["sample_rate"] = str(self.sample_rate) + + if self._callback is not None: + kwargs["callback"] = self._callback + if self._callback_method is not None: + kwargs["callback_method"] = self._callback_method + if self._tag is not None: + kwargs["tag"] = str(self._tag) + if self._mip_opt_out is not None: + kwargs["mip_opt_out"] = str(self._mip_opt_out).lower() + # Any remaining values in extra (that didn't map to declared fields) for key, value in s.extra.items(): if value is not None: kwargs[key] = str(value).lower() if isinstance(value, bool) else str(value) - # Always inject sample_rate from service level. - kwargs["sample_rate"] = str(self.sample_rate) - if self._addons: for key, value in self._addons.items(): kwargs[key] = str(value) diff --git a/src/pipecat/services/elevenlabs/stt.py b/src/pipecat/services/elevenlabs/stt.py index 2d75abff9..f9899f7f1 100644 --- a/src/pipecat/services/elevenlabs/stt.py +++ b/src/pipecat/services/elevenlabs/stt.py @@ -182,7 +182,8 @@ class ElevenLabsSTTSettings(STTSettings): """Settings for the ElevenLabs file-based STT service. Parameters: - tag_audio_events: Whether to include audio event tags in transcription. + tag_audio_events: Whether to include audio events like (laughter), + (coughing) in the transcription. """ tag_audio_events: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -195,7 +196,6 @@ class ElevenLabsRealtimeSTTSettings(STTSettings): See ``ElevenLabsRealtimeSTTService.InputParams`` for detailed descriptions. Parameters: - commit_strategy: How to segment speech - manual (Pipecat VAD) or vad (ElevenLabs VAD). vad_silence_threshold_secs: Seconds of silence before VAD commits (0.3-3.0). vad_threshold: VAD sensitivity (0.1-0.9, lower is more sensitive). min_speech_duration_ms: Minimum speech duration for VAD (50-2000ms). @@ -205,7 +205,6 @@ class ElevenLabsRealtimeSTTSettings(STTSettings): include_language_detection: Whether to include language detection in transcripts. """ - commit_strategy: CommitStrategy | _NotGiven = field(default_factory=lambda: NOT_GIVEN) vad_silence_threshold_secs: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) vad_threshold: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) min_speech_duration_ms: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -495,6 +494,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): *, api_key: str, base_url: str = "api.elevenlabs.io", + commit_strategy: CommitStrategy = CommitStrategy.MANUAL, model: Optional[str] = None, sample_rate: Optional[int] = None, params: Optional[InputParams] = None, @@ -507,6 +507,9 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): Args: api_key: ElevenLabs API key for authentication. base_url: Base URL for ElevenLabs WebSocket API. + commit_strategy: How to segment speech — ``CommitStrategy.MANUAL`` + (Pipecat VAD) or ``CommitStrategy.VAD`` (ElevenLabs VAD). + Defaults to ``CommitStrategy.MANUAL``. model: Model ID for transcription. .. deprecated:: 0.0.105 @@ -528,7 +531,6 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): default_settings = ElevenLabsRealtimeSTTSettings( model="scribe_v2_realtime", language=None, - commit_strategy=CommitStrategy.MANUAL, vad_silence_threshold_secs=None, vad_threshold=None, min_speech_duration_ms=None, @@ -548,7 +550,8 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): _warn_deprecated_param("params", ElevenLabsRealtimeSTTSettings) if not settings: default_settings.language = params.language_code - default_settings.commit_strategy = params.commit_strategy + if params.commit_strategy != CommitStrategy.MANUAL: + commit_strategy = params.commit_strategy default_settings.vad_silence_threshold_secs = params.vad_silence_threshold_secs default_settings.vad_threshold = params.vad_threshold default_settings.min_speech_duration_ms = params.min_speech_duration_ms @@ -575,6 +578,9 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): self._audio_format = "" # initialized in start() self._receive_task = None + # Init-only config (not runtime-updatable). + self._commit_strategy = commit_strategy + self._connected_event = asyncio.Event() self._connected_event.set() @@ -651,7 +657,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): await self._start_metrics() elif isinstance(frame, VADUserStoppedSpeakingFrame): # Send commit when user stops speaking (manual commit mode) - if self._settings.commit_strategy == CommitStrategy.MANUAL: + if self._commit_strategy == CommitStrategy.MANUAL: if self._websocket and self._websocket.state is State.OPEN: try: commit_message = { @@ -754,7 +760,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): params.append(f"language_code={self._settings.language}") params.append(f"audio_format={self._audio_format}") - params.append(f"commit_strategy={self._settings.commit_strategy.value}") + params.append(f"commit_strategy={self._commit_strategy.value}") # Add optional parameters if self._settings.include_timestamps: @@ -771,7 +777,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): ) # Add VAD parameters if using VAD commit strategy and values are specified - if self._settings.commit_strategy == CommitStrategy.VAD: + if self._commit_strategy == CommitStrategy.VAD: if self._settings.vad_silence_threshold_secs is not None: params.append( f"vad_silence_threshold_secs={self._settings.vad_silence_threshold_secs}" @@ -931,7 +937,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): await self._handle_transcription(text, True, language) - finalized = self._settings.commit_strategy == CommitStrategy.MANUAL + finalized = self._commit_strategy == CommitStrategy.MANUAL await self.push_frame( TranscriptionFrame( @@ -975,7 +981,7 @@ class ElevenLabsRealtimeSTTService(WebsocketSTTService): await self._handle_transcription(text, True, language) - finalized = self._settings.commit_strategy == CommitStrategy.MANUAL + finalized = self._commit_strategy == CommitStrategy.MANUAL # This message is sent after committed_transcript when include_timestamps=true. # It contains the full transcript data including text and word-level timestamps. diff --git a/src/pipecat/services/fal/stt.py b/src/pipecat/services/fal/stt.py index 4428599b1..18b8ed85c 100644 --- a/src/pipecat/services/fal/stt.py +++ b/src/pipecat/services/fal/stt.py @@ -12,7 +12,7 @@ transcription using segmented audio processing. import base64 import os -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import AsyncGenerator, Optional import aiohttp @@ -20,7 +20,7 @@ from loguru import logger from pydantic import BaseModel from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _warn_deprecated_param from pipecat.services.stt_latency import FAL_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -143,18 +143,9 @@ def language_to_fal_language(language: Language) -> Optional[str]: @dataclass class FalSTTSettings(STTSettings): - """Settings for the Fal Wizper STT service. + """Settings for the Fal Wizper STT service.""" - Parameters: - task: Task to perform ('transcribe' or 'translate'). Defaults to - 'transcribe'. - chunk_level: Level of chunking ('segment'). Defaults to 'segment'. - version: Version of Wizper model to use. Defaults to '3'. - """ - - task: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - chunk_level: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - version: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class FalSTTService(SegmentedSTTService): @@ -189,6 +180,9 @@ class FalSTTService(SegmentedSTTService): *, api_key: Optional[str] = None, aiohttp_session: Optional[aiohttp.ClientSession] = None, + task: str = "transcribe", + chunk_level: str = "segment", + version: str = "3", sample_rate: Optional[int] = None, params: Optional[InputParams] = None, settings: Optional[FalSTTSettings] = None, @@ -201,11 +195,16 @@ class FalSTTService(SegmentedSTTService): api_key: Fal API key. If not provided, will check FAL_KEY environment variable. aiohttp_session: Optional aiohttp ClientSession for HTTP requests. If not provided, a session will be created and managed internally. + task: Task to perform (``"transcribe"`` or ``"translate"``). + Defaults to ``"transcribe"``. + chunk_level: Level of chunking (``"segment"``). Defaults to ``"segment"``. + version: Version of Wizper model to use. Defaults to ``"3"``. sample_rate: Audio sample rate in Hz. If not provided, uses the pipeline's rate. params: Configuration parameters for the Wizper API. .. deprecated:: 0.0.105 - Use ``settings=FalSTTSettings(...)`` instead. + Use ``settings=FalSTTSettings(...)`` for model/language and + direct init parameters for task/chunk_level/version instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -217,9 +216,6 @@ class FalSTTService(SegmentedSTTService): default_settings = FalSTTSettings( model=None, language=language_to_fal_language(Language.EN) or "en", - task="transcribe", - chunk_level="segment", - version="3", ) # 2. (no deprecated direct args for this service) @@ -231,9 +227,12 @@ class FalSTTService(SegmentedSTTService): default_settings.language = ( language_to_fal_language(params.language) if params.language else "en" ) - default_settings.task = params.task - default_settings.chunk_level = params.chunk_level - default_settings.version = params.version + if params.task != "transcribe": + task = params.task + if params.chunk_level != "segment": + chunk_level = params.chunk_level + if params.version != "3": + version = params.version # 4. Apply settings delta (canonical API, always wins) if settings is not None: @@ -246,6 +245,10 @@ class FalSTTService(SegmentedSTTService): **kwargs, ) + self._task = task + self._chunk_level = chunk_level + self._version = version + self._api_key = api_key or os.getenv("FAL_KEY", "") if not self._api_key: raise ValueError( @@ -301,7 +304,15 @@ class FalSTTService(SegmentedSTTService): self._session = aiohttp.ClientSession() data_uri = f"data:audio/x-wav;base64,{base64.b64encode(audio).decode()}" - payload = {"audio_url": data_uri, **self._settings.given_fields()} + payload: dict = {"audio_url": data_uri} + if self._settings.language is not None: + payload["language"] = self._settings.language + if self._task is not None: + payload["task"] = self._task + if self._chunk_level is not None: + payload["chunk_level"] = self._chunk_level + if self._version is not None: + payload["version"] = self._version headers = { "Authorization": f"Key {self._api_key}", "Content-Type": "application/json", diff --git a/src/pipecat/services/gladia/config.py b/src/pipecat/services/gladia/config.py index 5fd5bfdac..ec8997d7c 100644 --- a/src/pipecat/services/gladia/config.py +++ b/src/pipecat/services/gladia/config.py @@ -152,6 +152,10 @@ class MessagesConfig(BaseModel): class GladiaInputParams(BaseModel): """Configuration parameters for the Gladia STT service. + .. deprecated:: 0.0.105 + Use ``settings=GladiaSTTSettings(...)`` for runtime-updatable + fields and direct init parameters for encoding/bit_depth/channels. + Parameters: encoding: Audio encoding format bit_depth: Audio bit depth diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index 44e5bbd9c..f1eca2dc2 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -15,7 +15,7 @@ import base64 import json import warnings from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, Dict, Literal, Optional +from typing import Any, AsyncGenerator, Literal, Optional import aiohttp from loguru import logger @@ -191,28 +191,22 @@ class GladiaSTTSettings(STTSettings): """Settings for Gladia STT service. Parameters: - encoding: Audio encoding format. - bit_depth: Audio bit depth. - channels: Number of audio channels. + language_config: Language detection and handling configuration. custom_metadata: Additional metadata to include with requests. endpointing: Silence duration in seconds to mark end of speech. maximum_duration_without_endpointing: Maximum utterance duration without silence. - language_config: Detailed language configuration. pre_processing: Audio pre-processing options. realtime_processing: Real-time processing features. messages_config: WebSocket message filtering options. enable_vad: Enable VAD to trigger end of utterance detection. """ - encoding: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - bit_depth: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - channels: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - custom_metadata: Dict[str, Any] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + language_config: LanguageConfig | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + custom_metadata: dict[str, Any] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) endpointing: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) maximum_duration_without_endpointing: int | None | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) - language_config: LanguageConfig | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) pre_processing: PreProcessingConfig | None | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) @@ -247,6 +241,9 @@ class GladiaSTTService(WebsocketSTTService): api_key: str, region: Literal["us-west", "eu-west"] | None = None, url: str = "https://api.gladia.io/v2/live", + encoding: str = "wav/pcm", + bit_depth: int = 16, + channels: int = 1, confidence: Optional[float] = None, sample_rate: Optional[int] = None, model: Optional[str] = None, @@ -263,6 +260,9 @@ class GladiaSTTService(WebsocketSTTService): api_key: Gladia API key for authentication. region: Region used to process audio. eu-west or us-west. Defaults to eu-west. url: Gladia API URL. Defaults to "https://api.gladia.io/v2/live". + encoding: Audio encoding format. Defaults to ``"wav/pcm"``. + bit_depth: Audio bit depth. Defaults to 16. + channels: Number of audio channels. Defaults to 1. confidence: Minimum confidence threshold for transcriptions (0.0-1.0). .. deprecated:: 0.0.86 @@ -278,7 +278,8 @@ class GladiaSTTService(WebsocketSTTService): params: Additional configuration parameters for Gladia service. .. deprecated:: 0.0.105 - Use ``settings=GladiaSTTSettings(...)`` instead. + Use ``settings=GladiaSTTSettings(...)`` 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. should_interrupt: Determine whether the bot should be interrupted when @@ -303,13 +304,10 @@ class GladiaSTTService(WebsocketSTTService): default_settings = GladiaSTTSettings( model="solaria-1", language=None, - encoding="wav/pcm", - bit_depth=16, - channels=1, + language_config=None, custom_metadata=None, endpointing=None, maximum_duration_without_endpointing=5, - language_config=None, pre_processing=None, realtime_processing=None, messages_config=None, @@ -334,9 +332,13 @@ class GladiaSTTService(WebsocketSTTService): stacklevel=2, ) if not settings: - default_settings.encoding = params.encoding - default_settings.bit_depth = params.bit_depth - default_settings.channels = params.channels + # Extract init-only fields from params + if params.encoding is not None: + encoding = params.encoding + if params.bit_depth is not None: + bit_depth = params.bit_depth + if params.channels is not None: + channels = params.channels default_settings.custom_metadata = params.custom_metadata default_settings.endpointing = params.endpointing default_settings.maximum_duration_without_endpointing = ( @@ -347,14 +349,14 @@ class GladiaSTTService(WebsocketSTTService): default_settings.messages_config = params.messages_config default_settings.enable_vad = params.enable_vad # Resolve deprecated language → language_config at init time - language_config = params.language_config - if not language_config and params.language: + if params.language_config: + default_settings.language_config = params.language_config + elif params.language: language_code = self.language_to_service_language(params.language) if language_code: - language_config = LanguageConfig( + default_settings.language_config = LanguageConfig( languages=[language_code], code_switching=False ) - default_settings.language_config = language_config # 4. Apply settings delta (canonical API, always wins) if settings is not None: @@ -374,6 +376,11 @@ class GladiaSTTService(WebsocketSTTService): self._url = url self._receive_task = None + # Init-only connection config + self._encoding = encoding + self._bit_depth = bit_depth + self._channels = channels + # Session management self._session_url = None self._session_id = None @@ -411,14 +418,14 @@ class GladiaSTTService(WebsocketSTTService): """ return language_to_gladia_language(language) - def _prepare_settings(self) -> Dict[str, Any]: + def _prepare_settings(self) -> dict[str, Any]: s = self._settings settings = { - "encoding": s.encoding or "wav/pcm", - "bit_depth": s.bit_depth or 16, + "encoding": self._encoding or "wav/pcm", + "bit_depth": self._bit_depth or 16, "sample_rate": self.sample_rate, - "channels": s.channels or 1, + "channels": self._channels or 1, "model": s.model, } @@ -610,7 +617,7 @@ class GladiaSTTService(WebsocketSTTService): self._websocket = None await self._call_event_handler("on_disconnected") - async def _setup_gladia(self, settings: Dict[str, Any]): + async def _setup_gladia(self, settings: dict[str, Any]): async with aiohttp.ClientSession() as session: params = {} if self._region: diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index fff58d87a..e8ab072d0 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -12,7 +12,7 @@ WebSocket API for streaming audio transcription. import base64 import json -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -28,7 +28,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _warn_deprecated_param from pipecat.services.stt_latency import GRADIUM_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -68,14 +68,9 @@ def language_to_gradium_language(language: Language) -> Optional[str]: @dataclass class GradiumSTTSettings(STTSettings): - """Settings for the Gradium STT service. + """Settings for the Gradium STT service.""" - Parameters: - delay_in_frames: Delay in audio frames (80ms each) before text is - generated. Higher delays allow more context but increase latency. - """ - - delay_in_frames: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + pass class GradiumSTTService(WebsocketSTTService): @@ -112,6 +107,7 @@ class GradiumSTTService(WebsocketSTTService): *, api_key: str, api_endpoint_base_url: str = "wss://eu.api.gradium.ai/api/speech/asr", + delay_in_frames: Optional[int] = None, params: Optional[InputParams] = None, json_config: Optional[str] = None, settings: Optional[GradiumSTTSettings] = None, @@ -123,6 +119,9 @@ class GradiumSTTService(WebsocketSTTService): Args: api_key: Gradium API key for authentication. api_endpoint_base_url: WebSocket endpoint URL. Defaults to Gradium's streaming endpoint. + delay_in_frames: Delay in audio frames (80ms each) before text is + generated. Higher delays allow more context but increase latency. + Allowed values: 7, 8, 10, 12, 14, 16, 20, 24, 36, 48. params: Configuration parameters for language and delay settings. .. deprecated:: 0.0.105 @@ -152,7 +151,6 @@ class GradiumSTTService(WebsocketSTTService): default_settings = GradiumSTTSettings( model=None, language=None, - delay_in_frames=None, ) # 2. (no deprecated direct args for this service) @@ -162,7 +160,8 @@ class GradiumSTTService(WebsocketSTTService): _warn_deprecated_param("params", GradiumSTTSettings) if not settings: default_settings.language = params.language - default_settings.delay_in_frames = params.delay_in_frames + if params.delay_in_frames is not None: + delay_in_frames = params.delay_in_frames # 4. Apply settings delta (canonical API, always wins) if settings is not None: @@ -179,6 +178,7 @@ class GradiumSTTService(WebsocketSTTService): self._api_endpoint_base_url = api_endpoint_base_url self._websocket = None self._json_config = json_config + self._config_delay_in_frames = delay_in_frames self._receive_task = None @@ -358,8 +358,8 @@ class GradiumSTTService(WebsocketSTTService): gradium_language = language_to_gradium_language(self._settings.language) if gradium_language: json_config["language"] = gradium_language - if self._settings.delay_in_frames: - json_config["delay_in_frames"] = self._settings.delay_in_frames + if self._config_delay_in_frames: + json_config["delay_in_frames"] = self._config_delay_in_frames if json_config: setup_msg["json_config"] = json_config await self._websocket.send(json.dumps(setup_msg)) diff --git a/src/pipecat/services/groq/stt.py b/src/pipecat/services/groq/stt.py index b875f63d4..1733831c8 100644 --- a/src/pipecat/services/groq/stt.py +++ b/src/pipecat/services/groq/stt.py @@ -6,6 +6,7 @@ """Groq speech-to-text service implementation using Whisper models.""" +from dataclasses import dataclass from typing import Optional from pipecat.services.settings import _warn_deprecated_param @@ -18,6 +19,17 @@ from pipecat.services.whisper.base_stt import ( from pipecat.transcriptions.language import Language +@dataclass +class GroqSTTSettings(BaseWhisperSTTSettings): + """Settings for the Groq STT service. + + Parameters: + prompt: Optional prompt text to guide transcription style. + """ + + pass + + class GroqSTTService(BaseWhisperSTTService): """Groq Whisper speech-to-text service. @@ -25,6 +37,8 @@ class GroqSTTService(BaseWhisperSTTService): set via the api_key parameter or GROQ_API_KEY environment variable. """ + _settings: GroqSTTSettings + def __init__( self, *, @@ -34,7 +48,7 @@ class GroqSTTService(BaseWhisperSTTService): language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, - settings: Optional[BaseWhisperSTTSettings] = None, + settings: Optional[GroqSTTSettings] = None, ttfs_p99_latency: Optional[float] = GROQ_TTFS_P99, **kwargs, ): @@ -44,24 +58,24 @@ class GroqSTTService(BaseWhisperSTTService): model: Whisper model to use. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(model=...)`` instead. + Use ``settings=GroqSTTSettings(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=BaseWhisperSTTSettings(language=...)`` instead. + Use ``settings=GroqSTTSettings(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=GroqSTTSettings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. + Use ``settings=GroqSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -70,24 +84,25 @@ class GroqSTTService(BaseWhisperSTTService): **kwargs: Additional arguments passed to BaseWhisperSTTService. """ # --- 1. Hardcoded defaults --- - default_settings = BaseWhisperSTTSettings( + default_settings = GroqSTTSettings( model="whisper-large-v3-turbo", language=self.language_to_service_language(Language.EN), - base_url=base_url, + prompt=None, + temperature=None, ) # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + _warn_deprecated_param("model", GroqSTTSettings, "model") default_settings.model = model if language is not None: - _warn_deprecated_param("language", BaseWhisperSTTSettings, "language") + _warn_deprecated_param("language", GroqSTTSettings, "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", GroqSTTSettings, "prompt") default_settings.prompt = prompt if temperature is not None: - _warn_deprecated_param("temperature", BaseWhisperSTTSettings, "temperature") + _warn_deprecated_param("temperature", GroqSTTSettings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- @@ -105,7 +120,7 @@ class GroqSTTService(BaseWhisperSTTService): ) async def _transcribe(self, audio: bytes) -> Transcription: - assert self._language is not None # Assigned in the BaseWhisperSTTService class + assert self._settings.language is not None # Build kwargs dict with only set parameters kwargs = { @@ -113,13 +128,13 @@ class GroqSTTService(BaseWhisperSTTService): "model": self._settings.model, # Use verbose_json to get probability metrics "response_format": "verbose_json" if self._include_prob_metrics else "json", - "language": self._language, + "language": self._settings.language, } - if self._prompt is not None: - kwargs["prompt"] = self._prompt + if self._settings.prompt is not None: + kwargs["prompt"] = self._settings.prompt - if self._temperature is not None: - kwargs["temperature"] = self._temperature + if self._settings.temperature is not None: + kwargs["temperature"] = self._settings.temperature return await self._client.audio.transcriptions.create(**kwargs) diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index df785e25c..9b9b2bcf9 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -8,7 +8,7 @@ import asyncio from concurrent.futures import CancelledError as FuturesCancelledError -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, List, Mapping, Optional from loguru import logger @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( StartFrame, TranscriptionFrame, ) -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _warn_deprecated_param from pipecat.services.stt_latency import NVIDIA_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService, STTService from pipecat.transcriptions.language import Language, resolve_language @@ -110,11 +110,11 @@ class NvidiaSegmentedSTTSettings(STTSettings): boosted_lm_score: Score boost for specified words. """ - profanity_filter: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - automatic_punctuation: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - verbatim_transcripts: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - boosted_lm_words: List[str] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - boosted_lm_score: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + profanity_filter: bool = False + automatic_punctuation: bool = True + verbatim_transcripts: bool = False + boosted_lm_words: Optional[List[str]] = None + boosted_lm_score: float = 4.0 class NvidiaSTTService(STTService): @@ -586,19 +586,18 @@ class NvidiaSegmentedSTTService(SegmentedSTTService): def _create_recognition_config(self): """Create the NVIDIA Riva ASR recognition configuration.""" # Create base configuration + s = self._settings config = riva.client.RecognitionConfig( language_code=self._get_language_code(), max_alternatives=1, - profanity_filter=self._settings.profanity_filter, - enable_automatic_punctuation=self._settings.automatic_punctuation, - verbatim_transcripts=self._settings.verbatim_transcripts, + profanity_filter=s.profanity_filter, + enable_automatic_punctuation=s.automatic_punctuation, + verbatim_transcripts=s.verbatim_transcripts, ) # Add word boosting if specified - if self._settings.boosted_lm_words: - riva.client.add_word_boosting_to_config( - config, self._settings.boosted_lm_words, self._settings.boosted_lm_score - ) + if s.boosted_lm_words: + riva.client.add_word_boosting_to_config(config, s.boosted_lm_words, s.boosted_lm_score) # Add voice activity detection parameters riva.client.add_endpoint_parameters_to_config( diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index 7692deee5..fbd372523 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -16,7 +16,7 @@ Provides two STT services: import base64 import json -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, AsyncGenerator, Literal, Optional, Union from loguru import logger @@ -35,7 +35,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import OPENAI_REALTIME_TTFS_P99, OPENAI_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.services.whisper.base_stt import ( @@ -55,6 +55,13 @@ except ModuleNotFoundError: State = None +@dataclass +class OpenAISTTSettings(BaseWhisperSTTSettings): + """Settings for the OpenAI STT service.""" + + pass + + class OpenAISTTService(BaseWhisperSTTService): """OpenAI Speech-to-Text service that generates text from audio. @@ -62,6 +69,8 @@ class OpenAISTTService(BaseWhisperSTTService): set via the api_key parameter or OPENAI_API_KEY environment variable. """ + _settings: OpenAISTTSettings + def __init__( self, *, @@ -71,7 +80,7 @@ class OpenAISTTService(BaseWhisperSTTService): language: Optional[Language] = Language.EN, prompt: Optional[str] = None, temperature: Optional[float] = None, - settings: Optional[BaseWhisperSTTSettings] = None, + settings: Optional[OpenAISTTSettings] = None, ttfs_p99_latency: Optional[float] = OPENAI_TTFS_P99, **kwargs, ): @@ -81,13 +90,25 @@ class OpenAISTTService(BaseWhisperSTTService): model: Model to use — either gpt-4o or Whisper. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(model=...)`` instead. + Use ``settings=OpenAISTTSettings(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. + prompt: Optional text to guide the model's style or continue a previous segment. + + .. deprecated:: 0.0.105 + Use ``settings=OpenAISTTSettings(prompt=...)`` instead. + temperature: Optional sampling temperature between 0 and 1. Defaults to 0.0. + + .. deprecated:: 0.0.105 + Use ``settings=OpenAISTTSettings(temperature=...)`` instead. + settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. ttfs_p99_latency: P99 latency from speech end to final transcript in seconds. @@ -96,18 +117,23 @@ class OpenAISTTService(BaseWhisperSTTService): """ # --- 1. Hardcoded defaults --- _language = language or Language.EN - default_settings = BaseWhisperSTTSettings( + default_settings = OpenAISTTSettings( model="gpt-4o-transcribe", language=self.language_to_service_language(_language), - base_url=base_url, - prompt=prompt, - temperature=temperature, + prompt=None, + temperature=None, ) # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + _warn_deprecated_param("model", OpenAISTTSettings, "model") default_settings.model = model + if prompt is not None: + _warn_deprecated_param("prompt", OpenAISTTSettings, "prompt") + default_settings.prompt = prompt + if temperature is not None: + _warn_deprecated_param("temperature", OpenAISTTSettings, "temperature") + default_settings.temperature = temperature # --- 3. (no params object for this service) --- @@ -124,7 +150,7 @@ class OpenAISTTService(BaseWhisperSTTService): ) async def _transcribe(self, audio: bytes) -> Transcription: - assert self._language is not None # Assigned in the BaseWhisperSTTService class + assert self._settings.language is not None # Build kwargs dict with only set parameters kwargs = { @@ -162,7 +188,7 @@ class OpenAIRealtimeSTTSettings(STTSettings): prompt: Optional prompt text to guide transcription style. """ - prompt: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + prompt: str | None | _NotGiven = None class OpenAIRealtimeSTTService(WebsocketSTTService): @@ -228,8 +254,16 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): 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. + prompt: Optional prompt text to guide transcription style or provide keyword hints. + + .. deprecated:: 0.0.105 + Use ``settings=OpenAIRealtimeSTTSettings(prompt=...)`` instead. + turn_detection: Server-side VAD configuration. Defaults to ``False`` (disabled), which relies on a local VAD processor in the pipeline. Pass ``None`` to use server @@ -257,14 +291,20 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): # --- 1. Hardcoded defaults --- default_settings = OpenAIRealtimeSTTSettings( model="gpt-4o-transcribe", - language=language, - prompt=prompt, + language=Language.EN, + prompt=None, ) # --- 2. Deprecated direct-arg overrides --- if model is not None: _warn_deprecated_param("model", OpenAIRealtimeSTTSettings, "model") default_settings.model = model + if language is not None and language != Language.EN: + _warn_deprecated_param("language", OpenAIRealtimeSTTSettings, "language") + default_settings.language = language + if prompt is not None: + _warn_deprecated_param("prompt", OpenAIRealtimeSTTSettings, "prompt") + default_settings.prompt = prompt # --- 3. (no params object for this service) --- @@ -281,7 +321,6 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): self._api_key = api_key self._base_url = base_url - self._prompt = self._settings.prompt self._turn_detection = turn_detection self._noise_reduction = noise_reduction self._should_interrupt = should_interrupt @@ -318,8 +357,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): async def _update_settings(self, delta: STTSettings) -> dict[str, Any]: """Apply a settings delta and send session update if needed. - Keeps ``_language_code`` and ``_prompt`` in sync with settings - and sends a ``session.update`` to the server when the session is active. + Sends a ``session.update`` to the server when the session is active. Args: delta: A :class:`STTSettings` (or ``OpenAIRealtimeSTTSettings``) delta. @@ -329,13 +367,7 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): """ changed = await super()._update_settings(delta) - if not changed: - return changed - - if "prompt" in changed and isinstance(self._settings, OpenAIRealtimeSTTSettings): - self._prompt = self._settings.prompt - - if self._session_ready: + if changed and self._session_ready: await self._send_session_update() return changed @@ -492,8 +524,8 @@ class OpenAIRealtimeSTTService(WebsocketSTTService): if language_code: transcription["language"] = language_code - if self._prompt: - transcription["prompt"] = self._prompt + if self._settings.prompt: + transcription["prompt"] = self._settings.prompt input_audio: dict = { "format": { diff --git a/src/pipecat/services/openai/tts.py b/src/pipecat/services/openai/tts.py index feb6453c7..b4933ae9f 100644 --- a/src/pipecat/services/openai/tts.py +++ b/src/pipecat/services/openai/tts.py @@ -161,6 +161,8 @@ class OpenAITTSService(TTSService): model="gpt-4o-mini-tts", voice="alloy", language=None, + instructions=None, + speed=None, ) # 2. Apply direct init arg overrides (deprecated) diff --git a/src/pipecat/services/sambanova/stt.py b/src/pipecat/services/sambanova/stt.py index 60f638897..822c44da9 100644 --- a/src/pipecat/services/sambanova/stt.py +++ b/src/pipecat/services/sambanova/stt.py @@ -6,6 +6,7 @@ """SambaNova's Speech-to-Text service implementation for real-time transcription.""" +from dataclasses import dataclass from typing import Any, Optional from loguru import logger @@ -20,6 +21,13 @@ from pipecat.services.whisper.base_stt import ( from pipecat.transcriptions.language import Language +@dataclass +class SambaNovaSTTSettings(BaseWhisperSTTSettings): + """Settings for the SambaNova STT service.""" + + pass + + class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore """SambaNova Whisper speech-to-text service. @@ -36,7 +44,7 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore language: Optional[Language] = None, prompt: Optional[str] = None, temperature: Optional[float] = None, - settings: Optional[BaseWhisperSTTSettings] = None, + settings: Optional[SambaNovaSTTSettings] = None, ttfs_p99_latency: Optional[float] = SAMBANOVA_TTFS_P99, **kwargs: Any, ) -> None: @@ -46,24 +54,24 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore model: Whisper model to use. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(model=...)`` instead. + Use ``settings=SambaNovaSTTSettings(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=BaseWhisperSTTSettings(language=...)`` instead. + Use ``settings=SambaNovaSTTSettings(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=SambaNovaSTTSettings(prompt=...)`` instead. temperature: Optional sampling temperature between 0 and 1. .. deprecated:: 0.0.105 - Use ``settings=BaseWhisperSTTSettings(temperature=...)`` instead. + Use ``settings=SambaNovaSTTSettings(temperature=...)`` instead. settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. @@ -72,24 +80,25 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore **kwargs: Additional arguments passed to `pipecat.services.whisper.base_stt.BaseWhisperSTTService`. """ # --- 1. Hardcoded defaults --- - default_settings = BaseWhisperSTTSettings( + default_settings = SambaNovaSTTSettings( model="Whisper-Large-v3", language=self.language_to_service_language(Language.EN), - base_url=base_url, + prompt=None, + temperature=None, ) # --- 2. Deprecated direct-arg overrides --- if model is not None: - _warn_deprecated_param("model", BaseWhisperSTTSettings, "model") + _warn_deprecated_param("model", SambaNovaSTTSettings, "model") default_settings.model = model if language is not None: - _warn_deprecated_param("language", BaseWhisperSTTSettings, "language") + _warn_deprecated_param("language", SambaNovaSTTSettings, "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", SambaNovaSTTSettings, "prompt") default_settings.prompt = prompt if temperature is not None: - _warn_deprecated_param("temperature", BaseWhisperSTTSettings, "temperature") + _warn_deprecated_param("temperature", SambaNovaSTTSettings, "temperature") default_settings.temperature = temperature # --- 3. (no params object for this service) --- @@ -107,7 +116,7 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore ) async def _transcribe(self, audio: bytes) -> Transcription: - assert self._language is not None # Assigned in the BaseWhisperSTTService class + assert self._settings.language is not None if self._include_prob_metrics: # https://docs.sambanova.ai/docs/en/features/audio#request-parameters @@ -122,13 +131,13 @@ class SambaNovaSTTService(BaseWhisperSTTService): # type: ignore "file": ("audio.wav", audio, "audio/wav"), "model": self._settings.model, "response_format": "json", - "language": self._language, + "language": self._settings.language, } - if self._prompt is not None: - kwargs["prompt"] = self._prompt + if self._settings.prompt is not None: + kwargs["prompt"] = self._settings.prompt - if self._temperature is not None: - kwargs["temperature"] = self._temperature + if self._settings.temperature is not None: + kwargs["temperature"] = self._settings.temperature return await self._client.audio.transcriptions.create(**kwargs) diff --git a/src/pipecat/services/sarvam/stt.py b/src/pipecat/services/sarvam/stt.py index f255619bb..d8659a6e7 100644 --- a/src/pipecat/services/sarvam/stt.py +++ b/src/pipecat/services/sarvam/stt.py @@ -142,14 +142,13 @@ class SarvamSTTSettings(STTSettings): """Settings for the Sarvam STT service. Parameters: - prompt: Optional prompt to guide transcription/translation style. - mode: Mode of operation (transcribe, translate, verbatim, etc.). + prompt: Optional prompt to guide transcription/translation style/context. + Only applicable to models that support prompts (e.g., saaras:v2.5). vad_signals: Enable VAD signals in response. high_vad_sensitivity: Enable high VAD sensitivity. """ prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - mode: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) vad_signals: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) high_vad_sensitivity: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -204,6 +203,9 @@ class SarvamSTTService(STTService): *, api_key: str, model: Optional[str] = None, + mode: Optional[ + Literal["transcribe", "translate", "verbatim", "translit", "codemix"] + ] = None, sample_rate: Optional[int] = None, input_audio_codec: str = "wav", params: Optional[InputParams] = None, @@ -222,6 +224,9 @@ class SarvamSTTService(STTService): .. deprecated:: 0.0.105 Use ``settings=SarvamSTTSettings(model=...)`` instead. + mode: Mode of operation. Options: transcribe, translate, verbatim, + translit, codemix. Only applicable to models that support it + (e.g., saaras:v3). Defaults to the model's default mode. sample_rate: Audio sample rate. Defaults to 16000 if not specified. input_audio_codec: Audio codec/format of the input file. Defaults to "wav". params: Configuration parameters for Sarvam STT service. @@ -238,32 +243,32 @@ class SarvamSTTService(STTService): keepalive_interval: Seconds between idle checks when keepalive is enabled. **kwargs: Additional arguments passed to the parent STTService. """ - # 1. Initialize default_settings with hardcoded defaults + # --- 1. Hardcoded defaults --- default_settings = SarvamSTTSettings( model="saarika:v2.5", language=None, prompt=None, - mode=None, vad_signals=None, high_vad_sensitivity=None, ) - # 2. Apply direct init arg overrides (deprecated) + # --- 2. Deprecated direct-arg overrides --- if model is not None: _warn_deprecated_param("model", SarvamSTTSettings, "model") default_settings.model = model - # 3. Apply params overrides — only if settings not provided + # --- 3. Deprecated params overrides --- if params is not None: _warn_deprecated_param("params", SarvamSTTSettings) if not settings: default_settings.language = params.language default_settings.prompt = params.prompt - default_settings.mode = params.mode + if params.mode is not None: + mode = params.mode default_settings.vad_signals = params.vad_signals default_settings.high_vad_sensitivity = params.high_vad_sensitivity - # 4. Apply settings delta (canonical API, always wins) + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) @@ -278,7 +283,7 @@ class SarvamSTTService(STTService): # Validate parameters against model capabilities if default_settings.prompt is not None and not self._config.supports_prompt: raise ValueError(f"Model '{resolved_model}' does not support prompt parameter.") - if default_settings.mode is not None and not self._config.supports_mode: + if mode is not None and not self._config.supports_mode: raise ValueError(f"Model '{resolved_model}' does not support mode parameter.") if default_settings.language is not None and not self._config.supports_language: raise ValueError( @@ -286,8 +291,8 @@ class SarvamSTTService(STTService): ) # Resolve mode default from model config - if default_settings.mode is None: - default_settings.mode = self._config.default_mode + if mode is None: + mode = self._config.default_mode super().__init__( sample_rate=sample_rate, @@ -300,6 +305,9 @@ class SarvamSTTService(STTService): self._api_key = api_key + # Init-only connection config (not runtime-updatable) + self._mode = mode + # Store connection parameters self._input_audio_codec = input_audio_codec @@ -380,30 +388,26 @@ class SarvamSTTService(STTService): f"Model '{self._settings.model}' does not support language parameter " "(auto-detects language)." ) - - if isinstance(delta, SarvamSTTSettings): - if 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." - ) - if is_given(delta.mode) and delta.mode is not None: - if not self._config.supports_mode: - raise ValueError( - f"Model '{self._settings.model}' does not support mode parameter." - ) + if ( + isinstance(delta, SarvamSTTSettings) + 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." + ) changed = await super()._update_settings(delta) - # TODO: someday we could reconnect here to apply updated settings. - # Code might look something like the below: - # if not changed: - # return changed + # Prompt is a WebSocket connect-time parameter; reconnect to apply. + if "prompt" in changed: + await self._disconnect() + await self._connect() - # await self._disconnect() - # await self._connect() - - self._warn_unhandled_updated_settings(changed) + unhandled = {k: v for k, v in changed.items() if k != "prompt"} + if unhandled: + self._warn_unhandled_updated_settings(unhandled) return changed @@ -542,8 +546,8 @@ class SarvamSTTService(STTService): connect_kwargs["language_code"] = language_string # Add mode for models that support it - if self._config.supports_mode and self._settings.mode is not None: - connect_kwargs["mode"] = self._settings.mode + if self._config.supports_mode and self._mode is not None: + connect_kwargs["mode"] = self._mode # Prompt support differs across sarvamai versions. Prefer connect-time prompt # when available and gracefully degrade if the SDK doesn't accept it. diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index beadabf1b..483cad062 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -144,8 +144,6 @@ class SonioxSTTSettings(STTSettings): """Settings for Soniox STT service. Parameters: - audio_format: Audio format to use for transcription. - num_channels: Number of channels to use for transcription. language_hints: List of language hints to use for transcription. language_hints_strict: If true, strictly enforce language hints. context: Customization for transcription. String for models with @@ -156,8 +154,6 @@ class SonioxSTTSettings(STTSettings): client_reference_id: Client reference ID to use for transcription. """ - audio_format: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - num_channels: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) language_hints: List[Language] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) language_hints_strict: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) context: SonioxContextObject | str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -187,6 +183,8 @@ class SonioxSTTService(WebsocketSTTService): url: str = "wss://stt-rt.soniox.com/transcribe-websocket", sample_rate: Optional[int] = None, model: Optional[str] = None, + audio_format: str = "pcm_s16le", + num_channels: int = 1, params: Optional[SonioxInputParams] = None, vad_force_turn_endpoint: bool = True, settings: Optional[SonioxSTTSettings] = None, @@ -204,6 +202,8 @@ class SonioxSTTService(WebsocketSTTService): .. deprecated:: 0.0.105 Use ``settings=SonioxSTTSettings(model=...)`` instead. + audio_format: Audio format for transcription. Defaults to ``"pcm_s16le"``. + num_channels: Number of audio channels. Defaults to 1. params: Additional configuration parameters, such as language hints, context and speaker diarization. @@ -218,12 +218,10 @@ class SonioxSTTService(WebsocketSTTService): Override for your deployment. See https://github.com/pipecat-ai/stt-benchmark **kwargs: Additional arguments passed to the STTService. """ - # 1. Initialize default_settings with hardcoded defaults + # --- 1. Hardcoded defaults --- default_settings = SonioxSTTSettings( model="stt-rt-v4", language=None, - audio_format="pcm_s16le", - num_channels=1, language_hints=None, language_hints_strict=None, context=None, @@ -232,18 +230,20 @@ class SonioxSTTService(WebsocketSTTService): client_reference_id=None, ) - # 2. Apply direct init arg overrides (deprecated) + # --- 2. Deprecated direct-arg overrides --- if model is not None: _warn_deprecated_param("model", SonioxSTTSettings, "model") default_settings.model = model - # 3. Apply params overrides — only if settings not provided + # --- 3. Deprecated params overrides --- if params is not None: _warn_deprecated_param("params", SonioxSTTSettings) if not settings: default_settings.model = params.model - default_settings.audio_format = params.audio_format - default_settings.num_channels = params.num_channels + if params.audio_format is not None: + audio_format = params.audio_format + if params.num_channels is not None: + num_channels = params.num_channels default_settings.language_hints = params.language_hints default_settings.language_hints_strict = params.language_hints_strict default_settings.context = params.context @@ -253,7 +253,7 @@ class SonioxSTTService(WebsocketSTTService): ) default_settings.client_reference_id = params.client_reference_id - # 4. Apply settings delta (canonical API, always wins) + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) @@ -270,6 +270,10 @@ class SonioxSTTService(WebsocketSTTService): self._url = url self._vad_force_turn_endpoint = vad_force_turn_endpoint + # Init-only audio config + self._audio_format = audio_format + self._num_channels = num_channels + self._final_transcription_buffer = [] self._last_tokens_received: Optional[float] = None @@ -438,8 +442,8 @@ class SonioxSTTService(WebsocketSTTService): config = { "api_key": self._api_key, "model": s.model, - "audio_format": s.audio_format, - "num_channels": s.num_channels or 1, + "audio_format": self._audio_format, + "num_channels": self._num_channels, "enable_endpoint_detection": enable_endpoint_detection, "sample_rate": self.sample_rate, "language_hints": _prepare_language_hints(s.language_hints), diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index a0a5c8b64..b3ded9255 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -100,7 +100,6 @@ class SpeechmaticsSTTSettings(STTSettings): focus_mode: Speaker focus mode for diarization. known_speakers: List of known speaker labels and identifiers. additional_vocab: List of additional vocabulary entries. - audio_encoding: Audio encoding format. operating_point: Operating point for accuracy vs. latency. max_delay: Maximum delay in seconds for transcription. end_of_utterance_silence_trigger: Maximum delay for end of utterance trigger. @@ -126,7 +125,6 @@ class SpeechmaticsSTTSettings(STTSettings): additional_vocab: list[AdditionalVocabEntry] | _NotGiven = field( default_factory=lambda: NOT_GIVEN ) - audio_encoding: AudioEncoding | _NotGiven = field(default_factory=lambda: NOT_GIVEN) operating_point: OperatingPoint | _NotGiven = field(default_factory=lambda: NOT_GIVEN) max_delay: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) end_of_utterance_silence_trigger: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -344,8 +342,8 @@ class SpeechmaticsSTTService(STTService): class UpdateParams(BaseModel): """Update parameters for Speechmatics STT service. - These are the only parameters that can be changed once a session has started. If you need to - change the language, etc., then you must create a new instance of the service. + .. deprecated:: 0.0.104 + Use ``SpeechmaticsSTTSettings`` with ``STTUpdateSettingsFrame`` instead. Parameters: focus_speakers: List of speaker IDs to focus on. When enabled, only these speakers are @@ -379,6 +377,7 @@ class SpeechmaticsSTTService(STTService): api_key: str | None = None, base_url: str | None = None, sample_rate: int | None = None, + encoding: AudioEncoding = AudioEncoding.PCM_S16LE, params: InputParams | None = None, should_interrupt: bool = True, settings: SpeechmaticsSTTSettings | None = None, @@ -393,6 +392,7 @@ class SpeechmaticsSTTService(STTService): base_url: Base URL for Speechmatics API. Uses environment variable `SPEECHMATICS_RT_URL` or defaults to `wss://eu2.rt.speechmatics.com/v2`. sample_rate: Optional audio sample rate in Hz. + encoding: Audio encoding format. Defaults to ``AudioEncoding.PCM_S16LE``. params: Input parameters for the service. .. deprecated:: 0.0.105 @@ -423,7 +423,7 @@ class SpeechmaticsSTTService(STTService): _params = params or SpeechmaticsSTTService.InputParams() self._check_deprecated_args(kwargs, _params) - # 1. Initialize default_settings with hardcoded defaults + # --- 1. Hardcoded defaults --- default_settings = SpeechmaticsSTTSettings( model=None, # Will be resolved from operating_point after config is built language=Language.EN, @@ -436,7 +436,6 @@ class SpeechmaticsSTTService(STTService): focus_mode=SpeakerFocusMode.RETAIN, known_speakers=[], additional_vocab=[], - audio_encoding=AudioEncoding.PCM_S16LE, operating_point=None, max_delay=None, end_of_utterance_silence_trigger=None, @@ -451,9 +450,9 @@ class SpeechmaticsSTTService(STTService): extra_params=None, ) - # 2. No direct init arg overrides + # --- 2. No direct init arg overrides --- - # 3. Apply params overrides — only if settings not provided + # --- 3. Deprecated params overrides --- if params is not None: _warn_deprecated_param("params", SpeechmaticsSTTSettings) if not settings: @@ -475,7 +474,7 @@ class SpeechmaticsSTTService(STTService): default_settings.focus_mode = _params.focus_mode default_settings.known_speakers = _params.known_speakers default_settings.additional_vocab = _params.additional_vocab - default_settings.audio_encoding = _params.audio_encoding + encoding = _params.audio_encoding default_settings.operating_point = _params.operating_point default_settings.max_delay = _params.max_delay default_settings.end_of_utterance_silence_trigger = ( @@ -493,10 +492,11 @@ class SpeechmaticsSTTService(STTService): # Build SDK config from settings, then resolve model from operating_point self._client: VoiceAgentClient | None = None + self._audio_encoding = encoding self._config: VoiceAgentConfig = self._build_config(default_settings) default_settings.model = self._config.operating_point.value - # 4. Apply settings delta (canonical API, always wins) + # --- 4. Settings delta (canonical API, always wins) --- if settings is not None: default_settings.apply_update(settings) @@ -720,6 +720,9 @@ class SpeechmaticsSTTService(STTService): # Preset from turn detection mode config = VoiceAgentConfigPreset.load(s.turn_detection_mode.value) + # Audio encoding (init-only, stored as instance attribute) + config.audio_encoding = self._audio_encoding + # Language + domain language = s.language config.language = self._language_to_speechmatics_language(language) @@ -773,7 +776,7 @@ class SpeechmaticsSTTService(STTService): ) -> None: """Updates the speaker configuration. - .. deprecated:: + .. deprecated:: 0.0.104 Use ``STTUpdateSettingsFrame`` with ``SpeechmaticsSTTSettings(...)`` instead. diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index c2dde8acc..f89d7f5d0 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -10,15 +10,15 @@ This module provides common functionality for services implementing the Whisper interface, including language mapping, metrics generation, and error handling. """ -from dataclasses import dataclass, field -from typing import Any, AsyncGenerator, Optional +from dataclasses import dataclass +from typing import AsyncGenerator, Optional from loguru import logger from openai import AsyncOpenAI from openai.types.audio import Transcription from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame -from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import WHISPER_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -31,15 +31,13 @@ class BaseWhisperSTTSettings(STTSettings): """Settings for Whisper API-based STT services. Parameters: - base_url: API base URL. prompt: Optional text to guide the model's style or continue a previous segment. temperature: Sampling temperature between 0 and 1. """ - base_url: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - prompt: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - temperature: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + prompt: str | None | _NotGiven = None + temperature: float | None | _NotGiven = None def language_to_whisper_language(language: Language) -> Optional[str]: @@ -185,7 +183,6 @@ class BaseWhisperSTTService(SegmentedSTTService): default_settings = BaseWhisperSTTSettings( model=None, language=None, - base_url=base_url, ) # --- 2. Deprecated direct-arg overrides --- @@ -214,32 +211,12 @@ class BaseWhisperSTTService(SegmentedSTTService): **kwargs, ) self._client = self._create_client(api_key, base_url) - self._language = self._settings.language - self._prompt = self._settings.prompt - self._temperature = self._settings.temperature self._include_prob_metrics = include_prob_metrics self._push_empty_transcripts = push_empty_transcripts def _create_client(self, api_key: Optional[str], base_url: Optional[str]): return AsyncOpenAI(api_key=api_key, base_url=base_url) - async def _update_settings(self, delta: STTSettings) -> dict[str, Any]: - """Apply a settings delta, syncing instance variables. - - Keeps ``_language``, ``_prompt``, and ``_temperature`` in sync with - the settings fields. - """ - changed = await super()._update_settings(delta) - - if "language" in changed: - self._language = self._settings.language - if "prompt" in changed: - self._prompt = self._settings.prompt - if "temperature" in changed: - self._temperature = self._settings.temperature - - return changed - def can_generate_metrics(self) -> bool: """Whether this service can generate processing metrics. @@ -289,7 +266,7 @@ class BaseWhisperSTTService(SegmentedSTTService): logger.warning("Received empty transcription from API") if text or self._push_empty_transcripts: - await self._handle_transcription(text, True, self._language) + await self._handle_transcription(text, True, self._settings.language) logger.debug(f"Transcription: [{text}]") yield TranscriptionFrame( text, diff --git a/src/pipecat/services/whisper/stt.py b/src/pipecat/services/whisper/stt.py index f3ac0c948..af96f92c0 100644 --- a/src/pipecat/services/whisper/stt.py +++ b/src/pipecat/services/whisper/stt.py @@ -179,13 +179,9 @@ class WhisperSTTSettings(STTSettings): """Settings for the local Whisper (Faster Whisper) STT service. Parameters: - device: Inference device ('cpu', 'cuda', or 'auto'). - compute_type: Compute type for inference ('default', 'int8', etc.). no_speech_prob: Probability threshold for filtering non-speech segments. """ - device: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - compute_type: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) no_speech_prob: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -217,8 +213,8 @@ class WhisperSTTService(SegmentedSTTService): self, *, model: Optional[str | Model] = None, - device: Optional[str] = None, - compute_type: Optional[str] = None, + device: str = "auto", + compute_type: str = "default", no_speech_prob: Optional[float] = None, language: Optional[Language] = None, settings: Optional[WhisperSTTSettings] = None, @@ -233,15 +229,9 @@ class WhisperSTTService(SegmentedSTTService): Use ``settings=WhisperSTTSettings(model=...)`` instead. device: The device to run inference on ('cpu', 'cuda', or 'auto'). - - .. deprecated:: 0.0.105 - Use ``settings=WhisperSTTSettings(device=...)`` instead. - - compute_type: The compute type for inference ('default', 'int8', 'int8_float16', etc.). - - .. deprecated:: 0.0.105 - Use ``settings=WhisperSTTSettings(compute_type=...)`` instead. - + Defaults to ``"auto"``. + compute_type: The compute type for inference ('default', 'int8', + 'int8_float16', etc.). Defaults to ``"default"``. no_speech_prob: Probability threshold for filtering out non-speech segments. .. deprecated:: 0.0.105 @@ -260,8 +250,6 @@ class WhisperSTTService(SegmentedSTTService): default_settings = WhisperSTTSettings( model=Model.DISTIL_MEDIUM_EN.value, language=Language.EN, - device="auto", - compute_type="default", no_speech_prob=0.4, ) @@ -269,12 +257,6 @@ class WhisperSTTService(SegmentedSTTService): if model is not None: _warn_deprecated_param("model", WhisperSTTSettings, "model") default_settings.model = model if isinstance(model, str) else model.value - if device is not None: - _warn_deprecated_param("device", WhisperSTTSettings, "device") - default_settings.device = device - if compute_type is not None: - _warn_deprecated_param("compute_type", WhisperSTTSettings, "compute_type") - default_settings.compute_type = compute_type if no_speech_prob is not None: _warn_deprecated_param("no_speech_prob", WhisperSTTSettings, "no_speech_prob") default_settings.no_speech_prob = no_speech_prob @@ -292,9 +274,11 @@ class WhisperSTTService(SegmentedSTTService): settings=default_settings, **kwargs, ) - self._device: str = self._settings.device - self._compute_type = self._settings.compute_type - self._no_speech_prob = self._settings.no_speech_prob + + # Init-only inference config + self._device = device + self._compute_type = compute_type + self._model: Optional[WhisperModel] = None self._load() @@ -373,7 +357,7 @@ class WhisperSTTService(SegmentedSTTService): ) text: str = "" for segment in segments: - if segment.no_speech_prob < self._no_speech_prob: + if segment.no_speech_prob < self._settings.no_speech_prob: text += f"{segment.text} " await self.stop_processing_metrics() @@ -471,9 +455,6 @@ class WhisperSTTServiceMLX(WhisperSTTService): **kwargs, ) - self._no_speech_prob = self._settings.no_speech_prob - self._temperature = self._settings.temperature - # No need to call _load() as MLX Whisper loads models on demand @override @@ -514,7 +495,7 @@ class WhisperSTTServiceMLX(WhisperSTTService): mlx_whisper.transcribe, audio_float, path_or_hf_repo=self._settings.model, - temperature=self._temperature, + temperature=self._settings.temperature, language=self._settings.language, ) text: str = "" @@ -523,7 +504,7 @@ class WhisperSTTServiceMLX(WhisperSTTService): if segment.get("compression_ratio", None) == 0.5555555555555556: continue - if segment.get("no_speech_prob", 0.0) < self._no_speech_prob: + if segment.get("no_speech_prob", 0.0) < self._settings.no_speech_prob: text += f"{segment.get('text', '')} " if len(text.strip()) == 0: diff --git a/tests/test_settings.py b/tests/test_settings.py index ce3e35af0..201e85745 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -328,8 +328,6 @@ class TestDeepgramSTTSettingsApplyUpdate: defaults = dict( model="nova-3-general", language="en", - encoding="linear16", - channels=1, interim_results=True, smart_format=False, punctuate=True, @@ -350,8 +348,8 @@ class TestDeepgramSTTSettingsApplyUpdate: assert current.punctuate is False assert "punctuate" in changed # Other fields are untouched - assert current.encoding == "linear16" - assert current.channels == 1 + assert current.model == "nova-3-general" + assert current.language == "en" def test_apply_update_model(self): """model field is updated directly.""" @@ -427,8 +425,6 @@ class TestDeepgramSTTSettingsFromMapping: current = DeepgramSTTSettings( model="nova-3-general", language="en", - encoding="linear16", - channels=1, interim_results=True, punctuate=True, profanity_filter=True, @@ -442,7 +438,6 @@ class TestDeepgramSTTSettingsFromMapping: assert current.punctuate is False assert current.diarize is True # Unchanged fields stay put - assert current.encoding == "linear16" assert current.model == "nova-3-general" assert "punctuate" in changed @@ -451,8 +446,6 @@ class TestDeepgramSTTSettingsFromMapping: current = DeepgramSTTSettings( model="nova-3-general", language="en", - encoding="linear16", - channels=1, ) raw = {"model": "nova-2"} @@ -474,16 +467,13 @@ class TestDeepgramSageMakerSTTSettings: store = DeepgramSageMakerSTTSettings( model="nova-3", language="en", - encoding="linear16", - channels=1, - punctuate=True, ) - delta = DeepgramSageMakerSTTSettings(punctuate=False) + delta = DeepgramSageMakerSTTSettings(model="nova-2") changed = store.apply_update(delta) - assert store.punctuate is False - assert store.encoding == "linear16" - assert "punctuate" in changed + assert store.model == "nova-2" + assert store.language == "en" + assert "model" in changed # --------------------------------------------------------------------------- @@ -499,17 +489,17 @@ class TestDeepgramSTTSettingsExtraSync: return DeepgramSTTService(api_key="test-key", sample_rate=16000, **kwargs) def test_extra_synced_to_declared_field_at_init(self): - """If LiveOptions has unknown params in _extra, they can be synced if they match fields.""" + """LiveOptions params that match declared fields are synced at init.""" from pipecat.services.deepgram.stt import LiveOptions - # Use **kwargs to pass undeclared params - live_options = LiveOptions(numerals=True) # 'numerals' goes into _extra + live_options = LiveOptions(numerals=True) svc = self._make_service(live_options=live_options) - # 'numerals' doesn't match a declared DeepgramSTTSettings field, - # so it should stay in extra - assert svc._settings.extra["numerals"] is True + # 'numerals' is a declared DeepgramSTTSettings field, + # so it should be promoted from extra to the declared field + assert svc._settings.numerals is True + assert "numerals" not in svc._settings.extra def test_declared_field_from_live_options(self): """LiveOptions fields that match DeepgramSTTSettings fields are applied.""" @@ -532,7 +522,7 @@ class TestDeepgramSTTSettingsExtraSync: raw_dict = { "diarize": True, # matches declared field "punctuate": False, # matches declared field - "numerals": True, # doesn't match - stays in extra + "custom_param": "value", # doesn't match - stays in extra } delta = DeepgramSTTSettings.from_mapping(raw_dict) @@ -541,7 +531,7 @@ class TestDeepgramSTTSettingsExtraSync: assert delta.diarize is True assert delta.punctuate is False # Unknown stays in extra - assert delta.extra["numerals"] is True + assert delta.extra["custom_param"] == "value" # Now simulate syncing (though from_mapping already routes correctly) delta._sync_extra_to_fields() @@ -549,7 +539,7 @@ class TestDeepgramSTTSettingsExtraSync: # Still the same - from_mapping already put them in the right place assert delta.diarize is True assert delta.punctuate is False - assert delta.extra["numerals"] is True + assert delta.extra["custom_param"] == "value" def test_sync_promotes_extra_to_field_when_not_given(self): """_sync_extra_to_fields promotes extra dict entries to declared fields.""" @@ -611,16 +601,17 @@ class TestDeepgramSTTSettingsExtraSync: """Unknown params (not matching fields) stay in extra and get forwarded.""" from pipecat.services.deepgram.stt import LiveOptions - # numerals isn't a declared field in DeepgramSTTSettings + # 'numerals' is now a declared field; 'custom_param' is not live_options = LiveOptions(numerals=True, custom_param="test") svc = self._make_service(live_options=live_options) - # Should be in extra - assert svc._settings.extra["numerals"] is True + # 'numerals' is a declared field, so it should be promoted + assert svc._settings.numerals is True + # 'custom_param' is unknown, so it stays in extra assert svc._settings.extra["custom_param"] == "test" - # And forwarded to kwargs + # Both forwarded to kwargs kwargs = svc._build_connect_kwargs() assert kwargs["numerals"] == "true" assert kwargs["custom_param"] == "test" From a4375274b29c4cc4a0ecfc4e88cdda97b3017783 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 18:04:59 -0500 Subject: [PATCH 08/17] Add Settings subclasses to all services and auto-discovered init tests - Add dedicated Settings subclasses to 20 LLM services that were borrowing parent Settings classes (e.g. AzureLLMSettings, GroqLLMSettings) so users don't need cross-module imports - Fix field defaults to NOT_GIVEN in BaseWhisperSTTSettings, OpenAIRealtimeSTTSettings, and NvidiaSegmentedSTTSettings for delta-mode safety - Fix incomplete default_settings in AWS, Cartesia, ElevenLabs, Fish, and Whisper services so validate_complete() passes - Add auto-discovered tests that verify all Settings classes default to NOT_GIVEN (delta safety) and all services initialize with complete settings (store completeness) --- src/pipecat/services/aws/stt.py | 1 + src/pipecat/services/azure/llm.py | 14 +- src/pipecat/services/azure/realtime/llm.py | 11 +- src/pipecat/services/cartesia/tts.py | 2 + src/pipecat/services/cerebras/llm.py | 14 +- src/pipecat/services/deepseek/llm.py | 14 +- src/pipecat/services/elevenlabs/tts.py | 17 ++ src/pipecat/services/fireworks/llm.py | 14 +- src/pipecat/services/fish/tts.py | 1 + .../services/google/gemini_live/llm_vertex.py | 16 +- src/pipecat/services/google/llm_openai.py | 14 +- src/pipecat/services/google/llm_vertex.py | 16 +- src/pipecat/services/grok/llm.py | 13 +- src/pipecat/services/groq/llm.py | 14 +- src/pipecat/services/mistral/llm.py | 14 +- src/pipecat/services/nvidia/llm.py | 14 +- src/pipecat/services/nvidia/stt.py | 14 +- src/pipecat/services/ollama/llm.py | 14 +- src/pipecat/services/openai/stt.py | 6 +- .../services/openai_realtime_beta/azure.py | 10 +- src/pipecat/services/openpipe/llm.py | 14 +- src/pipecat/services/openrouter/llm.py | 14 +- src/pipecat/services/perplexity/llm.py | 14 +- src/pipecat/services/qwen/llm.py | 14 +- src/pipecat/services/sambanova/llm.py | 14 +- src/pipecat/services/together/llm.py | 14 +- src/pipecat/services/whisper/base_stt.py | 10 +- tests/test_service_init.py | 181 ++++++++++++++++++ 28 files changed, 436 insertions(+), 72 deletions(-) create mode 100644 tests/test_service_init.py diff --git a/src/pipecat/services/aws/stt.py b/src/pipecat/services/aws/stt.py index dd2f2f97b..f46f5259c 100644 --- a/src/pipecat/services/aws/stt.py +++ b/src/pipecat/services/aws/stt.py @@ -98,6 +98,7 @@ class AWSTranscribeSTTService(WebsocketSTTService): """ # 1. Initialize default_settings with hardcoded defaults default_settings = AWSTranscribeSTTSettings( + model=None, language=self.language_to_service_language(Language.EN) or "en-US", ) diff --git a/src/pipecat/services/azure/llm.py b/src/pipecat/services/azure/llm.py index 19a31320e..5f1ce2698 100644 --- a/src/pipecat/services/azure/llm.py +++ b/src/pipecat/services/azure/llm.py @@ -6,6 +6,7 @@ """Azure OpenAI service implementation for the Pipecat AI framework.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -16,6 +17,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class AzureLLMSettings(OpenAILLMSettings): + """Settings for Azure OpenAI LLM service.""" + + pass + + class AzureLLMService(OpenAILLMService): """A service for interacting with Azure OpenAI using the OpenAI-compatible interface. @@ -30,7 +38,7 @@ class AzureLLMService(OpenAILLMService): endpoint: str, model: Optional[str] = None, api_version: str = "2024-09-01-preview", - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[AzureLLMSettings] = None, **kwargs, ): """Initialize the Azure LLM service. @@ -49,11 +57,11 @@ class AzureLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="gpt-4o") + default_settings = AzureLLMSettings(model="gpt-4o") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", AzureLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/azure/realtime/llm.py b/src/pipecat/services/azure/realtime/llm.py index 39c9bd707..fa645d8c1 100644 --- a/src/pipecat/services/azure/realtime/llm.py +++ b/src/pipecat/services/azure/realtime/llm.py @@ -6,9 +6,11 @@ """Azure OpenAI Realtime LLM service implementation.""" +from dataclasses import dataclass + from loguru import logger -from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService +from pipecat.services.openai.realtime.llm import OpenAIRealtimeLLMService, OpenAIRealtimeLLMSettings try: from websockets.asyncio.client import connect as websocket_connect @@ -18,6 +20,13 @@ except ModuleNotFoundError as e: raise Exception(f"Missing module: {e}") +@dataclass +class AzureRealtimeLLMSettings(OpenAIRealtimeLLMSettings): + """Settings for Azure Realtime LLM service.""" + + pass + + class AzureRealtimeLLMService(OpenAIRealtimeLLMService): """Azure OpenAI Realtime LLM service with Azure-specific authentication. diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index 71017074b..166aa70af 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -301,6 +301,7 @@ class CartesiaTTSService(AudioContextTTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaTTSSettings( model="sonic-3", + voice=None, language=language_to_cartesia_language(Language.EN), generation_config=None, pronunciation_dict_id=None, @@ -745,6 +746,7 @@ class CartesiaHttpTTSService(TTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = CartesiaTTSSettings( model="sonic-3", + voice=None, language=language_to_cartesia_language(Language.EN), generation_config=None, pronunciation_dict_id=None, diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index c952b9552..40862f252 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -6,6 +6,7 @@ """Cerebras LLM service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -16,6 +17,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class CerebrasLLMSettings(OpenAILLMSettings): + """Settings for Cerebras LLM service.""" + + pass + + class CerebrasLLMService(OpenAILLMService): """A service for interacting with Cerebras's API using the OpenAI-compatible interface. @@ -29,7 +37,7 @@ class CerebrasLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.cerebras.ai/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[CerebrasLLMSettings] = None, **kwargs, ): """Initialize the Cerebras LLM service. @@ -47,11 +55,11 @@ class CerebrasLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="gpt-oss-120b") + default_settings = CerebrasLLMSettings(model="gpt-oss-120b") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", CerebrasLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index 3d7c67e2a..d778639ef 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -6,6 +6,7 @@ """DeepSeek LLM service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -16,6 +17,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class DeepSeekLLMSettings(OpenAILLMSettings): + """Settings for DeepSeek LLM service.""" + + pass + + class DeepSeekLLMService(OpenAILLMService): """A service for interacting with DeepSeek's API using the OpenAI-compatible interface. @@ -29,7 +37,7 @@ class DeepSeekLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.deepseek.com/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[DeepSeekLLMSettings] = None, **kwargs, ): """Initialize the DeepSeek LLM service. @@ -47,11 +55,11 @@ class DeepSeekLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="deepseek-chat") + default_settings = DeepSeekLLMSettings(model="deepseek-chat") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", DeepSeekLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index c22455e7a..cfb08eb6d 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -418,6 +418,14 @@ class ElevenLabsTTSService(AudioContextTTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = ElevenLabsTTSSettings( model="eleven_turbo_v2_5", + voice=None, + language=None, + stability=None, + similarity_boost=None, + style=None, + use_speaker_boost=None, + speed=None, + apply_text_normalization=None, ) # Track init-only URL params through the override chain @@ -986,6 +994,15 @@ class ElevenLabsHttpTTSService(TTSService): # 1. Initialize default_settings with hardcoded defaults default_settings = ElevenLabsHttpTTSSettings( model="eleven_turbo_v2_5", + voice=None, + language=None, + optimize_streaming_latency=None, + stability=None, + similarity_boost=None, + style=None, + use_speaker_boost=None, + speed=None, + apply_text_normalization=None, ) # 2. Apply direct init arg overrides (deprecated) diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index e7866c55d..7ba3f9eac 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -6,6 +6,7 @@ """Fireworks AI service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -16,6 +17,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class FireworksLLMSettings(OpenAILLMSettings): + """Settings for Fireworks LLM service.""" + + pass + + class FireworksLLMService(OpenAILLMService): """A service for interacting with Fireworks AI using the OpenAI-compatible interface. @@ -29,7 +37,7 @@ class FireworksLLMService(OpenAILLMService): api_key: str, model: Optional[str] = None, base_url: str = "https://api.fireworks.ai/inference/v1", - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[FireworksLLMSettings] = None, **kwargs, ): """Initialize the Fireworks LLM service. @@ -47,11 +55,11 @@ class FireworksLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="accounts/fireworks/models/firefunction-v2") + default_settings = FireworksLLMSettings(model="accounts/fireworks/models/firefunction-v2") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", FireworksLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index 78b021c51..9ea749546 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -173,6 +173,7 @@ class FishAudioTTSService(InterruptibleTTSService): default_settings = FishAudioTTSSettings( model="s1", voice=None, + language=None, latency="normal", normalize=True, prosody_speed=1.0, diff --git a/src/pipecat/services/google/gemini_live/llm_vertex.py b/src/pipecat/services/google/gemini_live/llm_vertex.py index 5d63251d9..43d3ab207 100644 --- a/src/pipecat/services/google/gemini_live/llm_vertex.py +++ b/src/pipecat/services/google/gemini_live/llm_vertex.py @@ -12,6 +12,7 @@ streaming responses, and tool usage. """ import json +from dataclasses import dataclass from typing import List, Optional, Union from loguru import logger @@ -41,6 +42,13 @@ except ModuleNotFoundError as e: raise Exception(f"Missing module: {e}") +@dataclass +class GeminiLiveVertexLLMSettings(GeminiLiveLLMSettings): + """Settings for Gemini Live Vertex LLM service.""" + + pass + + class GeminiLiveVertexLLMService(GeminiLiveLLMService): """Provides access to Google's Gemini Live model via Vertex AI. @@ -63,7 +71,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): system_instruction: Optional[str] = None, tools: Optional[Union[List[dict], ToolsSchema]] = None, params: Optional[InputParams] = None, - settings: Optional[GeminiLiveLLMSettings] = None, + settings: Optional[GeminiLiveVertexLLMSettings] = None, inference_on_context_initialization: bool = True, file_api_base_url: str = "https://generativelanguage.googleapis.com/v1beta/files", http_options: Optional[HttpOptions] = None, @@ -122,7 +130,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # double deprecation warnings from the parent. # 1. Initialize default_settings with hardcoded defaults - default_settings = GeminiLiveLLMSettings( + default_settings = GeminiLiveVertexLLMSettings( model="google/gemini-live-2.5-flash-native-audio", frequency_penalty=None, max_tokens=4096, @@ -146,12 +154,12 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GeminiLiveLLMSettings, "model") + _warn_deprecated_param("model", GeminiLiveVertexLLMSettings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GeminiLiveLLMSettings) + _warn_deprecated_param("params", GeminiLiveVertexLLMSettings) if not settings: default_settings.frequency_penalty = params.frequency_penalty default_settings.max_tokens = params.max_tokens diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index b33eefd9a..1d7ae6bc4 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -12,6 +12,7 @@ API format through Google's Gemini API OpenAI compatibility layer. import json import os +from dataclasses import dataclass from typing import Optional from openai import AsyncStream @@ -32,6 +33,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class GoogleOpenAILLMSettings(OpenAILLMSettings): + """Settings for Google OpenAI-compatible LLM service.""" + + pass + + class GoogleLLMOpenAIBetaService(OpenAILLMService): """Google LLM service using OpenAI-compatible API format. @@ -56,7 +64,7 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): api_key: str, base_url: str = "https://generativelanguage.googleapis.com/v1beta/openai/", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[GoogleOpenAILLMSettings] = None, **kwargs, ): """Initialize the Google LLM service. @@ -85,11 +93,11 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): ) # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="gemini-2.0-flash") + default_settings = GoogleOpenAILLMSettings(model="gemini-2.0-flash") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", GoogleOpenAILLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/google/llm_vertex.py b/src/pipecat/services/google/llm_vertex.py index b1a9de584..e21341614 100644 --- a/src/pipecat/services/google/llm_vertex.py +++ b/src/pipecat/services/google/llm_vertex.py @@ -12,6 +12,7 @@ extending the GoogleLLMService with Vertex AI authentication. import json import os +from dataclasses import dataclass # Suppress gRPC fork warnings os.environ["GRPC_ENABLE_FORK_SUPPORT"] = "false" @@ -39,6 +40,13 @@ except ModuleNotFoundError as e: raise Exception(f"Missing module: {e}") +@dataclass +class GoogleVertexLLMSettings(GoogleLLMSettings): + """Settings for Google Vertex LLM service.""" + + pass + + class GoogleVertexLLMService(GoogleLLMService): """Google Vertex AI LLM service extending GoogleLLMService. @@ -104,7 +112,7 @@ class GoogleVertexLLMService(GoogleLLMService): location: Optional[str] = None, project_id: Optional[str] = None, params: Optional[GoogleLLMService.InputParams] = None, - settings: Optional[GoogleLLMSettings] = None, + settings: Optional[GoogleVertexLLMSettings] = None, system_instruction: Optional[str] = None, tools: Optional[list] = None, tool_config: Optional[dict] = None, @@ -183,7 +191,7 @@ class GoogleVertexLLMService(GoogleLLMService): self._location = location # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleLLMSettings( + default_settings = GoogleVertexLLMSettings( model="gemini-2.5-flash", max_tokens=4096, temperature=None, @@ -200,12 +208,12 @@ class GoogleVertexLLMService(GoogleLLMService): # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", GoogleLLMSettings, "model") + _warn_deprecated_param("model", GoogleVertexLLMSettings, "model") default_settings.model = model # 3. Apply params overrides — only if settings not provided if params is not None: - _warn_deprecated_param("params", GoogleLLMSettings) + _warn_deprecated_param("params", GoogleVertexLLMSettings) if not settings: default_settings.max_tokens = params.max_tokens default_settings.temperature = params.temperature diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index 98c925ac5..7f9ac643b 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -70,6 +70,13 @@ class GrokContextAggregatorPair: return self._assistant +@dataclass +class GrokLLMSettings(OpenAILLMSettings): + """Settings for Grok LLM service.""" + + pass + + class GrokLLMService(OpenAILLMService): """A service for interacting with Grok's API using the OpenAI-compatible interface. @@ -85,7 +92,7 @@ class GrokLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.x.ai/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[GrokLLMSettings] = None, **kwargs, ): """Initialize the GrokLLMService with API key and model. @@ -103,11 +110,11 @@ class GrokLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="grok-3-beta") + default_settings = GrokLLMSettings(model="grok-3-beta") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", GrokLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index c69776ad0..5b81a4c7d 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -6,6 +6,7 @@ """Groq LLM Service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -15,6 +16,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class GroqLLMSettings(OpenAILLMSettings): + """Settings for Groq LLM service.""" + + pass + + class GroqLLMService(OpenAILLMService): """A service for interacting with Groq's API using the OpenAI-compatible interface. @@ -28,7 +36,7 @@ class GroqLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.groq.com/openai/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[GroqLLMSettings] = None, **kwargs, ): """Initialize Groq LLM service. @@ -46,11 +54,11 @@ class GroqLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="llama-3.3-70b-versatile") + default_settings = GroqLLMSettings(model="llama-3.3-70b-versatile") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", GroqLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index 57ab45d6f..c4deab4c3 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -6,6 +6,7 @@ """Mistral LLM service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import List, Optional, Sequence from loguru import logger @@ -18,6 +19,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class MistralLLMSettings(OpenAILLMSettings): + """Settings for Mistral LLM service.""" + + pass + + class MistralLLMService(OpenAILLMService): """A service for interacting with Mistral's API using the OpenAI-compatible interface. @@ -31,7 +39,7 @@ class MistralLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.mistral.ai/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[MistralLLMSettings] = None, **kwargs, ): """Initialize the Mistral LLM service. @@ -49,11 +57,11 @@ class MistralLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="mistral-small-latest") + default_settings = MistralLLMSettings(model="mistral-small-latest") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", MistralLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index 88245464e..4ebfac0d8 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -10,6 +10,7 @@ This module provides a service for interacting with NVIDIA's NIM (NVIDIA Inferen Microservice) API while maintaining compatibility with the OpenAI-style interface. """ +from dataclasses import dataclass from typing import Optional from pipecat.metrics.metrics import LLMTokenUsage @@ -20,6 +21,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class NvidiaLLMSettings(OpenAILLMSettings): + """Settings for NVIDIA LLM service.""" + + pass + + class NvidiaLLMService(OpenAILLMService): """A service for interacting with NVIDIA's NIM (NVIDIA Inference Microservice) API. @@ -34,7 +42,7 @@ class NvidiaLLMService(OpenAILLMService): api_key: str, base_url: str = "https://integrate.api.nvidia.com/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[NvidiaLLMSettings] = None, **kwargs, ): """Initialize the NvidiaLLMService. @@ -53,11 +61,11 @@ class NvidiaLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="nvidia/llama-3.1-nemotron-70b-instruct") + default_settings = NvidiaLLMSettings(model="nvidia/llama-3.1-nemotron-70b-instruct") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", NvidiaLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/nvidia/stt.py b/src/pipecat/services/nvidia/stt.py index 9b9b2bcf9..6823965a9 100644 --- a/src/pipecat/services/nvidia/stt.py +++ b/src/pipecat/services/nvidia/stt.py @@ -8,7 +8,7 @@ import asyncio from concurrent.futures import CancelledError as FuturesCancelledError -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Any, AsyncGenerator, List, Mapping, Optional from loguru import logger @@ -23,7 +23,7 @@ from pipecat.frames.frames import ( StartFrame, TranscriptionFrame, ) -from pipecat.services.settings import STTSettings, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import NVIDIA_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService, STTService from pipecat.transcriptions.language import Language, resolve_language @@ -110,11 +110,11 @@ class NvidiaSegmentedSTTSettings(STTSettings): boosted_lm_score: Score boost for specified words. """ - profanity_filter: bool = False - automatic_punctuation: bool = True - verbatim_transcripts: bool = False - boosted_lm_words: Optional[List[str]] = None - boosted_lm_score: float = 4.0 + profanity_filter: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + automatic_punctuation: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + verbatim_transcripts: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + boosted_lm_words: List[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + boosted_lm_score: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class NvidiaSTTService(STTService): diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index 477a80b5f..cd0c68099 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -6,6 +6,7 @@ """OLLama LLM service implementation for Pipecat AI framework.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -15,6 +16,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class OllamaLLMSettings(OpenAILLMSettings): + """Settings for Ollama LLM service.""" + + pass + + class OLLamaLLMService(OpenAILLMService): """OLLama LLM service that provides local language model capabilities. @@ -27,7 +35,7 @@ class OLLamaLLMService(OpenAILLMService): *, model: Optional[str] = None, base_url: str = "http://localhost:11434/v1", - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[OllamaLLMSettings] = None, **kwargs, ): """Initialize OLLama LLM service. @@ -45,11 +53,11 @@ class OLLamaLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="llama2") + default_settings = OllamaLLMSettings(model="llama2") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", OllamaLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/openai/stt.py b/src/pipecat/services/openai/stt.py index fbd372523..0e1e4f594 100644 --- a/src/pipecat/services/openai/stt.py +++ b/src/pipecat/services/openai/stt.py @@ -16,7 +16,7 @@ Provides two STT services: import base64 import json -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Any, AsyncGenerator, Literal, Optional, Union from loguru import logger @@ -35,7 +35,7 @@ from pipecat.frames.frames import ( VADUserStoppedSpeakingFrame, ) from pipecat.processors.frame_processor import FrameDirection -from pipecat.services.settings import STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import OPENAI_REALTIME_TTFS_P99, OPENAI_TTFS_P99 from pipecat.services.stt_service import WebsocketSTTService from pipecat.services.whisper.base_stt import ( @@ -188,7 +188,7 @@ class OpenAIRealtimeSTTSettings(STTSettings): prompt: Optional prompt text to guide transcription style. """ - prompt: str | None | _NotGiven = None + prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class OpenAIRealtimeSTTService(WebsocketSTTService): diff --git a/src/pipecat/services/openai_realtime_beta/azure.py b/src/pipecat/services/openai_realtime_beta/azure.py index 6370ac0f4..fb85b1e79 100644 --- a/src/pipecat/services/openai_realtime_beta/azure.py +++ b/src/pipecat/services/openai_realtime_beta/azure.py @@ -7,10 +7,11 @@ """Azure OpenAI Realtime Beta LLM service implementation.""" import warnings +from dataclasses import dataclass from loguru import logger -from .openai import OpenAIRealtimeBetaLLMService +from .openai import OpenAIRealtimeBetaLLMService, OpenAIRealtimeBetaLLMSettings try: from websockets.asyncio.client import connect as websocket_connect @@ -22,6 +23,13 @@ except ModuleNotFoundError as e: raise Exception(f"Missing module: {e}") +@dataclass +class AzureRealtimeBetaLLMSettings(OpenAIRealtimeBetaLLMSettings): + """Settings for Azure Realtime Beta LLM service.""" + + pass + + class AzureRealtimeBetaLLMService(OpenAIRealtimeBetaLLMService): """Azure OpenAI Realtime Beta LLM service with Azure-specific authentication. diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index 431de832d..b2e953e64 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -10,6 +10,7 @@ This module provides an OpenPipe-specific implementation of the OpenAI LLM servi enabling integration with OpenPipe's fine-tuning and monitoring capabilities. """ +from dataclasses import dataclass from typing import Dict, Optional from loguru import logger @@ -27,6 +28,13 @@ except ModuleNotFoundError as e: raise Exception(f"Missing module: {e}") +@dataclass +class OpenPipeLLMSettings(OpenAILLMSettings): + """Settings for OpenPipe LLM service.""" + + pass + + class OpenPipeLLMService(OpenAILLMService): """OpenPipe-powered Large Language Model service. @@ -44,7 +52,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[OpenAILLMSettings] = None, + settings: Optional[OpenPipeLLMSettings] = None, **kwargs, ): """Initialize OpenPipe LLM service. @@ -65,11 +73,11 @@ class OpenPipeLLMService(OpenAILLMService): **kwargs: Additional arguments passed to parent OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="gpt-4.1") + default_settings = OpenPipeLLMSettings(model="gpt-4.1") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", OpenPipeLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index 8c42069d8..fa2f170ee 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -10,6 +10,7 @@ This module provides an OpenAI-compatible interface for interacting with OpenRou extending the base OpenAI LLM service functionality. """ +from dataclasses import dataclass from typing import Any, Dict, Optional from loguru import logger @@ -19,6 +20,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class OpenRouterLLMSettings(OpenAILLMSettings): + """Settings for OpenRouter LLM service.""" + + pass + + class OpenRouterLLMService(OpenAILLMService): """A service for interacting with OpenRouter's API using the OpenAI-compatible interface. @@ -32,7 +40,7 @@ class OpenRouterLLMService(OpenAILLMService): api_key: Optional[str] = None, model: Optional[str] = None, base_url: str = "https://openrouter.ai/api/v1", - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[OpenRouterLLMSettings] = None, **kwargs, ): """Initialize the OpenRouter LLM service. @@ -51,11 +59,11 @@ class OpenRouterLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="openai/gpt-4o-2024-11-20") + default_settings = OpenRouterLLMSettings(model="openai/gpt-4o-2024-11-20") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", OpenRouterLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index 8195dd50e..d90aea6a4 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -11,6 +11,7 @@ an OpenAI-compatible interface. It handles Perplexity's unique token usage reporting patterns while maintaining compatibility with the Pipecat framework. """ +from dataclasses import dataclass from typing import Optional from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams @@ -22,6 +23,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class PerplexityLLMSettings(OpenAILLMSettings): + """Settings for Perplexity LLM service.""" + + pass + + class PerplexityLLMService(OpenAILLMService): """A service for interacting with Perplexity's API. @@ -36,7 +44,7 @@ class PerplexityLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.perplexity.ai", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[PerplexityLLMSettings] = None, **kwargs, ): """Initialize the Perplexity LLM service. @@ -54,11 +62,11 @@ class PerplexityLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="sonar") + default_settings = PerplexityLLMSettings(model="sonar") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", PerplexityLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index b983e00cd..6d9abeefe 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -6,6 +6,7 @@ """Qwen LLM service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -15,6 +16,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class QwenLLMSettings(OpenAILLMSettings): + """Settings for Qwen LLM service.""" + + pass + + class QwenLLMService(OpenAILLMService): """A service for interacting with Alibaba Cloud's Qwen LLM API using the OpenAI-compatible interface. @@ -28,7 +36,7 @@ class QwenLLMService(OpenAILLMService): api_key: str, base_url: str = "https://dashscope-intl.aliyuncs.com/compatible-mode/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[QwenLLMSettings] = None, **kwargs, ): """Initialize the Qwen LLM service. @@ -46,11 +54,11 @@ class QwenLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="qwen-plus") + default_settings = QwenLLMSettings(model="qwen-plus") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", QwenLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index 2468dad13..f87b432cc 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -7,6 +7,7 @@ """SambaNova LLM service implementation using OpenAI-compatible interface.""" import json +from dataclasses import dataclass from typing import Any, Dict, Optional from loguru import logger @@ -27,6 +28,13 @@ from pipecat.services.settings import _warn_deprecated_param from pipecat.utils.tracing.service_decorators import traced_llm +@dataclass +class SambaNovaLLMSettings(OpenAILLMSettings): + """Settings for SambaNova LLM service.""" + + pass + + class SambaNovaLLMService(OpenAILLMService): # type: ignore """A service for interacting with SambaNova using the OpenAI-compatible interface. @@ -40,7 +48,7 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore api_key: str, model: Optional[str] = None, base_url: str = "https://api.sambanova.ai/v1", - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[SambaNovaLLMSettings] = None, **kwargs: Dict[Any, Any], ) -> None: """Initialize SambaNova LLM service. @@ -58,11 +66,11 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="Llama-4-Maverick-17B-128E-Instruct") + default_settings = SambaNovaLLMSettings(model="Llama-4-Maverick-17B-128E-Instruct") # 2. Apply direct init arg overrides (deprecated) if model is not None: - _warn_deprecated_param("model", OpenAILLMSettings, "model") + _warn_deprecated_param("model", SambaNovaLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index 9ec8e9fc2..23e38f752 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -6,6 +6,7 @@ """Together.ai LLM service implementation using OpenAI-compatible interface.""" +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -15,6 +16,13 @@ from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.settings import _warn_deprecated_param +@dataclass +class TogetherLLMSettings(OpenAILLMSettings): + """Settings for Together LLM service.""" + + pass + + class TogetherLLMService(OpenAILLMService): """A service for interacting with Together.ai's API using the OpenAI-compatible interface. @@ -28,7 +36,7 @@ class TogetherLLMService(OpenAILLMService): api_key: str, base_url: str = "https://api.together.xyz/v1", model: Optional[str] = None, - settings: Optional[OpenAILLMSettings] = None, + settings: Optional[TogetherLLMSettings] = None, **kwargs, ): """Initialize Together.ai LLM service. @@ -46,11 +54,11 @@ class TogetherLLMService(OpenAILLMService): **kwargs: Additional keyword arguments passed to OpenAILLMService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAILLMSettings(model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo") + default_settings = TogetherLLMSettings(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", OpenAILLMSettings, "model") + _warn_deprecated_param("model", TogetherLLMSettings, "model") default_settings.model = model # 4. Apply settings delta (canonical API, always wins) diff --git a/src/pipecat/services/whisper/base_stt.py b/src/pipecat/services/whisper/base_stt.py index f89d7f5d0..13de0f251 100644 --- a/src/pipecat/services/whisper/base_stt.py +++ b/src/pipecat/services/whisper/base_stt.py @@ -10,7 +10,7 @@ This module provides common functionality for services implementing the Whisper interface, including language mapping, metrics generation, and error handling. """ -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import AsyncGenerator, Optional from loguru import logger @@ -18,7 +18,7 @@ from openai import AsyncOpenAI from openai.types.audio import Transcription from pipecat.frames.frames import ErrorFrame, Frame, TranscriptionFrame -from pipecat.services.settings import STTSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, STTSettings, _NotGiven, _warn_deprecated_param from pipecat.services.stt_latency import WHISPER_TTFS_P99 from pipecat.services.stt_service import SegmentedSTTService from pipecat.transcriptions.language import Language, resolve_language @@ -36,8 +36,8 @@ class BaseWhisperSTTSettings(STTSettings): temperature: Sampling temperature between 0 and 1. """ - prompt: str | None | _NotGiven = None - temperature: float | None | _NotGiven = None + prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) def language_to_whisper_language(language: Language) -> Optional[str]: @@ -183,6 +183,8 @@ class BaseWhisperSTTService(SegmentedSTTService): default_settings = BaseWhisperSTTSettings( model=None, language=None, + prompt=None, + temperature=None, ) # --- 2. Deprecated direct-arg overrides --- diff --git a/tests/test_service_init.py b/tests/test_service_init.py new file mode 100644 index 000000000..73cb6a337 --- /dev/null +++ b/tests/test_service_init.py @@ -0,0 +1,181 @@ +# +# Copyright (c) 2024-2026, Daily +# +# SPDX-License-Identifier: BSD 2-Clause License +# + +"""Tests for service settings and initialization patterns. + +Settings objects operate in two modes: + +- **Store mode** (``self._settings``): the live state inside a service. + Every field must hold a real value (``None`` is fine, ``NOT_GIVEN`` is not). +- **Delta mode** (``FooSettings()`` with no args): a sparse update. + Every field must default to ``NOT_GIVEN`` so ``apply_update()`` skips + untouched fields and doesn't accidentally overwrite the store. + +These tests verify both sides of that contract automatically: + +1. **Delta defaults** — Instantiate every ``ServiceSettings`` subclass with + no arguments and assert that every field is ``NOT_GIVEN``. Catches the + bug where a field defaults to ``None`` instead of ``NOT_GIVEN``, which + would cause partial deltas to silently overwrite unrelated store values. + +2. **Store completeness** — Instantiate every concrete service with dummy + args and assert that ``_settings`` contains no ``NOT_GIVEN`` values. + This is the same check that ``validate_complete()`` runs in ``start()``, + but caught here at unit-test time without needing a running pipeline. + Catches services that forget to initialize a field in ``default_settings``. + +All Settings and Service classes are auto-discovered via ``pkgutil``; +new services are covered automatically with no per-service maintenance. +""" + +import importlib +import inspect +import pkgutil +import warnings +from dataclasses import fields + +import pytest + +import pipecat.services +from pipecat.services.ai_service import AIService +from pipecat.services.settings import ServiceSettings, is_given + +# Modules that define abstract base service classes (not concrete services). +_BASE_MODULES = frozenset( + { + "pipecat.services.ai_service", + "pipecat.services.llm_service", + "pipecat.services.stt_service", + "pipecat.services.tts_service", + "pipecat.services.image_gen_service", + "pipecat.services.vision_service", + } +) + + +# --------------------------------------------------------------------------- +# Auto-discovery +# --------------------------------------------------------------------------- + + +def _all_subclasses(cls): + result = set() + for sub in cls.__subclasses__(): + result.add(sub) + result.update(_all_subclasses(sub)) + return result + + +def _import_all_service_modules(): + """Import every module under pipecat.services (skipping missing deps).""" + package = pipecat.services + for _importer, modname, _ispkg in pkgutil.walk_packages( + package.__path__, prefix=package.__name__ + "." + ): + try: + importlib.import_module(modname) + except Exception: + continue + + +_import_all_service_modules() + +ALL_SETTINGS_CLASSES = sorted(_all_subclasses(ServiceSettings), key=lambda c: c.__qualname__) +assert ALL_SETTINGS_CLASSES, "No settings classes discovered" + + +# --------------------------------------------------------------------------- +# Service instantiation helpers +# --------------------------------------------------------------------------- + + +def _try_instantiate(cls): + """Try to instantiate a service with dummy values for required args. + + Inspects the __init__ signature and passes "test" for every required + keyword-only parameter. Services that need non-string required args + or fail for other reasons will raise and be skipped by the test. + """ + sig = inspect.signature(cls.__init__) + kwargs = {} + for name, param in sig.parameters.items(): + if name == "self": + continue + if param.kind in (param.VAR_POSITIONAL, param.VAR_KEYWORD): + continue + if param.default is not param.empty: + continue + # Required parameter — pass a dummy string + kwargs[name] = "test" + return cls(**kwargs) + + +def _discover_service_classes(): + """Return concrete service classes that can be instantiated with dummy args.""" + result = [] + for cls in sorted(_all_subclasses(AIService), key=lambda c: c.__qualname__): + # Skip abstract base classes defined in framework modules. + if cls.__module__ in _BASE_MODULES: + continue + try: + svc = _try_instantiate(cls) + except Exception: + continue + if hasattr(svc, "_settings"): + result.append(cls) + return result + + +ALL_SERVICE_CLASSES = _discover_service_classes() +assert ALL_SERVICE_CLASSES, "No service classes could be instantiated" + + +# --------------------------------------------------------------------------- +# 1. Settings defaults: delta-mode safety +# --------------------------------------------------------------------------- + + +@pytest.mark.parametrize("settings_cls", ALL_SETTINGS_CLASSES, ids=lambda c: c.__qualname__) +def test_delta_defaults_are_not_given(settings_cls): + """Every field must default to NOT_GIVEN so empty deltas are no-ops. + + A field that defaults to None instead of NOT_GIVEN will cause + apply_update() to overwrite the corresponding store value whenever + a partial delta is applied. + """ + instance = settings_cls() + for f in fields(instance): + if f.name == "extra": + continue + val = getattr(instance, f.name) + assert not is_given(val), ( + f"{settings_cls.__qualname__}.{f.name} defaults to {val!r}, expected NOT_GIVEN" + ) + + +# --------------------------------------------------------------------------- +# 2. Service construction: store-mode completeness +# --------------------------------------------------------------------------- + + +@pytest.mark.parametrize("service_cls", ALL_SERVICE_CLASSES, ids=lambda c: c.__qualname__) +def test_service_settings_complete(service_cls): + """After construction, _settings must have no NOT_GIVEN values. + + This is what validate_complete() checks in start(). Catching it + here means we don't need a running pipeline to find missing defaults. + """ + try: + svc = _try_instantiate(service_cls) + except Exception: + pytest.skip("Cannot re-instantiate (environment issue)") + for f in fields(svc._settings): + if f.name == "extra": + continue + val = getattr(svc._settings, f.name) + assert is_given(val), ( + f"{service_cls.__qualname__}._settings.{f.name} is NOT_GIVEN after construction" + ) From 939d753c2b350b894fc760ae8f1afa7ade91e98b Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 21:12:44 -0500 Subject: [PATCH 09/17] Update LLMs --- src/pipecat/services/aws/llm.py | 22 ++++-- src/pipecat/services/aws/nova_sonic/llm.py | 14 ++-- src/pipecat/services/azure/realtime/llm.py | 2 + src/pipecat/services/cerebras/llm.py | 2 + src/pipecat/services/deepseek/llm.py | 2 + src/pipecat/services/fireworks/llm.py | 2 + .../services/google/gemini_live/llm.py | 12 ++- .../services/google/gemini_live/llm_vertex.py | 10 ++- src/pipecat/services/google/llm_openai.py | 2 + src/pipecat/services/google/llm_vertex.py | 2 + src/pipecat/services/grok/llm.py | 2 + src/pipecat/services/grok/realtime/llm.py | 73 ++++++------------- src/pipecat/services/groq/llm.py | 2 + src/pipecat/services/mistral/llm.py | 2 + src/pipecat/services/nvidia/llm.py | 2 + src/pipecat/services/ollama/llm.py | 2 + src/pipecat/services/openai/base_llm.py | 9 +-- src/pipecat/services/openai/llm.py | 10 ++- src/pipecat/services/openai/realtime/llm.py | 60 +++++---------- .../services/openai_realtime_beta/azure.py | 2 + .../services/openai_realtime_beta/openai.py | 49 ++++--------- src/pipecat/services/openpipe/llm.py | 2 + src/pipecat/services/openrouter/llm.py | 2 + src/pipecat/services/perplexity/llm.py | 2 + src/pipecat/services/qwen/llm.py | 2 + src/pipecat/services/sambanova/llm.py | 2 + src/pipecat/services/together/llm.py | 2 + 27 files changed, 144 insertions(+), 151 deletions(-) diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index d688b6114..3b0392a0e 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -75,10 +75,12 @@ class AWSBedrockLLMSettings(LLMSettings): """Settings for AWS Bedrock LLM services. Parameters: + stop_sequences: List of strings that stop generation. latency: Performance mode - "standard" or "optimized". additional_model_request_fields: Additional model-specific parameters. """ + stop_sequences: List[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) latency: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) additional_model_request_fields: Dict[str, Any] | _NotGiven = field( default_factory=lambda: NOT_GIVEN @@ -810,6 +812,10 @@ class AWSBedrockLLMService(LLMService): deprecated parameters and *settings* are provided, *settings* values take precedence. stop_sequences: List of strings that stop generation. + + .. deprecated:: 0.0.105 + Use ``settings=AWSBedrockLLMSettings(stop_sequences=...)`` instead. + client_config: Custom boto3 client configuration. retry_timeout_secs: Request timeout in seconds for retry logic. retry_on_timeout: Whether to retry the request once if it times out. @@ -828,6 +834,7 @@ class AWSBedrockLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, + stop_sequences=None, latency=None, additional_model_request_fields={}, ) @@ -836,6 +843,9 @@ class AWSBedrockLLMService(LLMService): if model is not None: _warn_deprecated_param("model", AWSBedrockLLMSettings, "model") default_settings.model = model + if stop_sequences is not None: + _warn_deprecated_param("stop_sequences", AWSBedrockLLMSettings, "stop_sequences") + default_settings.stop_sequences = stop_sequences # 3. Apply params overrides — only if settings not provided if params is not None: @@ -844,6 +854,8 @@ class AWSBedrockLLMService(LLMService): default_settings.max_tokens = params.max_tokens default_settings.temperature = params.temperature default_settings.top_p = params.top_p + if params.stop_sequences: + default_settings.stop_sequences = params.stop_sequences default_settings.latency = params.latency if isinstance(params.additional_model_request_fields, dict): default_settings.additional_model_request_fields = ( @@ -856,14 +868,6 @@ class AWSBedrockLLMService(LLMService): super().__init__(settings=default_settings, **kwargs) - # Handle stop_sequences (not a settings field) - if stop_sequences is not None: - self._stop_sequences = stop_sequences - elif params is not None: - self._stop_sequences = params.stop_sequences or [] - else: - self._stop_sequences = [] - # Initialize the AWS Bedrock client if not client_config: client_config = Config( @@ -915,6 +919,8 @@ class AWSBedrockLLMService(LLMService): inference_config["temperature"] = self._settings.temperature if self._settings.top_p is not None: inference_config["topP"] = self._settings.top_p + if self._settings.stop_sequences: + inference_config["stopSequences"] = self._settings.stop_sequences return inference_config async def run_inference( diff --git a/src/pipecat/services/aws/nova_sonic/llm.py b/src/pipecat/services/aws/nova_sonic/llm.py index 7fec1c73c..9103ebdfd 100644 --- a/src/pipecat/services/aws/nova_sonic/llm.py +++ b/src/pipecat/services/aws/nova_sonic/llm.py @@ -191,12 +191,12 @@ class AWSNovaSonicLLMSettings(LLMSettings): """Settings for AWS Nova Sonic LLM service. Parameters: - voice_id: Voice for speech synthesis. + voice: Voice identifier for speech synthesis. endpointing_sensitivity: Controls how quickly Nova Sonic decides the user has stopped speaking. Can be "LOW", "MEDIUM", or "HIGH". """ - voice_id: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + voice: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) endpointing_sensitivity: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -250,7 +250,7 @@ class AWSNovaSonicLLMService(LLMService): - Nova Sonic (the older model): see https://docs.aws.amazon.com/nova/latest/userguide/available-voices.html. .. deprecated:: - Use ``settings=AWSNovaSonicLLMSettings(voice_id=...)`` instead. + Use ``settings=AWSNovaSonicLLMSettings(voice=...)`` instead. params: Model parameters for audio configuration and inference. @@ -273,7 +273,7 @@ class AWSNovaSonicLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = AWSNovaSonicLLMSettings( model="amazon.nova-2-sonic-v1:0", - voice_id="matthew", + voice="matthew", temperature=0.7, max_tokens=1024, top_p=0.9, @@ -291,8 +291,8 @@ class AWSNovaSonicLLMService(LLMService): _warn_deprecated_param("model", AWSNovaSonicLLMSettings, "model") default_settings.model = model if voice_id != "matthew": - _warn_deprecated_param("voice_id", AWSNovaSonicLLMSettings, "voice_id") - default_settings.voice_id = voice_id + _warn_deprecated_param("voice_id", AWSNovaSonicLLMSettings, "voice") + default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: @@ -811,7 +811,7 @@ class AWSNovaSonicLLMService(LLMService): "sampleRateHertz": {self._output_sample_rate}, "sampleSizeBits": {self._output_sample_size}, "channelCount": {self._output_channel_count}, - "voiceId": "{self._settings.voice_id}", + "voiceId": "{self._settings.voice}", "encoding": "base64", "audioType": "SPEECH" }}{tools_config} diff --git a/src/pipecat/services/azure/realtime/llm.py b/src/pipecat/services/azure/realtime/llm.py index fa645d8c1..0de2217d8 100644 --- a/src/pipecat/services/azure/realtime/llm.py +++ b/src/pipecat/services/azure/realtime/llm.py @@ -35,6 +35,8 @@ class AzureRealtimeLLMService(OpenAIRealtimeLLMService): real-time audio and text communication capabilities as the base OpenAI service. """ + _settings: AzureRealtimeLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index 40862f252..d98a2d7a4 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -31,6 +31,8 @@ class CerebrasLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: CerebrasLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/deepseek/llm.py b/src/pipecat/services/deepseek/llm.py index d778639ef..684e971ca 100644 --- a/src/pipecat/services/deepseek/llm.py +++ b/src/pipecat/services/deepseek/llm.py @@ -31,6 +31,8 @@ class DeepSeekLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: DeepSeekLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index 7ba3f9eac..86665cc48 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -31,6 +31,8 @@ class FireworksLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: FireworksLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/google/gemini_live/llm.py b/src/pipecat/services/google/gemini_live/llm.py index 6e7a8f8a1..146a0fcc4 100644 --- a/src/pipecat/services/google/gemini_live/llm.py +++ b/src/pipecat/services/google/gemini_live/llm.py @@ -610,6 +610,7 @@ class GeminiLiveLLMSettings(LLMSettings): """Settings for Gemini Live LLM services. Parameters: + voice: TTS voice identifier (e.g. ``"Charon"``). modalities: Response modalities. language: Language for generation. media_resolution: Media resolution setting. @@ -620,6 +621,7 @@ class GeminiLiveLLMSettings(LLMSettings): proactivity: Proactivity configuration. """ + voice: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) modalities: GeminiModalities | _NotGiven = field(default_factory=lambda: NOT_GIVEN) language: Language | str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) media_resolution: GeminiMediaResolution | _NotGiven = field(default_factory=lambda: NOT_GIVEN) @@ -680,6 +682,9 @@ class GeminiLiveLLMService(LLMService): Use ``settings=GeminiLiveLLMSettings(model=...)`` instead. voice_id: TTS voice identifier. Defaults to "Charon". + + .. deprecated:: 0.0.105 + Use ``settings=GeminiLiveLLMSettings(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. @@ -712,6 +717,7 @@ class GeminiLiveLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = GeminiLiveLLMSettings( model="models/gemini-2.5-flash-native-audio-preview-12-2025", + voice="Charon", frequency_penalty=None, max_tokens=4096, presence_penalty=None, @@ -736,6 +742,9 @@ class GeminiLiveLLMService(LLMService): if model is not None: _warn_deprecated_param("model", GeminiLiveLLMSettings, "model") default_settings.model = model + if voice_id != "Charon": + _warn_deprecated_param("voice_id", GeminiLiveLLMSettings, "voice") + default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: @@ -776,7 +785,6 @@ class GeminiLiveLLMService(LLMService): self._last_sent_time = 0 self._base_url = base_url - self._voice_id = voice_id self._language_code = params.language if params is not None else Language.EN_US self._system_instruction_from_init = system_instruction @@ -1184,7 +1192,7 @@ class GeminiLiveLLMService(LLMService): response_modalities=[Modality(self._settings.modalities.value)], speech_config=SpeechConfig( voice_config=VoiceConfig( - prebuilt_voice_config={"voice_name": self._voice_id} + prebuilt_voice_config={"voice_name": self._settings.voice} ), language_code=self._settings.language, ), diff --git a/src/pipecat/services/google/gemini_live/llm_vertex.py b/src/pipecat/services/google/gemini_live/llm_vertex.py index 43d3ab207..6264ea285 100644 --- a/src/pipecat/services/google/gemini_live/llm_vertex.py +++ b/src/pipecat/services/google/gemini_live/llm_vertex.py @@ -57,6 +57,8 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): responses, and tool usage. """ + _settings: GeminiLiveVertexLLMSettings + def __init__( self, *, @@ -90,6 +92,9 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): Use ``settings=GeminiLiveLLMSettings(model=...)`` instead. voice_id: TTS voice identifier. Defaults to "Charon". + + .. deprecated:: 0.0.105 + Use ``settings=GeminiLiveVertexLLMSettings(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. @@ -132,6 +137,7 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = GeminiLiveVertexLLMSettings( model="google/gemini-live-2.5-flash-native-audio", + voice="Charon", frequency_penalty=None, max_tokens=4096, presence_penalty=None, @@ -156,6 +162,9 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): if model is not None: _warn_deprecated_param("model", GeminiLiveVertexLLMSettings, "model") default_settings.model = model + if voice_id != "Charon": + _warn_deprecated_param("voice_id", GeminiLiveVertexLLMSettings, "voice") + default_settings.voice = voice_id # 3. Apply params overrides — only if settings not provided if params is not None: @@ -193,7 +202,6 @@ class GeminiLiveVertexLLMService(GeminiLiveLLMService): # api_key is required by parent class, but actually not used with # Vertex api_key="dummy", - voice_id=voice_id, start_audio_paused=start_audio_paused, start_video_paused=start_video_paused, system_instruction=system_instruction, diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index 1d7ae6bc4..96e208fcb 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -58,6 +58,8 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): https://ai.google.dev/gemini-api/docs/openai """ + _settings: GoogleOpenAILLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/google/llm_vertex.py b/src/pipecat/services/google/llm_vertex.py index e21341614..27f168042 100644 --- a/src/pipecat/services/google/llm_vertex.py +++ b/src/pipecat/services/google/llm_vertex.py @@ -59,6 +59,8 @@ class GoogleVertexLLMService(GoogleLLMService): https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference """ + _settings: GoogleVertexLLMSettings + class InputParams(GoogleLLMService.InputParams): """Input parameters specific to Vertex AI. diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index 7f9ac643b..59741cf9a 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -86,6 +86,8 @@ class GrokLLMService(OpenAILLMService): processing and reports final totals. """ + _settings: GrokLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/grok/realtime/llm.py b/src/pipecat/services/grok/realtime/llm.py index 2f2df1b45..638477b5e 100644 --- a/src/pipecat/services/grok/realtime/llm.py +++ b/src/pipecat/services/grok/realtime/llm.py @@ -13,7 +13,7 @@ https://docs.x.ai/docs/guides/voice/agent import base64 import json import time -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, Optional from loguru import logger @@ -56,7 +56,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import LLMSettings from pipecat.utils.time import time_now_iso8601 from . import events @@ -88,15 +88,9 @@ class CurrentAudioResponse: @dataclass class GrokRealtimeLLMSettings(LLMSettings): - """Settings for Grok Realtime LLM services. + """Settings for Grok Realtime LLM services.""" - Parameters: - session_properties: Grok Realtime session configuration. - """ - - session_properties: events.SessionProperties | _NotGiven = field( - default_factory=lambda: NOT_GIVEN - ) + pass class GrokRealtimeLLMService(LLMService): @@ -137,19 +131,13 @@ class GrokRealtimeLLMService(LLMService): base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.x.ai/v1/realtime". session_properties: Configuration properties for the realtime session. - - .. deprecated:: - Use ``settings=GrokRealtimeLLMSettings(session_properties=...)`` - instead. - If None, uses default SessionProperties with voice "Ara". To set a different voice, configure it in session_properties: session_properties = events.SessionProperties(voice="Rex") Available voices: Ara, Rex, Sal, Eve, Leo. - settings: Grok Realtime LLM settings. If provided together with deprecated - top-level parameters, the ``settings`` values take precedence. + settings: Runtime-updatable settings for this service. start_audio_paused: Whether to start with audio input paused. Defaults to False. **kwargs: Additional arguments passed to parent LLMService. """ @@ -165,17 +153,9 @@ class GrokRealtimeLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - session_properties=events.SessionProperties(), ) - # 2. Apply direct init arg overrides (deprecated) - if session_properties is not None: - _warn_deprecated_param( - "session_properties", GrokRealtimeLLMSettings, "session_properties" - ) - default_settings.session_properties = session_properties - - # 4. Apply settings delta (canonical API, always wins) + # 2. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -187,6 +167,7 @@ class GrokRealtimeLLMService(LLMService): self.api_key = api_key self.base_url = base_url + self._session_properties = session_properties or events.SessionProperties() self._audio_input_paused = start_audio_paused self._websocket = None @@ -235,13 +216,13 @@ class GrokRealtimeLLMService(LLMService): Configured sample rate or None if not manually configured. For PCMU/PCMA formats, returns 8000 Hz (G.711 standard). """ - if not self._settings.session_properties.audio: + if not self._session_properties.audio: return None audio_config = ( - self._settings.session_properties.audio.input + self._session_properties.audio.input if direction == "input" - else self._settings.session_properties.audio.output + else self._session_properties.audio.output ) if audio_config and audio_config.format: @@ -271,8 +252,8 @@ class GrokRealtimeLLMService(LLMService): def _is_turn_detection_enabled(self) -> bool: """Check if server-side VAD is enabled.""" - if self._settings.session_properties.turn_detection: - return self._settings.session_properties.turn_detection.type == "server_vad" + if self._session_properties.turn_detection: + return self._session_properties.turn_detection.type == "server_vad" return False async def _handle_interruption(self): @@ -339,7 +320,7 @@ class GrokRealtimeLLMService(LLMService): input_sample_rate: Sample rate for audio input (Hz). output_sample_rate: Sample rate for audio output (Hz). """ - props = self._settings.session_properties + props = self._session_properties if not props.audio: props.audio = events.AudioConfiguration() if not props.audio.input: @@ -395,7 +376,12 @@ class GrokRealtimeLLMService(LLMService): # directly. The frame.delta path falls through to super, which calls # _update_settings → our override handles the rest. if isinstance(frame, LLMUpdateSettingsFrame) and frame.delta is None: - self._settings.session_properties = events.SessionProperties(**frame.settings) + # Capture current audio config before replacing session properties. + input_rate = self._get_configured_sample_rate("input") + output_rate = self._get_configured_sample_rate("output") + self._session_properties = events.SessionProperties(**frame.settings) + if input_rate and output_rate: + self._ensure_audio_config(input_rate, output_rate) await self._send_session_update() await self.push_frame(frame, direction) return @@ -498,29 +484,14 @@ class GrokRealtimeLLMService(LLMService): await self.push_error(error_msg=f"Error sending client event: {e}", exception=e) async def _update_settings(self, delta): - """Apply a settings delta, sending a session update if needed.""" - # Capture current sample rates before the update replaces them. - input_rate = self._get_configured_sample_rate("input") - output_rate = self._get_configured_sample_rate("output") - + """Apply a settings delta.""" changed = await super()._update_settings(delta) - - if "session_properties" in changed: - if input_rate and output_rate: - self._ensure_audio_config(input_rate, output_rate) - else: - logger.warning( - "Attempting to apply session properties update without configured sample rates. " - "Audio configuration may be incomplete." - ) - await self._send_session_update() - - self._warn_unhandled_updated_settings(changed.keys() - {"session_properties"}) + self._warn_unhandled_updated_settings(changed.keys()) return changed async def _send_session_update(self): """Update session settings on the server.""" - settings = self._settings.session_properties + settings = self._session_properties adapter: GrokRealtimeLLMAdapter = self.get_llm_adapter() if self._context: diff --git a/src/pipecat/services/groq/llm.py b/src/pipecat/services/groq/llm.py index 5b81a4c7d..d7fc7f939 100644 --- a/src/pipecat/services/groq/llm.py +++ b/src/pipecat/services/groq/llm.py @@ -30,6 +30,8 @@ class GroqLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: GroqLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index c4deab4c3..801c02f9e 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -33,6 +33,8 @@ class MistralLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: MistralLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/nvidia/llm.py b/src/pipecat/services/nvidia/llm.py index 4ebfac0d8..48ccbaaf4 100644 --- a/src/pipecat/services/nvidia/llm.py +++ b/src/pipecat/services/nvidia/llm.py @@ -36,6 +36,8 @@ class NvidiaLLMService(OpenAILLMService): in token usage reporting between NIM (incremental) and OpenAI (final summary). """ + _settings: NvidiaLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/ollama/llm.py b/src/pipecat/services/ollama/llm.py index cd0c68099..d1c0eeebd 100644 --- a/src/pipecat/services/ollama/llm.py +++ b/src/pipecat/services/ollama/llm.py @@ -30,6 +30,8 @@ class OLLamaLLMService(OpenAILLMService): providing a compatible interface for running large language models locally. """ + _settings: OllamaLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index d44fbcf41..52fb451c3 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -53,11 +53,9 @@ class OpenAILLMSettings(LLMSettings): Parameters: max_completion_tokens: Maximum completion tokens to generate. - service_tier: Service tier to use (e.g., "auto", "flex", "priority"). """ max_completion_tokens: int | _NotGiven = field(default_factory=lambda: _NOT_GIVEN) - service_tier: str | _NotGiven = field(default_factory=lambda: _NOT_GIVEN) class BaseOpenAILLMService(LLMService): @@ -118,6 +116,7 @@ class BaseOpenAILLMService(LLMService): organization=None, project=None, default_headers: Optional[Mapping[str, str]] = None, + service_tier: Optional[str] = None, params: Optional[InputParams] = None, settings: Optional[OpenAILLMSettings] = None, retry_timeout_secs: Optional[float] = 5.0, @@ -138,6 +137,7 @@ class BaseOpenAILLMService(LLMService): organization: OpenAI organization ID. project: OpenAI project ID. default_headers: Additional HTTP headers to include in requests. + service_tier: Service tier to use (e.g., "auto", "flex", "priority"). params: Input parameters for model configuration and behavior. .. deprecated:: 0.0.105 @@ -161,7 +161,6 @@ class BaseOpenAILLMService(LLMService): top_k=None, max_tokens=NOT_GIVEN, max_completion_tokens=NOT_GIVEN, - service_tier=NOT_GIVEN, filter_incomplete_user_turns=False, user_turn_completion_config=None, extra={}, @@ -180,7 +179,6 @@ class BaseOpenAILLMService(LLMService): default_settings.top_p = params.top_p default_settings.max_tokens = params.max_tokens default_settings.max_completion_tokens = params.max_completion_tokens - default_settings.service_tier = params.service_tier if isinstance(params.extra, dict): default_settings.extra = params.extra @@ -192,6 +190,7 @@ class BaseOpenAILLMService(LLMService): settings=default_settings, **kwargs, ) + self._service_tier = service_tier self._retry_timeout_secs = retry_timeout_secs self._retry_on_timeout = retry_on_timeout self._system_instruction = system_instruction @@ -321,7 +320,7 @@ class BaseOpenAILLMService(LLMService): "top_p": self._settings.top_p, "max_tokens": self._settings.max_tokens, "max_completion_tokens": self._settings.max_completion_tokens, - "service_tier": self._settings.service_tier, + "service_tier": self._service_tier, } # Messages, tools, tool_choice diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index a81d3dc29..f2e3ad00a 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -76,6 +76,7 @@ class OpenAILLMService(BaseOpenAILLMService): self, *, model: Optional[str] = None, + service_tier: Optional[str] = None, params: Optional[BaseOpenAILLMService.InputParams] = None, settings: Optional[OpenAILLMSettings] = None, **kwargs, @@ -88,6 +89,7 @@ class OpenAILLMService(BaseOpenAILLMService): .. deprecated:: 0.0.105 Use ``settings=OpenAILLMSettings(model=...)`` instead. + service_tier: Service tier to use (e.g., "auto", "flex", "priority"). params: Input parameters for model configuration. .. deprecated:: 0.0.105 @@ -108,7 +110,6 @@ class OpenAILLMService(BaseOpenAILLMService): top_k=None, max_tokens=NOT_GIVEN, max_completion_tokens=NOT_GIVEN, - service_tier=NOT_GIVEN, filter_incomplete_user_turns=False, user_turn_completion_config=None, extra={}, @@ -119,6 +120,10 @@ class OpenAILLMService(BaseOpenAILLMService): _warn_deprecated_param("model", OpenAILLMSettings, "model") default_settings.model = model + # Handle service_tier from deprecated params + if params is not None and not settings and params.service_tier is not NOT_GIVEN: + service_tier = service_tier or params.service_tier + # 3. Apply params overrides — only if settings not provided if params is not None: _warn_deprecated_param("params", OpenAILLMSettings) @@ -130,7 +135,6 @@ class OpenAILLMService(BaseOpenAILLMService): default_settings.top_p = params.top_p default_settings.max_tokens = params.max_tokens default_settings.max_completion_tokens = params.max_completion_tokens - default_settings.service_tier = params.service_tier if isinstance(params.extra, dict): default_settings.extra = params.extra @@ -138,7 +142,7 @@ class OpenAILLMService(BaseOpenAILLMService): if settings is not None: default_settings.apply_update(settings) - super().__init__(settings=default_settings, **kwargs) + super().__init__(service_tier=service_tier, settings=default_settings, **kwargs) def create_context_aggregator( self, diff --git a/src/pipecat/services/openai/realtime/llm.py b/src/pipecat/services/openai/realtime/llm.py index 1230ed2db..761d7244b 100644 --- a/src/pipecat/services/openai/realtime/llm.py +++ b/src/pipecat/services/openai/realtime/llm.py @@ -10,7 +10,7 @@ import base64 import io import json import time -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Any, Optional from loguru import logger @@ -59,7 +59,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( ) from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import LLMSettings, _warn_deprecated_param from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_openai_realtime, traced_stt @@ -93,15 +93,9 @@ class CurrentAudioResponse: @dataclass class OpenAIRealtimeLLMSettings(LLMSettings): - """Settings for OpenAI Realtime LLM services. + """Settings for OpenAI Realtime LLM services.""" - Parameters: - session_properties: OpenAI Realtime session configuration. - """ - - session_properties: events.SessionProperties | _NotGiven = field( - default_factory=lambda: NOT_GIVEN - ) + pass class OpenAIRealtimeLLMService(LLMService): @@ -145,15 +139,8 @@ class OpenAIRealtimeLLMService(LLMService): base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.openai.com/v1/realtime". session_properties: Configuration properties for the realtime session. - - .. deprecated:: - Use ``settings=OpenAIRealtimeLLMSettings(session_properties=...)`` - instead. - - These are session-level settings that can be updated during the session - (except for voice and model). If None, uses default SessionProperties. - settings: Realtime LLM settings. If provided together with deprecated - top-level parameters, the ``settings`` values take precedence. + If None, uses default SessionProperties. + settings: Runtime-updatable settings for this service. 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. video_frame_detail: Detail level for video processing. Can be "auto", "low", or "high". @@ -192,20 +179,14 @@ class OpenAIRealtimeLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - session_properties=events.SessionProperties(), ) # 2. Apply direct init arg overrides (deprecated) if model is not None: _warn_deprecated_param("model", OpenAIRealtimeLLMSettings, "model") default_settings.model = model - if session_properties is not None: - _warn_deprecated_param( - "session_properties", OpenAIRealtimeLLMSettings, "session_properties" - ) - default_settings.session_properties = session_properties - # 4. Apply settings delta (canonical API, always wins) + # 3. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -220,6 +201,7 @@ class OpenAIRealtimeLLMService(LLMService): self.api_key = api_key self.base_url = full_url + self._session_properties = session_properties or events.SessionProperties() self._audio_input_paused = start_audio_paused self._video_input_paused = start_video_paused self._video_frame_detail = video_frame_detail @@ -282,12 +264,12 @@ class OpenAIRealtimeLLMService(LLMService): def _is_modality_enabled(self, modality: str) -> bool: """Check if a specific modality is enabled, "text" or "audio".""" - modalities = self._settings.session_properties.output_modalities or ["audio", "text"] + modalities = self._session_properties.output_modalities or ["audio", "text"] return modality in modalities def _get_enabled_modalities(self) -> list[str]: """Get the list of enabled modalities.""" - modalities = self._settings.session_properties.output_modalities or ["audio", "text"] + modalities = self._session_properties.output_modalities or ["audio", "text"] # API only supports single modality responses: either ["text"] or ["audio"] if "audio" in modalities: return ["audio"] @@ -360,9 +342,9 @@ class OpenAIRealtimeLLMService(LLMService): # None and False are different. Check for False. None means we're using OpenAI's # built-in turn detection defaults. turn_detection_disabled = ( - self._settings.session_properties.audio - and self._settings.session_properties.audio.input - and self._settings.session_properties.audio.input.turn_detection is False + self._session_properties.audio + and self._session_properties.audio.input + and self._session_properties.audio.input.turn_detection is False ) if turn_detection_disabled: await self.send_client_event(events.InputAudioBufferClearEvent()) @@ -382,9 +364,9 @@ class OpenAIRealtimeLLMService(LLMService): # None and False are different. Check for False. None means we're using OpenAI's # built-in turn detection defaults. turn_detection_disabled = ( - self._settings.session_properties.audio - and self._settings.session_properties.audio.input - and self._settings.session_properties.audio.input.turn_detection is False + self._session_properties.audio + and self._session_properties.audio.input + and self._session_properties.audio.input.turn_detection is False ) if turn_detection_disabled: await self.send_client_event(events.InputAudioBufferCommitEvent()) @@ -457,7 +439,7 @@ class OpenAIRealtimeLLMService(LLMService): # directly. The frame.delta path falls through to super, which calls # _update_settings → our override handles the rest. if isinstance(frame, LLMUpdateSettingsFrame) and frame.delta is None: - self._settings.session_properties = events.SessionProperties(**frame.settings) + self._session_properties = events.SessionProperties(**frame.settings) await self._send_session_update() await self.push_frame(frame, direction) return @@ -576,15 +558,13 @@ class OpenAIRealtimeLLMService(LLMService): await self.push_error(error_msg=f"Error sending client event: {e}", exception=e) async def _update_settings(self, delta): - """Apply a settings delta, sending a session update if needed.""" + """Apply a settings delta.""" changed = await super()._update_settings(delta) - if "session_properties" in changed: - await self._send_session_update() - self._warn_unhandled_updated_settings(changed.keys() - {"session_properties"}) + self._warn_unhandled_updated_settings(changed.keys()) return changed async def _send_session_update(self): - settings = self._settings.session_properties + settings = self._session_properties adapter: OpenAIRealtimeLLMAdapter = self.get_llm_adapter() if self._context: diff --git a/src/pipecat/services/openai_realtime_beta/azure.py b/src/pipecat/services/openai_realtime_beta/azure.py index fb85b1e79..72a1201f7 100644 --- a/src/pipecat/services/openai_realtime_beta/azure.py +++ b/src/pipecat/services/openai_realtime_beta/azure.py @@ -42,6 +42,8 @@ class AzureRealtimeBetaLLMService(OpenAIRealtimeBetaLLMService): real-time audio and text communication capabilities as the base OpenAI service. """ + _settings: AzureRealtimeBetaLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index 11b60c3b9..67a892e6f 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -10,7 +10,7 @@ import base64 import json import time import warnings -from dataclasses import dataclass, field +from dataclasses import dataclass from typing import Optional from loguru import logger @@ -54,7 +54,7 @@ from pipecat.processors.aggregators.openai_llm_context import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.services.llm_service import FunctionCallFromLLM, LLMService from pipecat.services.openai.llm import OpenAIContextAggregatorPair -from pipecat.services.settings import NOT_GIVEN, LLMSettings, _NotGiven, _warn_deprecated_param +from pipecat.services.settings import LLMSettings, _warn_deprecated_param from pipecat.transcriptions.language import Language from pipecat.utils.time import time_now_iso8601 from pipecat.utils.tracing.service_decorators import traced_openai_realtime, traced_stt @@ -94,15 +94,9 @@ class CurrentAudioResponse: @dataclass class OpenAIRealtimeBetaLLMSettings(LLMSettings): - """Settings for OpenAI Realtime Beta LLM services. + """Settings for OpenAI Realtime Beta LLM services.""" - Parameters: - session_properties: OpenAI Realtime session configuration. - """ - - session_properties: events.SessionProperties | _NotGiven = field( - default_factory=lambda: NOT_GIVEN - ) + pass class OpenAIRealtimeBetaLLMService(LLMService): @@ -146,14 +140,8 @@ class OpenAIRealtimeBetaLLMService(LLMService): base_url: WebSocket base URL for the realtime API. Defaults to "wss://api.openai.com/v1/realtime". session_properties: Configuration properties for the realtime session. - - .. deprecated:: - Use ``settings=OpenAIRealtimeBetaLLMSettings(session_properties=...)`` - instead. - If None, uses default SessionProperties. - settings: Realtime Beta LLM settings. If provided together with deprecated - top-level parameters, the ``settings`` values take precedence. + settings: Runtime-updatable settings for this service. start_audio_paused: Whether to start with audio input paused. Defaults to False. send_transcription_frames: Whether to emit transcription frames. Defaults to True. **kwargs: Additional arguments passed to parent LLMService. @@ -179,20 +167,13 @@ class OpenAIRealtimeBetaLLMService(LLMService): seed=None, filter_incomplete_user_turns=False, user_turn_completion_config=None, - session_properties=events.SessionProperties(), ) # 2. Apply direct init arg overrides (deprecated) if model is not None: _warn_deprecated_param("model", OpenAIRealtimeBetaLLMSettings, "model") default_settings.model = model - if session_properties is not None: - _warn_deprecated_param( - "session_properties", OpenAIRealtimeBetaLLMSettings, "session_properties" - ) - default_settings.session_properties = session_properties - - # 4. Apply settings delta (canonical API, always wins) + # 3. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -205,6 +186,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): self.api_key = api_key self.base_url = full_url + self._session_properties = session_properties or events.SessionProperties() self._audio_input_paused = start_audio_paused self._send_transcription_frames = send_transcription_frames self._websocket = None @@ -243,12 +225,12 @@ class OpenAIRealtimeBetaLLMService(LLMService): def _is_modality_enabled(self, modality: str) -> bool: """Check if a specific modality is enabled, "text" or "audio".""" - modalities = self._settings.session_properties.modalities or ["audio", "text"] + modalities = self._session_properties.modalities or ["audio", "text"] return modality in modalities def _get_enabled_modalities(self) -> list[str]: """Get the list of enabled modalities.""" - return self._settings.session_properties.modalities or ["audio", "text"] + return self._session_properties.modalities or ["audio", "text"] async def retrieve_conversation_item(self, item_id: str): """Retrieve a conversation item by ID from the server. @@ -315,7 +297,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): async def _handle_interruption(self): # None and False are different. Check for False. None means we're using OpenAI's # built-in turn detection defaults. - if self._settings.session_properties.turn_detection is False: + if self._session_properties.turn_detection is False: await self.send_client_event(events.InputAudioBufferClearEvent()) await self.send_client_event(events.ResponseCancelEvent()) await self._truncate_current_audio_response() @@ -332,7 +314,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): async def _handle_user_stopped_speaking(self, frame): # None and False are different. Check for False. None means we're using OpenAI's # built-in turn detection defaults. - if self._settings.session_properties.turn_detection is False: + if self._session_properties.turn_detection is False: await self.send_client_event(events.InputAudioBufferCommitEvent()) await self.send_client_event(events.ResponseCreateEvent()) @@ -403,7 +385,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): # directly. The frame.delta path falls through to super, which calls # _update_settings → our override handles the rest. if isinstance(frame, LLMUpdateSettingsFrame) and frame.delta is None: - self._settings.session_properties = events.SessionProperties(**frame.settings) + self._session_properties = events.SessionProperties(**frame.settings) await self._send_session_update() await self.push_frame(frame, direction) return @@ -520,14 +502,13 @@ class OpenAIRealtimeBetaLLMService(LLMService): await self.push_error(error_msg=f"Error sending client event: {e}", exception=e) async def _update_settings(self, delta): - """Apply a settings delta, sending a session update if needed.""" + """Apply a settings delta.""" changed = await super()._update_settings(delta) - if "session_properties" in changed: - await self._send_session_update() + self._warn_unhandled_updated_settings(changed.keys()) return changed async def _send_session_update(self): - settings = self._settings.session_properties + settings = self._session_properties # tools given in the context override the tools in the session properties if self._context and self._context.tools: settings.tools = self._context.tools diff --git a/src/pipecat/services/openpipe/llm.py b/src/pipecat/services/openpipe/llm.py index b2e953e64..f6437feef 100644 --- a/src/pipecat/services/openpipe/llm.py +++ b/src/pipecat/services/openpipe/llm.py @@ -43,6 +43,8 @@ class OpenPipeLLMService(OpenAILLMService): for model training and evaluation. """ + _settings: OpenPipeLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/openrouter/llm.py b/src/pipecat/services/openrouter/llm.py index fa2f170ee..03591de46 100644 --- a/src/pipecat/services/openrouter/llm.py +++ b/src/pipecat/services/openrouter/llm.py @@ -34,6 +34,8 @@ class OpenRouterLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: OpenRouterLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index d90aea6a4..9969020c5 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -38,6 +38,8 @@ class PerplexityLLMService(OpenAILLMService): in token usage reporting between Perplexity (incremental) and OpenAI (final summary). """ + _settings: PerplexityLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/qwen/llm.py b/src/pipecat/services/qwen/llm.py index 6d9abeefe..e08566418 100644 --- a/src/pipecat/services/qwen/llm.py +++ b/src/pipecat/services/qwen/llm.py @@ -30,6 +30,8 @@ class QwenLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: QwenLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index f87b432cc..cdd2139da 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -42,6 +42,8 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: SambaNovaLLMSettings + def __init__( self, *, diff --git a/src/pipecat/services/together/llm.py b/src/pipecat/services/together/llm.py index 23e38f752..2fa952a95 100644 --- a/src/pipecat/services/together/llm.py +++ b/src/pipecat/services/together/llm.py @@ -30,6 +30,8 @@ class TogetherLLMService(OpenAILLMService): maintaining full compatibility with OpenAI's interface and functionality. """ + _settings: TogetherLLMSettings + def __init__( self, *, From 14c3a88f02332615e900b76af4ca614c48c1e733 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 21:20:54 -0500 Subject: [PATCH 10/17] Fix tests --- tests/test_service_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_service_init.py b/tests/test_service_init.py index 73cb6a337..67dcbb324 100644 --- a/tests/test_service_init.py +++ b/tests/test_service_init.py @@ -73,7 +73,7 @@ def _import_all_service_modules(): """Import every module under pipecat.services (skipping missing deps).""" package = pipecat.services for _importer, modname, _ispkg in pkgutil.walk_packages( - package.__path__, prefix=package.__name__ + "." + package.__path__, prefix=package.__name__ + ".", onerror=lambda _name: None ): try: importlib.import_module(modname) From 62554a2390088164a589bb5599a28627c8c4ac56 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 22:55:51 -0500 Subject: [PATCH 11/17] Update examples --- .../foundational/01-say-one-thing-piper.py | 4 +- .../foundational/01-say-one-thing-rime.py | 6 +- examples/foundational/01-say-one-thing.py | 6 +- examples/foundational/01a-local-audio.py | 6 +- examples/foundational/01b-livekit-audio.py | 6 +- examples/foundational/02-llm-say-one-thing.py | 6 +- .../04-transports-small-webrtc.py | 6 +- examples/foundational/04a-transports-daily.py | 12 ++-- .../foundational/04b-transports-livekit.py | 6 +- .../foundational/05-sync-speech-and-image.py | 6 +- .../05a-local-sync-speech-and-image.py | 6 +- .../foundational/06-listen-and-respond.py | 6 +- examples/foundational/06a-image-sync.py | 6 +- .../07-interruptible-cartesia-http.py | 6 +- .../07a-interruptible-speechmatics-vad.py | 37 +++++------- .../07a-interruptible-speechmatics.py | 36 +++++------- .../07b-interruptible-langchain.py | 6 +- .../07c-interruptible-deepgram-flux.py | 15 +++-- .../07c-interruptible-deepgram-http.py | 10 ++-- .../07c-interruptible-deepgram-vad.py | 17 ++++-- .../07c-interruptible-deepgram.py | 9 ++- .../07d-interruptible-elevenlabs-http.py | 6 +- .../07d-interruptible-elevenlabs.py | 6 +- .../foundational/07g-interruptible-openai.py | 23 ++++---- .../07h-interruptible-openpipe.py | 6 +- .../foundational/07i-interruptible-xtts.py | 6 +- .../07j-interruptible-gladia-vad.py | 28 +++++---- .../foundational/07j-interruptible-gladia.py | 28 +++++---- .../foundational/07k-interruptible-lmnt.py | 9 ++- .../foundational/07l-interruptible-groq.py | 6 +- .../07m-interruptible-aws-strands.py | 9 ++- .../foundational/07m-interruptible-aws.py | 9 ++- .../07n-interruptible-gemini-image.py | 22 ++++--- .../foundational/07n-interruptible-gemini.py | 14 +++-- .../07n-interruptible-google-http.py | 27 +++++---- .../foundational/07n-interruptible-google.py | 27 +++++---- ...interruptible-assemblyai-turn-detection.py | 11 ++-- .../07o-interruptible-assemblyai.py | 6 +- .../07p-interruptible-krisp-viva.py | 7 ++- .../foundational/07p-interruptible-krisp.py | 9 ++- .../07q-interruptible-rime-http.py | 7 ++- .../foundational/07q-interruptible-rime.py | 6 +- .../foundational/07r-interruptible-nvidia.py | 6 +- .../07s-interruptible-google-audio-in.py | 13 +++-- .../foundational/07t-interruptible-fish.py | 6 +- .../07v-interruptible-neuphonic-http.py | 6 +- .../07v-interruptible-neuphonic.py | 6 +- .../foundational/07w-interruptible-fal.py | 6 +- .../foundational/07x-interruptible-local.py | 6 +- .../foundational/07y-interruptible-minimax.py | 6 +- .../07z-interruptible-sarvam-http.py | 6 +- .../foundational/07z-interruptible-sarvam.py | 14 +++-- .../foundational/07za-interruptible-soniox.py | 20 ++++--- .../07zb-interruptible-inworld-http.py | 10 ++-- .../07zb-interruptible-inworld.py | 10 ++-- .../07zc-interruptible-asyncai-http.py | 6 +- .../07zc-interruptible-asyncai.py | 6 +- .../07zd-interruptible-aicoustics.py | 6 +- .../foundational/07ze-interruptible-hume.py | 6 +- .../07zf-interruptible-gradium.py | 10 ++-- .../foundational/07zg-interruptible-camb.py | 6 +- .../foundational/07zi-interruptible-piper.py | 8 ++- .../foundational/07zj-interruptible-kokoro.py | 8 ++- .../07zk-interruptible-resemble.py | 6 +- .../foundational/08-custom-frame-processor.py | 6 +- examples/foundational/10-wake-phrase.py | 6 +- examples/foundational/11-sound-effects.py | 6 +- .../foundational/12-describe-image-openai.py | 6 +- .../12a-describe-image-anthropic.py | 6 +- .../foundational/12b-describe-image-aws.py | 20 ++++--- .../12c-describe-image-gemini-flash.py | 6 +- .../12d-describe-image-moondream.py | 6 +- .../13b-deepgram-transcription.py | 6 +- .../foundational/13c-gladia-transcription.py | 6 +- .../foundational/13c-gladia-translation.py | 12 ++-- .../13d-assemblyai-transcription.py | 7 +-- examples/foundational/13e-whisper-mlx.py | 8 ++- .../13g-sambanova-transcription.py | 6 +- .../13h-speechmatics-transcription.py | 4 +- .../foundational/13l-gradium-transcription.py | 7 ++- .../foundational/13m-openai-transcription.py | 8 ++- examples/foundational/14-function-calling.py | 6 +- .../14a-function-calling-anthropic.py | 22 +++---- .../14c-function-calling-together.py | 12 ++-- .../14d-function-calling-anthropic-video.py | 6 +- .../14d-function-calling-aws-video.py | 20 ++++--- ...14d-function-calling-gemini-flash-video.py | 6 +- .../14d-function-calling-moondream-video.py | 6 +- .../14d-function-calling-openai-video.py | 6 +- .../14e-function-calling-google.py | 58 ++++++++++--------- .../foundational/14f-function-calling-groq.py | 6 +- .../foundational/14g-function-calling-grok.py | 6 +- .../14h-function-calling-azure.py | 12 ++-- .../14i-function-calling-fireworks.py | 12 ++-- .../14j-function-calling-nvidia.py | 29 ++++------ .../14k-function-calling-cerebras.py | 6 +- .../14l-function-calling-deepseek.py | 12 ++-- .../14m-function-calling-openrouter.py | 16 +++-- .../14n-function-calling-perplexity.py | 20 +++---- ...o-function-calling-gemini-openai-format.py | 11 +++- .../14p-function-calling-gemini-vertex-ai.py | 7 ++- .../foundational/14q-function-calling-qwen.py | 6 +- .../foundational/14r-function-calling-aws.py | 17 ++++-- .../14s-function-calling-sambanova.py | 6 +- .../14t-function-calling-direct.py | 6 +- .../14u-function-calling-ollama.py | 12 ++-- .../14v-function-calling-openai.py | 16 ++--- .../14w-function-calling-mistral.py | 6 +- .../14x-function-calling-openpipe.py | 6 +- examples/foundational/15-switch-voices.py | 14 +++-- examples/foundational/15a-switch-languages.py | 10 +++- .../16-gpu-container-local-bot.py | 12 ++-- examples/foundational/17-detect-user-idle.py | 6 +- .../19b-openai-realtime-beta-text.py | 6 +- .../foundational/19b-openai-realtime-text.py | 6 +- .../20a-persistent-context-openai.py | 6 +- .../20c-persistent-context-anthropic.py | 10 ++-- .../20d-persistent-context-gemini.py | 6 +- examples/foundational/21-tavus-transport.py | 6 +- .../foundational/21a-tavus-video-service.py | 6 +- .../22-filter-incomplete-turns.py | 24 ++++---- .../foundational/23-bot-background-sound.py | 6 +- .../foundational/24-user-mute-strategy.py | 9 ++- examples/foundational/25-google-audio-in.py | 18 +++--- examples/foundational/26d-gemini-live-text.py | 2 +- examples/foundational/27-simli-layer.py | 12 ++-- .../foundational/28-user-assistant-turns.py | 6 +- .../foundational/29-turn-tracking-observer.py | 6 +- examples/foundational/30-observer.py | 6 +- .../32-gemini-grounding-metadata.py | 6 +- examples/foundational/33-gemini-rag.py | 29 ++++++---- examples/foundational/34-audio-recording.py | 7 ++- .../35-pattern-pair-voice-switching.py | 23 ++++---- .../foundational/36-user-email-gathering.py | 6 +- examples/foundational/37-mem0.py | 12 ++-- examples/foundational/38-smart-turn-fal.py | 6 +- .../38a-smart-turn-local-coreml.py | 6 +- examples/foundational/38b-smart-turn-local.py | 6 +- examples/foundational/39-mcp-stdio.py | 40 ++++++------- .../foundational/39a-mcp-streamable-http.py | 6 +- .../39b-mcp-streamable-http-gemini-live.py | 6 +- examples/foundational/39c-multiple-mcp.py | 14 ++--- .../foundational/42-interruption-config.py | 6 +- examples/foundational/43-heygen-transport.py | 6 +- .../foundational/43a-heygen-video-service.py | 6 +- .../foundational/44-voicemail-detection.py | 6 +- .../45-before-and-after-events.py | 6 +- examples/foundational/47-sentry-metrics.py | 6 +- examples/foundational/48-service-switcher.py | 31 +++++----- .../foundational/49a-thinking-anthropic.py | 19 ++++-- examples/foundational/49b-thinking-google.py | 15 ++--- .../49c-thinking-functions-anthropic.py | 19 ++++-- .../49d-thinking-functions-google.py | 15 ++--- examples/foundational/52-live-translation.py | 6 +- .../53-concurrent-llm-evaluation.py | 43 ++++++-------- .../53-concurrent-llm-rtvi-ignored-sources.py | 43 +++++--------- .../54-context-summarization-openai.py | 6 +- .../54a-context-summarization-google.py | 6 +- ...54b-context-summarization-manual-openai.py | 36 +++++------- ...54c-context-summarization-dedicated-llm.py | 42 +++++++------- .../55a-update-settings-deepgram-flux-stt.py | 6 +- ...-update-settings-deepgram-sagemaker-stt.py | 6 +- .../55a-update-settings-deepgram-stt.py | 6 +- .../55b-update-settings-azure-stt.py | 6 +- .../55c-update-settings-google-stt.py | 6 +- .../55d-update-settings-assemblyai-stt.py | 6 +- .../55e-update-settings-gladia-stt.py | 6 +- ...update-settings-elevenlabs-realtime-stt.py | 6 +- .../55g-update-settings-elevenlabs-stt.py | 6 +- .../55h-update-settings-speechmatics-stt.py | 6 +- .../55i-update-settings-whisper-api-stt.py | 6 +- .../55j-update-settings-sarvam-stt.py | 6 +- .../55k-update-settings-soniox-stt.py | 6 +- .../55l-update-settings-aws-transcribe-stt.py | 6 +- .../55m-update-settings-cartesia-stt.py | 6 +- .../55n-update-settings-cartesia-http-tts.py | 4 +- .../55n-update-settings-cartesia-tts.py | 4 +- .../55zi-update-settings-azure-llm.py | 6 +- .../55zi-update-settings-openai-llm.py | 6 +- .../55zj-update-settings-anthropic-llm.py | 6 +- .../55zk-update-settings-google-llm.py | 6 +- .../55zk-update-settings-google-vertex-llm.py | 6 +- .../55zp-update-settings-aws-bedrock-llm.py | 6 +- .../55zq-update-settings-fal-stt.py | 6 +- .../55zr-update-settings-gradium-stt.py | 6 +- ...zt-update-settings-nvidia-segmented-stt.py | 6 +- .../55zt-update-settings-nvidia-stt.py | 6 +- ...5zu-update-settings-openai-realtime-stt.py | 6 +- .../55zx-update-settings-cerebras-llm.py | 6 +- .../55zy-update-settings-deepseek-llm.py | 6 +- .../55zz-update-settings-fireworks-llm.py | 6 +- .../55zza-update-settings-grok-llm.py | 6 +- .../55zzb-update-settings-groq-llm.py | 6 +- .../55zzc-update-settings-mistral-llm.py | 6 +- .../55zzd-update-settings-nvidia-llm.py | 6 +- .../55zze-update-settings-ollama-llm.py | 6 +- .../55zzf-update-settings-openrouter-llm.py | 6 +- .../55zzg-update-settings-perplexity-llm.py | 6 +- .../55zzh-update-settings-qwen-llm.py | 6 +- .../55zzi-update-settings-sambanova-llm.py | 6 +- .../55zzj-update-settings-together-llm.py | 6 +- .../55zzn-update-settings-groq-stt.py | 6 +- .../foundational/56-lemonslice-transport.py | 6 +- examples/quickstart/bot.py | 6 +- scripts/evals/eval.py | 2 +- src/pipecat/services/openai/base_llm.py | 2 +- src/pipecat/services/sarvam/tts.py | 21 +------ 207 files changed, 1241 insertions(+), 852 deletions(-) diff --git a/examples/foundational/01-say-one-thing-piper.py b/examples/foundational/01-say-one-thing-piper.py index cace8dbeb..6c4e1836e 100644 --- a/examples/foundational/01-say-one-thing-piper.py +++ b/examples/foundational/01-say-one-thing-piper.py @@ -39,7 +39,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: tts = PiperHttpTTSService( - base_url=os.getenv("PIPER_BASE_URL"), aiohttp_session=session, sample_rate=24000 + base_url=os.getenv("PIPER_BASE_URL"), + aiohttp_session=session, + sample_rate=24000, ) task = PipelineTask( diff --git a/examples/foundational/01-say-one-thing-rime.py b/examples/foundational/01-say-one-thing-rime.py index 2a31efa68..63667fac8 100644 --- a/examples/foundational/01-say-one-thing-rime.py +++ b/examples/foundational/01-say-one-thing-rime.py @@ -16,7 +16,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.rime.tts import RimeHttpTTSService +from pipecat.services.rime.tts import RimeHttpTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -39,8 +39,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: tts = RimeHttpTTSService( api_key=os.getenv("RIME_API_KEY", ""), - voice_id="rex", aiohttp_session=session, + settings=RimeTTSSettings( + voice="rex", + ), ) task = PipelineTask( diff --git a/examples/foundational/01-say-one-thing.py b/examples/foundational/01-say-one-thing.py index 7df26701c..bfcf829cc 100644 --- a/examples/foundational/01-say-one-thing.py +++ b/examples/foundational/01-say-one-thing.py @@ -15,7 +15,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -37,7 +37,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) task = PipelineTask( diff --git a/examples/foundational/01a-local-audio.py b/examples/foundational/01a-local-audio.py index 432880203..77565dffe 100644 --- a/examples/foundational/01a-local-audio.py +++ b/examples/foundational/01a-local-audio.py @@ -15,7 +15,7 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.transports.local.audio import LocalAudioTransport, LocalAudioTransportParams load_dotenv(override=True) @@ -29,7 +29,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) pipeline = Pipeline([tts, transport.output()]) diff --git a/examples/foundational/01b-livekit-audio.py b/examples/foundational/01b-livekit-audio.py index a7697646e..ad4c785eb 100644 --- a/examples/foundational/01b-livekit-audio.py +++ b/examples/foundational/01b-livekit-audio.py @@ -16,7 +16,7 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.livekit import configure -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.transports.livekit.transport import LiveKitParams, LiveKitTransport load_dotenv(override=True) @@ -37,7 +37,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) runner = PipelineRunner() diff --git a/examples/foundational/02-llm-say-one-thing.py b/examples/foundational/02-llm-say-one-thing.py index 9cfd7c39e..3ee536a64 100644 --- a/examples/foundational/02-llm-say-one-thing.py +++ b/examples/foundational/02-llm-say-one-thing.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -39,7 +39,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/04-transports-small-webrtc.py b/examples/foundational/04-transports-small-webrtc.py index d29171dd2..6cf32a285 100644 --- a/examples/foundational/04-transports-small-webrtc.py +++ b/examples/foundational/04-transports-small-webrtc.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import TransportParams @@ -67,7 +67,9 @@ async def run_example(webrtc_connection: SmallWebRTCConnection): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/04a-transports-daily.py b/examples/foundational/04a-transports-daily.py index b0a7958ef..8b23cb69e 100644 --- a/examples/foundational/04a-transports-daily.py +++ b/examples/foundational/04a-transports-daily.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.runner.daily import configure -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.daily.transport import DailyParams, DailyTransport load_dotenv(override=True) @@ -50,12 +50,16 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o", + settings=OpenAILLMSettings( + model="gpt-4o", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/04b-transports-livekit.py b/examples/foundational/04b-transports-livekit.py index e05c5ddc3..f55f106c1 100644 --- a/examples/foundational/04b-transports-livekit.py +++ b/examples/foundational/04b-transports-livekit.py @@ -29,7 +29,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.runner.livekit import configure -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.livekit.transport import LiveKitParams, LiveKitTransport @@ -62,7 +62,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) context = LLMContext() diff --git a/examples/foundational/05-sync-speech-and-image.py b/examples/foundational/05-sync-speech-and-image.py index c1b142670..95de1143b 100644 --- a/examples/foundational/05-sync-speech-and-image.py +++ b/examples/foundational/05-sync-speech-and-image.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.sentence import SentenceAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaHttpTTSService +from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings from pipecat.services.fal.image import FalImageGenService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -98,7 +98,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) imagegen = FalImageGenService( diff --git a/examples/foundational/05a-local-sync-speech-and-image.py b/examples/foundational/05a-local-sync-speech-and-image.py index 56309c0a5..03b690c11 100644 --- a/examples/foundational/05a-local-sync-speech-and-image.py +++ b/examples/foundational/05a-local-sync-speech-and-image.py @@ -28,7 +28,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.sentence import SentenceAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.services.cartesia.tts import CartesiaHttpTTSService +from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings from pipecat.services.fal.image import FalImageGenService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.local.tk import TkLocalTransport, TkTransportParams @@ -98,7 +98,9 @@ async def main(): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) imagegen = FalImageGenService( diff --git a/examples/foundational/06-listen-and-respond.py b/examples/foundational/06-listen-and-respond.py index 418b3b5af..c90d79c4e 100644 --- a/examples/foundational/06-listen-and-respond.py +++ b/examples/foundational/06-listen-and-respond.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -83,7 +83,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/06a-image-sync.py b/examples/foundational/06a-image-sync.py index f963aa339..666f4739c 100644 --- a/examples/foundational/06a-image-sync.py +++ b/examples/foundational/06a-image-sync.py @@ -29,7 +29,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -100,7 +100,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07-interruptible-cartesia-http.py b/examples/foundational/07-interruptible-cartesia-http.py index 8ce1ed375..b20289ce2 100644 --- a/examples/foundational/07-interruptible-cartesia-http.py +++ b/examples/foundational/07-interruptible-cartesia-http.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService -from pipecat.services.cartesia.tts import CartesiaHttpTTSService +from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -58,8 +58,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady aiohttp_session=session, + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07a-interruptible-speechmatics-vad.py b/examples/foundational/07a-interruptible-speechmatics-vad.py index d75ae2b1f..5bb8459e2 100644 --- a/examples/foundational/07a-interruptible-speechmatics-vad.py +++ b/examples/foundational/07a-interruptible-speechmatics-vad.py @@ -21,10 +21,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.base_llm import BaseOpenAILLMService +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.speechmatics.stt import SpeechmaticsSTTService -from pipecat.services.speechmatics.tts import SpeechmaticsTTSService +from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings +from pipecat.services.speechmatics.tts import SpeechmaticsTTSService, SpeechmaticsTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -93,7 +93,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( language=Language.EN, turn_detection_mode=SpeechmaticsSTTService.TurnDetectionMode.ADAPTIVE, # focus_speakers=["S1"], @@ -104,32 +104,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SpeechmaticsTTSService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - voice_id="sarah", + settings=SpeechmaticsTTSSettings( + voice="sarah", + ), aiohttp_session=session, ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - params=BaseOpenAILLMService.InputParams(temperature=0.75), + settings=OpenAILLMSettings( + temperature=0.75, + ), + system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful British assistant called Sarah. " - "Your goal is to demonstrate your capabilities in a succinct way. " - "Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. " - "Always include punctuation in your responses. " - "Give very short replies - do not give longer replies unless strictly necessary. " - "Respond to what the user said in a concise, funny, creative and helpful way. " - "Use `` tags to identify different speakers - do not use tags in your replies. " - "Do not respond to speakers within `` tags unless explicitly asked to. " - ), - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(user_turn_strategies=ExternalUserTurnStrategies()), @@ -160,7 +149,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Say a short hello to the user."}) + context.add_message({"role": "system", "content": "Say a short hello to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07a-interruptible-speechmatics.py b/examples/foundational/07a-interruptible-speechmatics.py index f8b4cdf19..caecb74be 100644 --- a/examples/foundational/07a-interruptible-speechmatics.py +++ b/examples/foundational/07a-interruptible-speechmatics.py @@ -22,10 +22,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.base_llm import BaseOpenAILLMService +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.speechmatics.stt import SpeechmaticsSTTService -from pipecat.services.speechmatics.tts import SpeechmaticsTTSService +from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings +from pipecat.services.speechmatics.tts import SpeechmaticsTTSService, SpeechmaticsTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -76,7 +76,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( language=Language.EN, speaker_active_format="<{speaker_id}>{text}", ), @@ -84,31 +84,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SpeechmaticsTTSService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - voice_id="sarah", + settings=SpeechmaticsTTSSettings( + voice="sarah", + ), aiohttp_session=session, ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - params=BaseOpenAILLMService.InputParams(temperature=0.75), + settings=OpenAILLMSettings( + temperature=0.75, + ), + system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful British assistant called Sarah. " - "Your goal is to demonstrate your capabilities in a succinct way. " - "Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. " - "Always include punctuation in your responses. " - "Give very short replies - do not give longer replies unless strictly necessary. " - "Respond to what the user said in a concise, funny, creative and helpful way. " - "Use `` tags to identify different speakers - do not use tags in your replies." - ), - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -139,7 +129,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Say a short hello to the user."}) + context.add_message({"role": "system", "content": "Say a short hello to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07b-interruptible-langchain.py b/examples/foundational/07b-interruptible-langchain.py index 21290b576..e7a5dc1b8 100644 --- a/examples/foundational/07b-interruptible-langchain.py +++ b/examples/foundational/07b-interruptible-langchain.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frameworks.langchain import LangchainProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) prompt = ChatPromptTemplate.from_messages( diff --git a/examples/foundational/07c-interruptible-deepgram-flux.py b/examples/foundational/07c-interruptible-deepgram-flux.py index 3f2d6e28d..4eafc24a7 100644 --- a/examples/foundational/07c-interruptible-deepgram-flux.py +++ b/examples/foundational/07c-interruptible-deepgram-flux.py @@ -22,8 +22,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService, DeepgramFluxSTTSettings +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,10 +56,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramFluxSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - params=DeepgramFluxSTTService.InputParams(min_confidence=0.3), + settings=DeepgramFluxSTTSettings( + min_confidence=0.3, + ), ) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-2-andromeda-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07c-interruptible-deepgram-http.py b/examples/foundational/07c-interruptible-deepgram-http.py index 6955ccbd1..e6281fbc5 100644 --- a/examples/foundational/07c-interruptible-deepgram-http.py +++ b/examples/foundational/07c-interruptible-deepgram-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramHttpTTSService +from pipecat.services.deepgram.tts import DeepgramHttpTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = DeepgramHttpTTSService( api_key=os.getenv("DEEPGRAM_API_KEY"), - voice="aura-2-andromeda-en", + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), aiohttp_session=session, ) @@ -68,9 +70,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) - messages = [] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/07c-interruptible-deepgram-vad.py b/examples/foundational/07c-interruptible-deepgram-vad.py index aaa81fc90..81acad665 100644 --- a/examples/foundational/07c-interruptible-deepgram-vad.py +++ b/examples/foundational/07c-interruptible-deepgram-vad.py @@ -7,7 +7,6 @@ import os -from deepgram import LiveOptions from dotenv import load_dotenv from loguru import logger @@ -22,8 +21,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,10 +55,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - live_options=LiveOptions(vad_events=True, utterance_end_ms="1000"), + settings=DeepgramSTTSettings( + vad_events=True, + utterance_end_ms="1000", + ), ) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-2-andromeda-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07c-interruptible-deepgram.py b/examples/foundational/07c-interruptible-deepgram.py index 1cbfc72cc..d33a19d56 100644 --- a/examples/foundational/07c-interruptible-deepgram.py +++ b/examples/foundational/07c-interruptible-deepgram.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -55,7 +55,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-2-andromeda-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07d-interruptible-elevenlabs-http.py b/examples/foundational/07d-interruptible-elevenlabs-http.py index 85cffc270..0dd95900c 100644 --- a/examples/foundational/07d-interruptible-elevenlabs-http.py +++ b/examples/foundational/07d-interruptible-elevenlabs-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.stt import ElevenLabsSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService, ElevenLabsHttpTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -63,8 +63,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsHttpTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), aiohttp_session=session, + settings=ElevenLabsHttpTTSSettings( + voice=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07d-interruptible-elevenlabs.py b/examples/foundational/07d-interruptible-elevenlabs.py index b55345f33..c4f31ac9b 100644 --- a/examples/foundational/07d-interruptible-elevenlabs.py +++ b/examples/foundational/07d-interruptible-elevenlabs.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.stt import ElevenLabsRealtimeSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07g-interruptible-openai.py b/examples/foundational/07g-interruptible-openai.py index a29e8210f..86b6c9267 100644 --- a/examples/foundational/07g-interruptible-openai.py +++ b/examples/foundational/07g-interruptible-openai.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.openai.stt import OpenAIRealtimeSTTService -from pipecat.services.openai.tts import OpenAITTSService +from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings +from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -55,16 +55,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAIRealtimeSTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related to dogs, such as breed names.", - language=Language.EN, - # Uses local VAD by default. - # To enable server-side VAD, set turn_detection=None or - # a dict with server_vad settings. - # turn_detection={"type": "server_vad", "threshold": 0.5}, + settings=OpenAIRealtimeSTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related to dogs, such as breed names.", + language=Language.EN, + ), ) - tts = OpenAITTSService(api_key=os.getenv("OPENAI_API_KEY"), voice="ballad") + tts = OpenAITTSService( + api_key=os.getenv("OPENAI_API_KEY"), + settings=OpenAITTSSettings( + voice="ballad", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07h-interruptible-openpipe.py b/examples/foundational/07h-interruptible-openpipe.py index e3ddc05b8..6dbf04296 100644 --- a/examples/foundational/07h-interruptible-openpipe.py +++ b/examples/foundational/07h-interruptible-openpipe.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openpipe.llm import OpenPipeLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) timestamp = int(time.time()) diff --git a/examples/foundational/07i-interruptible-xtts.py b/examples/foundational/07i-interruptible-xtts.py index 00883e37f..6837917aa 100644 --- a/examples/foundational/07i-interruptible-xtts.py +++ b/examples/foundational/07i-interruptible-xtts.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.xtts.tts import XTTSService +from pipecat.services.xtts.tts import XTTSService, XTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = XTTSService( aiohttp_session=session, - voice_id="Claribel Dervla", + settings=XTTSSettings( + voice="Claribel Dervla", + ), base_url="http://localhost:8000", ) diff --git a/examples/foundational/07j-interruptible-gladia-vad.py b/examples/foundational/07j-interruptible-gladia-vad.py index f0874f0f3..2983e1605 100644 --- a/examples/foundational/07j-interruptible-gladia-vad.py +++ b/examples/foundational/07j-interruptible-gladia-vad.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.gladia.config import GladiaInputParams, LanguageConfig -from pipecat.services.gladia.stt import GladiaSTTService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.gladia.config import LanguageConfig +from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,7 +58,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY", ""), region=os.getenv("GLADIA_REGION"), - params=GladiaInputParams( + settings=GladiaSTTSettings( language_config=LanguageConfig( languages=[Language.EN], ), @@ -68,19 +68,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY", ""), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY", "")) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY", ""), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) - messages = [ - { - "role": "system", - "content": f"You are a helpful LLM. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams( @@ -114,7 +112,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "system", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07j-interruptible-gladia.py b/examples/foundational/07j-interruptible-gladia.py index 4bebffce7..5dca15834 100644 --- a/examples/foundational/07j-interruptible-gladia.py +++ b/examples/foundational/07j-interruptible-gladia.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.gladia.config import GladiaInputParams, LanguageConfig -from pipecat.services.gladia.stt import GladiaSTTService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.gladia.config import LanguageConfig +from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY", ""), region=os.getenv("GLADIA_REGION"), - params=GladiaInputParams( + settings=GladiaSTTSettings( language_config=LanguageConfig( languages=[Language.EN], ) @@ -66,19 +66,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY", ""), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY", "")) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY", ""), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) - messages = [ - { - "role": "system", - "content": f"You are a helpful LLM. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -109,7 +107,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "system", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07k-interruptible-lmnt.py b/examples/foundational/07k-interruptible-lmnt.py index 246caee19..debf186b1 100644 --- a/examples/foundational/07k-interruptible-lmnt.py +++ b/examples/foundational/07k-interruptible-lmnt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.lmnt.tts import LmntTTSService +from pipecat.services.lmnt.tts import LmntTTSService, LmntTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = LmntTTSService(api_key=os.getenv("LMNT_API_KEY"), voice_id="morgan") + tts = LmntTTSService( + api_key=os.getenv("LMNT_API_KEY"), + settings=LmntTTSSettings( + voice="morgan", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07l-interruptible-groq.py b/examples/foundational/07l-interruptible-groq.py index 5a16d789e..dd532b71c 100644 --- a/examples/foundational/07l-interruptible-groq.py +++ b/examples/foundational/07l-interruptible-groq.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.services.groq.stt import GroqSTTService from pipecat.services.groq.tts import GroqTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - model="meta-llama/llama-4-maverick-17b-128e-instruct", + settings=GroqLLMSettings( + model="meta-llama/llama-4-maverick-17b-128e-instruct", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07m-interruptible-aws-strands.py b/examples/foundational/07m-interruptible-aws-strands.py index 2e0fc18d8..c65709a7b 100644 --- a/examples/foundational/07m-interruptible-aws-strands.py +++ b/examples/foundational/07m-interruptible-aws-strands.py @@ -22,7 +22,7 @@ from pipecat.processors.frameworks.strands_agents import StrandsAgentsProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.stt import AWSTranscribeSTTService -from pipecat.services.aws.tts import AWSPollyTTSService +from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -95,8 +95,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS - voice_id="Joanna", - params=AWSPollyTTSService.InputParams(engine="generative", rate="1.1"), + settings=AWSPollyTTSSettings( + voice="Joanna", + engine="generative", + rate="1.1", + ), ) # Create Strands agent processor diff --git a/examples/foundational/07m-interruptible-aws.py b/examples/foundational/07m-interruptible-aws.py index b30220bcd..48a632a35 100644 --- a/examples/foundational/07m-interruptible-aws.py +++ b/examples/foundational/07m-interruptible-aws.py @@ -22,7 +22,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.llm import AWSBedrockLLMService from pipecat.services.aws.stt import AWSTranscribeSTTService -from pipecat.services.aws.tts import AWSPollyTTSService +from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,8 +54,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS - voice_id="Joanna", - params=AWSPollyTTSService.InputParams(engine="generative", rate="1.1"), + settings=AWSPollyTTSSettings( + voice="Joanna", + engine="generative", + rate="1.1", + ), ) llm = AWSBedrockLLMService( diff --git a/examples/foundational/07n-interruptible-gemini-image.py b/examples/foundational/07n-interruptible-gemini-image.py index b7d3281b9..2b1d191c4 100644 --- a/examples/foundational/07n-interruptible-gemini-image.py +++ b/examples/foundational/07n-interruptible-gemini-image.py @@ -37,9 +37,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GoogleTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GoogleTTSService, GoogleTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -70,20 +70,26 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + settings=GoogleSTTSettings( + languages=Language.EN_US, + ), ) tts = GoogleTTSService( - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleTTSService.InputParams(language=Language.EN_US), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + settings=GoogleTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash-image", - # model="gemini-3-pro-image-preview", # A more powerful model, but slower, + settings=GoogleLLMSettings( + model="gemini-2.5-flash-image", + # model="gemini-3-pro-image-preview", # A more powerful model, but slower, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07n-interruptible-gemini.py b/examples/foundational/07n-interruptible-gemini.py index 74f732926..7a631f473 100644 --- a/examples/foundational/07n-interruptible-gemini.py +++ b/examples/foundational/07n-interruptible-gemini.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GeminiTTSService +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GeminiTTSService, GeminiTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,15 +54,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot with Gemini TTS") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US), + settings=GoogleSTTSettings( + languages=Language.EN_US, + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) tts = GeminiTTSService( credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), - model="gemini-2.5-flash-tts", - voice_id="Charon", - params=GeminiTTSService.InputParams( + settings=GeminiTTSSettings( + model="gemini-2.5-flash-tts", + voice="Charon", language=Language.EN_US, prompt="You are a helpful AI assistant. Speak in a natural, conversational tone.", ), diff --git a/examples/foundational/07n-interruptible-google-http.py b/examples/foundational/07n-interruptible-google-http.py index e5f82ffc5..1f570366a 100644 --- a/examples/foundational/07n-interruptible-google-http.py +++ b/examples/foundational/07n-interruptible-google-http.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GoogleHttpTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GoogleHttpTTSService, GoogleHttpTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,24 +54,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US, model="chirp_3"), + settings=GoogleSTTSettings( + languages=Language.EN_US, + model="chirp_3", + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), location="us", ) tts = GoogleHttpTTSService( - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleHttpTTSService.InputParams(language=Language.EN_US), + settings=GoogleHttpTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", - # force a certain amount of thinking if you want it - # params=GoogleLLMService.InputParams( - # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) - # ), + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + # force a certain amount of thinking if you want it + # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07n-interruptible-google.py b/examples/foundational/07n-interruptible-google.py index 090fdbbdc..439676238 100644 --- a/examples/foundational/07n-interruptible-google.py +++ b/examples/foundational/07n-interruptible-google.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GoogleTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GoogleTTSService, GoogleTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,24 +54,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US, model="chirp_3"), + settings=GoogleSTTSettings( + languages=Language.EN_US, + model="chirp_3", + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), location="us", ) tts = GoogleTTSService( - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleTTSService.InputParams(language=Language.EN_US), + settings=GoogleTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", - # force a certain amount of thinking if you want it - # params=GoogleLLMService.InputParams( - # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) - # ), + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + # force a certain amount of thinking if you want it + # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096), + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07o-interruptible-assemblyai-turn-detection.py b/examples/foundational/07o-interruptible-assemblyai-turn-detection.py index 7a0226277..6f2ec36f2 100644 --- a/examples/foundational/07o-interruptible-assemblyai-turn-detection.py +++ b/examples/foundational/07o-interruptible-assemblyai-turn-detection.py @@ -22,9 +22,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.assemblyai.models import AssemblyAIConnectionParams -from pipecat.services.assemblyai.stt import AssemblyAISTTService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -94,7 +93,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = AssemblyAISTTService( api_key=os.getenv("ASSEMBLYAI_API_KEY"), vad_force_turn_endpoint=False, # Use AssemblyAI's built-in turn detection - connection_params=AssemblyAIConnectionParams( + settings=AssemblyAISTTSettings( speech_model="u3-rt-pro", # Optional: Tune turn detection timing (defaults shown below) # min_turn_silence=100, # Default @@ -108,7 +107,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07o-interruptible-assemblyai.py b/examples/foundational/07o-interruptible-assemblyai.py index 8378f7bba..10d6a8cd4 100644 --- a/examples/foundational/07o-interruptible-assemblyai.py +++ b/examples/foundational/07o-interruptible-assemblyai.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.stt import AssemblyAISTTService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07p-interruptible-krisp-viva.py b/examples/foundational/07p-interruptible-krisp-viva.py index 4df652ae0..1b10202f3 100644 --- a/examples/foundational/07p-interruptible-krisp-viva.py +++ b/examples/foundational/07p-interruptible-krisp-viva.py @@ -43,7 +43,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -84,7 +84,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), voice_id="71a7ad14-091c-4e8e-a314-022ece01c121" + api_key=os.getenv("CARTESIA_API_KEY"), + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07p-interruptible-krisp.py b/examples/foundational/07p-interruptible-krisp.py index ad737ba05..54d88d32a 100644 --- a/examples/foundational/07p-interruptible-krisp.py +++ b/examples/foundational/07p-interruptible-krisp.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -58,7 +58,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-helios-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-helios-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07q-interruptible-rime-http.py b/examples/foundational/07q-interruptible-rime-http.py index 4e390b123..c735e39c9 100644 --- a/examples/foundational/07q-interruptible-rime-http.py +++ b/examples/foundational/07q-interruptible-rime-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.rime.tts import RimeHttpTTSService +from pipecat.services.rime.tts import RimeHttpTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -60,7 +60,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = RimeHttpTTSService( api_key=os.getenv("RIME_API_KEY", ""), - voice_id="luna", + settings=RimeTTSSettings( + voice="luna", + model="arcana", + ), model="arcana", aiohttp_session=session, ) diff --git a/examples/foundational/07q-interruptible-rime.py b/examples/foundational/07q-interruptible-rime.py index cebf6bfd0..dbc6b91e6 100644 --- a/examples/foundational/07q-interruptible-rime.py +++ b/examples/foundational/07q-interruptible-rime.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.rime.tts import RimeTTSService +from pipecat.services.rime.tts import RimeTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = RimeTTSService( api_key=os.getenv("RIME_API_KEY", ""), - voice_id="luna", + settings=RimeTTSSettings( + voice="luna", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07r-interruptible-nvidia.py b/examples/foundational/07r-interruptible-nvidia.py index f50667267..69a5fbc15 100644 --- a/examples/foundational/07r-interruptible-nvidia.py +++ b/examples/foundational/07r-interruptible-nvidia.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.nvidia.llm import NvidiaLLMService +from pipecat.services.nvidia.llm import NvidiaLLMService, NvidiaLLMSettings from pipecat.services.nvidia.stt import NvidiaSTTService from pipecat.services.nvidia.tts import NvidiaTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = NvidiaLLMService( api_key=os.getenv("NVIDIA_API_KEY"), - model="meta/llama-3.3-70b-instruct", + settings=NvidiaLLMSettings( + model="meta/llama-3.3-70b-instruct", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07s-interruptible-google-audio-in.py b/examples/foundational/07s-interruptible-google-audio-in.py index 1de374a3f..d4067b620 100644 --- a/examples/foundational/07s-interruptible-google-audio-in.py +++ b/examples/foundational/07s-interruptible-google-audio-in.py @@ -36,8 +36,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.tts import GoogleTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.tts import GoogleTTSService, GoogleTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -216,7 +216,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), # force a certain amount of thinking if you want it # params=GoogleLLMService.InputParams( # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) @@ -224,7 +226,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = GoogleTTSService( - voice_id="en-US-Chirp3-HD-Charon", + settings=GoogleTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), params=GoogleTTSService.InputParams(language=Language.EN_US), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) diff --git a/examples/foundational/07t-interruptible-fish.py b/examples/foundational/07t-interruptible-fish.py index 8b4152103..d54d34c1c 100644 --- a/examples/foundational/07t-interruptible-fish.py +++ b/examples/foundational/07t-interruptible-fish.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.fish.tts import FishAudioTTSService +from pipecat.services.fish.tts import FishAudioTTSService, FishAudioTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = FishAudioTTSService( api_key=os.getenv("FISH_API_KEY"), - model="4ce7e917cedd4bc2bb2e6ff3a46acaa1", # Barack Obama + settings=FishAudioTTSSettings( + model="4ce7e917cedd4bc2bb2e6ff3a46acaa1", # Barack Obama + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07v-interruptible-neuphonic-http.py b/examples/foundational/07v-interruptible-neuphonic-http.py index 60a08e623..081d9d6cc 100644 --- a/examples/foundational/07v-interruptible-neuphonic-http.py +++ b/examples/foundational/07v-interruptible-neuphonic-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService +from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService, NeuphonicTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = NeuphonicHttpTTSService( api_key=os.getenv("NEUPHONIC_API_KEY"), - voice_id="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + settings=NeuphonicTTSSettings( + voice="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + ), aiohttp_session=session, ) diff --git a/examples/foundational/07v-interruptible-neuphonic.py b/examples/foundational/07v-interruptible-neuphonic.py index 02d6862a8..3f30ab9c7 100644 --- a/examples/foundational/07v-interruptible-neuphonic.py +++ b/examples/foundational/07v-interruptible-neuphonic.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.neuphonic.tts import NeuphonicTTSService +from pipecat.services.neuphonic.tts import NeuphonicTTSService, NeuphonicTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = NeuphonicTTSService( api_key=os.getenv("NEUPHONIC_API_KEY"), - voice_id="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + settings=NeuphonicTTSSettings( + voice="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07w-interruptible-fal.py b/examples/foundational/07w-interruptible-fal.py index 6d88e8624..7e0e53bc9 100644 --- a/examples/foundational/07w-interruptible-fal.py +++ b/examples/foundational/07w-interruptible-fal.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.fal.stt import FalSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07x-interruptible-local.py b/examples/foundational/07x-interruptible-local.py index 3465f67b2..63cf2bbb1 100644 --- a/examples/foundational/07x-interruptible-local.py +++ b/examples/foundational/07x-interruptible-local.py @@ -21,7 +21,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.local.audio import LocalAudioTransport, LocalAudioTransportParams @@ -44,7 +44,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07y-interruptible-minimax.py b/examples/foundational/07y-interruptible-minimax.py index f23d86f34..690c35178 100644 --- a/examples/foundational/07y-interruptible-minimax.py +++ b/examples/foundational/07y-interruptible-minimax.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.minimax.tts import MiniMaxHttpTTSService +from pipecat.services.minimax.tts import MiniMaxHttpTTSService, MiniMaxTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("MINIMAX_API_KEY", ""), group_id=os.getenv("MINIMAX_GROUP_ID", ""), aiohttp_session=session, - params=MiniMaxHttpTTSService.InputParams(language=Language.EN), + settings=MiniMaxTTSSettings( + language=Language.EN, + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07z-interruptible-sarvam-http.py b/examples/foundational/07z-interruptible-sarvam-http.py index 1f9a8a4e3..33f1277e6 100644 --- a/examples/foundational/07z-interruptible-sarvam-http.py +++ b/examples/foundational/07z-interruptible-sarvam-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.sarvam.stt import SarvamSTTService -from pipecat.services.sarvam.tts import SarvamHttpTTSService +from pipecat.services.sarvam.tts import SarvamHttpTTSService, SarvamHttpTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SarvamHttpTTSService( api_key=os.getenv("SARVAM_API_KEY"), aiohttp_session=session, - params=SarvamHttpTTSService.InputParams(language=Language.EN), + settings=SarvamHttpTTSSettings( + language=Language.EN, + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07z-interruptible-sarvam.py b/examples/foundational/07z-interruptible-sarvam.py index a9a03e7d4..60b5bcc8b 100644 --- a/examples/foundational/07z-interruptible-sarvam.py +++ b/examples/foundational/07z-interruptible-sarvam.py @@ -22,8 +22,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.sarvam.stt import SarvamSTTService -from pipecat.services.sarvam.tts import SarvamTTSService +from pipecat.services.sarvam.stt import SarvamSTTService, SarvamSTTSettings +from pipecat.services.sarvam.tts import SarvamTTSService, SarvamTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,13 +54,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = SarvamSTTService( api_key=os.getenv("SARVAM_API_KEY"), - model="saarika:v2.5", + settings=SarvamSTTSettings( + model="saarika:v2.5", + ), ) tts = SarvamTTSService( api_key=os.getenv("SARVAM_API_KEY"), - model="bulbul:v2", - voice_id="manisha", + settings=SarvamTTSSettings( + model="bulbul:v2", + voice="manisha", + ), ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07za-interruptible-soniox.py b/examples/foundational/07za-interruptible-soniox.py index f2d651e5b..56b2dee1e 100644 --- a/examples/foundational/07za-interruptible-soniox.py +++ b/examples/foundational/07za-interruptible-soniox.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.soniox.stt import SonioxInputParams, SonioxSTTService +from pipecat.services.soniox.stt import SonioxSTTService, SonioxSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -51,17 +51,21 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = SonioxSTTService( - api_key=os.getenv("SONIOX_API_KEY"), - params=SonioxInputParams( - language_hints=[Language.EN], - language_hints_strict=True, + stt = ( + SonioxSTTService( + api_key=os.getenv("SONIOX_API_KEY"), + settings=SonioxSTTSettings( + language_hints=[Language.EN], + language_hints_strict=True, + ), ), ) tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zb-interruptible-inworld-http.py b/examples/foundational/07zb-interruptible-inworld-http.py index 9ef465781..ffbdbb444 100644 --- a/examples/foundational/07zb-interruptible-inworld-http.py +++ b/examples/foundational/07zb-interruptible-inworld-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.inworld.tts import InworldHttpTTSService +from pipecat.services.inworld.tts import InworldHttpTTSService, InworldTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,10 +58,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = InworldHttpTTSService( api_key=os.getenv("INWORLD_API_KEY", ""), aiohttp_session=session, - voice_id="Ashley", - model="inworld-tts-1", - # Set to False for non-streaming mode or True for streaming mode. streaming=True, + settings=InworldTTSSettings( + voice="Ashley", + model="inworld-tts-1", + ), + # Set to False for non-streaming mode or True for streaming mode. ) llm = OpenAILLMService( diff --git a/examples/foundational/07zb-interruptible-inworld.py b/examples/foundational/07zb-interruptible-inworld.py index 7cdbfd88a..6c8b53706 100644 --- a/examples/foundational/07zb-interruptible-inworld.py +++ b/examples/foundational/07zb-interruptible-inworld.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.inworld.tts import InworldTTSService +from pipecat.services.inworld.tts import InworldTTSService, InworldTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,9 +56,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = InworldTTSService( api_key=os.getenv("INWORLD_API_KEY", ""), - voice_id="Ashley", - model="inworld-tts-1", - temperature=1.1, + settings=InworldTTSSettings( + voice="Ashley", + model="inworld-tts-1", + temperature=1.1, + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zc-interruptible-asyncai-http.py b/examples/foundational/07zc-interruptible-asyncai-http.py index 17d187ac8..3246feac4 100644 --- a/examples/foundational/07zc-interruptible-asyncai-http.py +++ b/examples/foundational/07zc-interruptible-asyncai-http.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.asyncai.tts import AsyncAIHttpTTSService +from pipecat.services.asyncai.tts import AsyncAIHttpTTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AsyncAIHttpTTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), - voice_id=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04"), + settings=AsyncAITTSSettings( + voice="e0f39dc4-f691-4e78-bba5-5c636692cc04", + ), aiohttp_session=session, ) diff --git a/examples/foundational/07zc-interruptible-asyncai.py b/examples/foundational/07zc-interruptible-asyncai.py index 799842658..093f03ccb 100644 --- a/examples/foundational/07zc-interruptible-asyncai.py +++ b/examples/foundational/07zc-interruptible-asyncai.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.asyncai.tts import AsyncAITTSService +from pipecat.services.asyncai.tts import AsyncAITTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AsyncAITTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), - voice_id=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04"), + settings=AsyncAITTSSettings( + voice="e0f39dc4-f691-4e78-bba5-5c636692cc04", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zd-interruptible-aicoustics.py b/examples/foundational/07zd-interruptible-aicoustics.py index 9e9f6ddd6..cedb95a9e 100644 --- a/examples/foundational/07zd-interruptible-aicoustics.py +++ b/examples/foundational/07zd-interruptible-aicoustics.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -77,7 +77,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07ze-interruptible-hume.py b/examples/foundational/07ze-interruptible-hume.py index 395aa75d4..70ace62e9 100644 --- a/examples/foundational/07ze-interruptible-hume.py +++ b/examples/foundational/07ze-interruptible-hume.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.hume.tts import HUME_SAMPLE_RATE, HumeTTSService +from pipecat.services.hume.tts import HUME_SAMPLE_RATE, HumeTTSService, HumeTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = HumeTTSService( api_key=os.getenv("HUME_API_KEY"), # Replace with your Hume voice ID - voice_id="f898a92e-685f-43fa-985b-a46920f0650b", + settings=HumeTTSSettings( + voice="f898a92e-685f-43fa-985b-a46920f0650b", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zf-interruptible-gradium.py b/examples/foundational/07zf-interruptible-gradium.py index d76735897..ff164c790 100644 --- a/examples/foundational/07zf-interruptible-gradium.py +++ b/examples/foundational/07zf-interruptible-gradium.py @@ -21,8 +21,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.gradium.stt import GradiumSTTService -from pipecat.services.gradium.tts import GradiumTTSService +from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings +from pipecat.services.gradium.tts import GradiumTTSService, GradiumTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,15 +55,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GradiumSTTService( api_key=os.getenv("GRADIUM_API_KEY"), api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", - params=GradiumSTTService.InputParams( + settings=GradiumSTTSettings( language=Language.EN, ), ) tts = GradiumTTSService( api_key=os.getenv("GRADIUM_API_KEY"), - voice_id="YTpq7expH9539ERJ", url="wss://us.api.gradium.ai/api/speech/tts", + settings=GradiumTTSSettings( + voice="YTpq7expH9539ERJ", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zg-interruptible-camb.py b/examples/foundational/07zg-interruptible-camb.py index 669315603..f98303b26 100644 --- a/examples/foundational/07zg-interruptible-camb.py +++ b/examples/foundational/07zg-interruptible-camb.py @@ -21,7 +21,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.camb.tts import CambTTSService +from pipecat.services.camb.tts import CambTTSService, CambTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CambTTSService( api_key=os.getenv("CAMB_API_KEY"), - model="mars-flash", + settings=CambTTSSettings( + model="mars-flash", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zi-interruptible-piper.py b/examples/foundational/07zi-interruptible-piper.py index 9d07f9cdf..fb38cba6a 100644 --- a/examples/foundational/07zi-interruptible-piper.py +++ b/examples/foundational/07zi-interruptible-piper.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.piper.tts import PiperTTSService +from pipecat.services.piper.tts import PiperTTSService, PiperTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,7 +54,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = PiperTTSService(voice_id="en_US-ryan-high") + tts = PiperTTSService( + settings=PiperTTSSettings( + voice="en_US-ryan-high", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07zj-interruptible-kokoro.py b/examples/foundational/07zj-interruptible-kokoro.py index 04ab90145..7271ef42d 100644 --- a/examples/foundational/07zj-interruptible-kokoro.py +++ b/examples/foundational/07zj-interruptible-kokoro.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.kokoro.tts import KokoroTTSService +from pipecat.services.kokoro.tts import KokoroTTSService, KokoroTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = KokoroTTSService(voice_id="af_heart") + tts = KokoroTTSService( + settings=KokoroTTSSettings( + voice="af_heart", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07zk-interruptible-resemble.py b/examples/foundational/07zk-interruptible-resemble.py index d9298815d..5e89eaa6e 100644 --- a/examples/foundational/07zk-interruptible-resemble.py +++ b/examples/foundational/07zk-interruptible-resemble.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.resembleai.tts import ResembleAITTSService +from pipecat.services.resembleai.tts import ResembleAITTSService, ResembleAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ResembleAITTSService( api_key=os.getenv("RESEMBLE_API_KEY"), - voice_id=os.getenv("RESEMBLE_VOICE_UUID"), + settings=ResembleAITTSSettings( + voice=os.getenv("RESEMBLE_VOICE_UUID"), + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/08-custom-frame-processor.py b/examples/foundational/08-custom-frame-processor.py index a4b5b2127..cfab184cb 100644 --- a/examples/foundational/08-custom-frame-processor.py +++ b/examples/foundational/08-custom-frame-processor.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -95,7 +95,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/10-wake-phrase.py b/examples/foundational/10-wake-phrase.py index 52a7d1225..a57ef6f96 100644 --- a/examples/foundational/10-wake-phrase.py +++ b/examples/foundational/10-wake-phrase.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.filters.wake_check_filter import WakeCheckFilter from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/11-sound-effects.py b/examples/foundational/11-sound-effects.py index 401c36b8e..332c1536a 100644 --- a/examples/foundational/11-sound-effects.py +++ b/examples/foundational/11-sound-effects.py @@ -30,7 +30,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.logger import FrameLogger from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -111,7 +111,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) context = LLMContext() diff --git a/examples/foundational/12-describe-image-openai.py b/examples/foundational/12-describe-image-openai.py index dc45451fe..4d22e4046 100644 --- a/examples/foundational/12-describe-image-openai.py +++ b/examples/foundational/12-describe-image-openai.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -53,7 +53,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/12a-describe-image-anthropic.py b/examples/foundational/12a-describe-image-anthropic.py index a1151ddf9..79e4460a2 100644 --- a/examples/foundational/12a-describe-image-anthropic.py +++ b/examples/foundational/12a-describe-image-anthropic.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -53,7 +53,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( diff --git a/examples/foundational/12b-describe-image-aws.py b/examples/foundational/12b-describe-image-aws.py index 43a6ae232..b4db59409 100644 --- a/examples/foundational/12b-describe-image-aws.py +++ b/examples/foundational/12b-describe-image-aws.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.llm import AWSBedrockLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -53,16 +53,20 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", - # Note: usually, prefer providing latency="optimized" param. - # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, - # which we need for image input. - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", + # Note: usually, prefer providing latency="optimized" param. + # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, + # which we need for image input. + params=AWSBedrockLLMService.InputParams(temperature=0.8), + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", ) diff --git a/examples/foundational/12c-describe-image-gemini-flash.py b/examples/foundational/12c-describe-image-gemini-flash.py index 9adbe62d2..1f550dd6f 100644 --- a/examples/foundational/12c-describe-image-gemini-flash.py +++ b/examples/foundational/12c-describe-image-gemini-flash.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -53,7 +53,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/12d-describe-image-moondream.py b/examples/foundational/12d-describe-image-moondream.py index 070b004a1..21fc79ed5 100644 --- a/examples/foundational/12d-describe-image-moondream.py +++ b/examples/foundational/12d-describe-image-moondream.py @@ -17,7 +17,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.moondream.vision import MoondreamService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -42,7 +42,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) vision = MoondreamService() diff --git a/examples/foundational/13b-deepgram-transcription.py b/examples/foundational/13b-deepgram-transcription.py index ed83bd1d5..61ba5c266 100644 --- a/examples/foundational/13b-deepgram-transcription.py +++ b/examples/foundational/13b-deepgram-transcription.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.deepgram.stt import DeepgramSTTService, Language, LiveOptions +from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings, Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -49,7 +49,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - live_options=LiveOptions(language=Language.EN), + settings=DeepgramSTTSettings( + language=Language.EN, + ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/13c-gladia-transcription.py b/examples/foundational/13c-gladia-transcription.py index c98fda727..8771cb8d4 100644 --- a/examples/foundational/13c-gladia-transcription.py +++ b/examples/foundational/13c-gladia-transcription.py @@ -50,7 +50,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY"), region=os.getenv("GLADIA_REGION"), - # live_options=LiveOptions(language=Language.FR), + # settings=GladiaSTTSettings( + # language_config=LanguageConfig( + # languages=[Language.FR], + # ), + # ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/13c-gladia-translation.py b/examples/foundational/13c-gladia-translation.py index edc294858..9f7b6a6da 100644 --- a/examples/foundational/13c-gladia-translation.py +++ b/examples/foundational/13c-gladia-translation.py @@ -22,7 +22,7 @@ from pipecat.services.gladia.config import ( RealtimeProcessingConfig, TranslationConfig, ) -from pipecat.services.gladia.stt import GladiaSTTService +from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,16 +59,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY"), region=os.getenv("GLADIA_REGION"), - params=GladiaInputParams( + settings=GladiaSTTSettings( language_config=LanguageConfig( - languages=[Language.EN], # Input in English + languages=[Language.EN], code_switching=False, ), realtime_processing=RealtimeProcessingConfig( - translation=True, # Enable translation + translation=True, translation_config=TranslationConfig( - target_languages=[Language.ES], # Translate to Spanish - model="enhanced", # Use the enhanced translation model + target_languages=[Language.ES], + model="enhanced", ), ), ), diff --git a/examples/foundational/13d-assemblyai-transcription.py b/examples/foundational/13d-assemblyai-transcription.py index 2dcbaf59b..c4ca9cd6b 100644 --- a/examples/foundational/13d-assemblyai-transcription.py +++ b/examples/foundational/13d-assemblyai-transcription.py @@ -16,8 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.assemblyai.models import AssemblyAIConnectionParams -from pipecat.services.assemblyai.stt import AssemblyAISTTService +from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -50,8 +49,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = AssemblyAISTTService( api_key=os.getenv("ASSEMBLYAI_API_KEY"), - connection_params=AssemblyAIConnectionParams( - speech_model="u3-rt-pro", + settings=AssemblyAISTTSettings( + model="u3-rt-pro", ), ) diff --git a/examples/foundational/13e-whisper-mlx.py b/examples/foundational/13e-whisper-mlx.py index ba90d0850..0f11d4397 100644 --- a/examples/foundational/13e-whisper-mlx.py +++ b/examples/foundational/13e-whisper-mlx.py @@ -18,7 +18,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.whisper.stt import MLXModel, WhisperSTTServiceMLX +from pipecat.services.whisper.stt import MLXModel, WhisperMLXSTTSettings, WhisperSTTServiceMLX from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -77,7 +77,11 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = WhisperSTTServiceMLX(model=MLXModel.LARGE_V3_TURBO) + stt = WhisperSTTServiceMLX( + settings=WhisperMLXSTTSettings( + model=MLXModel.LARGE_V3_TURBO, + ), + ) tl = TranscriptionLogger() diff --git a/examples/foundational/13g-sambanova-transcription.py b/examples/foundational/13g-sambanova-transcription.py index cebeea615..1e399c38f 100644 --- a/examples/foundational/13g-sambanova-transcription.py +++ b/examples/foundational/13g-sambanova-transcription.py @@ -19,7 +19,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.sambanova.stt import SambaNovaSTTService +from pipecat.services.sambanova.stt import SambaNovaSTTService, SambaNovaSTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -79,7 +79,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SambaNovaSTTService( - model="Whisper-Large-v3", + settings=SambaNovaSTTSettings( + model="Whisper-Large-v3", + ), api_key=os.getenv("SAMBANOVA_API_KEY"), ) diff --git a/examples/foundational/13h-speechmatics-transcription.py b/examples/foundational/13h-speechmatics-transcription.py index f1d1d93c6..d013357f6 100644 --- a/examples/foundational/13h-speechmatics-transcription.py +++ b/examples/foundational/13h-speechmatics-transcription.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.speechmatics.stt import SpeechmaticsSTTService +from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( language=Language.EN, speaker_active_format="<{speaker_id}>{text}", ), diff --git a/examples/foundational/13l-gradium-transcription.py b/examples/foundational/13l-gradium-transcription.py index 38709dff7..84b23017c 100644 --- a/examples/foundational/13l-gradium-transcription.py +++ b/examples/foundational/13l-gradium-transcription.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.gradium.stt import GradiumSTTService +from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -52,7 +52,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GradiumSTTService( api_key=os.getenv("GRADIUM_API_KEY"), api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", - params=GradiumSTTService.InputParams(language=Language.EN, delay_in_frames=8), + settings=GradiumSTTSettings( + language=Language.EN, + delay_in_frames=8, + ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/13m-openai-transcription.py b/examples/foundational/13m-openai-transcription.py index 2ef35cb3f..8dc9e0101 100644 --- a/examples/foundational/13m-openai-transcription.py +++ b/examples/foundational/13m-openai-transcription.py @@ -18,7 +18,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.stt import OpenAIRealtimeSTTService +from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -53,8 +53,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAIRealtimeSTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related to dogs, such as breed names.", + settings=OpenAIRealtimeSTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related to dogs, such as breed names.", + ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/14-function-calling.py b/examples/foundational/14-function-calling.py index 0087af9fc..2a3206dbc 100644 --- a/examples/foundational/14-function-calling.py +++ b/examples/foundational/14-function-calling.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14a-function-calling-anthropic.py b/examples/foundational/14a-function-calling-anthropic.py index 36030bc2b..0fd40af4f 100644 --- a/examples/foundational/14a-function-calling-anthropic.py +++ b/examples/foundational/14a-function-calling-anthropic.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -69,10 +69,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY")) + llm = AnthropicLLMService( + api_key=os.getenv("ANTHROPIC_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) llm.register_function("get_weather", get_weather) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) @@ -100,16 +105,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function, restaurant_function]) - # todo: test with very short initial user message - - # messages = [{"role": "system", - # "content": "You are a helpful assistant who can report the weather in any location in the universe. Respond concisely. Your response will be turned into speech so use only simple words and punctuation."}, - # {"role": "user", - # "content": " Start the conversation by introducing yourself."}] - - messages = [{"role": "user", "content": "Say 'hello' to start the conversation."}] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/14c-function-calling-together.py b/examples/foundational/14c-function-calling-together.py index 214d6f292..6362e1ea6 100644 --- a/examples/foundational/14c-function-calling-together.py +++ b/examples/foundational/14c-function-calling-together.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.together.llm import TogetherLLMService +from pipecat.services.together.llm import TogetherLLMService, TogetherLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,12 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = TogetherLLMService( api_key=os.getenv("TOGETHER_API_KEY"), - model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + settings=TogetherLLMSettings( + model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14d-function-calling-anthropic-video.py b/examples/foundational/14d-function-calling-anthropic-video.py index cddde3647..fee17734c 100644 --- a/examples/foundational/14d-function-calling-anthropic-video.py +++ b/examples/foundational/14d-function-calling-anthropic-video.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import ( maybe_capture_participant_camera, ) from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -90,7 +90,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Anthropic for vision analysis diff --git a/examples/foundational/14d-function-calling-aws-video.py b/examples/foundational/14d-function-calling-aws-video.py index 396ea0a32..234552d92 100644 --- a/examples/foundational/14d-function-calling-aws-video.py +++ b/examples/foundational/14d-function-calling-aws-video.py @@ -28,8 +28,8 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.aws.llm import AWSBedrockLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -90,17 +90,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # AWS for vision analysis llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", - # Note: usually, prefer providing latency="optimized" param. - # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, - # which we need for image input. - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", + # Note: usually, prefer providing latency="optimized" param. + # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, + # which we need for image input. + temperature=0.8, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14d-function-calling-gemini-flash-video.py b/examples/foundational/14d-function-calling-gemini-flash-video.py index c59767406..f1255d287 100644 --- a/examples/foundational/14d-function-calling-gemini-flash-video.py +++ b/examples/foundational/14d-function-calling-gemini-flash-video.py @@ -28,7 +28,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -90,7 +90,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Google Gemini model for vision analysis diff --git a/examples/foundational/14d-function-calling-moondream-video.py b/examples/foundational/14d-function-calling-moondream-video.py index d0913e3dc..6ffb10213 100644 --- a/examples/foundational/14d-function-calling-moondream-video.py +++ b/examples/foundational/14d-function-calling-moondream-video.py @@ -37,7 +37,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.moondream.vision import MoondreamService @@ -121,7 +121,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14d-function-calling-openai-video.py b/examples/foundational/14d-function-calling-openai-video.py index 50365eb29..235815a5c 100644 --- a/examples/foundational/14d-function-calling-openai-video.py +++ b/examples/foundational/14d-function-calling-openai-video.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -91,7 +91,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14e-function-calling-google.py b/examples/foundational/14e-function-calling-google.py index cae32146e..08308dee3 100644 --- a/examples/foundational/14e-function-calling-google.py +++ b/examples/foundational/14e-function-calling-google.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -100,10 +100,34 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) + system_prompt = """\ +You are a helpful assistant who converses with a user and answers questions. Respond concisely to general questions. + +Your response will be turned into speech so use only simple words and punctuation. + +You have access to three tools: get_weather, get_restaurant_recommendation, and get_image. + +You can respond to questions about the weather using the get_weather tool. + +You can answer questions about the user's video stream using the get_image tool. Some examples of phrases that \ +indicate you should use the get_image tool are: +- What do you see? +- What's in the video? +- Can you describe the video? +- Tell me about what you see. +- Tell me something interesting about what you see. +- What's happening in the video? +""" + + llm = GoogleLLMService( + api_key=os.getenv("GOOGLE_API_KEY"), + system_instruction=system_prompt, + ) llm.register_function("get_weather", get_weather) llm.register_function("get_image", get_image) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) @@ -156,29 +180,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function, get_image_function, restaurant_function]) - system_prompt = """\ -You are a helpful assistant who converses with a user and answers questions. Respond concisely to general questions. - -Your response will be turned into speech so use only simple words and punctuation. - -You have access to three tools: get_weather, get_restaurant_recommendation, and get_image. - -You can respond to questions about the weather using the get_weather tool. - -You can answer questions about the user's video stream using the get_image tool. Some examples of phrases that \ -indicate you should use the get_image tool are: -- What do you see? -- What's in the video? -- Can you describe the video? -- Tell me about what you see. -- Tell me something interesting about what you see. -- What's happening in the video? -""" - messages = [ - {"role": "system", "content": system_prompt}, - ] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -214,9 +216,9 @@ indicate you should use the get_image tool are: client_id = get_transport_client_id(transport, client) # Kick off the conversation. - messages.append( + context.add_message( { - "role": "system", + "role": "user", "content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.", } ) diff --git a/examples/foundational/14f-function-calling-groq.py b/examples/foundational/14f-function-calling-groq.py index e6cfb3659..11bbda12d 100644 --- a/examples/foundational/14f-function-calling-groq.py +++ b/examples/foundational/14f-function-calling-groq.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.groq.llm import GroqLLMService from pipecat.services.groq.stt import GroqSTTService from pipecat.services.llm_service import FunctionCallParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GroqLLMService( diff --git a/examples/foundational/14g-function-calling-grok.py b/examples/foundational/14g-function-calling-grok.py index 51435a2a0..7ff89658d 100644 --- a/examples/foundational/14g-function-calling-grok.py +++ b/examples/foundational/14g-function-calling-grok.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.grok.llm import GrokLLMService from pipecat.services.llm_service import FunctionCallParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GrokLLMService( diff --git a/examples/foundational/14h-function-calling-azure.py b/examples/foundational/14h-function-calling-azure.py index 192cebb92..9df6abeef 100644 --- a/examples/foundational/14h-function-calling-azure.py +++ b/examples/foundational/14h-function-calling-azure.py @@ -24,8 +24,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.llm import AzureLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.azure.llm import AzureLLMService, AzureLLMSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -64,13 +64,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AzureLLMService( api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), - model=os.getenv("AZURE_CHATGPT_MODEL"), + settings=AzureLLMSettings( + model=os.getenv("AZURE_CHATGPT_MODEL"), + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14i-function-calling-fireworks.py b/examples/foundational/14i-function-calling-fireworks.py index be006e062..6a274c09f 100644 --- a/examples/foundational/14i-function-calling-fireworks.py +++ b/examples/foundational/14i-function-calling-fireworks.py @@ -24,9 +24,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.fireworks.llm import FireworksLLMService +from pipecat.services.fireworks.llm import FireworksLLMService, FireworksLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -64,12 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = FireworksLLMService( api_key=os.getenv("FIREWORKS_API_KEY"), - model="accounts/fireworks/models/gpt-oss-20b", + settings=FireworksLLMSettings( + model="accounts/fireworks/models/gpt-oss-20b", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14j-function-calling-nvidia.py b/examples/foundational/14j-function-calling-nvidia.py index e079c228f..680952d75 100644 --- a/examples/foundational/14j-function-calling-nvidia.py +++ b/examples/foundational/14j-function-calling-nvidia.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.nvidia.llm import NvidiaLLMService +from pipecat.services.nvidia.llm import NvidiaLLMService, NvidiaLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,15 +64,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady - # text_filters=[MarkdownTextFilter()], + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = NvidiaLLMService( api_key=os.getenv("NVIDIA_API_KEY"), - model="nvidia/llama-3.3-nemotron-super-49b-v1.5", - # Recommended when turning thinking off - params=NvidiaLLMService.InputParams(temperature=0.0), + settings=NvidiaLLMSettings( + model="nvidia/llama-3.3-nemotron-super-49b-v1.5", + # Recommended when turning thinking off + temperature=0.0, + ), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. @@ -99,17 +103,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): required=["location", "format"], ) tools = ToolsSchema(standard_tools=[weather_function]) - messages = [ - # Disable thinking by sending this message first - # Check the model for the corresponding "no thinking" message - {"role": "system", "content": "/no_think"}, - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/14k-function-calling-cerebras.py b/examples/foundational/14k-function-calling-cerebras.py index 81df8723c..118062769 100644 --- a/examples/foundational/14k-function-calling-cerebras.py +++ b/examples/foundational/14k-function-calling-cerebras.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.cerebras.llm import CerebrasLLMService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = CerebrasLLMService( diff --git a/examples/foundational/14l-function-calling-deepseek.py b/examples/foundational/14l-function-calling-deepseek.py index 93643146a..9c2068236 100644 --- a/examples/foundational/14l-function-calling-deepseek.py +++ b/examples/foundational/14l-function-calling-deepseek.py @@ -24,9 +24,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepseek.llm import DeepSeekLLMService +from pipecat.services.deepseek.llm import DeepSeekLLMService, DeepSeekLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -64,12 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = DeepSeekLLMService( api_key=os.getenv("DEEPSEEK_API_KEY"), - model="deepseek-chat", + settings=DeepSeekLLMSettings( + model="deepseek-chat", + ), system_instruction="""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. You have one functions available: diff --git a/examples/foundational/14m-function-calling-openrouter.py b/examples/foundational/14m-function-calling-openrouter.py index 9504021ff..dbcd1813f 100644 --- a/examples/foundational/14m-function-calling-openrouter.py +++ b/examples/foundational/14m-function-calling-openrouter.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.tts import AzureTTSService +from pipecat.services.azure.tts import AzureTTSService, AzureTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openrouter.llm import OpenRouterLLMService +from pipecat.services.openrouter.llm import OpenRouterLLMService, OpenRouterLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -65,13 +65,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AzureTTSService( api_key=os.getenv("AZURE_SPEECH_API_KEY"), region=os.getenv("AZURE_SPEECH_REGION"), - voice="en-US-JennyNeural", - params=AzureTTSService.InputParams(language="en-US", rate="1.1", style="cheerful"), + settings=AzureTTSSettings( + voice="en-US-JennyNeural", + language="en-US", + rate="1.1", + style="cheerful", + ), ) llm = OpenRouterLLMService( api_key=os.getenv("OPENROUTER_API_KEY"), - model="openai/gpt-4o-2024-11-20", + settings=OpenRouterLLMSettings( + model="openai/gpt-4o-2024-11-20", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14n-function-calling-perplexity.py b/examples/foundational/14n-function-calling-perplexity.py index 2f1a18d52..4857b614f 100644 --- a/examples/foundational/14n-function-calling-perplexity.py +++ b/examples/foundational/14n-function-calling-perplexity.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.perplexity.llm import PerplexityLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,19 +62,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = PerplexityLLMService(api_key=os.getenv("PERPLEXITY_API_KEY")) + llm = PerplexityLLMService( + api_key=os.getenv("PERPLEXITY_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way, but try to be brief.", + ) - messages = [ - { - "role": "user", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way, but try to be brief.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/14o-function-calling-gemini-openai-format.py b/examples/foundational/14o-function-calling-gemini-openai-format.py index c3772eb2c..4a752586f 100644 --- a/examples/foundational/14o-function-calling-gemini-openai-format.py +++ b/examples/foundational/14o-function-calling-gemini-openai-format.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.google.llm_openai import GoogleLLMOpenAIBetaService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -64,10 +64,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) - llm = GoogleLLMOpenAIBetaService(api_key=os.getenv("GOOGLE_API_KEY")) + llm = GoogleLLMOpenAIBetaService( + api_key=os.getenv("GOOGLE_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. llm.register_function("get_current_weather", fetch_weather_from_api) diff --git a/examples/foundational/14p-function-calling-gemini-vertex-ai.py b/examples/foundational/14p-function-calling-gemini-vertex-ai.py index a71f3c8d1..3ff062201 100644 --- a/examples/foundational/14p-function-calling-gemini-vertex-ai.py +++ b/examples/foundational/14p-function-calling-gemini-vertex-ai.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.google.llm_vertex import GoogleVertexLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -64,13 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) llm = GoogleVertexLLMService( credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), location=os.getenv("GOOGLE_CLOUD_LOCATION"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14q-function-calling-qwen.py b/examples/foundational/14q-function-calling-qwen.py index 32c551b29..58d34a3e1 100644 --- a/examples/foundational/14q-function-calling-qwen.py +++ b/examples/foundational/14q-function-calling-qwen.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.qwen.llm import QwenLLMService @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = QwenLLMService( diff --git a/examples/foundational/14r-function-calling-aws.py b/examples/foundational/14r-function-calling-aws.py index 1ce5c4220..9e8e9836f 100644 --- a/examples/foundational/14r-function-calling-aws.py +++ b/examples/foundational/14r-function-calling-aws.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.llm import AWSBedrockLLMService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings from pipecat.services.aws.stt import AWSTranscribeSTTService -from pipecat.services.aws.tts import AWSPollyTTSService +from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -66,14 +66,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS - voice_id="Joanna", - params=AWSPollyTTSService.InputParams(engine="generative", rate="1.1"), + settings=AWSPollyTTSSettings( + voice_id="Joanna", + engine="generative", + rate="1.1", + ), ) llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-haiku-4-5-20251001-v1:0", - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-haiku-4-5-20251001-v1:0", + temperature=0.8, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/14s-function-calling-sambanova.py b/examples/foundational/14s-function-calling-sambanova.py index 1548b2aa1..8cb007691 100644 --- a/examples/foundational/14s-function-calling-sambanova.py +++ b/examples/foundational/14s-function-calling-sambanova.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.sambanova.llm import SambaNovaLLMService from pipecat.services.sambanova.stt import SambaNovaSTTService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = SambaNovaLLMService( diff --git a/examples/foundational/14t-function-calling-direct.py b/examples/foundational/14t-function-calling-direct.py index 31efb7ac9..b2912b91a 100644 --- a/examples/foundational/14t-function-calling-direct.py +++ b/examples/foundational/14t-function-calling-direct.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -80,7 +80,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14u-function-calling-ollama.py b/examples/foundational/14u-function-calling-ollama.py index b7c65dedf..53b81402d 100644 --- a/examples/foundational/14u-function-calling-ollama.py +++ b/examples/foundational/14u-function-calling-ollama.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.ollama.llm import OLLamaLLMService +from pipecat.services.ollama.llm import OLLamaLLMService, OLLamaLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -68,11 +68,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OLLamaLLMService( - model="llama3.2", + settings=OLLamaLLMSettings( + model="llama3.2", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # Update to the model you're running locally diff --git a/examples/foundational/14v-function-calling-openai.py b/examples/foundational/14v-function-calling-openai.py index 920275975..77bacc091 100644 --- a/examples/foundational/14v-function-calling-openai.py +++ b/examples/foundational/14v-function-calling-openai.py @@ -25,8 +25,8 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.openai.stt import OpenAISTTService -from pipecat.services.openai.tts import OpenAITTSService +from pipecat.services.openai.stt import OpenAISTTService, OpenAISTTSettings +from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -65,15 +65,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAISTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related weather, such as temperature and conditions. And restaurant names.", + settings=OpenAISTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related weather, such as temperature and conditions. And restaurant names.", + ), ) - # voice choices: ash, ballad, or any other voice available in the OpenAI TTS API - # see https://www.openai.fm/ tts = OpenAITTSService( api_key=os.getenv("OPENAI_API_KEY"), - voice="ballad", + settings=OpenAITTSSettings( + voice="ballad", + ), instructions="Please speak clearly and at a moderate pace.", ) diff --git a/examples/foundational/14w-function-calling-mistral.py b/examples/foundational/14w-function-calling-mistral.py index e17d31f72..fa809414b 100644 --- a/examples/foundational/14w-function-calling-mistral.py +++ b/examples/foundational/14w-function-calling-mistral.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.mistral.llm import MistralLLMService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = MistralLLMService( diff --git a/examples/foundational/14x-function-calling-openpipe.py b/examples/foundational/14x-function-calling-openpipe.py index 8a71a83d7..61382c435 100644 --- a/examples/foundational/14x-function-calling-openpipe.py +++ b/examples/foundational/14x-function-calling-openpipe.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openpipe.llm import OpenPipeLLMService @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) timestamp = int(time.time()) diff --git a/examples/foundational/15-switch-voices.py b/examples/foundational/15-switch-voices.py index 4478c067b..f749a03c7 100644 --- a/examples/foundational/15-switch-voices.py +++ b/examples/foundational/15-switch-voices.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -43,17 +43,23 @@ class SwitchVoices(ParallelPipeline): news_lady = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="bf991597-6c13-47e4-8411-91ec2de5c466", # Newslady + settings=CartesiaTTSSettings( + voice="bf991597-6c13-47e4-8411-91ec2de5c466", # Newslady + ), ) british_lady = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) barbershop_man = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="a0e99841-438c-4a64-b679-ae501e7d6091", # Barbershop Man + settings=CartesiaTTSSettings( + voice="a0e99841-438c-4a64-b679-ae501e7d6091", # Barbershop Man + ), ) super().__init__( diff --git a/examples/foundational/15a-switch-languages.py b/examples/foundational/15a-switch-languages.py index 3ad897077..dad7e0ee3 100644 --- a/examples/foundational/15a-switch-languages.py +++ b/examples/foundational/15a-switch-languages.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -44,12 +44,16 @@ class SwitchLanguage(ParallelPipeline): english_tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) spanish_tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + settings=CartesiaTTSSettings( + voice="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + ), ) super().__init__( diff --git a/examples/foundational/16-gpu-container-local-bot.py b/examples/foundational/16-gpu-container-local-bot.py index 8367e1044..cf02b37ce 100644 --- a/examples/foundational/16-gpu-container-local-bot.py +++ b/examples/foundational/16-gpu-container-local-bot.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import ( DailyOutputTransportMessageFrame, @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = DeepgramTTSService( api_key=os.getenv("DEEPGRAM_API_KEY"), - voice="aura-asteria-en", + settings=DeepgramTTSSettings( + voice="aura-asteria-en", + ), base_url="http://0.0.0.0:8080", ) @@ -68,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # To use OpenAI # api_key=os.getenv("OPENAI_API_KEY"), # Or, to use a local vLLM (or similar) api server - model="meta-llama/Meta-Llama-3-8B-Instruct", + settings=OpenAILLMSettings( + model="meta-llama/Meta-Llama-3-8B-Instruct", + ), base_url="http://0.0.0.0:8000/v1", system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/17-detect-user-idle.py b/examples/foundational/17-detect-user-idle.py index 217162ea8..9da863bc9 100644 --- a/examples/foundational/17-detect-user-idle.py +++ b/examples/foundational/17-detect-user-idle.py @@ -32,7 +32,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -115,7 +115,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/19b-openai-realtime-beta-text.py b/examples/foundational/19b-openai-realtime-beta-text.py index 83e1563a0..7a4ad3469 100644 --- a/examples/foundational/19b-openai-realtime-beta-text.py +++ b/examples/foundational/19b-openai-realtime-beta-text.py @@ -21,7 +21,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai_realtime_beta import ( InputAudioNoiseReduction, @@ -147,7 +147,9 @@ Remember, your responses should be short. Just one or two sentences, usually. Re tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # you can either register a single function for all function calls, or specific functions diff --git a/examples/foundational/19b-openai-realtime-text.py b/examples/foundational/19b-openai-realtime-text.py index 38731d72a..98dc81c3b 100644 --- a/examples/foundational/19b-openai-realtime-text.py +++ b/examples/foundational/19b-openai-realtime-text.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.realtime.events import ( AudioConfiguration, @@ -154,7 +154,9 @@ Remember, your responses should be short. Just one or two sentences, usually. Re tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # you can either register a single function for all function calls, or specific functions diff --git a/examples/foundational/20a-persistent-context-openai.py b/examples/foundational/20a-persistent-context-openai.py index be40add52..acdcefb92 100644 --- a/examples/foundational/20a-persistent-context-openai.py +++ b/examples/foundational/20a-persistent-context-openai.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -180,7 +180,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) diff --git a/examples/foundational/20c-persistent-context-anthropic.py b/examples/foundational/20c-persistent-context-anthropic.py index d99f4debf..5f2a3f317 100644 --- a/examples/foundational/20c-persistent-context-anthropic.py +++ b/examples/foundational/20c-persistent-context-anthropic.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -189,12 +189,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-5-sonnet-latest" - ) + llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY")) # you can either register a single function for all function calls, or specific functions # llm.register_function(None, fetch_weather_from_api) diff --git a/examples/foundational/20d-persistent-context-gemini.py b/examples/foundational/20d-persistent-context-gemini.py index 3bcd3c106..ca5186532 100644 --- a/examples/foundational/20d-persistent-context-gemini.py +++ b/examples/foundational/20d-persistent-context-gemini.py @@ -31,7 +31,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -257,7 +257,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) diff --git a/examples/foundational/21-tavus-transport.py b/examples/foundational/21-tavus-transport.py index b16ebbf38..06d904c21 100644 --- a/examples/foundational/21-tavus-transport.py +++ b/examples/foundational/21-tavus-transport.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.transports.tavus.transport import TavusParams, TavusTransport @@ -51,7 +51,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="a167e0f3-df7e-4d52-a9c3-f949145efdab", + settings=CartesiaTTSSettings( + voice="a167e0f3-df7e-4d52-a9c3-f949145efdab", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/21a-tavus-video-service.py b/examples/foundational/21a-tavus-video-service.py index 7e32579b0..c756a7821 100644 --- a/examples/foundational/21a-tavus-video-service.py +++ b/examples/foundational/21a-tavus-video-service.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.tavus.video import TavusVideoService @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="a167e0f3-df7e-4d52-a9c3-f949145efdab", + settings=CartesiaTTSSettings( + voice="a167e0f3-df7e-4d52-a9c3-f949145efdab", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/22-filter-incomplete-turns.py b/examples/foundational/22-filter-incomplete-turns.py index b7d094d1e..876999bcd 100644 --- a/examples/foundational/22-filter-incomplete-turns.py +++ b/examples/foundational/22-filter-incomplete-turns.py @@ -35,7 +35,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -68,21 +68,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - messages = [ - { - "role": "system", - "content": f"""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.""", - } - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams( @@ -128,9 +126,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append( + context.add_message( { - "role": "system", + "role": "user", "content": "Please introduce yourself to the user, asking them a question that will require a complete response. To start, say 'Let me start with a fun one. If you could travel anywhere in the world right now, where would you go and why?'", } ) diff --git a/examples/foundational/23-bot-background-sound.py b/examples/foundational/23-bot-background-sound.py index a57e8f446..a88ebc9bc 100644 --- a/examples/foundational/23-bot-background-sound.py +++ b/examples/foundational/23-bot-background-sound.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -75,7 +75,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/24-user-mute-strategy.py b/examples/foundational/24-user-mute-strategy.py index 36b537e6a..d4276f04a 100644 --- a/examples/foundational/24-user-mute-strategy.py +++ b/examples/foundational/24-user-mute-strategy.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -71,7 +71,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-helios-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-helena-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/25-google-audio-in.py b/examples/foundational/25-google-audio-in.py index 40903e1d5..a278ea4b3 100644 --- a/examples/foundational/25-google-audio-in.py +++ b/examples/foundational/25-google-audio-in.py @@ -32,8 +32,8 @@ from pipecat.processors.aggregators.llm_response_universal import LLMContextAggr from pipecat.processors.frame_processor import FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -290,13 +290,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) conversation_llm = GoogleLLMService( name="Conversation", - model="gemini-2.0-flash-001", - # model="gemini-exp-1121", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), api_key=os.getenv("GOOGLE_API_KEY"), # we can give the GoogleLLMService a system instruction to use directly # in the GenerativeModel constructor. Let's do that rather than put @@ -306,8 +309,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): input_transcription_llm = GoogleLLMService( name="Transcription", - model="gemini-2.0-flash-001", - # model="gemini-exp-1121", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), api_key=os.getenv("GOOGLE_API_KEY"), system_instruction=transcriber_system_message, ) diff --git a/examples/foundational/26d-gemini-live-text.py b/examples/foundational/26d-gemini-live-text.py index 1b3845fa3..eebe9874d 100644 --- a/examples/foundational/26d-gemini-live-text.py +++ b/examples/foundational/26d-gemini-live-text.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.google.gemini_live.llm import ( GeminiLiveLLMService, GeminiModalities, diff --git a/examples/foundational/27-simli-layer.py b/examples/foundational/27-simli-layer.py index fb469fbe1..05d0649d6 100644 --- a/examples/foundational/27-simli-layer.py +++ b/examples/foundational/27-simli-layer.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.simli.video import SimliVideoService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", + ), ) simli_ai = SimliVideoService( @@ -70,7 +72,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-mini", + settings=OpenAILLMSettings( + model="gpt-4o-mini", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/28-user-assistant-turns.py b/examples/foundational/28-user-assistant-turns.py index 9dd1fa2a1..d59ad3870 100644 --- a/examples/foundational/28-user-assistant-turns.py +++ b/examples/foundational/28-user-assistant-turns.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -122,7 +122,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/29-turn-tracking-observer.py b/examples/foundational/29-turn-tracking-observer.py index 9ba22dfda..0dd164bd0 100644 --- a/examples/foundational/29-turn-tracking-observer.py +++ b/examples/foundational/29-turn-tracking-observer.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -73,7 +73,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/30-observer.py b/examples/foundational/30-observer.py index 4616e0e03..5ee0bdaed 100644 --- a/examples/foundational/30-observer.py +++ b/examples/foundational/30-observer.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_input import BaseInputTransport @@ -104,7 +104,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/32-gemini-grounding-metadata.py b/examples/foundational/32-gemini-grounding-metadata.py index 19844b1fa..2977e19bc 100644 --- a/examples/foundational/32-gemini-grounding-metadata.py +++ b/examples/foundational/32-gemini-grounding-metadata.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService, LLMSearchResponseFrame from pipecat.services.llm_service import LLMService @@ -99,7 +99,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Initialize the Gemini Multimodal Live model diff --git a/examples/foundational/33-gemini-rag.py b/examples/foundational/33-gemini-rag.py index ae95ce117..c34a9c83e 100644 --- a/examples/foundational/33-gemini-rag.py +++ b/examples/foundational/33-gemini-rag.py @@ -69,9 +69,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -183,11 +183,24 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="f9836c6e-a0bd-460e-9d3c-f7299fa60f94", # Southern Lady + settings=CartesiaTTSSettings( + voice="f9836c6e-a0bd-460e-9d3c-f7299fa60f94", # Southern Lady + ), ) + system_prompt = """\ +You are a helpful assistant who converses with a user and answers questions. + +You have access to the tool, query_knowledge_base, that allows you to query the knowledge base for the answer to the user's question. + +Your response will be turned into speech so use only simple words and punctuation. +""" + llm = GoogleLLMService( - model=VOICE_MODEL, + settings=GoogleLLMSettings( + model=VOICE_MODEL, + ), + system_instruction=system_prompt, api_key=os.getenv("GOOGLE_API_KEY"), ) llm.register_function("query_knowledge_base", query_knowledge_base) @@ -205,15 +218,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[query_function]) - system_prompt = """\ -You are a helpful assistant who converses with a user and answers questions. - -You have access to the tool, query_knowledge_base, that allows you to query the knowledge base for the answer to the user's question. - -Your response will be turned into speech so use only simple words and punctuation. -""" messages = [ - {"role": "system", "content": system_prompt}, {"role": "user", "content": "Greet the user."}, ] diff --git a/examples/foundational/34-audio-recording.py b/examples/foundational/34-audio-recording.py index 8435acbde..aa52c213a 100644 --- a/examples/foundational/34-audio-recording.py +++ b/examples/foundational/34-audio-recording.py @@ -63,7 +63,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -112,12 +112,13 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", + ), ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4", system_instruction="You are a helpful assistant demonstrating audio recording capabilities. Keep your responses brief and clear.", ) diff --git a/examples/foundational/35-pattern-pair-voice-switching.py b/examples/foundational/35-pattern-pair-voice-switching.py index cacc04459..c10e185b0 100644 --- a/examples/foundational/35-pattern-pair-voice-switching.py +++ b/examples/foundational/35-pattern-pair-voice-switching.py @@ -56,7 +56,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -129,13 +129,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize TTS with narrator voice as default tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id=VOICE_IDS["narrator"], + settings=CartesiaTTSSettings( + voice=VOICE_IDS["narrator"], + ), text_aggregator=pattern_aggregator, ) - # Initialize LLM - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - # System prompt for storytelling with voice switching system_prompt = """You are an engaging storyteller that uses different voices to bring stories to life. @@ -184,15 +183,13 @@ FOLLOW THESE RULES: Remember: Use narrator voice for EVERYTHING except the actual quoted dialogue.""" - # Set up LLM context - messages = [ - { - "role": "system", - "content": system_prompt, - }, - ] + # Initialize LLM + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction=system_prompt, + ) - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/36-user-email-gathering.py b/examples/foundational/36-user-email-gathering.py index 95450c695..9c4bdd4ac 100644 --- a/examples/foundational/36-user-email-gathering.py +++ b/examples/foundational/36-user-email-gathering.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # (see https://docs.cartesia.ai/build-with-sonic/formatting-text-for-sonic/spelling-out-input-text) tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Rime offers a function `spell()` that we can use to ask the user diff --git a/examples/foundational/37-mem0.py b/examples/foundational/37-mem0.py index bfc651f3a..e02d86915 100644 --- a/examples/foundational/37-mem0.py +++ b/examples/foundational/37-mem0.py @@ -60,9 +60,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.mem0.memory import Mem0MemoryService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -166,7 +166,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize text-to-speech service tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY"), - voice_id="pNInz6obpgDQGcFmaJgB", + settings=ElevenLabsTTSSettings( + voice="pNInz6obpgDQGcFmaJgB", + ), ) # ===================================================================== @@ -223,7 +225,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize LLM service llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-mini", + settings=OpenAILLMSettings( + model="gpt-4o-mini", + ), system_instruction="""You are a personal assistant. You can remember things about the person you are talking to. Some Guidelines: - Make sure your responses are friendly yet short and concise. diff --git a/examples/foundational/38-smart-turn-fal.py b/examples/foundational/38-smart-turn-fal.py index fe8992784..384652b29 100644 --- a/examples/foundational/38-smart-turn-fal.py +++ b/examples/foundational/38-smart-turn-fal.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/38a-smart-turn-local-coreml.py b/examples/foundational/38a-smart-turn-local-coreml.py index 166fbbe12..01585982d 100644 --- a/examples/foundational/38a-smart-turn-local-coreml.py +++ b/examples/foundational/38a-smart-turn-local-coreml.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -76,7 +76,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/38b-smart-turn-local.py b/examples/foundational/38b-smart-turn-local.py index 962b608da..aceff9bc9 100644 --- a/examples/foundational/38b-smart-turn-local.py +++ b/examples/foundational/38b-smart-turn-local.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/39-mcp-stdio.py b/examples/foundational/39-mcp-stdio.py index 2daf21626..0919e2fb0 100644 --- a/examples/foundational/39-mcp-stdio.py +++ b/examples/foundational/39-mcp-stdio.py @@ -36,7 +36,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mcp_service import MCPClient from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -137,12 +137,25 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-7-sonnet-latest" - ) + system = f""" + You are a helpful LLM in a WebRTC call. + Your goal is to demonstrate your capabilities in a succinct way. + You have access to tools to search the Rijksmuseum collection. + Offer, for example, to show a floral still life, use the `search_artwork` tool. + The tool may respond with a JSON object with an `artworks` array. Choose the art from that array. + Once the tool has responded, tell the user the title and use the `open_image_in_browser` tool. + Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. + Respond to what the user said in a creative and helpful way. + Don't overexplain what you are doing. + Just respond with short sentences when you are carrying out tool calls. + """ + + llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"), system_instruction=system) try: mcp = MCPClient( @@ -169,22 +182,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.error(f"error registering tools") logger.exception("error trace:") - system = f""" - You are a helpful LLM in a WebRTC call. - Your goal is to demonstrate your capabilities in a succinct way. - You have access to tools to search the Rijksmuseum collection. - Offer, for example, to show a floral still life, use the `search_artwork` tool. - The tool may respond with a JSON object with an `artworks` array. Choose the art from that array. - Once the tool has responded, tell the user the title and use the `open_image_in_browser` tool. - Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. - Respond to what the user said in a creative and helpful way. - Don't overexplain what you are doing. - Just respond with short sentences when you are carrying out tool calls. - """ - - messages = [{"role": "system", "content": system}] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/39a-mcp-streamable-http.py b/examples/foundational/39a-mcp-streamable-http.py index 2af2ba9cb..870556073 100644 --- a/examples/foundational/39a-mcp-streamable-http.py +++ b/examples/foundational/39a-mcp-streamable-http.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.mcp_service import MCPClient @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"), model="gemini-2.0-flash") diff --git a/examples/foundational/39b-mcp-streamable-http-gemini-live.py b/examples/foundational/39b-mcp-streamable-http-gemini-live.py index c4c427bd8..8a0ea57fd 100644 --- a/examples/foundational/39b-mcp-streamable-http-gemini-live.py +++ b/examples/foundational/39b-mcp-streamable-http-gemini-live.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService from pipecat.services.mcp_service import MCPClient @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) try: diff --git a/examples/foundational/39c-multiple-mcp.py b/examples/foundational/39c-multiple-mcp.py index 5f662cdb8..dcda884ec 100644 --- a/examples/foundational/39c-multiple-mcp.py +++ b/examples/foundational/39c-multiple-mcp.py @@ -38,7 +38,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mcp_service import MCPClient from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -120,11 +120,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady - ) - - llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-7-sonnet-latest" + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) system = f""" @@ -141,7 +139,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): Just respond with short sentences when you are carrying out tool calls. """ - messages = [{"role": "system", "content": system}] + llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"), system_instruction=system) try: rijksmuseum_mcp = MCPClient( @@ -184,7 +182,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): all_standard_tools = rijksmuseum_tools.standard_tools + github_tools.standard_tools all_tools = ToolsSchema(standard_tools=all_standard_tools) - context = LLMContext(messages, all_tools) + context = LLMContext(tools=all_tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/42-interruption-config.py b/examples/foundational/42-interruption-config.py index 4491f9ee0..f8add9019 100644 --- a/examples/foundational/42-interruption-config.py +++ b/examples/foundational/42-interruption-config.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/43-heygen-transport.py b/examples/foundational/43-heygen-transport.py index e38cb7b6e..5797aeb25 100644 --- a/examples/foundational/43-heygen-transport.py +++ b/examples/foundational/43-heygen-transport.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.heygen.api_liveavatar import LiveAvatarNewSessionRequest @@ -56,7 +56,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="00967b2f-88a6-4a31-8153-110a92134b9f", + settings=CartesiaTTSSettings( + voice="00967b2f-88a6-4a31-8153-110a92134b9f", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/43a-heygen-video-service.py b/examples/foundational/43a-heygen-video-service.py index 2b23fe1f8..5be8f1caa 100644 --- a/examples/foundational/43a-heygen-video-service.py +++ b/examples/foundational/43a-heygen-video-service.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.heygen.api_liveavatar import LiveAvatarNewSessionRequest @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="00967b2f-88a6-4a31-8153-110a92134b9f", + settings=CartesiaTTSSettings( + voice="00967b2f-88a6-4a31-8153-110a92134b9f", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/44-voicemail-detection.py b/examples/foundational/44-voicemail-detection.py index f7cf14f71..e46c59cc0 100644 --- a/examples/foundational/44-voicemail-detection.py +++ b/examples/foundational/44-voicemail-detection.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/45-before-and-after-events.py b/examples/foundational/45-before-and-after-events.py index 405af49f3..db71e283d 100644 --- a/examples/foundational/45-before-and-after-events.py +++ b/examples/foundational/45-before-and-after-events.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/47-sentry-metrics.py b/examples/foundational/47-sentry-metrics.py index ef20745e4..f9983c46f 100644 --- a/examples/foundational/47-sentry-metrics.py +++ b/examples/foundational/47-sentry-metrics.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.metrics.sentry import SentryMetrics from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), metrics=SentryMetrics(), ) diff --git a/examples/foundational/48-service-switcher.py b/examples/foundational/48-service-switcher.py index 4aaafa508..dd7d9ec82 100644 --- a/examples/foundational/48-service-switcher.py +++ b/examples/foundational/48-service-switcher.py @@ -27,9 +27,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -102,15 +102,24 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts_cartesia = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), + ) + tts_deepgram = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-helena-en", + ), ) - tts_deepgram = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY")) tts_switcher = ServiceSwitcher( services=[tts_cartesia, tts_deepgram], strategy_type=ServiceSwitcherStrategyManual ) - llm_openai = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - llm_google = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) + system = "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way." + + llm_openai = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system) + llm_google = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"), system_instruction=system) llm_switcher = LLMSwitcher( llms=[llm_openai, llm_google], strategy_type=ServiceSwitcherStrategyManual ) @@ -119,15 +128,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Register a "direct" function llm_switcher.register_direct_function(get_restaurant_recommendation) - messages = [ - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] tools = ToolsSchema(standard_tools=[weather_function, get_restaurant_recommendation]) - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -158,7 +161,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) await asyncio.sleep(15) print(f"Switching to {stt_deepgram}") diff --git a/examples/foundational/49a-thinking-anthropic.py b/examples/foundational/49a-thinking-anthropic.py index 28dd33565..fa84e7c6c 100644 --- a/examples/foundational/49a-thinking-anthropic.py +++ b/examples/foundational/49a-thinking-anthropic.py @@ -22,8 +22,12 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.anthropic.llm import ( + AnthropicLLMService, + AnthropicLLMSettings, + AnthropicThinkingConfig, +) +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,13 +60,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - params=AnthropicLLMService.InputParams( - thinking=AnthropicLLMService.ThinkingConfig(type="enabled", budget_tokens=2048) + settings=AnthropicLLMSettings( + thinking=AnthropicThinkingConfig( + type="enabled", + budget_tokens=2048, + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/49b-thinking-google.py b/examples/foundational/49b-thinking-google.py index 32677bcbb..0fb0a30f0 100644 --- a/examples/foundational/49b-thinking-google.py +++ b/examples/foundational/49b-thinking-google.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings, GoogleThinkingConfig from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,18 +56,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), # model="gemini-3-pro-preview", # A more powerful reasoning model, but slower - params=GoogleLLMService.InputParams( - thinking=GoogleLLMService.ThinkingConfig( - # thinking_level="low", # Use this field instead of thinking_budget for Gemini 3 Pro. Defaults to "high". + settings=GoogleLLMSettings( + thinking=GoogleThinkingConfig( thinking_budget=-1, # Dynamic thinking include_thoughts=True, - ) + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/49c-thinking-functions-anthropic.py b/examples/foundational/49c-thinking-functions-anthropic.py index b070871b1..4fb66470d 100644 --- a/examples/foundational/49c-thinking-functions-anthropic.py +++ b/examples/foundational/49c-thinking-functions-anthropic.py @@ -23,8 +23,12 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.anthropic.llm import ( + AnthropicLLMService, + AnthropicLLMSettings, + AnthropicThinkingConfig, +) +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -77,13 +81,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - params=AnthropicLLMService.InputParams( - thinking=AnthropicLLMService.ThinkingConfig(type="enabled", budget_tokens=2048) + settings=AnthropicLLMSettings( + thinking=AnthropicThinkingConfig( + type="enabled", + budget_tokens=2048, + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/49d-thinking-functions-google.py b/examples/foundational/49d-thinking-functions-google.py index 9b5a333de..3963fc387 100644 --- a/examples/foundational/49d-thinking-functions-google.py +++ b/examples/foundational/49d-thinking-functions-google.py @@ -23,9 +23,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings, GoogleThinkingConfig from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -77,18 +77,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), # model="gemini-3-pro-preview", # A more powerful reasoning model, but slower - params=GoogleLLMService.InputParams( - thinking=GoogleLLMService.ThinkingConfig( - # thinking_level="low", # Use this field instead of thinking_budget for Gemini 3 Pro. Defaults to "high". + settings=GoogleLLMSettings( + thinking=GoogleThinkingConfig( thinking_budget=-1, # Dynamic thinking include_thoughts=True, - ) + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/52-live-translation.py b/examples/foundational/52-live-translation.py index 6ab0bac18..15598667f 100644 --- a/examples/foundational/52-live-translation.py +++ b/examples/foundational/52-live-translation.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + settings=CartesiaTTSSettings( + voice="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/53-concurrent-llm-evaluation.py b/examples/foundational/53-concurrent-llm-evaluation.py index 9fb44a44f..a93ca2ada 100644 --- a/examples/foundational/53-concurrent-llm-evaluation.py +++ b/examples/foundational/53-concurrent-llm-evaluation.py @@ -24,9 +24,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.vad_processor import VADProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,31 +62,24 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - openai_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - - openai_messages = [ - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] + openai_llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) groq_llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), model="meta-llama/llama-4-maverick-17b-128e-instruct" + api_key=os.getenv("GROQ_API_KEY"), + settings=GroqLLMSettings(model="meta-llama/llama-4-maverick-17b-128e-instruct"), + system_instruction="You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", ) - groq_messages = [ - { - "role": "system", - "content": "You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", - }, - ] - - openai_context = LLMContext(openai_messages) - groq_context = LLMContext(groq_messages) + openai_context = LLMContext() + groq_context = LLMContext() # We use an external VADProcessor because the UserTurnProcessor is shared # across multiple parallel aggregators. The VADProcessor emits @@ -147,11 +140,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - openai_messages.append( - {"role": "system", "content": "Please introduce yourself to the user."} + openai_context.add_message( + {"role": "user", "content": "Please introduce yourself to the user."} ) - groq_messages.append( - {"role": "system", "content": "Please introduce yourself to the user."} + groq_context.add_message( + {"role": "user", "content": "Please introduce yourself to the user."} ) await task.queue_frames([LLMRunFrame()]) diff --git a/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py b/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py index b16f8831f..f449269e9 100644 --- a/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py +++ b/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py @@ -31,7 +31,7 @@ from pipecat.processors.audio.vad_processor import VADProcessor from pipecat.processors.frameworks.rtvi import RTVIObserverParams from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -67,40 +67,27 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Main LLM — drives the conversation. Its RTVI events reach the client. - main_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - - main_messages = [ - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] + main_llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) # Evaluator LLM — silently grades the user's message in the background. # Its RTVI events will be suppressed so the client is unaware of this branch. evaluator_llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), name="EvaluatorLLM", + system_instruction="You are a silent quality evaluator. When given a user message, respond with a single JSON object: {'score': <1-5>, 'reason': ''}. Do not respond conversationally.", ) - evaluator_messages = [ - { - "role": "system", - "content": ( - "You are a silent quality evaluator. When given a user message, " - "respond with a single JSON object: " - '{"score": <1-5>, "reason": ""}. ' - "Do not respond conversationally." - ), - }, - ] - - main_context = LLMContext(main_messages) - evaluator_context = LLMContext(evaluator_messages) + main_context = LLMContext() + evaluator_context = LLMContext() # We use an external VADProcessor because the UserTurnProcessor is shared # across multiple parallel aggregators. The VADProcessor emits @@ -163,10 +150,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): @transport.event_handler("on_client_connected") async def on_client_connected(transport, client): logger.info("Client connected") - main_messages.append( - {"role": "system", "content": "Please introduce yourself to the user."} + main_context.add_message( + {"role": "user", "content": "Please introduce yourself to the user."} + ) + evaluator_context.add_message( + {"role": "user", "content": "Ready to evaluate user messages."} ) - evaluator_messages.append({"role": "system", "content": "Ready to evaluate user messages."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/54-context-summarization-openai.py b/examples/foundational/54-context-summarization-openai.py index 25ea496c3..8c7c38d62 100644 --- a/examples/foundational/54-context-summarization-openai.py +++ b/examples/foundational/54-context-summarization-openai.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -81,7 +81,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/54a-context-summarization-google.py b/examples/foundational/54a-context-summarization-google.py index c79e96c3d..21e2ef459 100644 --- a/examples/foundational/54a-context-summarization-google.py +++ b/examples/foundational/54a-context-summarization-google.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -81,7 +81,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/54b-context-summarization-manual-openai.py b/examples/foundational/54b-context-summarization-manual-openai.py index c1ff83ef0..0fd2c0bd7 100644 --- a/examples/foundational/54b-context-summarization-manual-openai.py +++ b/examples/foundational/54b-context-summarization-manual-openai.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -78,10 +78,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + system_prompt = """You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your + capabilities in a succinct way. Your output will be spoken aloud, so avoid + special characters that can't easily be spoken, such as emojis or bullet points. + Respond to what the user said in a creative and helpful way. + If the user asks you to summarize the conversation, call the + summarize_conversation function. After summarization, briefly acknowledge + that the conversation history has been compressed. + """ + + llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) llm.register_function("summarize_conversation", summarize_conversation) @@ -97,22 +108,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[summarize_function]) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your " - "capabilities in a succinct way. Your output will be spoken aloud, so avoid " - "special characters that can't easily be spoken, such as emojis or bullet points. " - "Respond to what the user said in a creative and helpful way. " - "If the user asks you to summarize the conversation, call the " - "summarize_conversation function. After summarization, briefly acknowledge " - "that the conversation history has been compressed." - ), - }, - ] - - context = LLMContext(messages, tools=tools) + context = LLMContext(tools=tools) # Automatic summarization is NOT enabled here (enable_auto_context_summarization # defaults to False). The summarizer is still created internally so that @@ -147,7 +143,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info("Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/54c-context-summarization-dedicated-llm.py b/examples/foundational/54c-context-summarization-dedicated-llm.py index 1dce3890f..ce0f7658f 100644 --- a/examples/foundational/54c-context-summarization-dedicated-llm.py +++ b/examples/foundational/54c-context-summarization-dedicated-llm.py @@ -36,9 +36,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -93,16 +93,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) + system_prompt = """You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your + capabilities in a succinct way. Your output will be spoken aloud, so avoid + special characters that can't easily be spoken, such as emojis or bullet points. + Respond to what the user said in a creative and helpful way. + You have access to tools to get the current weather - use them when relevant. + When you see a block, it contains a compressed summary + of earlier conversation. Use it as reference but don't mention it to the user. + """ + # Primary LLM for conversation (could be any provider) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) # Dedicated cheap/fast LLM for summarization only summarization_llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), ) # Register tool functions @@ -126,22 +139,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function]) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate " - "your capabilities in a succinct way. Your output will be spoken aloud, " - "so avoid special characters that can't easily be spoken. Respond to what " - "the user said in a creative and helpful way. You have access to tools to " - "get the current weather - use them when relevant.\n\n" - "When you see a block, it contains a compressed summary " - "of earlier conversation. Use it as reference but don't mention it to the user." - ), - }, - ] - - context = LLMContext(messages, tools=tools) + context = LLMContext(tools=tools) # Create aggregators with custom summarization user_aggregator, assistant_aggregator = LLMContextAggregatorPair( @@ -211,7 +209,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info("Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/55a-update-settings-deepgram-flux-stt.py b/examples/foundational/55a-update-settings-deepgram-flux-stt.py index ef58fe8fb..0a507aaed 100644 --- a/examples/foundational/55a-update-settings-deepgram-flux-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-flux-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService, DeepgramFluxSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py b/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py index 489ea1276..b6f2142bc 100644 --- a/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.sagemaker.stt import ( DeepgramSageMakerSTTService, DeepgramSageMakerSTTSettings, @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55a-update-settings-deepgram-stt.py b/examples/foundational/55a-update-settings-deepgram-stt.py index b0521bb19..b914d8085 100644 --- a/examples/foundational/55a-update-settings-deepgram-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55b-update-settings-azure-stt.py b/examples/foundational/55b-update-settings-azure-stt.py index 1d3b3fcee..c54b1a0d8 100644 --- a/examples/foundational/55b-update-settings-azure-stt.py +++ b/examples/foundational/55b-update-settings-azure-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.stt import AzureSTTService, AzureSTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55c-update-settings-google-stt.py b/examples/foundational/55c-update-settings-google-stt.py index 2956b8047..23b312f5f 100644 --- a/examples/foundational/55c-update-settings-google-stt.py +++ b/examples/foundational/55c-update-settings-google-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55d-update-settings-assemblyai-stt.py b/examples/foundational/55d-update-settings-assemblyai-stt.py index f8c366a44..e6d10d04f 100644 --- a/examples/foundational/55d-update-settings-assemblyai-stt.py +++ b/examples/foundational/55d-update-settings-assemblyai-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.models import AssemblyAIConnectionParams from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55e-update-settings-gladia-stt.py b/examples/foundational/55e-update-settings-gladia-stt.py index 5b8283f72..6cc3fc92a 100644 --- a/examples/foundational/55e-update-settings-gladia-stt.py +++ b/examples/foundational/55e-update-settings-gladia-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py b/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py index 8d2c17778..ef1e44b61 100644 --- a/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py +++ b/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.elevenlabs.stt import ( ElevenLabsRealtimeSTTService, ElevenLabsRealtimeSTTSettings, @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55g-update-settings-elevenlabs-stt.py b/examples/foundational/55g-update-settings-elevenlabs-stt.py index 0395f273d..c3fb9eac9 100644 --- a/examples/foundational/55g-update-settings-elevenlabs-stt.py +++ b/examples/foundational/55g-update-settings-elevenlabs-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.elevenlabs.stt import ElevenLabsSTTService, ElevenLabsSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55h-update-settings-speechmatics-stt.py b/examples/foundational/55h-update-settings-speechmatics-stt.py index ba775199a..1471f7ef2 100644 --- a/examples/foundational/55h-update-settings-speechmatics-stt.py +++ b/examples/foundational/55h-update-settings-speechmatics-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings from pipecat.transcriptions.language import Language @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55i-update-settings-whisper-api-stt.py b/examples/foundational/55i-update-settings-whisper-api-stt.py index 962a70485..6b957a0be 100644 --- a/examples/foundational/55i-update-settings-whisper-api-stt.py +++ b/examples/foundational/55i-update-settings-whisper-api-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.stt import OpenAISTTService from pipecat.services.whisper.base_stt import BaseWhisperSTTSettings @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55j-update-settings-sarvam-stt.py b/examples/foundational/55j-update-settings-sarvam-stt.py index 58f0f80c7..57ebccab5 100644 --- a/examples/foundational/55j-update-settings-sarvam-stt.py +++ b/examples/foundational/55j-update-settings-sarvam-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.sarvam.stt import SarvamSTTService, SarvamSTTSettings from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55k-update-settings-soniox-stt.py b/examples/foundational/55k-update-settings-soniox-stt.py index b31a0e708..ac339e3c1 100644 --- a/examples/foundational/55k-update-settings-soniox-stt.py +++ b/examples/foundational/55k-update-settings-soniox-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.soniox.stt import SonioxSTTService, SonioxSTTSettings from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55l-update-settings-aws-transcribe-stt.py b/examples/foundational/55l-update-settings-aws-transcribe-stt.py index 910bc66b4..5594f21d9 100644 --- a/examples/foundational/55l-update-settings-aws-transcribe-stt.py +++ b/examples/foundational/55l-update-settings-aws-transcribe-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.stt import AWSTranscribeSTTService, AWSTranscribeSTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55m-update-settings-cartesia-stt.py b/examples/foundational/55m-update-settings-cartesia-stt.py index 4956d8d75..f1a984d9b 100644 --- a/examples/foundational/55m-update-settings-cartesia-stt.py +++ b/examples/foundational/55m-update-settings-cartesia-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService, CartesiaSTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55n-update-settings-cartesia-http-tts.py b/examples/foundational/55n-update-settings-cartesia-http-tts.py index 0423d855f..a58a8a778 100644 --- a/examples/foundational/55n-update-settings-cartesia-http-tts.py +++ b/examples/foundational/55n-update-settings-cartesia-http-tts.py @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55n-update-settings-cartesia-tts.py b/examples/foundational/55n-update-settings-cartesia-tts.py index 2ee07b830..e729c53f2 100644 --- a/examples/foundational/55n-update-settings-cartesia-tts.py +++ b/examples/foundational/55n-update-settings-cartesia-tts.py @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zi-update-settings-azure-llm.py b/examples/foundational/55zi-update-settings-azure-llm.py index b6e8ccf71..29748491b 100644 --- a/examples/foundational/55zi-update-settings-azure-llm.py +++ b/examples/foundational/55zi-update-settings-azure-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.llm import AzureLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AzureLLMService( diff --git a/examples/foundational/55zi-update-settings-openai-llm.py b/examples/foundational/55zi-update-settings-openai-llm.py index c9fb026f3..123fc7a04 100644 --- a/examples/foundational/55zi-update-settings-openai-llm.py +++ b/examples/foundational/55zi-update-settings-openai-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zj-update-settings-anthropic-llm.py b/examples/foundational/55zj-update-settings-anthropic-llm.py index 59ac73da6..d44102f2d 100644 --- a/examples/foundational/55zj-update-settings-anthropic-llm.py +++ b/examples/foundational/55zj-update-settings-anthropic-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( diff --git a/examples/foundational/55zk-update-settings-google-llm.py b/examples/foundational/55zk-update-settings-google-llm.py index 4a0a3de0f..d1222e422 100644 --- a/examples/foundational/55zk-update-settings-google-llm.py +++ b/examples/foundational/55zk-update-settings-google-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/55zk-update-settings-google-vertex-llm.py b/examples/foundational/55zk-update-settings-google-vertex-llm.py index fe8ef808b..aa9452d09 100644 --- a/examples/foundational/55zk-update-settings-google-vertex-llm.py +++ b/examples/foundational/55zk-update-settings-google-vertex-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMSettings from pipecat.services.google.llm_vertex import GoogleVertexLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleVertexLLMService( diff --git a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py index 72b5ae9be..c543ef50c 100644 --- a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py +++ b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AWSBedrockLLMService( diff --git a/examples/foundational/55zq-update-settings-fal-stt.py b/examples/foundational/55zq-update-settings-fal-stt.py index 22ee38929..96f916d81 100644 --- a/examples/foundational/55zq-update-settings-fal-stt.py +++ b/examples/foundational/55zq-update-settings-fal-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.fal.stt import FalSTTService, FalSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zr-update-settings-gradium-stt.py b/examples/foundational/55zr-update-settings-gradium-stt.py index 65c70519d..0b3085125 100644 --- a/examples/foundational/55zr-update-settings-gradium-stt.py +++ b/examples/foundational/55zr-update-settings-gradium-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py b/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py index 122619aaa..55a6719be 100644 --- a/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py +++ b/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.nvidia.stt import NvidiaSegmentedSTTService, NvidiaSegmentedSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zt-update-settings-nvidia-stt.py b/examples/foundational/55zt-update-settings-nvidia-stt.py index 232db9bf3..2f15895d2 100644 --- a/examples/foundational/55zt-update-settings-nvidia-stt.py +++ b/examples/foundational/55zt-update-settings-nvidia-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.nvidia.stt import NvidiaSTTService, NvidiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zu-update-settings-openai-realtime-stt.py b/examples/foundational/55zu-update-settings-openai-realtime-stt.py index eb7be5c97..7cc31085b 100644 --- a/examples/foundational/55zu-update-settings-openai-realtime-stt.py +++ b/examples/foundational/55zu-update-settings-openai-realtime-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zx-update-settings-cerebras-llm.py b/examples/foundational/55zx-update-settings-cerebras-llm.py index 3937345e1..dc09cdae7 100644 --- a/examples/foundational/55zx-update-settings-cerebras-llm.py +++ b/examples/foundational/55zx-update-settings-cerebras-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.cerebras.llm import CerebrasLLMService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = CerebrasLLMService( diff --git a/examples/foundational/55zy-update-settings-deepseek-llm.py b/examples/foundational/55zy-update-settings-deepseek-llm.py index c96107c40..fe6e18185 100644 --- a/examples/foundational/55zy-update-settings-deepseek-llm.py +++ b/examples/foundational/55zy-update-settings-deepseek-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepseek.llm import DeepSeekLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = DeepSeekLLMService( diff --git a/examples/foundational/55zz-update-settings-fireworks-llm.py b/examples/foundational/55zz-update-settings-fireworks-llm.py index 8c4388251..19b9276e6 100644 --- a/examples/foundational/55zz-update-settings-fireworks-llm.py +++ b/examples/foundational/55zz-update-settings-fireworks-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.fireworks.llm import FireworksLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = FireworksLLMService( diff --git a/examples/foundational/55zza-update-settings-grok-llm.py b/examples/foundational/55zza-update-settings-grok-llm.py index e75c70b5f..c40f40ac6 100644 --- a/examples/foundational/55zza-update-settings-grok-llm.py +++ b/examples/foundational/55zza-update-settings-grok-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.grok.llm import GrokLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GrokLLMService( diff --git a/examples/foundational/55zzb-update-settings-groq-llm.py b/examples/foundational/55zzb-update-settings-groq-llm.py index 2f7f82bb2..be5467b8a 100644 --- a/examples/foundational/55zzb-update-settings-groq-llm.py +++ b/examples/foundational/55zzb-update-settings-groq-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.groq.llm import GroqLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GroqLLMService( diff --git a/examples/foundational/55zzc-update-settings-mistral-llm.py b/examples/foundational/55zzc-update-settings-mistral-llm.py index ab3bd4f76..f6fa824d4 100644 --- a/examples/foundational/55zzc-update-settings-mistral-llm.py +++ b/examples/foundational/55zzc-update-settings-mistral-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mistral.llm import MistralLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = MistralLLMService( diff --git a/examples/foundational/55zzd-update-settings-nvidia-llm.py b/examples/foundational/55zzd-update-settings-nvidia-llm.py index a8699c71b..5e26e8213 100644 --- a/examples/foundational/55zzd-update-settings-nvidia-llm.py +++ b/examples/foundational/55zzd-update-settings-nvidia-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.nvidia.llm import NvidiaLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = NvidiaLLMService( diff --git a/examples/foundational/55zze-update-settings-ollama-llm.py b/examples/foundational/55zze-update-settings-ollama-llm.py index 4595604fd..7e3fa02de 100644 --- a/examples/foundational/55zze-update-settings-ollama-llm.py +++ b/examples/foundational/55zze-update-settings-ollama-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.ollama.llm import OLLamaLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OLLamaLLMService( diff --git a/examples/foundational/55zzf-update-settings-openrouter-llm.py b/examples/foundational/55zzf-update-settings-openrouter-llm.py index 9a381d88b..c31a7c43c 100644 --- a/examples/foundational/55zzf-update-settings-openrouter-llm.py +++ b/examples/foundational/55zzf-update-settings-openrouter-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openrouter.llm import OpenRouterLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenRouterLLMService( diff --git a/examples/foundational/55zzg-update-settings-perplexity-llm.py b/examples/foundational/55zzg-update-settings-perplexity-llm.py index f55975685..5227c6063 100644 --- a/examples/foundational/55zzg-update-settings-perplexity-llm.py +++ b/examples/foundational/55zzg-update-settings-perplexity-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.perplexity.llm import PerplexityLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = PerplexityLLMService(api_key=os.getenv("PERPLEXITY_API_KEY")) diff --git a/examples/foundational/55zzh-update-settings-qwen-llm.py b/examples/foundational/55zzh-update-settings-qwen-llm.py index 019e916cb..5c6d17d1d 100644 --- a/examples/foundational/55zzh-update-settings-qwen-llm.py +++ b/examples/foundational/55zzh-update-settings-qwen-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.qwen.llm import QwenLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = QwenLLMService( diff --git a/examples/foundational/55zzi-update-settings-sambanova-llm.py b/examples/foundational/55zzi-update-settings-sambanova-llm.py index 040e95da1..cececc078 100644 --- a/examples/foundational/55zzi-update-settings-sambanova-llm.py +++ b/examples/foundational/55zzi-update-settings-sambanova-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.sambanova.llm import SambaNovaLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = SambaNovaLLMService( diff --git a/examples/foundational/55zzj-update-settings-together-llm.py b/examples/foundational/55zzj-update-settings-together-llm.py index b1c8c049d..4e1c9732f 100644 --- a/examples/foundational/55zzj-update-settings-together-llm.py +++ b/examples/foundational/55zzj-update-settings-together-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.together.llm import TogetherLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = TogetherLLMService( diff --git a/examples/foundational/55zzn-update-settings-groq-stt.py b/examples/foundational/55zzn-update-settings-groq-stt.py index 1d488119c..7a8551be2 100644 --- a/examples/foundational/55zzn-update-settings-groq-stt.py +++ b/examples/foundational/55zzn-update-settings-groq-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.groq.stt import GroqSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.whisper.base_stt import BaseWhisperSTTSettings @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/56-lemonslice-transport.py b/examples/foundational/56-lemonslice-transport.py index a3b6b60d3..6085f3b00 100644 --- a/examples/foundational/56-lemonslice-transport.py +++ b/examples/foundational/56-lemonslice-transport.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.groq.llm import GroqLLMService from pipecat.transports.lemonslice.transport import ( LemonSliceNewSessionRequest, @@ -62,7 +62,9 @@ async def main(): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) context = LLMContext() diff --git a/examples/quickstart/bot.py b/examples/quickstart/bot.py index fbe27d783..956331d50 100644 --- a/examples/quickstart/bot.py +++ b/examples/quickstart/bot.py @@ -45,7 +45,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) diff --git a/scripts/evals/eval.py b/scripts/evals/eval.py index 8084bc3a1..d45e6343b 100644 --- a/scripts/evals/eval.py +++ b/scripts/evals/eval.py @@ -48,7 +48,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService, LiveOptions from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 52fb451c3..cf4101305 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -320,7 +320,7 @@ class BaseOpenAILLMService(LLMService): "top_p": self._settings.top_p, "max_tokens": self._settings.max_tokens, "max_completion_tokens": self._settings.max_completion_tokens, - "service_tier": self._service_tier, + "service_tier": self._service_tier if self._service_tier is not None else NOT_GIVEN, } # Messages, tools, tool_choice diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 659a58bdd..0d605fc6b 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -272,37 +272,22 @@ class SarvamHttpTTSSettings(TTSSettings): @dataclass -class SarvamTTSSettings(TTSSettings): +class SarvamTTSSettings(SarvamHttpTTSSettings): """Settings for Sarvam WebSocket TTS service. + Extends :class:`SarvamHttpTTSSettings` with WebSocket-specific buffering parameters. + Parameters: - enable_preprocessing: Enable text preprocessing. Defaults to False. - **Note:** Always enabled for bulbul:v3-beta. min_buffer_size: Minimum characters to buffer before generating audio. Lower values reduce latency but may affect quality. Defaults to 50. max_chunk_length: Maximum characters processed in a single chunk. Controls memory usage and processing efficiency. Defaults to 150. - pace: Speech pace multiplier. Defaults to 1.0. - - bulbul:v2: Range 0.3 to 3.0 - - bulbul:v3-beta: Range 0.5 to 2.0 - pitch: Voice pitch adjustment (-0.75 to 0.75). Defaults to 0.0. - **Note:** Only supported for bulbul:v2. Ignored for v3 models. - loudness: Volume multiplier (0.3 to 3.0). Defaults to 1.0. - **Note:** Only supported for bulbul:v2. Ignored for v3 models. - temperature: Controls output randomness for bulbul:v3-beta (0.01 to 1.0). - Lower = more deterministic, higher = more random. Defaults to 0.6. - **Note:** Only supported for bulbul:v3-beta. Ignored for v2. """ _aliases: ClassVar[Dict[str, str]] = {"target_language_code": "language"} - enable_preprocessing: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) min_buffer_size: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) max_chunk_length: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pace: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pitch: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - loudness: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class SarvamHttpTTSService(TTSService): From 8a203dd98feafd8dd662f85ae580040da5cf1b62 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 23:29:50 -0500 Subject: [PATCH 12/17] Update more examples, misc services --- examples/foundational/03-still-frame.py | 6 +- .../foundational/03a-local-still-frame.py | 6 +- .../foundational/05-sync-speech-and-image.py | 6 +- .../05a-local-sync-speech-and-image.py | 6 +- ...o-function-calling-gemini-openai-format.py | 2 +- .../14p-function-calling-gemini-vertex-ai.py | 2 +- .../foundational/14r-function-calling-aws.py | 2 +- .../foundational/36-user-email-gathering.py | 4 +- .../55d-update-settings-assemblyai-stt.py | 9 +-- .../55h-update-settings-speechmatics-stt.py | 2 +- ...55o-update-settings-elevenlabs-http-tts.py | 2 +- .../55o-update-settings-elevenlabs-tts.py | 2 +- .../55u-update-settings-rime-http-tts.py | 4 +- .../55u-update-settings-rime-tts.py | 2 +- .../55v-update-settings-lmnt-tts.py | 2 +- .../55w-update-settings-fish-tts.py | 2 +- .../55z-update-settings-hume-tts.py | 2 +- .../55zc-update-settings-gemini-tts.py | 6 +- .../55zh-update-settings-resembleai-tts.py | 2 +- .../55zi-update-settings-azure-llm.py | 4 +- .../55zp-update-settings-aws-bedrock-llm.py | 6 +- .../55zv-update-settings-asyncai-http-tts.py | 4 +- .../55zv-update-settings-asyncai-tts.py | 4 +- .../55zw-update-settings-gradium-tts.py | 2 +- .../55zz-update-settings-fireworks-llm.py | 4 +- .../55zzb-update-settings-groq-llm.py | 4 +- .../55zzd-update-settings-nvidia-llm.py | 4 +- .../55zze-update-settings-ollama-llm.py | 4 +- .../55zzh-update-settings-qwen-llm.py | 4 +- .../55zzj-update-settings-together-llm.py | 4 +- src/pipecat/services/azure/image.py | 35 ++++++++-- src/pipecat/services/fal/image.py | 70 +++++++++++++++++-- src/pipecat/services/google/image.py | 33 ++++++--- src/pipecat/services/heygen/video.py | 10 ++- src/pipecat/services/openai/image.py | 31 ++++++-- src/pipecat/services/tavus/video.py | 10 ++- 36 files changed, 221 insertions(+), 81 deletions(-) diff --git a/examples/foundational/03-still-frame.py b/examples/foundational/03-still-frame.py index def125165..a98a53637 100644 --- a/examples/foundational/03-still-frame.py +++ b/examples/foundational/03-still-frame.py @@ -16,7 +16,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.fal.image import FalImageGenService +from pipecat.services.fal.image import FalImageGenService, FalImageGenSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -45,7 +45,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: imagegen = FalImageGenService( - params=FalImageGenService.InputParams(image_size="square_hd"), + settings=FalImageGenSettings( + image_size="square_hd", + ), aiohttp_session=session, key=os.getenv("FAL_KEY"), ) diff --git a/examples/foundational/03a-local-still-frame.py b/examples/foundational/03a-local-still-frame.py index b25c51c4a..db67848e8 100644 --- a/examples/foundational/03a-local-still-frame.py +++ b/examples/foundational/03a-local-still-frame.py @@ -17,7 +17,7 @@ from pipecat.frames.frames import TextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask -from pipecat.services.fal.image import FalImageGenService +from pipecat.services.fal.image import FalImageGenService, FalImageGenSettings from pipecat.transports.local.tk import TkLocalTransport, TkTransportParams load_dotenv(override=True) @@ -37,7 +37,9 @@ async def main(): ) imagegen = FalImageGenService( - params=FalImageGenService.InputParams(image_size="square_hd"), + settings=FalImageGenSettings( + image_size="square_hd", + ), aiohttp_session=session, key=os.getenv("FAL_KEY"), ) diff --git a/examples/foundational/05-sync-speech-and-image.py b/examples/foundational/05-sync-speech-and-image.py index 95de1143b..b77ff1612 100644 --- a/examples/foundational/05-sync-speech-and-image.py +++ b/examples/foundational/05-sync-speech-and-image.py @@ -28,7 +28,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings -from pipecat.services.fal.image import FalImageGenService +from pipecat.services.fal.image import FalImageGenService, FalImageGenSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -104,7 +104,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) imagegen = FalImageGenService( - params=FalImageGenService.InputParams(image_size="square_hd"), + settings=FalImageGenSettings( + image_size="square_hd", + ), aiohttp_session=session, key=os.getenv("FAL_KEY"), ) diff --git a/examples/foundational/05a-local-sync-speech-and-image.py b/examples/foundational/05a-local-sync-speech-and-image.py index 03b690c11..993e8eb07 100644 --- a/examples/foundational/05a-local-sync-speech-and-image.py +++ b/examples/foundational/05a-local-sync-speech-and-image.py @@ -29,7 +29,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.sentence import SentenceAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings -from pipecat.services.fal.image import FalImageGenService +from pipecat.services.fal.image import FalImageGenService, FalImageGenSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.local.tk import TkLocalTransport, TkTransportParams @@ -104,7 +104,9 @@ async def main(): ) imagegen = FalImageGenService( - params=FalImageGenService.InputParams(image_size="square_hd"), + settings=FalImageGenSettings( + image_size="square_hd", + ), aiohttp_session=session, key=os.getenv("FAL_KEY"), ) diff --git a/examples/foundational/14o-function-calling-gemini-openai-format.py b/examples/foundational/14o-function-calling-gemini-openai-format.py index 4a752586f..5eb8ff89d 100644 --- a/examples/foundational/14o-function-calling-gemini-openai-format.py +++ b/examples/foundational/14o-function-calling-gemini-openai-format.py @@ -65,7 +65,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), settings=ElevenLabsTTSSettings( - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + voice=os.getenv("ELEVENLABS_VOICE_ID", ""), ), ) diff --git a/examples/foundational/14p-function-calling-gemini-vertex-ai.py b/examples/foundational/14p-function-calling-gemini-vertex-ai.py index 3ff062201..bf7b9458d 100644 --- a/examples/foundational/14p-function-calling-gemini-vertex-ai.py +++ b/examples/foundational/14p-function-calling-gemini-vertex-ai.py @@ -65,7 +65,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), settings=ElevenLabsTTSSettings( - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + voice=os.getenv("ELEVENLABS_VOICE_ID", ""), ), ) diff --git a/examples/foundational/14r-function-calling-aws.py b/examples/foundational/14r-function-calling-aws.py index 9e8e9836f..9d7e4e7a1 100644 --- a/examples/foundational/14r-function-calling-aws.py +++ b/examples/foundational/14r-function-calling-aws.py @@ -67,7 +67,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS settings=AWSPollyTTSSettings( - voice_id="Joanna", + voice="Joanna", engine="generative", rate="1.1", ), diff --git a/examples/foundational/36-user-email-gathering.py b/examples/foundational/36-user-email-gathering.py index 9c4bdd4ac..5bdb937d0 100644 --- a/examples/foundational/36-user-email-gathering.py +++ b/examples/foundational/36-user-email-gathering.py @@ -77,7 +77,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # (see https://docs.rime.ai/api-reference/spell) # tts = RimeHttpTTSService( # api_key=os.getenv("RIME_API_KEY", ""), - # voice_id="eva", + # settings=RimeTTSSettings( + # voice="eva", + # ), # aiohttp_session=session, # ) diff --git a/examples/foundational/55d-update-settings-assemblyai-stt.py b/examples/foundational/55d-update-settings-assemblyai-stt.py index e6d10d04f..9cd5641fd 100644 --- a/examples/foundational/55d-update-settings-assemblyai-stt.py +++ b/examples/foundational/55d-update-settings-assemblyai-stt.py @@ -22,7 +22,6 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.assemblyai.models import AssemblyAIConnectionParams from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService @@ -53,8 +52,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = AssemblyAISTTService( api_key=os.getenv("ASSEMBLYAI_API_KEY"), - connection_params=AssemblyAIConnectionParams( - speech_model="u3-rt-pro", + settings=AssemblyAISTTSettings( + model="u3-rt-pro", ), ) @@ -111,9 +110,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): await task.queue_frame( STTUpdateSettingsFrame( delta=AssemblyAISTTSettings( - connection_params=AssemblyAIConnectionParams( - keyterms_prompt=["Xiomara", "Saoirse", "Krzystof", "Nguyen", "Pipecat"] - ) + keyterms_prompt=["Xiomara", "Saoirse", "Krzystof", "Nguyen", "Pipecat"] ) ) ) diff --git a/examples/foundational/55h-update-settings-speechmatics-stt.py b/examples/foundational/55h-update-settings-speechmatics-stt.py index 1471f7ef2..7a0f493a8 100644 --- a/examples/foundational/55h-update-settings-speechmatics-stt.py +++ b/examples/foundational/55h-update-settings-speechmatics-stt.py @@ -53,7 +53,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( enable_diarization=True, speaker_active_format="<{speaker_id}>{text}", speaker_passive_format="<{speaker_id}>{text}", diff --git a/examples/foundational/55o-update-settings-elevenlabs-http-tts.py b/examples/foundational/55o-update-settings-elevenlabs-http-tts.py index 7cdf97c25..c6160d1c2 100644 --- a/examples/foundational/55o-update-settings-elevenlabs-http-tts.py +++ b/examples/foundational/55o-update-settings-elevenlabs-http-tts.py @@ -58,7 +58,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsHttpTTSService( api_key=os.getenv("ELEVENLABS_API_KEY"), - voice_id=os.getenv("ELEVENLABS_VOICE_ID"), + settings=ElevenLabsHttpTTSSettings(voice=os.getenv("ELEVENLABS_VOICE_ID")), aiohttp_session=session, ) diff --git a/examples/foundational/55o-update-settings-elevenlabs-tts.py b/examples/foundational/55o-update-settings-elevenlabs-tts.py index 6d5d74a17..104dd314f 100644 --- a/examples/foundational/55o-update-settings-elevenlabs-tts.py +++ b/examples/foundational/55o-update-settings-elevenlabs-tts.py @@ -55,7 +55,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY"), - voice_id=os.getenv("ELEVENLABS_VOICE_ID"), + settings=ElevenLabsTTSSettings(voice=os.getenv("ELEVENLABS_VOICE_ID")), ) llm = OpenAILLMService( diff --git a/examples/foundational/55u-update-settings-rime-http-tts.py b/examples/foundational/55u-update-settings-rime-http-tts.py index f57d2b83e..8515b796e 100644 --- a/examples/foundational/55u-update-settings-rime-http-tts.py +++ b/examples/foundational/55u-update-settings-rime-http-tts.py @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) tts = RimeHttpTTSService( - api_key=os.getenv("RIME_API_KEY"), voice_id="eva", aiohttp_session=session + api_key=os.getenv("RIME_API_KEY"), + settings=RimeTTSSettings(voice="eva"), + aiohttp_session=session, ) llm = OpenAILLMService( diff --git a/examples/foundational/55u-update-settings-rime-tts.py b/examples/foundational/55u-update-settings-rime-tts.py index 5c4cdee67..72c63af8c 100644 --- a/examples/foundational/55u-update-settings-rime-tts.py +++ b/examples/foundational/55u-update-settings-rime-tts.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = RimeTTSService( api_key=os.getenv("RIME_API_KEY"), - voice_id="luna", + settings=RimeTTSSettings(voice="luna"), ) llm = OpenAILLMService( diff --git a/examples/foundational/55v-update-settings-lmnt-tts.py b/examples/foundational/55v-update-settings-lmnt-tts.py index 0a2c27401..d0651c84e 100644 --- a/examples/foundational/55v-update-settings-lmnt-tts.py +++ b/examples/foundational/55v-update-settings-lmnt-tts.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = LmntTTSService( api_key=os.getenv("LMNT_API_KEY"), - voice_id="lily", + settings=LmntTTSSettings(voice="lily"), ) llm = OpenAILLMService( diff --git a/examples/foundational/55w-update-settings-fish-tts.py b/examples/foundational/55w-update-settings-fish-tts.py index 87a4a2072..ff95838f7 100644 --- a/examples/foundational/55w-update-settings-fish-tts.py +++ b/examples/foundational/55w-update-settings-fish-tts.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = FishAudioTTSService( api_key=os.getenv("FISH_API_KEY"), - model="4ce7e917cedd4bc2bb2e6ff3a46acaa1", # Barack Obama + settings=FishAudioTTSSettings(voice="4ce7e917cedd4bc2bb2e6ff3a46acaa1"), # Barack Obama ) llm = OpenAILLMService( diff --git a/examples/foundational/55z-update-settings-hume-tts.py b/examples/foundational/55z-update-settings-hume-tts.py index f16745cad..d01dc78bf 100644 --- a/examples/foundational/55z-update-settings-hume-tts.py +++ b/examples/foundational/55z-update-settings-hume-tts.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = HumeTTSService( api_key=os.getenv("HUME_API_KEY"), - voice_id="f898a92e-685f-43fa-985b-a46920f0650b", + settings=HumeTTSSettings(voice="f898a92e-685f-43fa-985b-a46920f0650b"), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zc-update-settings-gemini-tts.py b/examples/foundational/55zc-update-settings-gemini-tts.py index 637ee65a7..99a91d176 100644 --- a/examples/foundational/55zc-update-settings-gemini-tts.py +++ b/examples/foundational/55zc-update-settings-gemini-tts.py @@ -55,9 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = GeminiTTSService( credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), - model="gemini-2.5-flash-tts", - voice_id="Charon", - params=GeminiTTSService.InputParams( + settings=GeminiTTSSettings( + model="gemini-2.5-flash-tts", + voice="Charon", language=Language.EN_US, prompt="You are a helpful AI assistant. Speak in a natural, conversational tone.", ), diff --git a/examples/foundational/55zh-update-settings-resembleai-tts.py b/examples/foundational/55zh-update-settings-resembleai-tts.py index 7aba67b1f..8428357b5 100644 --- a/examples/foundational/55zh-update-settings-resembleai-tts.py +++ b/examples/foundational/55zh-update-settings-resembleai-tts.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ResembleAITTSService( api_key=os.getenv("RESEMBLE_API_KEY"), - voice_id=os.getenv("RESEMBLE_VOICE_UUID"), + settings=ResembleAITTSSettings(voice=os.getenv("RESEMBLE_VOICE_UUID")), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zi-update-settings-azure-llm.py b/examples/foundational/55zi-update-settings-azure-llm.py index 29748491b..b7fe5d745 100644 --- a/examples/foundational/55zi-update-settings-azure-llm.py +++ b/examples/foundational/55zi-update-settings-azure-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.llm import AzureLLMService +from pipecat.services.azure.llm import AzureLLMService, AzureLLMSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -63,7 +63,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AzureLLMService( api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), - model=os.getenv("AZURE_CHATGPT_MODEL"), + settings=AzureLLMSettings(model=os.getenv("AZURE_CHATGPT_MODEL")), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py index c543ef50c..3d5d93b6a 100644 --- a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py +++ b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py @@ -61,8 +61,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-haiku-4-5-20251001-v1:0", - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-haiku-4-5-20251001-v1:0", + temperature=0.8, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/55zv-update-settings-asyncai-http-tts.py b/examples/foundational/55zv-update-settings-asyncai-http-tts.py index 79ca4382e..2063cda3a 100644 --- a/examples/foundational/55zv-update-settings-asyncai-http-tts.py +++ b/examples/foundational/55zv-update-settings-asyncai-http-tts.py @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AsyncAIHttpTTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), - voice_id=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04"), + settings=AsyncAITTSSettings( + voice=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04") + ), aiohttp_session=session, ) diff --git a/examples/foundational/55zv-update-settings-asyncai-tts.py b/examples/foundational/55zv-update-settings-asyncai-tts.py index 7e5463d2b..10cace018 100644 --- a/examples/foundational/55zv-update-settings-asyncai-tts.py +++ b/examples/foundational/55zv-update-settings-asyncai-tts.py @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AsyncAITTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), - voice_id=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04"), + settings=AsyncAITTSSettings( + voice=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04") + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zw-update-settings-gradium-tts.py b/examples/foundational/55zw-update-settings-gradium-tts.py index e12d20dd2..5c33e090a 100644 --- a/examples/foundational/55zw-update-settings-gradium-tts.py +++ b/examples/foundational/55zw-update-settings-gradium-tts.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = GradiumTTSService( api_key=os.getenv("GRADIUM_API_KEY"), - voice_id="YTpq7expH9539ERJ", + settings=GradiumTTSSettings(voice="YTpq7expH9539ERJ"), url="wss://us.api.gradium.ai/api/speech/tts", ) diff --git a/examples/foundational/55zz-update-settings-fireworks-llm.py b/examples/foundational/55zz-update-settings-fireworks-llm.py index 19b9276e6..56d29cfac 100644 --- a/examples/foundational/55zz-update-settings-fireworks-llm.py +++ b/examples/foundational/55zz-update-settings-fireworks-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.fireworks.llm import FireworksLLMService +from pipecat.services.fireworks.llm import FireworksLLMService, FireworksLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = FireworksLLMService( api_key=os.getenv("FIREWORKS_API_KEY"), - model="accounts/fireworks/models/gpt-oss-20b", + settings=FireworksLLMSettings(model="accounts/fireworks/models/gpt-oss-20b"), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/55zzb-update-settings-groq-llm.py b/examples/foundational/55zzb-update-settings-groq-llm.py index be5467b8a..35cec306f 100644 --- a/examples/foundational/55zzb-update-settings-groq-llm.py +++ b/examples/foundational/55zzb-update-settings-groq-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - model="meta-llama/llama-4-maverick-17b-128e-instruct", + settings=GroqLLMSettings(model="meta-llama/llama-4-maverick-17b-128e-instruct"), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/55zzd-update-settings-nvidia-llm.py b/examples/foundational/55zzd-update-settings-nvidia-llm.py index 5e26e8213..68d168461 100644 --- a/examples/foundational/55zzd-update-settings-nvidia-llm.py +++ b/examples/foundational/55zzd-update-settings-nvidia-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.nvidia.llm import NvidiaLLMService +from pipecat.services.nvidia.llm import NvidiaLLMService, NvidiaLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = NvidiaLLMService( api_key=os.getenv("NVIDIA_API_KEY"), - model="meta/llama-3.1-405b-instruct", + settings=NvidiaLLMSettings(model="meta/llama-3.1-405b-instruct"), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/55zze-update-settings-ollama-llm.py b/examples/foundational/55zze-update-settings-ollama-llm.py index 7e3fa02de..8a3a5f973 100644 --- a/examples/foundational/55zze-update-settings-ollama-llm.py +++ b/examples/foundational/55zze-update-settings-ollama-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.ollama.llm import OLLamaLLMService +from pipecat.services.ollama.llm import OLLamaLLMService, OllamaLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -61,7 +61,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OLLamaLLMService( - model="llama3.2", + settings=OllamaLLMSettings(model="llama3.2"), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # Update to the model you're running locally diff --git a/examples/foundational/55zzh-update-settings-qwen-llm.py b/examples/foundational/55zzh-update-settings-qwen-llm.py index 5c6d17d1d..dd95308ec 100644 --- a/examples/foundational/55zzh-update-settings-qwen-llm.py +++ b/examples/foundational/55zzh-update-settings-qwen-llm.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings -from pipecat.services.qwen.llm import QwenLLMService +from pipecat.services.qwen.llm import QwenLLMService, QwenLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = QwenLLMService( api_key=os.getenv("QWEN_API_KEY"), - model="qwen2.5-72b-instruct", + settings=QwenLLMSettings(model="qwen2.5-72b-instruct"), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/55zzj-update-settings-together-llm.py b/examples/foundational/55zzj-update-settings-together-llm.py index 4e1c9732f..c3cfafea2 100644 --- a/examples/foundational/55zzj-update-settings-together-llm.py +++ b/examples/foundational/55zzj-update-settings-together-llm.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings -from pipecat.services.together.llm import TogetherLLMService +from pipecat.services.together.llm import TogetherLLMService, TogetherLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = TogetherLLMService( api_key=os.getenv("TOGETHER_API_KEY"), - model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + settings=TogetherLLMSettings(model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/src/pipecat/services/azure/image.py b/src/pipecat/services/azure/image.py index 2a1286c78..28ac68bf9 100644 --- a/src/pipecat/services/azure/image.py +++ b/src/pipecat/services/azure/image.py @@ -12,7 +12,7 @@ using REST endpoints for creating images from text prompts. import asyncio import io -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import AsyncGenerator, Optional import aiohttp @@ -20,7 +20,7 @@ from PIL import Image from pipecat.frames.frames import ErrorFrame, Frame, URLImageRawFrame from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, ImageGenSettings, _NotGiven, _warn_deprecated_param @dataclass @@ -29,8 +29,11 @@ class AzureImageGenSettings(ImageGenSettings): Parameters: model: Azure image generation model identifier. + image_size: Target size for generated images. """ + image_size: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + class AzureImageGenServiceREST(ImageGenService): """Azure OpenAI REST-based image generation service. @@ -40,10 +43,12 @@ class AzureImageGenServiceREST(ImageGenService): and automatic image download and processing. """ + _settings: AzureImageGenSettings + def __init__( self, *, - image_size: str, + image_size: Optional[str] = None, api_key: str, endpoint: str, model: Optional[str] = None, @@ -55,6 +60,10 @@ class AzureImageGenServiceREST(ImageGenService): Args: image_size: Size specification for generated images (e.g., "1024x1024"). + + .. deprecated:: 0.0.105 + Use ``settings=AzureImageGenSettings(image_size=...)`` instead. + api_key: Azure OpenAI API key for authentication. endpoint: Azure OpenAI endpoint URL. model: The image generation model to use. @@ -67,10 +76,22 @@ class AzureImageGenServiceREST(ImageGenService): settings: Runtime-updatable settings. When provided alongside deprecated parameters, ``settings`` values take precedence. """ + # 1. Initialize default_settings with hardcoded defaults + default_settings = AzureImageGenSettings( + model=None, + image_size=None, + ) + + # 2. Apply direct init arg overrides (deprecated) if model is not None: _warn_deprecated_param("model", AzureImageGenSettings, "model") + default_settings.model = model - default_settings = AzureImageGenSettings(model=model) + if image_size is not None: + _warn_deprecated_param("image_size", AzureImageGenSettings, "image_size") + default_settings.image_size = image_size + + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) @@ -79,7 +100,6 @@ class AzureImageGenServiceREST(ImageGenService): self._api_key = api_key self._azure_endpoint = endpoint self._api_version = api_version - self._image_size = image_size self._aiohttp_session = aiohttp_session async def run_image_gen(self, prompt: str) -> AsyncGenerator[Frame, None]: @@ -97,12 +117,13 @@ class AzureImageGenServiceREST(ImageGenService): headers = {"api-key": self._api_key, "Content-Type": "application/json"} body = { - # Enter your prompt text here "prompt": prompt, - "size": self._image_size, "n": 1, } + if self._settings.image_size is not None: + body["size"] = self._settings.image_size + async with self._aiohttp_session.post(url, headers=headers, json=body) as submission: # We never get past this line, because this header isn't # defined on a 429 response, but something is eating our diff --git a/src/pipecat/services/fal/image.py b/src/pipecat/services/fal/image.py index 342aaa4a9..c6fb81003 100644 --- a/src/pipecat/services/fal/image.py +++ b/src/pipecat/services/fal/image.py @@ -13,8 +13,8 @@ for creating images from text prompts using various AI models. import asyncio import io import os -from dataclasses import dataclass -from typing import AsyncGenerator, Dict, Optional, Union +from dataclasses import dataclass, field +from typing import Any, AsyncGenerator, Dict, Optional, Union import aiohttp from loguru import logger @@ -23,7 +23,7 @@ from pydantic import BaseModel from pipecat.frames.frames import ErrorFrame, Frame, URLImageRawFrame from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, ImageGenSettings, _NotGiven, _warn_deprecated_param @dataclass @@ -32,8 +32,36 @@ class FalImageGenSettings(ImageGenSettings): Parameters: model: Fal.ai model identifier. + seed: Random seed for reproducible generation. ``None`` uses a random seed. + num_inference_steps: Number of inference steps for generation. + num_images: Number of images to generate. + image_size: Image dimensions as a string preset or dict with width/height. + expand_prompt: Whether to automatically expand/enhance the prompt. + enable_safety_checker: Whether to enable content safety filtering. + format: Output image format. """ + seed: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + num_inference_steps: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + num_images: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + image_size: str | Dict[str, int] | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + expand_prompt: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + enable_safety_checker: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + + def to_api_arguments(self) -> Dict[str, Any]: + """Build the Fal API arguments dict from settings, excluding None values.""" + args: Dict[str, Any] = {} + if self.seed is not None: + args["seed"] = self.seed + args["num_inference_steps"] = self.num_inference_steps + args["num_images"] = self.num_images + args["image_size"] = self.image_size + args["expand_prompt"] = self.expand_prompt + args["enable_safety_checker"] = self.enable_safety_checker + args["format"] = self.format + return args + class FalImageGenService(ImageGenService): """Fal's image generation service. @@ -45,6 +73,9 @@ class FalImageGenService(ImageGenService): class InputParams(BaseModel): """Input parameters for Fal.ai image generation. + .. deprecated:: 0.0.105 + Use ``settings=FalImageGenSettings(...)`` instead. + Parameters: seed: Random seed for reproducible generation. If None, uses random seed. num_inference_steps: Number of inference steps for generation. Defaults to 8. @@ -63,10 +94,12 @@ class FalImageGenService(ImageGenService): enable_safety_checker: bool = True format: str = "png" + _settings: FalImageGenSettings + def __init__( self, *, - params: InputParams, + params: Optional[InputParams] = None, aiohttp_session: aiohttp.ClientSession, model: Optional[str] = None, key: Optional[str] = None, @@ -77,6 +110,10 @@ class FalImageGenService(ImageGenService): Args: params: Input parameters for image generation configuration. + + .. deprecated:: 0.0.105 + Use ``settings=FalImageGenSettings(...)`` 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". @@ -89,19 +126,38 @@ class FalImageGenService(ImageGenService): **kwargs: Additional arguments passed to parent ImageGenService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = FalImageGenSettings(model="fal-ai/fast-sdxl") + default_settings = FalImageGenSettings( + model="fal-ai/fast-sdxl", + seed=None, + num_inference_steps=8, + num_images=1, + image_size="square_hd", + expand_prompt=False, + enable_safety_checker=True, + format="png", + ) # 2. Apply direct init arg overrides (deprecated) if model is not None: _warn_deprecated_param("model", FalImageGenSettings, "model") default_settings.model = model + if params is not None: + _warn_deprecated_param("params", FalImageGenSettings) + if not settings: + default_settings.seed = params.seed + default_settings.num_inference_steps = params.num_inference_steps + default_settings.num_images = params.num_images + default_settings.image_size = params.image_size + default_settings.expand_prompt = params.expand_prompt + default_settings.enable_safety_checker = params.enable_safety_checker + default_settings.format = params.format + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) super().__init__(settings=default_settings, **kwargs) - self._params = params self._aiohttp_session = aiohttp_session self._api_key = key or os.getenv("FAL_KEY", "") if key: @@ -129,7 +185,7 @@ class FalImageGenService(ImageGenService): "Authorization": f"Key {self._api_key}", "Content-Type": "application/json", } - payload = {"prompt": prompt, **self._params.model_dump(exclude_none=True)} + payload = {"prompt": prompt, **self._settings.to_api_arguments()} async with self._aiohttp_session.post( f"https://fal.run/{self._settings.model}", diff --git a/src/pipecat/services/google/image.py b/src/pipecat/services/google/image.py index d15d5d0ed..4c351cc6e 100644 --- a/src/pipecat/services/google/image.py +++ b/src/pipecat/services/google/image.py @@ -16,7 +16,7 @@ import os # Suppress gRPC fork warnings os.environ["GRPC_ENABLE_FORK_SUPPORT"] = "false" -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Any, AsyncGenerator, Optional from loguru import logger @@ -26,7 +26,7 @@ from pydantic import BaseModel, Field from pipecat.frames.frames import ErrorFrame, Frame, URLImageRawFrame from pipecat.services.google.utils import update_google_client_http_options from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, ImageGenSettings, _NotGiven, _warn_deprecated_param try: from google import genai @@ -43,8 +43,13 @@ class GoogleImageGenSettings(ImageGenSettings): Parameters: model: Google Imagen model identifier. + number_of_images: Number of images to generate per request. + negative_prompt: Text describing what not to include in generated images. """ + number_of_images: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + negative_prompt: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + class GoogleImageGenService(ImageGenService): """Google AI image generation service using Imagen models. @@ -57,6 +62,9 @@ class GoogleImageGenService(ImageGenService): class InputParams(BaseModel): """Configuration parameters for Google image generation. + .. deprecated:: 0.0.105 + Use ``settings=GoogleImageGenSettings(...)`` instead. + Parameters: number_of_images: Number of images to generate (1-8). Defaults to 1. model: Google Imagen model to use. Defaults to "imagen-3.0-generate-002". @@ -67,6 +75,8 @@ class GoogleImageGenService(ImageGenService): model: str = Field(default="imagen-3.0-generate-002") negative_prompt: Optional[str] = Field(default=None) + _settings: GoogleImageGenSettings + def __init__( self, *, @@ -83,7 +93,7 @@ class GoogleImageGenService(ImageGenService): params: Configuration parameters for image generation. .. deprecated:: 0.0.105 - Use ``settings=GoogleImageGenSettings(model=...)`` instead. + Use ``settings=GoogleImageGenSettings(...)`` instead. http_options: HTTP options for the client. settings: Runtime-updatable settings. When provided alongside deprecated @@ -91,20 +101,25 @@ class GoogleImageGenService(ImageGenService): **kwargs: Additional arguments passed to the parent ImageGenService. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = GoogleImageGenSettings(model="imagen-3.0-generate-002") + default_settings = GoogleImageGenSettings( + model="imagen-3.0-generate-002", + number_of_images=1, + negative_prompt=None, + ) - # 3. Apply params overrides — only if settings not provided + # 2. Apply params overrides (deprecated) if params is not None: _warn_deprecated_param("params", GoogleImageGenSettings) if not settings: default_settings.model = params.model + default_settings.number_of_images = params.number_of_images + default_settings.negative_prompt = params.negative_prompt # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) super().__init__(settings=default_settings, **kwargs) - self._params = params or GoogleImageGenService.InputParams() # Add client header http_options = update_google_client_http_options(http_options) @@ -137,11 +152,11 @@ class GoogleImageGenService(ImageGenService): try: response = await self._client.aio.models.generate_images( - model=self._params.model, + model=self._settings.model, prompt=prompt, config=types.GenerateImagesConfig( - number_of_images=self._params.number_of_images, - negative_prompt=self._params.negative_prompt, + number_of_images=self._settings.number_of_images, + negative_prompt=self._settings.negative_prompt, ), ) await self.stop_ttfb_metrics() diff --git a/src/pipecat/services/heygen/video.py b/src/pipecat/services/heygen/video.py index 020ecdfcf..18df8ac60 100644 --- a/src/pipecat/services/heygen/video.py +++ b/src/pipecat/services/heygen/video.py @@ -12,6 +12,7 @@ audio/video streaming capabilities through the HeyGen API. """ import asyncio +from dataclasses import dataclass from typing import Optional, Union import aiohttp @@ -52,6 +53,13 @@ from pipecat.transports.base_transport import TransportParams AVATAR_VAD_STOP_SECS = 0.35 +@dataclass +class HeyGenVideoSettings(ServiceSettings): + """Settings for the HeyGen video service.""" + + pass + + class HeyGenVideoService(AIService): """A service that integrates HeyGen's interactive avatar capabilities into the pipeline. @@ -81,7 +89,7 @@ class HeyGenVideoService(AIService): session: aiohttp.ClientSession, session_request: Optional[Union[LiveAvatarNewSessionRequest, NewSessionRequest]] = None, service_type: Optional[ServiceType] = None, - settings: Optional[ServiceSettings] = None, + settings: Optional[HeyGenVideoSettings] = None, **kwargs, ) -> None: """Initialize the HeyGen video service. diff --git a/src/pipecat/services/openai/image.py b/src/pipecat/services/openai/image.py index 4120db8c6..397d8c3d2 100644 --- a/src/pipecat/services/openai/image.py +++ b/src/pipecat/services/openai/image.py @@ -11,7 +11,7 @@ for creating images from text prompts. """ import io -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import AsyncGenerator, Literal, Optional import aiohttp @@ -25,7 +25,7 @@ from pipecat.frames.frames import ( URLImageRawFrame, ) from pipecat.services.image_service import ImageGenService -from pipecat.services.settings import ImageGenSettings, _warn_deprecated_param +from pipecat.services.settings import NOT_GIVEN, ImageGenSettings, _NotGiven, _warn_deprecated_param @dataclass @@ -34,8 +34,11 @@ class OpenAIImageGenSettings(ImageGenSettings): Parameters: model: DALL-E model identifier. + image_size: Target size for generated images. """ + image_size: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) + class OpenAIImageGenService(ImageGenService): """OpenAI DALL-E image generation service. @@ -45,13 +48,17 @@ class OpenAIImageGenService(ImageGenService): with configurable quality and style parameters. """ + _settings: OpenAIImageGenSettings + def __init__( self, *, api_key: str, base_url: Optional[str] = None, aiohttp_session: aiohttp.ClientSession, - image_size: Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"], + image_size: Optional[ + Literal["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"] + ] = None, model: Optional[str] = None, settings: Optional[OpenAIImageGenSettings] = None, ): @@ -61,7 +68,11 @@ class OpenAIImageGenService(ImageGenService): api_key: OpenAI API key for authentication. base_url: Custom base URL for OpenAI API. If None, uses default. aiohttp_session: HTTP session for downloading generated images. - image_size: Target size for generated images. + image_size: Target size for generated images. Defaults to "1024x1024". + + .. deprecated:: 0.0.105 + Use ``settings=OpenAIImageGenSettings(image_size=...)`` instead. + model: DALL-E model to use for generation. Defaults to "dall-e-3". .. deprecated:: 0.0.105 @@ -71,19 +82,25 @@ class OpenAIImageGenService(ImageGenService): parameters, ``settings`` values take precedence. """ # 1. Initialize default_settings with hardcoded defaults - default_settings = OpenAIImageGenSettings(model="dall-e-3") + default_settings = OpenAIImageGenSettings( + 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") default_settings.model = model + if image_size is not None: + _warn_deprecated_param("image_size", OpenAIImageGenSettings, "image_size") + default_settings.image_size = image_size + # 4. Apply settings delta (canonical API, always wins) if settings is not None: default_settings.apply_update(settings) super().__init__(settings=default_settings) - self._image_size = image_size self._client = AsyncOpenAI(api_key=api_key, base_url=base_url) self._aiohttp_session = aiohttp_session @@ -99,7 +116,7 @@ class OpenAIImageGenService(ImageGenService): logger.debug(f"Generating image from prompt: {prompt}") image = await self._client.images.generate( - prompt=prompt, model=self._settings.model, n=1, size=self._image_size + prompt=prompt, model=self._settings.model, n=1, size=self._settings.image_size ) image_url = image.data[0].url diff --git a/src/pipecat/services/tavus/video.py b/src/pipecat/services/tavus/video.py index e6725fac1..4a7211033 100644 --- a/src/pipecat/services/tavus/video.py +++ b/src/pipecat/services/tavus/video.py @@ -11,6 +11,7 @@ avatar functionality through Tavus's streaming API. """ import asyncio +from dataclasses import dataclass from typing import Optional import aiohttp @@ -38,6 +39,13 @@ from pipecat.services.settings import ServiceSettings from pipecat.transports.tavus.transport import TavusCallbacks, TavusParams, TavusTransportClient +@dataclass +class TavusVideoSettings(ServiceSettings): + """Settings for the Tavus video service.""" + + pass + + class TavusVideoService(AIService): """Service that proxies audio to Tavus and receives audio and video in return. @@ -58,7 +66,7 @@ class TavusVideoService(AIService): replica_id: str, persona_id: str = "pipecat-stream", session: aiohttp.ClientSession, - settings: Optional[ServiceSettings] = None, + settings: Optional[TavusVideoSettings] = None, **kwargs, ) -> None: """Initialize the Tavus video service. From ab371852084b47ff540623383324286cb496733a Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Fri, 6 Mar 2026 08:32:59 -0500 Subject: [PATCH 13/17] Update run_eval_pipeline with the latest settings, system_instruction patterns --- scripts/evals/eval.py | 59 ++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/scripts/evals/eval.py b/scripts/evals/eval.py index d45e6343b..c2316e123 100644 --- a/scripts/evals/eval.py +++ b/scripts/evals/eval.py @@ -49,7 +49,7 @@ from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.deepgram.stt import DeepgramSTTService, LiveOptions +from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.daily.transport import DailyParams, DailyTransport @@ -243,7 +243,7 @@ async def run_eval_pipeline( # 5" (in audio) this can be converted to "32 is 5". stt = DeepgramSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - live_options=LiveOptions( + settings=DeepgramSTTSettings( language="multi", smart_format=False, ), @@ -251,10 +251,32 @@ async def run_eval_pipeline( tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="97f4b8fb-f2fe-444b-bb9a-c109783a857a", # Nathan + settings=CartesiaTTSSettings( + voice="97f4b8fb-f2fe-444b-bb9a-c109783a857a", # Nathan + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + # Load example prompt depending on image. + example_prompt = "" + example_image: Optional[ImageFile] = None + if isinstance(eval_config.prompt, str): + example_prompt = eval_config.prompt + elif isinstance(eval_config.prompt, tuple): + example_prompt, example_image = eval_config.prompt + + common_system_prompt = ( + "You should only call the eval function if:\n" + "- The user explicitly attempts to answer the question, AND\n" + f"- Their answer can be cleanly evaluated using: {eval_config.eval}\n" + "Ignore greetings, comments, non-answers, or requests for clarification.\n" + "Numerical word answers are allowed (e.g., 'five' is the same as '5').\n" + ) + if eval_config.eval_speaks_first: + system_prompt = f"You are an evaluation agent, be extremly brief. You will start the conversation by saying: '{example_prompt}'. {common_system_prompt}" + else: + system_prompt = f"You are an evaluation agent, be extremly brief. First, ask one question: {example_prompt}. {common_system_prompt}" + + llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) llm.register_function("eval_function", eval_runner.function_assert_eval) @@ -281,34 +303,7 @@ async def run_eval_pipeline( ) tools = ToolsSchema(standard_tools=[eval_function]) - # Load example prompt depending on image. - example_prompt = "" - example_image: Optional[ImageFile] = None - if isinstance(eval_config.prompt, str): - example_prompt = eval_config.prompt - elif isinstance(eval_config.prompt, tuple): - example_prompt, example_image = eval_config.prompt - - common_system_prompt = ( - "You should only call the eval function if:\n" - "- The user explicitly attempts to answer the question, AND\n" - f"- Their answer can be cleanly evaluated using: {eval_config.eval}\n" - "Ignore greetings, comments, non-answers, or requests for clarification.\n" - "Numerical word answers are allowed (e.g., 'five' is the same as '5').\n" - ) - if eval_config.eval_speaks_first: - system_prompt = f"You are an evaluation agent, be extremly brief. You will start the conversation by saying: '{example_prompt}'. {common_system_prompt}" - else: - system_prompt = f"You are an evaluation agent, be extremly brief. First, ask one question: {example_prompt}. {common_system_prompt}" - - messages = [ - { - "role": "system", - "content": system_prompt, - }, - ] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) context_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams( From ee2895a783a8d07bad8637939a37d88be51dd366 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Fri, 6 Mar 2026 08:44:15 -0500 Subject: [PATCH 14/17] Update COMMUNITY_INTEGRATIONS.md with full Service Settings guidance Broaden the "Dynamic Settings Updates" section into "Service Settings" covering the complete settings pattern: defining a Settings subclass, wiring it into __init__ with defaults + apply_update, and distinguishing init-only config from runtime-updatable fields. --- COMMUNITY_INTEGRATIONS.md | 95 ++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/COMMUNITY_INTEGRATIONS.md b/COMMUNITY_INTEGRATIONS.md index ff8d08ea5..5dd9e5764 100644 --- a/COMMUNITY_INTEGRATIONS.md +++ b/COMMUNITY_INTEGRATIONS.md @@ -231,49 +231,102 @@ def can_generate_metrics(self) -> bool: return True ``` -### Dynamic Settings Updates +### Service Settings -STT, LLM, and TTS services support runtime configuration changes via `*UpdateSettingsFrame`s (e.g. `STTUpdateSettingsFrame`, `TTSUpdateSettingsFrame`, `LLMUpdateSettingsFrame`). +Every STT, LLM, TTS, and image-generation service exposes a **Settings dataclass** that serves two roles: -Each service declares a settings dataclass that extends the appropriate base (`STTSettings`, `TTSSettings`, `LLMSettings`). Fields default to `NOT_GIVEN` so that update objects can represent sparse deltas: +1. **Store mode** — the service's `self._settings` holds the current value of every runtime-updatable field. +2. **Delta mode** — an update frame carries only the fields that changed; unset fields remain `NOT_GIVEN`. + +#### Defining your Settings class + +Extend `STTSettings`, `TTSSettings`, `LLMSettings`, or `ImageGenSettings`. The base classes already provide common fields (e.g. `model`, `voice`, `language`). You only need to add **service-specific knobs that should be runtime-updatable**: ```python from dataclasses import dataclass, field -from pipecat.services.settings import STTSettings, NOT_GIVEN +from pipecat.services.settings import TTSSettings, NOT_GIVEN @dataclass -class MySTTSettings(STTSettings): - """Settings for my STT service. +class MyTTSSettings(TTSSettings): + """Settings for MyTTS service. Parameters: - region: Cloud region for the service. + speaking_rate: Speed multiplier (0.5–2.0). """ - region: str = field(default_factory=lambda: NOT_GIVEN) + speaking_rate: float | None = field(default_factory=lambda: NOT_GIVEN) ``` -The service stores its current settings in `self._settings` and declares the type with a class-level annotation for editor support: +**What goes in Settings vs. `__init__` params:** + +| Belongs in Settings | Stays as `__init__` params | +| -------------------------------------------------------- | ----------------------------------------- | +| Model name, voice, language | API keys, auth tokens | +| Service-specific tuning knobs (rate, pitch, temperature) | Base URLs, endpoint overrides | +| Anything users may want to change mid-session | Audio encoding, sample format | +| | Connection parameters (timeouts, retries) | + +The rule of thumb: if a caller might send an update frame to change it at runtime, it belongs in Settings. Everything else is init-only config stored as `self._xxx`. + +#### Wiring settings into `__init__` + +Accept an **optional** `settings` parameter. Build a `default_settings` object with all fields set to real values, then merge any caller overrides with `apply_update`: ```python -class MySTTService(STTService): - _settings: MySTTSettings +from typing import Optional - def __init__(self, *, model: str, language: str, region: str, **kwargs): - # An initial value should be provided for every settings field. - # This will be validated at service start. - # (If you track sample_rate, it can be a placeholder value like 0; see - # "Sample Rate Handling"). - super().__init__( - settings=MySTTSettings(model=model, language=language, region=region), **kwargs +class MyTTSService(TTSService): + _settings: MyTTSSettings + + def __init__( + self, + *, + api_key: str, + settings: Optional[MyTTSSettings] = None, + **kwargs, + ): + # 1. Defaults — every field has a real value (store mode). + default_settings = MyTTSSettings( + model="my-model-v1", + voice="default-voice", + language="en", + speaking_rate=1.0, ) + + # 2. Merge caller overrides (only given fields win). + if settings is not None: + default_settings.apply_update(settings) + + # 3. Pass the fully-populated settings to the base class. + super().__init__(settings=default_settings, **kwargs) + + # 4. Init-only config stored separately. + self._api_key = api_key ``` +This pattern lets callers override only what they care about: + +```python +# Uses all defaults +svc = MyTTSService(api_key="sk-xxx") + +# Overrides just the voice +svc = MyTTSService( + api_key="sk-xxx", + settings=MyTTSSettings(voice="custom-voice"), +) +``` + +#### Reacting to runtime changes + +STT, LLM, and TTS services support runtime configuration changes via `*UpdateSettingsFrame`s (e.g. `STTUpdateSettingsFrame`, `TTSUpdateSettingsFrame`, `LLMUpdateSettingsFrame`). + To react to runtime setting changes, override `_update_settings`. The base implementation applies the delta to `self._settings` and returns a `dict` mapping each changed field name to its **pre-update** value. Your override should call `super()` first, then act on the changed fields. A common implementation might look like: ```python -async def _update_settings(self, update: STTSettings) -> dict[str, Any]: - """Apply a settings update, reconfiguring the recognizer if needed.""" +async def _update_settings(self, update: TTSSettings) -> dict[str, Any]: + """Apply a settings update, reconfiguring the connection if needed.""" changed = await super()._update_settings(update) if not changed: @@ -292,7 +345,7 @@ Note that, in this example, the service requires a reconnect to apply the new la If your service can't yet apply certain settings at runtime, call `self._warn_unhandled_updated_settings(changed)` with any unhandled field names so users get a clear log message: ```python -async def _update_settings(self, update: STTSettings) -> dict[str, Any]: +async def _update_settings(self, update: TTSSettings) -> dict[str, Any]: changed = await super()._update_settings(update) if not changed: From 78deaa735d69e08a07b1385651b6de6367757dd1 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Thu, 5 Mar 2026 14:03:32 -0500 Subject: [PATCH 15/17] Move `system_instruction` into `LLMSettings` Add `system_instruction` field to `LLMSettings` so it is runtime-updatable via settings. For Google (GoogleLLMService, GoogleVertexLLMService), deprecate the init-time arg since it was already shipped. For Anthropic, AWS Bedrock, and OpenAI, remove the init-time arg entirely since it was never shipped. Still need to handle realtime services (OpenAI Realtime, Grok Realtime, Gemini Live). --- examples/foundational/02-llm-say-one-thing.py | 6 ++++-- .../foundational/04-transports-small-webrtc.py | 6 ++++-- examples/foundational/04a-transports-daily.py | 2 +- examples/foundational/04b-transports-livekit.py | 6 ++++-- examples/foundational/06-listen-and-respond.py | 6 ++++-- examples/foundational/06a-image-sync.py | 6 ++++-- .../07-interruptible-cartesia-http.py | 6 ++++-- examples/foundational/07-interruptible.py | 6 ++++-- .../07a-interruptible-speechmatics-vad.py | 2 +- .../07a-interruptible-speechmatics.py | 2 +- .../07c-interruptible-deepgram-flux.py | 6 ++++-- .../07c-interruptible-deepgram-http.py | 6 ++++-- .../07c-interruptible-deepgram-sagemaker.py | 2 +- .../07c-interruptible-deepgram-vad.py | 6 ++++-- .../foundational/07c-interruptible-deepgram.py | 6 ++++-- .../07d-interruptible-elevenlabs-http.py | 6 ++++-- .../foundational/07d-interruptible-elevenlabs.py | 6 ++++-- .../foundational/07f-interruptible-azure-http.py | 6 ++++-- examples/foundational/07f-interruptible-azure.py | 6 ++++-- .../07g-interruptible-openai-http.py | 6 ++++-- .../foundational/07g-interruptible-openai.py | 6 ++++-- .../foundational/07h-interruptible-openpipe.py | 6 ++++-- examples/foundational/07i-interruptible-xtts.py | 6 ++++-- .../foundational/07j-interruptible-gladia-vad.py | 6 ++++-- .../foundational/07j-interruptible-gladia.py | 6 ++++-- examples/foundational/07k-interruptible-lmnt.py | 6 ++++-- examples/foundational/07l-interruptible-groq.py | 2 +- examples/foundational/07m-interruptible-aws.py | 6 ++++-- .../07n-interruptible-gemini-image.py | 2 +- .../foundational/07n-interruptible-gemini.py | 6 ++++-- .../07n-interruptible-google-http.py | 2 +- .../foundational/07n-interruptible-google.py | 2 +- ...7o-interruptible-assemblyai-turn-detection.py | 6 ++++-- .../foundational/07o-interruptible-assemblyai.py | 6 ++++-- .../foundational/07p-interruptible-krisp-viva.py | 6 ++++-- examples/foundational/07p-interruptible-krisp.py | 6 ++++-- .../foundational/07q-interruptible-rime-http.py | 6 ++++-- examples/foundational/07q-interruptible-rime.py | 6 ++++-- .../foundational/07r-interruptible-nvidia.py | 2 +- examples/foundational/07t-interruptible-fish.py | 6 ++++-- .../07v-interruptible-neuphonic-http.py | 6 ++++-- .../foundational/07v-interruptible-neuphonic.py | 6 ++++-- examples/foundational/07w-interruptible-fal.py | 6 ++++-- examples/foundational/07x-interruptible-local.py | 6 ++++-- .../foundational/07y-interruptible-minimax.py | 6 ++++-- .../07z-interruptible-sarvam-http.py | 6 ++++-- .../foundational/07z-interruptible-sarvam.py | 6 ++++-- .../foundational/07za-interruptible-soniox.py | 6 ++++-- .../07zb-interruptible-inworld-http.py | 6 ++++-- .../foundational/07zb-interruptible-inworld.py | 6 ++++-- .../07zc-interruptible-asyncai-http.py | 6 ++++-- .../foundational/07zc-interruptible-asyncai.py | 6 ++++-- .../07zd-interruptible-aicoustics.py | 6 ++++-- examples/foundational/07ze-interruptible-hume.py | 6 ++++-- .../foundational/07zf-interruptible-gradium.py | 6 ++++-- examples/foundational/07zg-interruptible-camb.py | 6 ++++-- .../foundational/07zi-interruptible-piper.py | 6 ++++-- .../foundational/07zj-interruptible-kokoro.py | 6 ++++-- .../foundational/07zk-interruptible-resemble.py | 6 ++++-- .../foundational/08-custom-frame-processor.py | 6 ++++-- examples/foundational/10-wake-phrase.py | 6 ++++-- examples/foundational/11-sound-effects.py | 6 ++++-- .../foundational/12-describe-image-openai.py | 6 ++++-- .../foundational/12a-describe-image-anthropic.py | 6 ++++-- examples/foundational/12b-describe-image-aws.py | 2 +- .../12c-describe-image-gemini-flash.py | 6 ++++-- examples/foundational/14-function-calling.py | 6 ++++-- .../14a-function-calling-anthropic.py | 6 ++++-- .../14c-function-calling-together.py | 2 +- .../14d-function-calling-anthropic-video.py | 6 ++++-- .../14d-function-calling-aws-video.py | 2 +- .../14d-function-calling-gemini-flash-video.py | 6 ++++-- .../14d-function-calling-moondream-video.py | 6 ++++-- .../14d-function-calling-openai-video.py | 6 ++++-- .../foundational/14e-function-calling-google.py | 6 ++++-- .../foundational/14f-function-calling-groq.py | 6 ++++-- .../foundational/14g-function-calling-grok.py | 6 ++++-- .../foundational/14h-function-calling-azure.py | 2 +- .../14i-function-calling-fireworks.py | 2 +- .../foundational/14j-function-calling-nvidia.py | 2 +- .../14k-function-calling-cerebras.py | 6 ++++-- .../14l-function-calling-deepseek.py | 4 ++-- .../14m-function-calling-openrouter.py | 2 +- .../14n-function-calling-perplexity.py | 7 +++++-- .../14o-function-calling-gemini-openai-format.py | 6 ++++-- .../14p-function-calling-gemini-vertex-ai.py | 6 ++++-- .../foundational/14q-function-calling-qwen.py | 6 ++++-- .../foundational/14r-function-calling-aws.py | 2 +- .../14s-function-calling-sambanova.py | 6 ++++-- .../foundational/14t-function-calling-direct.py | 6 ++++-- .../foundational/14u-function-calling-ollama.py | 2 +- .../foundational/14v-function-calling-openai.py | 6 ++++-- .../foundational/14w-function-calling-mistral.py | 6 ++++-- .../14x-function-calling-openpipe.py | 6 ++++-- examples/foundational/15-switch-voices.py | 6 ++++-- examples/foundational/15a-switch-languages.py | 6 ++++-- .../foundational/16-gpu-container-local-bot.py | 2 +- examples/foundational/17-detect-user-idle.py | 6 ++++-- examples/foundational/21-tavus-transport.py | 6 ++++-- examples/foundational/21a-tavus-video-service.py | 6 ++++-- .../foundational/22-filter-incomplete-turns.py | 6 ++++-- examples/foundational/23-bot-background-sound.py | 6 ++++-- examples/foundational/24-user-mute-strategy.py | 6 ++++-- examples/foundational/25-google-audio-in.py | 4 ++-- examples/foundational/27-simli-layer.py | 2 +- examples/foundational/28-user-assistant-turns.py | 6 ++++-- .../foundational/29-turn-tracking-observer.py | 6 ++++-- examples/foundational/30-observer.py | 6 ++++-- .../foundational/32-gemini-grounding-metadata.py | 6 ++++-- examples/foundational/33-gemini-rag.py | 2 +- examples/foundational/34-audio-recording.py | 6 ++++-- .../35-pattern-pair-voice-switching.py | 6 ++++-- examples/foundational/36-user-email-gathering.py | 6 ++++-- examples/foundational/37-mem0.py | 4 ++-- examples/foundational/38-smart-turn-fal.py | 6 ++++-- .../foundational/38a-smart-turn-local-coreml.py | 6 ++++-- examples/foundational/38b-smart-turn-local.py | 6 ++++-- examples/foundational/39-mcp-stdio.py | 9 +++++++-- examples/foundational/39c-multiple-mcp.py | 9 +++++++-- examples/foundational/42-interruption-config.py | 6 ++++-- examples/foundational/43-heygen-transport.py | 6 ++++-- .../foundational/43a-heygen-video-service.py | 6 ++++-- examples/foundational/44-voicemail-detection.py | 6 ++++-- .../foundational/45-before-and-after-events.py | 6 ++++-- examples/foundational/47-sentry-metrics.py | 6 ++++-- examples/foundational/48-service-switcher.py | 14 ++++++++++---- examples/foundational/49a-thinking-anthropic.py | 2 +- examples/foundational/49b-thinking-google.py | 2 +- .../49c-thinking-functions-anthropic.py | 2 +- .../49d-thinking-functions-google.py | 2 +- examples/foundational/52-live-translation.py | 6 ++++-- .../foundational/53-concurrent-llm-evaluation.py | 12 ++++++++---- .../53-concurrent-llm-rtvi-ignored-sources.py | 10 +++++++--- .../54-context-summarization-openai.py | 6 ++++-- .../54a-context-summarization-google.py | 6 ++++-- .../54b-context-summarization-manual-openai.py | 9 +++++++-- .../54c-context-summarization-dedicated-llm.py | 9 +++++++-- .../55a-update-settings-deepgram-flux-stt.py | 6 ++++-- ...55a-update-settings-deepgram-sagemaker-stt.py | 6 ++++-- .../55a-update-settings-deepgram-stt.py | 6 ++++-- .../55b-update-settings-azure-stt.py | 6 ++++-- .../55c-update-settings-google-stt.py | 6 ++++-- .../55d-update-settings-assemblyai-stt.py | 6 ++++-- .../55e-update-settings-gladia-stt.py | 6 ++++-- ...5f-update-settings-elevenlabs-realtime-stt.py | 6 ++++-- .../55g-update-settings-elevenlabs-stt.py | 6 ++++-- .../55h-update-settings-speechmatics-stt.py | 6 ++++-- .../55i-update-settings-whisper-api-stt.py | 6 ++++-- .../55j-update-settings-sarvam-stt.py | 6 ++++-- .../55k-update-settings-soniox-stt.py | 6 ++++-- .../55l-update-settings-aws-transcribe-stt.py | 6 ++++-- .../55m-update-settings-cartesia-stt.py | 6 ++++-- .../55n-update-settings-cartesia-http-tts.py | 6 ++++-- .../55n-update-settings-cartesia-tts.py | 6 ++++-- .../55o-update-settings-elevenlabs-http-tts.py | 6 ++++-- .../55o-update-settings-elevenlabs-tts.py | 6 ++++-- .../55p-update-settings-openai-tts.py | 6 ++++-- .../55q-update-settings-deepgram-http-tts.py | 6 ++++-- ...55q-update-settings-deepgram-sagemaker-tts.py | 6 ++++-- .../55q-update-settings-deepgram-tts.py | 6 ++++-- .../55r-update-settings-azure-http-tts.py | 6 ++++-- .../55r-update-settings-azure-tts.py | 6 ++++-- .../55s-update-settings-google-http-tts.py | 6 ++++-- .../55s-update-settings-google-stream-tts.py | 6 ++++-- .../55u-update-settings-rime-http-tts.py | 6 ++++-- .../foundational/55u-update-settings-rime-tts.py | 6 ++++-- .../foundational/55v-update-settings-lmnt-tts.py | 6 ++++-- .../foundational/55w-update-settings-fish-tts.py | 6 ++++-- .../55x-update-settings-minimax-tts.py | 6 ++++-- .../foundational/55y-update-settings-groq-tts.py | 6 ++++-- .../foundational/55z-update-settings-hume-tts.py | 6 ++++-- .../55za-update-settings-neuphonic-http-tts.py | 6 ++++-- .../55za-update-settings-neuphonic-tts.py | 6 ++++-- .../55zb-update-settings-inworld-http-tts.py | 6 ++++-- .../55zb-update-settings-inworld-tts.py | 6 ++++-- .../55zc-update-settings-gemini-tts.py | 6 ++++-- .../55zd-update-settings-aws-polly-tts.py | 6 ++++-- .../55ze-update-settings-sarvam-http-tts.py | 6 ++++-- .../55ze-update-settings-sarvam-tts.py | 6 ++++-- .../55zf-update-settings-camb-tts.py | 6 ++++-- .../55zh-update-settings-resembleai-tts.py | 6 ++++-- .../55zi-update-settings-azure-llm.py | 6 ++++-- .../55zi-update-settings-openai-llm.py | 4 +++- .../55zj-update-settings-anthropic-llm.py | 4 +++- .../55zk-update-settings-google-llm.py | 4 +++- .../55zk-update-settings-google-vertex-llm.py | 6 ++++-- .../55zp-update-settings-aws-bedrock-llm.py | 2 +- .../foundational/55zq-update-settings-fal-stt.py | 6 ++++-- .../55zr-update-settings-gradium-stt.py | 6 ++++-- .../55zt-update-settings-nvidia-segmented-stt.py | 6 ++++-- .../55zt-update-settings-nvidia-stt.py | 6 ++++-- .../55zu-update-settings-openai-realtime-stt.py | 6 ++++-- .../55zv-update-settings-asyncai-http-tts.py | 6 ++++-- .../55zv-update-settings-asyncai-tts.py | 6 ++++-- .../55zw-update-settings-gradium-tts.py | 6 ++++-- .../55zx-update-settings-cerebras-llm.py | 6 ++++-- .../55zy-update-settings-deepseek-llm.py | 6 ++++-- .../55zz-update-settings-fireworks-llm.py | 6 ++++-- .../55zza-update-settings-grok-llm.py | 6 ++++-- .../55zzb-update-settings-groq-llm.py | 6 ++++-- .../55zzc-update-settings-mistral-llm.py | 6 ++++-- .../55zzd-update-settings-nvidia-llm.py | 6 ++++-- .../55zze-update-settings-ollama-llm.py | 6 ++++-- .../55zzf-update-settings-openrouter-llm.py | 6 ++++-- .../55zzh-update-settings-qwen-llm.py | 6 ++++-- .../55zzi-update-settings-sambanova-llm.py | 6 ++++-- .../55zzj-update-settings-together-llm.py | 6 ++++-- .../55zzl-update-settings-nvidia-tts.py | 6 ++++-- .../55zzm-update-settings-speechmatics-tts.py | 6 ++++-- .../55zzn-update-settings-groq-stt.py | 6 ++++-- examples/foundational/56-lemonslice-transport.py | 6 ++++-- src/pipecat/services/anthropic/llm.py | 12 +++++------- src/pipecat/services/aws/llm.py | 12 +++++------- src/pipecat/services/cerebras/llm.py | 8 ++++++++ src/pipecat/services/fireworks/llm.py | 8 ++++++++ src/pipecat/services/google/llm.py | 16 ++++++++++++---- src/pipecat/services/google/llm_vertex.py | 10 +++++++++- src/pipecat/services/mistral/llm.py | 7 +++++++ src/pipecat/services/openai/base_llm.py | 12 +++++------- src/pipecat/services/openai/llm.py | 1 + src/pipecat/services/perplexity/llm.py | 7 +++++++ src/pipecat/services/sambanova/llm.py | 8 ++++++++ src/pipecat/services/settings.py | 2 ++ 223 files changed, 860 insertions(+), 424 deletions(-) diff --git a/examples/foundational/02-llm-say-one-thing.py b/examples/foundational/02-llm-say-one-thing.py index 3ee536a64..988ff634f 100644 --- a/examples/foundational/02-llm-say-one-thing.py +++ b/examples/foundational/02-llm-say-one-thing.py @@ -17,7 +17,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -46,7 +46,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are an LLM in a WebRTC session, and this is a 'hello world' demo.", + settings=OpenAILLMSettings( + system_instruction="You are an LLM in a WebRTC session, and this is a 'hello world' demo.", + ), ) task = PipelineTask( diff --git a/examples/foundational/04-transports-small-webrtc.py b/examples/foundational/04-transports-small-webrtc.py index 6cf32a285..a26fdf5c0 100644 --- a/examples/foundational/04-transports-small-webrtc.py +++ b/examples/foundational/04-transports-small-webrtc.py @@ -29,7 +29,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import TransportParams from pipecat.transports.smallwebrtc.connection import IceServer, SmallWebRTCConnection from pipecat.transports.smallwebrtc.transport import SmallWebRTCTransport @@ -74,7 +74,9 @@ async def run_example(webrtc_connection: SmallWebRTCConnection): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/04a-transports-daily.py b/examples/foundational/04a-transports-daily.py index 8b23cb69e..15b5e20e2 100644 --- a/examples/foundational/04a-transports-daily.py +++ b/examples/foundational/04a-transports-daily.py @@ -59,8 +59,8 @@ async def main(): api_key=os.getenv("OPENAI_API_KEY"), settings=OpenAILLMSettings( model="gpt-4o", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/04b-transports-livekit.py b/examples/foundational/04b-transports-livekit.py index f55f106c1..1f4709b0b 100644 --- a/examples/foundational/04b-transports-livekit.py +++ b/examples/foundational/04b-transports-livekit.py @@ -31,7 +31,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.livekit import configure from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.livekit.transport import LiveKitParams, LiveKitTransport load_dotenv(override=True) @@ -57,7 +57,9 @@ async def main(): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) tts = CartesiaTTSService( diff --git a/examples/foundational/06-listen-and-respond.py b/examples/foundational/06-listen-and-respond.py index c90d79c4e..1e2f88a93 100644 --- a/examples/foundational/06-listen-and-respond.py +++ b/examples/foundational/06-listen-and-respond.py @@ -30,7 +30,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -90,7 +90,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) ml = MetricsLogger() diff --git a/examples/foundational/06a-image-sync.py b/examples/foundational/06a-image-sync.py index 666f4739c..007a41143 100644 --- a/examples/foundational/06a-image-sync.py +++ b/examples/foundational/06a-image-sync.py @@ -31,7 +31,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -107,7 +107,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07-interruptible-cartesia-http.py b/examples/foundational/07-interruptible-cartesia-http.py index b20289ce2..ac409f55d 100644 --- a/examples/foundational/07-interruptible-cartesia-http.py +++ b/examples/foundational/07-interruptible-cartesia-http.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07-interruptible.py b/examples/foundational/07-interruptible.py index b8a334ec0..05a751a68 100644 --- a/examples/foundational/07-interruptible.py +++ b/examples/foundational/07-interruptible.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.tts_service import TextAggregationMode from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07a-interruptible-speechmatics-vad.py b/examples/foundational/07a-interruptible-speechmatics-vad.py index 5bb8459e2..a6a287f83 100644 --- a/examples/foundational/07a-interruptible-speechmatics-vad.py +++ b/examples/foundational/07a-interruptible-speechmatics-vad.py @@ -114,8 +114,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENAI_API_KEY"), settings=OpenAILLMSettings( temperature=0.75, + system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ), - system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ) context = LLMContext() diff --git a/examples/foundational/07a-interruptible-speechmatics.py b/examples/foundational/07a-interruptible-speechmatics.py index caecb74be..d4e4dc638 100644 --- a/examples/foundational/07a-interruptible-speechmatics.py +++ b/examples/foundational/07a-interruptible-speechmatics.py @@ -94,8 +94,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENAI_API_KEY"), settings=OpenAILLMSettings( temperature=0.75, + system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ), - system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ) context = LLMContext() diff --git a/examples/foundational/07c-interruptible-deepgram-flux.py b/examples/foundational/07c-interruptible-deepgram-flux.py index 4eafc24a7..c205c5141 100644 --- a/examples/foundational/07c-interruptible-deepgram-flux.py +++ b/examples/foundational/07c-interruptible-deepgram-flux.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService, DeepgramFluxSTTSettings from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07c-interruptible-deepgram-http.py b/examples/foundational/07c-interruptible-deepgram-http.py index e6281fbc5..b4d829e96 100644 --- a/examples/foundational/07c-interruptible-deepgram-http.py +++ b/examples/foundational/07c-interruptible-deepgram-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramHttpTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07c-interruptible-deepgram-sagemaker.py b/examples/foundational/07c-interruptible-deepgram-sagemaker.py index 2f51bda8d..b1c54a27e 100644 --- a/examples/foundational/07c-interruptible-deepgram-sagemaker.py +++ b/examples/foundational/07c-interruptible-deepgram-sagemaker.py @@ -79,10 +79,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AWSBedrockLLMService( aws_region=os.getenv("AWS_REGION"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", settings=AWSBedrockLLMSettings( model="us.amazon.nova-pro-v1:0", temperature=0.8, + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), ) diff --git a/examples/foundational/07c-interruptible-deepgram-vad.py b/examples/foundational/07c-interruptible-deepgram-vad.py index 81acad665..4af1b0c72 100644 --- a/examples/foundational/07c-interruptible-deepgram-vad.py +++ b/examples/foundational/07c-interruptible-deepgram-vad.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07c-interruptible-deepgram.py b/examples/foundational/07c-interruptible-deepgram.py index d33a19d56..1a10c0b28 100644 --- a/examples/foundational/07c-interruptible-deepgram.py +++ b/examples/foundational/07c-interruptible-deepgram.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07d-interruptible-elevenlabs-http.py b/examples/foundational/07d-interruptible-elevenlabs-http.py index 0dd95900c..a7f68a599 100644 --- a/examples/foundational/07d-interruptible-elevenlabs-http.py +++ b/examples/foundational/07d-interruptible-elevenlabs-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.stt import ElevenLabsSTTService from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService, ElevenLabsHttpTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07d-interruptible-elevenlabs.py b/examples/foundational/07d-interruptible-elevenlabs.py index c4f31ac9b..ec62eac4d 100644 --- a/examples/foundational/07d-interruptible-elevenlabs.py +++ b/examples/foundational/07d-interruptible-elevenlabs.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.stt import ElevenLabsRealtimeSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07f-interruptible-azure-http.py b/examples/foundational/07f-interruptible-azure-http.py index 1946f66ee..38b840d6a 100644 --- a/examples/foundational/07f-interruptible-azure-http.py +++ b/examples/foundational/07f-interruptible-azure-http.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.llm import AzureLLMService +from pipecat.services.azure.llm import AzureLLMService, AzureLLMSettings from pipecat.services.azure.stt import AzureSTTService from pipecat.services.azure.tts import AzureHttpTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), model=os.getenv("AZURE_CHATGPT_MODEL"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AzureLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07f-interruptible-azure.py b/examples/foundational/07f-interruptible-azure.py index 68f5a72f9..7dafd8e1e 100644 --- a/examples/foundational/07f-interruptible-azure.py +++ b/examples/foundational/07f-interruptible-azure.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.llm import AzureLLMService +from pipecat.services.azure.llm import AzureLLMService, AzureLLMSettings from pipecat.services.azure.stt import AzureSTTService from pipecat.services.azure.tts import AzureTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), model=os.getenv("AZURE_CHATGPT_MODEL"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AzureLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07g-interruptible-openai-http.py b/examples/foundational/07g-interruptible-openai-http.py index 721d1795f..2b841be6a 100644 --- a/examples/foundational/07g-interruptible-openai-http.py +++ b/examples/foundational/07g-interruptible-openai-http.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.openai.stt import OpenAISTTService, OpenAISTTSettings from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -69,7 +69,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are very knowledgable about dogs. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are very knowledgable about dogs. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07g-interruptible-openai.py b/examples/foundational/07g-interruptible-openai.py index 86b6c9267..776feeb17 100644 --- a/examples/foundational/07g-interruptible-openai.py +++ b/examples/foundational/07g-interruptible-openai.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transcriptions.language import Language @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are very knowledgable about dogs. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are very knowledgable about dogs. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07h-interruptible-openpipe.py b/examples/foundational/07h-interruptible-openpipe.py index 6dbf04296..f7cd4d7d9 100644 --- a/examples/foundational/07h-interruptible-openpipe.py +++ b/examples/foundational/07h-interruptible-openpipe.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openpipe.llm import OpenPipeLLMService +from pipecat.services.openpipe.llm import OpenPipeLLMService, OpenPipeLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENAI_API_KEY"), openpipe_api_key=os.getenv("OPENPIPE_API_KEY"), tags={"conversation_id": f"pipecat-{timestamp}"}, - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenPipeLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07i-interruptible-xtts.py b/examples/foundational/07i-interruptible-xtts.py index 6837917aa..76f139cbf 100644 --- a/examples/foundational/07i-interruptible-xtts.py +++ b/examples/foundational/07i-interruptible-xtts.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.xtts.tts import XTTSService, XTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07j-interruptible-gladia-vad.py b/examples/foundational/07j-interruptible-gladia-vad.py index 2983e1605..3bc0c0404 100644 --- a/examples/foundational/07j-interruptible-gladia-vad.py +++ b/examples/foundational/07j-interruptible-gladia-vad.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gladia.config import LanguageConfig from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -75,7 +75,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY", ""), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07j-interruptible-gladia.py b/examples/foundational/07j-interruptible-gladia.py index 5dca15834..781e20942 100644 --- a/examples/foundational/07j-interruptible-gladia.py +++ b/examples/foundational/07j-interruptible-gladia.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gladia.config import LanguageConfig from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -73,7 +73,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY", ""), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07k-interruptible-lmnt.py b/examples/foundational/07k-interruptible-lmnt.py index debf186b1..cab1bca81 100644 --- a/examples/foundational/07k-interruptible-lmnt.py +++ b/examples/foundational/07k-interruptible-lmnt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.lmnt.tts import LmntTTSService, LmntTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07l-interruptible-groq.py b/examples/foundational/07l-interruptible-groq.py index dd532b71c..3fe64a460 100644 --- a/examples/foundational/07l-interruptible-groq.py +++ b/examples/foundational/07l-interruptible-groq.py @@ -58,8 +58,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("GROQ_API_KEY"), settings=GroqLLMSettings( model="meta-llama/llama-4-maverick-17b-128e-instruct", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) tts = GroqTTSService(api_key=os.getenv("GROQ_API_KEY")) diff --git a/examples/foundational/07m-interruptible-aws.py b/examples/foundational/07m-interruptible-aws.py index 48a632a35..8b7c0c29e 100644 --- a/examples/foundational/07m-interruptible-aws.py +++ b/examples/foundational/07m-interruptible-aws.py @@ -20,7 +20,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.llm import AWSBedrockLLMService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings from pipecat.services.aws.stt import AWSTranscribeSTTService from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): aws_region="us-west-2", model="us.anthropic.claude-haiku-4-5-20251001-v1:0", params=AWSBedrockLLMService.InputParams(temperature=0.8), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AWSBedrockLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07n-interruptible-gemini-image.py b/examples/foundational/07n-interruptible-gemini-image.py index 2b1d191c4..072998fa9 100644 --- a/examples/foundational/07n-interruptible-gemini-image.py +++ b/examples/foundational/07n-interruptible-gemini-image.py @@ -89,8 +89,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): settings=GoogleLLMSettings( model="gemini-2.5-flash-image", # model="gemini-3-pro-image-preview", # A more powerful model, but slower, + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/07n-interruptible-gemini.py b/examples/foundational/07n-interruptible-gemini.py index 7a631f473..a48efefad 100644 --- a/examples/foundational/07n-interruptible-gemini.py +++ b/examples/foundational/07n-interruptible-gemini.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings from pipecat.services.google.tts import GeminiTTSService, GeminiTTSSettings from pipecat.transcriptions.language import Language @@ -73,7 +73,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), model="gemini-2.5-flash", - system_instruction="""You are a helpful AI assistant in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. + settings=GoogleLLMSettings( + system_instruction="""You are a helpful AI assistant in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. IMPORTANT: You're using Gemini TTS which supports expressive markup tags. You can use these tags in your responses: - [sigh] - Insert a sigh sound @@ -91,6 +92,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): - "The answer is... [long pause] ...42!" Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.""", + ), ) context = LLMContext() diff --git a/examples/foundational/07n-interruptible-google-http.py b/examples/foundational/07n-interruptible-google-http.py index 1f570366a..0a6280618 100644 --- a/examples/foundational/07n-interruptible-google-http.py +++ b/examples/foundational/07n-interruptible-google-http.py @@ -76,8 +76,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): model="gemini-2.5-flash", # force a certain amount of thinking if you want it # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/07n-interruptible-google.py b/examples/foundational/07n-interruptible-google.py index 439676238..d6c57b548 100644 --- a/examples/foundational/07n-interruptible-google.py +++ b/examples/foundational/07n-interruptible-google.py @@ -76,8 +76,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): model="gemini-2.5-flash", # force a certain amount of thinking if you want it # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/07o-interruptible-assemblyai-turn-detection.py b/examples/foundational/07o-interruptible-assemblyai-turn-detection.py index 6f2ec36f2..b15e3038f 100644 --- a/examples/foundational/07o-interruptible-assemblyai-turn-detection.py +++ b/examples/foundational/07o-interruptible-assemblyai-turn-detection.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -114,7 +114,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07o-interruptible-assemblyai.py b/examples/foundational/07o-interruptible-assemblyai.py index 10d6a8cd4..8e58ddbf3 100644 --- a/examples/foundational/07o-interruptible-assemblyai.py +++ b/examples/foundational/07o-interruptible-assemblyai.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.stt import AssemblyAISTTService from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07p-interruptible-krisp-viva.py b/examples/foundational/07p-interruptible-krisp-viva.py index 1b10202f3..056a2f6cc 100644 --- a/examples/foundational/07p-interruptible-krisp-viva.py +++ b/examples/foundational/07p-interruptible-krisp-viva.py @@ -45,7 +45,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -92,7 +92,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07p-interruptible-krisp.py b/examples/foundational/07p-interruptible-krisp.py index 54d88d32a..b3ccfb30e 100644 --- a/examples/foundational/07p-interruptible-krisp.py +++ b/examples/foundational/07p-interruptible-krisp.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07q-interruptible-rime-http.py b/examples/foundational/07q-interruptible-rime-http.py index c735e39c9..ebbdc6946 100644 --- a/examples/foundational/07q-interruptible-rime-http.py +++ b/examples/foundational/07q-interruptible-rime-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.rime.tts import RimeHttpTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07q-interruptible-rime.py b/examples/foundational/07q-interruptible-rime.py index dbc6b91e6..bfcf5da41 100644 --- a/examples/foundational/07q-interruptible-rime.py +++ b/examples/foundational/07q-interruptible-rime.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.rime.tts import RimeTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07r-interruptible-nvidia.py b/examples/foundational/07r-interruptible-nvidia.py index 69a5fbc15..a5a477ba0 100644 --- a/examples/foundational/07r-interruptible-nvidia.py +++ b/examples/foundational/07r-interruptible-nvidia.py @@ -58,8 +58,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("NVIDIA_API_KEY"), settings=NvidiaLLMSettings( model="meta/llama-3.3-70b-instruct", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) tts = NvidiaTTSService(api_key=os.getenv("NVIDIA_API_KEY")) diff --git a/examples/foundational/07t-interruptible-fish.py b/examples/foundational/07t-interruptible-fish.py index d54d34c1c..4825c3110 100644 --- a/examples/foundational/07t-interruptible-fish.py +++ b/examples/foundational/07t-interruptible-fish.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.fish.tts import FishAudioTTSService, FishAudioTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07v-interruptible-neuphonic-http.py b/examples/foundational/07v-interruptible-neuphonic-http.py index 081d9d6cc..5c2934fcd 100644 --- a/examples/foundational/07v-interruptible-neuphonic-http.py +++ b/examples/foundational/07v-interruptible-neuphonic-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService, NeuphonicTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07v-interruptible-neuphonic.py b/examples/foundational/07v-interruptible-neuphonic.py index 3f30ab9c7..d70b187a7 100644 --- a/examples/foundational/07v-interruptible-neuphonic.py +++ b/examples/foundational/07v-interruptible-neuphonic.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.neuphonic.tts import NeuphonicTTSService, NeuphonicTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07w-interruptible-fal.py b/examples/foundational/07w-interruptible-fal.py index 7e0e53bc9..6539cbfc9 100644 --- a/examples/foundational/07w-interruptible-fal.py +++ b/examples/foundational/07w-interruptible-fal.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.fal.stt import FalSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -69,7 +69,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07x-interruptible-local.py b/examples/foundational/07x-interruptible-local.py index 63cf2bbb1..e0eeee03b 100644 --- a/examples/foundational/07x-interruptible-local.py +++ b/examples/foundational/07x-interruptible-local.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.local.audio import LocalAudioTransport, LocalAudioTransportParams load_dotenv(override=True) @@ -51,7 +51,9 @@ async def main(): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07y-interruptible-minimax.py b/examples/foundational/07y-interruptible-minimax.py index 690c35178..1213291e0 100644 --- a/examples/foundational/07y-interruptible-minimax.py +++ b/examples/foundational/07y-interruptible-minimax.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.minimax.tts import MiniMaxHttpTTSService, MiniMaxTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07z-interruptible-sarvam-http.py b/examples/foundational/07z-interruptible-sarvam-http.py index 33f1277e6..566cea75a 100644 --- a/examples/foundational/07z-interruptible-sarvam-http.py +++ b/examples/foundational/07z-interruptible-sarvam-http.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.sarvam.stt import SarvamSTTService from pipecat.services.sarvam.tts import SarvamHttpTTSService, SarvamHttpTTSSettings from pipecat.transcriptions.language import Language @@ -72,7 +72,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07z-interruptible-sarvam.py b/examples/foundational/07z-interruptible-sarvam.py index 60b5bcc8b..827ce947f 100644 --- a/examples/foundational/07z-interruptible-sarvam.py +++ b/examples/foundational/07z-interruptible-sarvam.py @@ -21,7 +21,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.sarvam.stt import SarvamSTTService, SarvamSTTSettings from pipecat.services.sarvam.tts import SarvamTTSService, SarvamTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07za-interruptible-soniox.py b/examples/foundational/07za-interruptible-soniox.py index 56b2dee1e..380033a11 100644 --- a/examples/foundational/07za-interruptible-soniox.py +++ b/examples/foundational/07za-interruptible-soniox.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.soniox.stt import SonioxSTTService, SonioxSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zb-interruptible-inworld-http.py b/examples/foundational/07zb-interruptible-inworld-http.py index ffbdbb444..1376ab8da 100644 --- a/examples/foundational/07zb-interruptible-inworld-http.py +++ b/examples/foundational/07zb-interruptible-inworld-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.inworld.tts import InworldHttpTTSService, InworldTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful AI demonstrating Inworld AI's TTS. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a friendly and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful AI demonstrating Inworld AI's TTS. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a friendly and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zb-interruptible-inworld.py b/examples/foundational/07zb-interruptible-inworld.py index 6c8b53706..9c9895ca9 100644 --- a/examples/foundational/07zb-interruptible-inworld.py +++ b/examples/foundational/07zb-interruptible-inworld.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.inworld.tts import InworldTTSService, InworldTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful AI demonstrating Inworld AI's TTS. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a friendly and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful AI demonstrating Inworld AI's TTS. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a friendly and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zc-interruptible-asyncai-http.py b/examples/foundational/07zc-interruptible-asyncai-http.py index 3246feac4..b3f46f671 100644 --- a/examples/foundational/07zc-interruptible-asyncai-http.py +++ b/examples/foundational/07zc-interruptible-asyncai-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.asyncai.tts import AsyncAIHttpTTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zc-interruptible-asyncai.py b/examples/foundational/07zc-interruptible-asyncai.py index 093f03ccb..b95a55ddb 100644 --- a/examples/foundational/07zc-interruptible-asyncai.py +++ b/examples/foundational/07zc-interruptible-asyncai.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.asyncai.tts import AsyncAITTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zd-interruptible-aicoustics.py b/examples/foundational/07zd-interruptible-aicoustics.py index cedb95a9e..481e098a2 100644 --- a/examples/foundational/07zd-interruptible-aicoustics.py +++ b/examples/foundational/07zd-interruptible-aicoustics.py @@ -27,7 +27,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -84,7 +84,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07ze-interruptible-hume.py b/examples/foundational/07ze-interruptible-hume.py index 70ace62e9..c5c352232 100644 --- a/examples/foundational/07ze-interruptible-hume.py +++ b/examples/foundational/07ze-interruptible-hume.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.hume.tts import HUME_SAMPLE_RATE, HumeTTSService, HumeTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zf-interruptible-gradium.py b/examples/foundational/07zf-interruptible-gradium.py index ff164c790..acf168f13 100644 --- a/examples/foundational/07zf-interruptible-gradium.py +++ b/examples/foundational/07zf-interruptible-gradium.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings from pipecat.services.gradium.tts import GradiumTTSService, GradiumTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zg-interruptible-camb.py b/examples/foundational/07zg-interruptible-camb.py index f98303b26..e8d5011e2 100644 --- a/examples/foundational/07zg-interruptible-camb.py +++ b/examples/foundational/07zg-interruptible-camb.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.camb.tts import CambTTSService, CambTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful voice assistant powered by Camb AI text-to-speech. ", + settings=OpenAILLMSettings( + system_instruction="You are a helpful voice assistant powered by Camb AI text-to-speech. ", + ), ) context = LLMContext() diff --git a/examples/foundational/07zi-interruptible-piper.py b/examples/foundational/07zi-interruptible-piper.py index fb38cba6a..9ac672fc2 100644 --- a/examples/foundational/07zi-interruptible-piper.py +++ b/examples/foundational/07zi-interruptible-piper.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.piper.tts import PiperTTSService, PiperTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zj-interruptible-kokoro.py b/examples/foundational/07zj-interruptible-kokoro.py index 7271ef42d..66a225d35 100644 --- a/examples/foundational/07zj-interruptible-kokoro.py +++ b/examples/foundational/07zj-interruptible-kokoro.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.kokoro.tts import KokoroTTSService, KokoroTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/07zk-interruptible-resemble.py b/examples/foundational/07zk-interruptible-resemble.py index 5e89eaa6e..2212fa80f 100644 --- a/examples/foundational/07zk-interruptible-resemble.py +++ b/examples/foundational/07zk-interruptible-resemble.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.resembleai.tts import ResembleAITTSService, ResembleAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/08-custom-frame-processor.py b/examples/foundational/08-custom-frame-processor.py index cfab184cb..820659207 100644 --- a/examples/foundational/08-custom-frame-processor.py +++ b/examples/foundational/08-custom-frame-processor.py @@ -28,7 +28,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -102,7 +102,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/10-wake-phrase.py b/examples/foundational/10-wake-phrase.py index a57ef6f96..de237659a 100644 --- a/examples/foundational/10-wake-phrase.py +++ b/examples/foundational/10-wake-phrase.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful assistant. Respond to what the user said in a creative and helpful way. Keep your responses brief.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful assistant. Respond to what the user said in a creative and helpful way. Keep your responses brief.", + ), ) hey_robot_filter = WakeCheckFilter(["hey robot", "hey, robot"]) diff --git a/examples/foundational/11-sound-effects.py b/examples/foundational/11-sound-effects.py index 332c1536a..664bd122c 100644 --- a/examples/foundational/11-sound-effects.py +++ b/examples/foundational/11-sound-effects.py @@ -32,7 +32,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -106,7 +106,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) tts = CartesiaTTSService( diff --git a/examples/foundational/12-describe-image-openai.py b/examples/foundational/12-describe-image-openai.py index 4d22e4046..d9b0be871 100644 --- a/examples/foundational/12-describe-image-openai.py +++ b/examples/foundational/12-describe-image-openai.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", + ), ) context = LLMContext() diff --git a/examples/foundational/12a-describe-image-anthropic.py b/examples/foundational/12a-describe-image-anthropic.py index 79e4460a2..5a10f24a5 100644 --- a/examples/foundational/12a-describe-image-anthropic.py +++ b/examples/foundational/12a-describe-image-anthropic.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService +from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", + settings=AnthropicLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", + ), ) context = LLMContext() diff --git a/examples/foundational/12b-describe-image-aws.py b/examples/foundational/12b-describe-image-aws.py index b4db59409..eaa5e3d19 100644 --- a/examples/foundational/12b-describe-image-aws.py +++ b/examples/foundational/12b-describe-image-aws.py @@ -66,8 +66,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, # which we need for image input. params=AWSBedrockLLMService.InputParams(temperature=0.8), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", ) context = LLMContext() diff --git a/examples/foundational/12c-describe-image-gemini-flash.py b/examples/foundational/12c-describe-image-gemini-flash.py index 1f550dd6f..2e76eff19 100644 --- a/examples/foundational/12c-describe-image-gemini-flash.py +++ b/examples/foundational/12c-describe-image-gemini-flash.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", + ), ) context = LLMContext() diff --git a/examples/foundational/14-function-calling.py b/examples/foundational/14-function-calling.py index 2a3206dbc..81cddec90 100644 --- a/examples/foundational/14-function-calling.py +++ b/examples/foundational/14-function-calling.py @@ -26,7 +26,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -74,7 +74,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14a-function-calling-anthropic.py b/examples/foundational/14a-function-calling-anthropic.py index 0fd40af4f..19bc314b8 100644 --- a/examples/foundational/14a-function-calling-anthropic.py +++ b/examples/foundational/14a-function-calling-anthropic.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService +from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -76,7 +76,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AnthropicLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) llm.register_function("get_weather", get_weather) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) diff --git a/examples/foundational/14c-function-calling-together.py b/examples/foundational/14c-function-calling-together.py index 6362e1ea6..66ed02c15 100644 --- a/examples/foundational/14c-function-calling-together.py +++ b/examples/foundational/14c-function-calling-together.py @@ -73,8 +73,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("TOGETHER_API_KEY"), settings=TogetherLLMSettings( model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14d-function-calling-anthropic-video.py b/examples/foundational/14d-function-calling-anthropic-video.py index fee17734c..f1e097902 100644 --- a/examples/foundational/14d-function-calling-anthropic-video.py +++ b/examples/foundational/14d-function-calling-anthropic-video.py @@ -28,7 +28,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.anthropic.llm import AnthropicLLMService +from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -98,7 +98,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Anthropic for vision analysis llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + settings=AnthropicLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + ), ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14d-function-calling-aws-video.py b/examples/foundational/14d-function-calling-aws-video.py index 234552d92..09ceaedd4 100644 --- a/examples/foundational/14d-function-calling-aws-video.py +++ b/examples/foundational/14d-function-calling-aws-video.py @@ -104,8 +104,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, # which we need for image input. temperature=0.8, + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14d-function-calling-gemini-flash-video.py b/examples/foundational/14d-function-calling-gemini-flash-video.py index f1255d287..a56349f96 100644 --- a/examples/foundational/14d-function-calling-gemini-flash-video.py +++ b/examples/foundational/14d-function-calling-gemini-flash-video.py @@ -30,7 +30,7 @@ from pipecat.runner.utils import ( ) from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -98,7 +98,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Google Gemini model for vision analysis llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + ), ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14d-function-calling-moondream-video.py b/examples/foundational/14d-function-calling-moondream-video.py index 6ffb10213..c32bf3549 100644 --- a/examples/foundational/14d-function-calling-moondream-video.py +++ b/examples/foundational/14d-function-calling-moondream-video.py @@ -41,7 +41,7 @@ from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSetting from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.moondream.vision import MoondreamService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -128,7 +128,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + ), ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14d-function-calling-openai-video.py b/examples/foundational/14d-function-calling-openai-video.py index 235815a5c..5bfa336aa 100644 --- a/examples/foundational/14d-function-calling-openai-video.py +++ b/examples/foundational/14d-function-calling-openai-video.py @@ -32,7 +32,7 @@ from pipecat.runner.utils import ( from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -98,7 +98,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", + ), ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14e-function-calling-google.py b/examples/foundational/14e-function-calling-google.py index 08308dee3..19a0392b9 100644 --- a/examples/foundational/14e-function-calling-google.py +++ b/examples/foundational/14e-function-calling-google.py @@ -31,7 +31,7 @@ from pipecat.runner.utils import ( ) from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -126,7 +126,9 @@ indicate you should use the get_image tool are: llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction=system_prompt, + settings=GoogleLLMSettings( + system_instruction=system_prompt, + ), ) llm.register_function("get_weather", get_weather) llm.register_function("get_image", get_image) diff --git a/examples/foundational/14f-function-calling-groq.py b/examples/foundational/14f-function-calling-groq.py index 11bbda12d..1b66e7e90 100644 --- a/examples/foundational/14f-function-calling-groq.py +++ b/examples/foundational/14f-function-calling-groq.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.services.groq.stt import GroqSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GroqLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14g-function-calling-grok.py b/examples/foundational/14g-function-calling-grok.py index 7ff89658d..eb607a5b8 100644 --- a/examples/foundational/14g-function-calling-grok.py +++ b/examples/foundational/14g-function-calling-grok.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.grok.llm import GrokLLMService +from pipecat.services.grok.llm import GrokLLMService, GrokLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GrokLLMService( api_key=os.getenv("GROK_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GrokLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14h-function-calling-azure.py b/examples/foundational/14h-function-calling-azure.py index 9df6abeef..7eb3cb9de 100644 --- a/examples/foundational/14h-function-calling-azure.py +++ b/examples/foundational/14h-function-calling-azure.py @@ -74,8 +74,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), settings=AzureLLMSettings( model=os.getenv("AZURE_CHATGPT_MODEL"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14i-function-calling-fireworks.py b/examples/foundational/14i-function-calling-fireworks.py index 6a274c09f..aad4b6ecf 100644 --- a/examples/foundational/14i-function-calling-fireworks.py +++ b/examples/foundational/14i-function-calling-fireworks.py @@ -73,8 +73,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("FIREWORKS_API_KEY"), settings=FireworksLLMSettings( model="accounts/fireworks/models/gpt-oss-20b", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14j-function-calling-nvidia.py b/examples/foundational/14j-function-calling-nvidia.py index 680952d75..87c6812e8 100644 --- a/examples/foundational/14j-function-calling-nvidia.py +++ b/examples/foundational/14j-function-calling-nvidia.py @@ -75,8 +75,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): model="nvidia/llama-3.3-nemotron-super-49b-v1.5", # Recommended when turning thinking off temperature=0.0, + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14k-function-calling-cerebras.py b/examples/foundational/14k-function-calling-cerebras.py index 118062769..4bbcf3f8e 100644 --- a/examples/foundational/14k-function-calling-cerebras.py +++ b/examples/foundational/14k-function-calling-cerebras.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.cerebras.llm import CerebrasLLMService +from pipecat.services.cerebras.llm import CerebrasLLMService, CerebrasLLMSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -71,7 +71,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = CerebrasLLMService( api_key=os.getenv("CEREBRAS_API_KEY"), - system_instruction="""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. + settings=CerebrasLLMSettings( + system_instruction="""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. You have one functions available: @@ -82,6 +83,7 @@ Infer whether to use Fahrenheit or Celsius automatically based on the location, Start by asking me for my location. Then, use 'get_weather_current' to give me a forecast. Respond to what the user said in a creative and helpful way.""", + ), ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14l-function-calling-deepseek.py b/examples/foundational/14l-function-calling-deepseek.py index 9c2068236..425a58ec6 100644 --- a/examples/foundational/14l-function-calling-deepseek.py +++ b/examples/foundational/14l-function-calling-deepseek.py @@ -73,8 +73,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("DEEPSEEK_API_KEY"), settings=DeepSeekLLMSettings( model="deepseek-chat", - ), - system_instruction="""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. + system_instruction="""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. You have one functions available: @@ -85,6 +84,7 @@ Infer whether to use Fahrenheit or Celsius automatically based on the location, Start by asking me for my location. Then, use 'get_weather_current' to give me a forecast. Respond to what the user said in a creative and helpful way.""", + ), ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14m-function-calling-openrouter.py b/examples/foundational/14m-function-calling-openrouter.py index dbcd1813f..fd39ef7af 100644 --- a/examples/foundational/14m-function-calling-openrouter.py +++ b/examples/foundational/14m-function-calling-openrouter.py @@ -77,8 +77,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENROUTER_API_KEY"), settings=OpenRouterLLMSettings( model="openai/gpt-4o-2024-11-20", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14n-function-calling-perplexity.py b/examples/foundational/14n-function-calling-perplexity.py index 4857b614f..78d397656 100644 --- a/examples/foundational/14n-function-calling-perplexity.py +++ b/examples/foundational/14n-function-calling-perplexity.py @@ -30,7 +30,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.perplexity.llm import PerplexityLLMService +from pipecat.services.perplexity.llm import PerplexityLLMService, PerplexityLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -69,7 +69,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = PerplexityLLMService( api_key=os.getenv("PERPLEXITY_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way, but try to be brief.", + settings=PerplexityLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way, but try to be brief.", + ), ) context = LLMContext() @@ -103,6 +105,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/14o-function-calling-gemini-openai-format.py b/examples/foundational/14o-function-calling-gemini-openai-format.py index 5eb8ff89d..82a77e4bb 100644 --- a/examples/foundational/14o-function-calling-gemini-openai-format.py +++ b/examples/foundational/14o-function-calling-gemini-openai-format.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings -from pipecat.services.google.llm_openai import GoogleLLMOpenAIBetaService +from pipecat.services.google.llm_openai import GoogleLLMOpenAIBetaService, OpenAILLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMOpenAIBetaService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14p-function-calling-gemini-vertex-ai.py b/examples/foundational/14p-function-calling-gemini-vertex-ai.py index bf7b9458d..026e41e59 100644 --- a/examples/foundational/14p-function-calling-gemini-vertex-ai.py +++ b/examples/foundational/14p-function-calling-gemini-vertex-ai.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings -from pipecat.services.google.llm_vertex import GoogleVertexLLMService +from pipecat.services.google.llm_vertex import GoogleVertexLLMService, GoogleVertexLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -73,7 +73,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), location=os.getenv("GOOGLE_CLOUD_LOCATION"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GoogleVertexLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14q-function-calling-qwen.py b/examples/foundational/14q-function-calling-qwen.py index 58d34a3e1..9aa1c3b91 100644 --- a/examples/foundational/14q-function-calling-qwen.py +++ b/examples/foundational/14q-function-calling-qwen.py @@ -27,7 +27,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.qwen.llm import QwenLLMService +from pipecat.services.qwen.llm import QwenLLMService, QwenLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -72,7 +72,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = QwenLLMService( api_key=os.getenv("QWEN_API_KEY"), model="qwen2.5-72b-instruct", - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=QwenLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14r-function-calling-aws.py b/examples/foundational/14r-function-calling-aws.py index 9d7e4e7a1..3693cba6c 100644 --- a/examples/foundational/14r-function-calling-aws.py +++ b/examples/foundational/14r-function-calling-aws.py @@ -78,8 +78,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): settings=AWSBedrockLLMSettings( model="us.anthropic.claude-haiku-4-5-20251001-v1:0", temperature=0.8, + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14s-function-calling-sambanova.py b/examples/foundational/14s-function-calling-sambanova.py index 8cb007691..46ae742f3 100644 --- a/examples/foundational/14s-function-calling-sambanova.py +++ b/examples/foundational/14s-function-calling-sambanova.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.sambanova.llm import SambaNovaLLMService +from pipecat.services.sambanova.llm import SambaNovaLLMService, SambaNovaLLMSettings from pipecat.services.sambanova.stt import SambaNovaSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -74,7 +74,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = SambaNovaLLMService( api_key=os.getenv("SAMBANOVA_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=SambaNovaLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14t-function-calling-direct.py b/examples/foundational/14t-function-calling-direct.py index b2912b91a..86a8d61b2 100644 --- a/examples/foundational/14t-function-calling-direct.py +++ b/examples/foundational/14t-function-calling-direct.py @@ -26,7 +26,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -87,7 +87,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14u-function-calling-ollama.py b/examples/foundational/14u-function-calling-ollama.py index 53b81402d..761bab4a4 100644 --- a/examples/foundational/14u-function-calling-ollama.py +++ b/examples/foundational/14u-function-calling-ollama.py @@ -76,8 +76,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OLLamaLLMService( settings=OLLamaLLMSettings( model="llama3.2", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # Update to the model you're running locally # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14v-function-calling-openai.py b/examples/foundational/14v-function-calling-openai.py index 77bacc091..5e86632ec 100644 --- a/examples/foundational/14v-function-calling-openai.py +++ b/examples/foundational/14v-function-calling-openai.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.openai.stt import OpenAISTTService, OpenAISTTSettings from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -82,7 +82,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # model choices: gpt-4o, gpt-4.1, etc. llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14w-function-calling-mistral.py b/examples/foundational/14w-function-calling-mistral.py index fa809414b..ce535c3ef 100644 --- a/examples/foundational/14w-function-calling-mistral.py +++ b/examples/foundational/14w-function-calling-mistral.py @@ -26,7 +26,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.mistral.llm import MistralLLMService +from pipecat.services.mistral.llm import MistralLLMService, MistralLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -74,7 +74,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = MistralLLMService( api_key=os.getenv("MISTRAL_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=MistralLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14x-function-calling-openpipe.py b/examples/foundational/14x-function-calling-openpipe.py index 61382c435..4f6898f5c 100644 --- a/examples/foundational/14x-function-calling-openpipe.py +++ b/examples/foundational/14x-function-calling-openpipe.py @@ -27,7 +27,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openpipe.llm import OpenPipeLLMService +from pipecat.services.openpipe.llm import OpenPipeLLMService, OpenPipeLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -78,7 +78,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENAI_API_KEY"), openpipe_api_key=os.getenv("OPENPIPE_API_KEY"), tags={"conversation_id": f"pipecat-{timestamp}"}, - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenPipeLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/15-switch-voices.py b/examples/foundational/15-switch-voices.py index f749a03c7..c298aaf0f 100644 --- a/examples/foundational/15-switch-voices.py +++ b/examples/foundational/15-switch-voices.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -120,7 +120,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities. Respond to what the user said in a creative and helpful way. Your output should not include non-alphanumeric characters. You can do the following voices: 'News Lady', 'British Lady' and 'Barbershop Man'.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities. Respond to what the user said in a creative and helpful way. Your output should not include non-alphanumeric characters. You can do the following voices: 'News Lady', 'British Lady' and 'Barbershop Man'.", + ), ) llm.register_function("switch_voice", tts.switch_voice) diff --git a/examples/foundational/15a-switch-languages.py b/examples/foundational/15a-switch-languages.py index dad7e0ee3..c19038ea2 100644 --- a/examples/foundational/15a-switch-languages.py +++ b/examples/foundational/15a-switch-languages.py @@ -30,7 +30,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -109,7 +109,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities. Respond to what the user said in a creative and helpful way. Your output should not include non-alphanumeric characters. You can speak the following languages: 'English' and 'Spanish'.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities. Respond to what the user said in a creative and helpful way. Your output should not include non-alphanumeric characters. You can speak the following languages: 'English' and 'Spanish'.", + ), ) llm.register_function("switch_language", tts.switch_language) diff --git a/examples/foundational/16-gpu-container-local-bot.py b/examples/foundational/16-gpu-container-local-bot.py index cf02b37ce..103b5216f 100644 --- a/examples/foundational/16-gpu-container-local-bot.py +++ b/examples/foundational/16-gpu-container-local-bot.py @@ -72,9 +72,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Or, to use a local vLLM (or similar) api server settings=OpenAILLMSettings( model="meta-llama/Meta-Llama-3-8B-Instruct", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), base_url="http://0.0.0.0:8000/v1", - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/17-detect-user-idle.py b/examples/foundational/17-detect-user-idle.py index 9da863bc9..ecb7ceea1 100644 --- a/examples/foundational/17-detect-user-idle.py +++ b/examples/foundational/17-detect-user-idle.py @@ -35,7 +35,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -122,7 +122,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) llm.register_function("get_current_weather", fetch_weather_from_api) diff --git a/examples/foundational/21-tavus-transport.py b/examples/foundational/21-tavus-transport.py index 06d904c21..7936a4555 100644 --- a/examples/foundational/21-tavus-transport.py +++ b/examples/foundational/21-tavus-transport.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.transports.tavus.transport import TavusParams, TavusTransport load_dotenv(override=True) @@ -58,7 +58,9 @@ async def main(): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/21a-tavus-video-service.py b/examples/foundational/21a-tavus-video-service.py index c756a7821..fd2ff5880 100644 --- a/examples/foundational/21a-tavus-video-service.py +++ b/examples/foundational/21a-tavus-video-service.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.tavus.video import TavusVideoService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) tavus = TavusVideoService( diff --git a/examples/foundational/22-filter-incomplete-turns.py b/examples/foundational/22-filter-incomplete-turns.py index 876999bcd..6d5af6be8 100644 --- a/examples/foundational/22-filter-incomplete-turns.py +++ b/examples/foundational/22-filter-incomplete-turns.py @@ -37,7 +37,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) tts = CartesiaTTSService( diff --git a/examples/foundational/23-bot-background-sound.py b/examples/foundational/23-bot-background-sound.py index a88ebc9bc..ad82ab8c3 100644 --- a/examples/foundational/23-bot-background-sound.py +++ b/examples/foundational/23-bot-background-sound.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -82,7 +82,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/24-user-mute-strategy.py b/examples/foundational/24-user-mute-strategy.py index d4276f04a..ab206de73 100644 --- a/examples/foundational/24-user-mute-strategy.py +++ b/examples/foundational/24-user-mute-strategy.py @@ -28,7 +28,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -80,7 +80,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful assistant who can check the weather. Always check the weather when a location is mentioned. Respond concisely and naturally. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful assistant who can check the weather. Always check the weather when a location is mentioned. Respond concisely and naturally. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points.", + ), ) llm.register_function("get_current_weather", fetch_weather_from_api) diff --git a/examples/foundational/25-google-audio-in.py b/examples/foundational/25-google-audio-in.py index a278ea4b3..1a8d203cd 100644 --- a/examples/foundational/25-google-audio-in.py +++ b/examples/foundational/25-google-audio-in.py @@ -299,21 +299,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): name="Conversation", settings=GoogleLLMSettings( model="gemini-2.5-flash", + system_instruction=conversation_system_message, ), api_key=os.getenv("GOOGLE_API_KEY"), # we can give the GoogleLLMService a system instruction to use directly # in the GenerativeModel constructor. Let's do that rather than put # our system message in the messages list. - system_instruction=conversation_system_message, ) input_transcription_llm = GoogleLLMService( name="Transcription", settings=GoogleLLMSettings( model="gemini-2.5-flash", + system_instruction=transcriber_system_message, ), api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction=transcriber_system_message, ) messages = [ diff --git a/examples/foundational/27-simli-layer.py b/examples/foundational/27-simli-layer.py index 05d0649d6..3120a1280 100644 --- a/examples/foundational/27-simli-layer.py +++ b/examples/foundational/27-simli-layer.py @@ -74,8 +74,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENAI_API_KEY"), settings=OpenAILLMSettings( model="gpt-4o-mini", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/28-user-assistant-turns.py b/examples/foundational/28-user-assistant-turns.py index d59ad3870..2a7cce980 100644 --- a/examples/foundational/28-user-assistant-turns.py +++ b/examples/foundational/28-user-assistant-turns.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -129,7 +129,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative, helpful, and brief way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative, helpful, and brief way.", + ), ) context = LLMContext() diff --git a/examples/foundational/29-turn-tracking-observer.py b/examples/foundational/29-turn-tracking-observer.py index 0dd164bd0..d83442456 100644 --- a/examples/foundational/29-turn-tracking-observer.py +++ b/examples/foundational/29-turn-tracking-observer.py @@ -30,7 +30,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -80,7 +80,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) llm.register_function("get_current_weather", fetch_weather_from_api) diff --git a/examples/foundational/30-observer.py b/examples/foundational/30-observer.py index 5ee0bdaed..c730a2993 100644 --- a/examples/foundational/30-observer.py +++ b/examples/foundational/30-observer.py @@ -36,7 +36,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_input import BaseInputTransport from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -111,7 +111,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/32-gemini-grounding-metadata.py b/examples/foundational/32-gemini-grounding-metadata.py index 2977e19bc..6c2b182f7 100644 --- a/examples/foundational/32-gemini-grounding-metadata.py +++ b/examples/foundational/32-gemini-grounding-metadata.py @@ -27,7 +27,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService, LLMSearchResponseFrame +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings, LLMSearchResponseFrame from pipecat.services.llm_service import LLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -107,7 +107,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize the Gemini Multimodal Live model llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction=system_instruction, + settings=GoogleLLMSettings( + system_instruction=system_instruction, + ), tools=tools, ) diff --git a/examples/foundational/33-gemini-rag.py b/examples/foundational/33-gemini-rag.py index c34a9c83e..3b1ba6bb9 100644 --- a/examples/foundational/33-gemini-rag.py +++ b/examples/foundational/33-gemini-rag.py @@ -199,8 +199,8 @@ Your response will be turned into speech so use only simple words and punctuatio llm = GoogleLLMService( settings=GoogleLLMSettings( model=VOICE_MODEL, + system_instruction=system_prompt, ), - system_instruction=system_prompt, api_key=os.getenv("GOOGLE_API_KEY"), ) llm.register_function("query_knowledge_base", query_knowledge_base) diff --git a/examples/foundational/34-audio-recording.py b/examples/foundational/34-audio-recording.py index aa52c213a..2bc413ec2 100644 --- a/examples/foundational/34-audio-recording.py +++ b/examples/foundational/34-audio-recording.py @@ -65,7 +65,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -119,7 +119,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful assistant demonstrating audio recording capabilities. Keep your responses brief and clear.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful assistant demonstrating audio recording capabilities. Keep your responses brief and clear.", + ), ) # Create audio buffer processor diff --git a/examples/foundational/35-pattern-pair-voice-switching.py b/examples/foundational/35-pattern-pair-voice-switching.py index c10e185b0..0c5c6256c 100644 --- a/examples/foundational/35-pattern-pair-voice-switching.py +++ b/examples/foundational/35-pattern-pair-voice-switching.py @@ -58,7 +58,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -186,7 +186,9 @@ Remember: Use narrator voice for EVERYTHING except the actual quoted dialogue."" # Initialize LLM llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction=system_prompt, + settings=OpenAILLMSettings( + system_instruction=system_prompt, + ), ) context = LLMContext() diff --git a/examples/foundational/36-user-email-gathering.py b/examples/foundational/36-user-email-gathering.py index 5bdb937d0..2f9c04fd8 100644 --- a/examples/foundational/36-user-email-gathering.py +++ b/examples/foundational/36-user-email-gathering.py @@ -27,7 +27,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -85,7 +85,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You need to gather a valid email or emails from the user. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. If the user provides one or more email addresses confirm them with the user. Enclose all emails with tags, for example a@a.com.", + settings=OpenAILLMSettings( + system_instruction="You need to gather a valid email or emails from the user. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. If the user provides one or more email addresses confirm them with the user. Enclose all emails with tags, for example a@a.com.", + ), ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/37-mem0.py b/examples/foundational/37-mem0.py index e02d86915..5e9dc351d 100644 --- a/examples/foundational/37-mem0.py +++ b/examples/foundational/37-mem0.py @@ -227,13 +227,13 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("OPENAI_API_KEY"), settings=OpenAILLMSettings( model="gpt-4o-mini", - ), - system_instruction="""You are a personal assistant. You can remember things about the person you are talking to. + system_instruction="""You are a personal assistant. You can remember things about the person you are talking to. Some Guidelines: - Make sure your responses are friendly yet short and concise. - If the user asks you to remember something, make sure to remember it. - Greet the user by their name if you know about it. """, + ), ) # Set up conversation context and management diff --git a/examples/foundational/38-smart-turn-fal.py b/examples/foundational/38-smart-turn-fal.py index 384652b29..2eafe6297 100644 --- a/examples/foundational/38-smart-turn-fal.py +++ b/examples/foundational/38-smart-turn-fal.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/38a-smart-turn-local-coreml.py b/examples/foundational/38a-smart-turn-local-coreml.py index 01585982d..4ed17642b 100644 --- a/examples/foundational/38a-smart-turn-local-coreml.py +++ b/examples/foundational/38a-smart-turn-local-coreml.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -83,7 +83,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/38b-smart-turn-local.py b/examples/foundational/38b-smart-turn-local.py index aceff9bc9..361889a5b 100644 --- a/examples/foundational/38b-smart-turn-local.py +++ b/examples/foundational/38b-smart-turn-local.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/39-mcp-stdio.py b/examples/foundational/39-mcp-stdio.py index 0919e2fb0..7e648cfd7 100644 --- a/examples/foundational/39-mcp-stdio.py +++ b/examples/foundational/39-mcp-stdio.py @@ -35,7 +35,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService +from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mcp_service import MCPClient @@ -155,7 +155,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): Just respond with short sentences when you are carrying out tool calls. """ - llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"), system_instruction=system) + llm = AnthropicLLMService( + api_key=os.getenv("ANTHROPIC_API_KEY"), + settings=AnthropicLLMSettings( + system_instruction=system, + ), + ) try: mcp = MCPClient( diff --git a/examples/foundational/39c-multiple-mcp.py b/examples/foundational/39c-multiple-mcp.py index dcda884ec..e4612efa4 100644 --- a/examples/foundational/39c-multiple-mcp.py +++ b/examples/foundational/39c-multiple-mcp.py @@ -37,7 +37,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService +from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mcp_service import MCPClient @@ -139,7 +139,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): Just respond with short sentences when you are carrying out tool calls. """ - llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"), system_instruction=system) + llm = AnthropicLLMService( + api_key=os.getenv("ANTHROPIC_API_KEY"), + settings=AnthropicLLMSettings( + system_instruction=system, + ), + ) try: rijksmuseum_mcp = MCPClient( diff --git a/examples/foundational/42-interruption-config.py b/examples/foundational/42-interruption-config.py index f8add9019..4c8e3ba23 100644 --- a/examples/foundational/42-interruption-config.py +++ b/examples/foundational/42-interruption-config.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/43-heygen-transport.py b/examples/foundational/43-heygen-transport.py index 5797aeb25..ad0e20764 100644 --- a/examples/foundational/43-heygen-transport.py +++ b/examples/foundational/43-heygen-transport.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.heygen.api_liveavatar import LiveAvatarNewSessionRequest from pipecat.transports.heygen.transport import HeyGenParams, HeyGenTransport, ServiceType @@ -63,7 +63,9 @@ async def main(): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful assistant. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Be succinct and respond to what the user said in a creative and helpful way.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful assistant. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Be succinct and respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/43a-heygen-video-service.py b/examples/foundational/43a-heygen-video-service.py index 5be8f1caa..e4bd0e460 100644 --- a/examples/foundational/43a-heygen-video-service.py +++ b/examples/foundational/43a-heygen-video-service.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.heygen.api_liveavatar import LiveAvatarNewSessionRequest from pipecat.services.heygen.client import ServiceType from pipecat.services.heygen.video import HeyGenVideoService @@ -70,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful assistant. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Be succinct and respond to what the user said in a creative and helpful way.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful assistant. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Be succinct and respond to what the user said in a creative and helpful way.", + ), ) heyGen = HeyGenVideoService( diff --git a/examples/foundational/44-voicemail-detection.py b/examples/foundational/44-voicemail-detection.py index e46c59cc0..ef7d73b38 100644 --- a/examples/foundational/44-voicemail-detection.py +++ b/examples/foundational/44-voicemail-detection.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) classifier_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) diff --git a/examples/foundational/45-before-and-after-events.py b/examples/foundational/45-before-and-after-events.py index db71e283d..c06837a4b 100644 --- a/examples/foundational/45-before-and-after-events.py +++ b/examples/foundational/45-before-and-after-events.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -74,7 +74,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/47-sentry-metrics.py b/examples/foundational/47-sentry-metrics.py index f9983c46f..d024ed73a 100644 --- a/examples/foundational/47-sentry-metrics.py +++ b/examples/foundational/47-sentry-metrics.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -75,7 +75,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), metrics=SentryMetrics(), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/48-service-switcher.py b/examples/foundational/48-service-switcher.py index dd7d9ec82..d0e3f09ec 100644 --- a/examples/foundational/48-service-switcher.py +++ b/examples/foundational/48-service-switcher.py @@ -30,9 +30,9 @@ from pipecat.services.cartesia.stt import CartesiaSTTService from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -118,8 +118,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): system = "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way." - llm_openai = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system) - llm_google = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"), system_instruction=system) + llm_openai = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + settings=OpenAILLMSettings(system_instruction=system), + ) + llm_google = GoogleLLMService( + api_key=os.getenv("GOOGLE_API_KEY"), + settings=GoogleLLMSettings(system_instruction=system), + ) llm_switcher = LLMSwitcher( llms=[llm_openai, llm_google], strategy_type=ServiceSwitcherStrategyManual ) diff --git a/examples/foundational/49a-thinking-anthropic.py b/examples/foundational/49a-thinking-anthropic.py index fa84e7c6c..a222ad19f 100644 --- a/examples/foundational/49a-thinking-anthropic.py +++ b/examples/foundational/49a-thinking-anthropic.py @@ -72,8 +72,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): type="enabled", budget_tokens=2048, ), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/49b-thinking-google.py b/examples/foundational/49b-thinking-google.py index 0fb0a30f0..05ec76f4c 100644 --- a/examples/foundational/49b-thinking-google.py +++ b/examples/foundational/49b-thinking-google.py @@ -69,8 +69,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): thinking_budget=-1, # Dynamic thinking include_thoughts=True, ), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/49c-thinking-functions-anthropic.py b/examples/foundational/49c-thinking-functions-anthropic.py index 4fb66470d..977b49800 100644 --- a/examples/foundational/49c-thinking-functions-anthropic.py +++ b/examples/foundational/49c-thinking-functions-anthropic.py @@ -93,8 +93,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): type="enabled", budget_tokens=2048, ), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) llm.register_direct_function(check_flight_status) diff --git a/examples/foundational/49d-thinking-functions-google.py b/examples/foundational/49d-thinking-functions-google.py index 3963fc387..81b01f744 100644 --- a/examples/foundational/49d-thinking-functions-google.py +++ b/examples/foundational/49d-thinking-functions-google.py @@ -90,8 +90,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): thinking_budget=-1, # Dynamic thinking include_thoughts=True, ), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) llm.register_direct_function(check_flight_status) diff --git a/examples/foundational/52-live-translation.py b/examples/foundational/52-live-translation.py index 15598667f..a90eb3ce4 100644 --- a/examples/foundational/52-live-translation.py +++ b/examples/foundational/52-live-translation.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a live translation assistant. Your sole purpose is to translate English text into Spanish. When you receive English text from the user, immediately translate it into natural, fluent Spanish. Do not add explanations, commentary, or extra information—only provide the Spanish translation of the text you receive.", + settings=OpenAILLMSettings( + system_instruction="You are a live translation assistant. Your sole purpose is to translate English text into Spanish. When you receive English text from the user, immediately translate it into natural, fluent Spanish. Do not add explanations, commentary, or extra information—only provide the Spanish translation of the text you receive.", + ), ) context = LLMContext() diff --git a/examples/foundational/53-concurrent-llm-evaluation.py b/examples/foundational/53-concurrent-llm-evaluation.py index a93ca2ada..0ae0afa18 100644 --- a/examples/foundational/53-concurrent-llm-evaluation.py +++ b/examples/foundational/53-concurrent-llm-evaluation.py @@ -27,7 +27,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -69,13 +69,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): openai_llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) groq_llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - settings=GroqLLMSettings(model="meta-llama/llama-4-maverick-17b-128e-instruct"), - system_instruction="You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", + settings=GroqLLMSettings( + model="meta-llama/llama-4-maverick-17b-128e-instruct", + system_instruction="You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", + ), ) openai_context = LLMContext() diff --git a/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py b/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py index f449269e9..d6b3feac3 100644 --- a/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py +++ b/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py @@ -33,7 +33,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -75,7 +75,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Main LLM — drives the conversation. Its RTVI events reach the client. main_llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # Evaluator LLM — silently grades the user's message in the background. @@ -83,7 +85,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): evaluator_llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), name="EvaluatorLLM", - system_instruction="You are a silent quality evaluator. When given a user message, respond with a single JSON object: {'score': <1-5>, 'reason': ''}. Do not respond conversationally.", + settings=OpenAILLMSettings( + system_instruction="You are a silent quality evaluator. When given a user message, respond with a single JSON object: {'score': <1-5>, 'reason': ''}. Do not respond conversationally.", + ), ) main_context = LLMContext() diff --git a/examples/foundational/54-context-summarization-openai.py b/examples/foundational/54-context-summarization-openai.py index 8c7c38d62..897ed171f 100644 --- a/examples/foundational/54-context-summarization-openai.py +++ b/examples/foundational/54-context-summarization-openai.py @@ -37,7 +37,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -88,7 +88,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You have access to tools to get the current weather - use them when relevant.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You have access to tools to get the current weather - use them when relevant.", + ), ) # Register tool functions diff --git a/examples/foundational/54a-context-summarization-google.py b/examples/foundational/54a-context-summarization-google.py index 21e2ef459..8242ea879 100644 --- a/examples/foundational/54a-context-summarization-google.py +++ b/examples/foundational/54a-context-summarization-google.py @@ -36,7 +36,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google import GoogleLLMService +from pipecat.services.google import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -88,7 +88,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You have access to tools to get the current weather - use them when relevant.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You have access to tools to get the current weather - use them when relevant.", + ), ) # Register tool functions diff --git a/examples/foundational/54b-context-summarization-manual-openai.py b/examples/foundational/54b-context-summarization-manual-openai.py index 0fd2c0bd7..ae1e9bf14 100644 --- a/examples/foundational/54b-context-summarization-manual-openai.py +++ b/examples/foundational/54b-context-summarization-manual-openai.py @@ -37,7 +37,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -92,7 +92,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): that the conversation history has been compressed. """ - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + settings=OpenAILLMSettings( + system_instruction=system_prompt, + ), + ) llm.register_function("summarize_conversation", summarize_conversation) diff --git a/examples/foundational/54c-context-summarization-dedicated-llm.py b/examples/foundational/54c-context-summarization-dedicated-llm.py index ce0f7658f..c3c4a0c2e 100644 --- a/examples/foundational/54c-context-summarization-dedicated-llm.py +++ b/examples/foundational/54c-context-summarization-dedicated-llm.py @@ -40,7 +40,7 @@ from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSetting from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -108,7 +108,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): """ # Primary LLM for conversation (could be any provider) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + settings=OpenAILLMSettings( + system_instruction=system_prompt, + ), + ) # Dedicated cheap/fast LLM for summarization only summarization_llm = GoogleLLMService( diff --git a/examples/foundational/55a-update-settings-deepgram-flux-stt.py b/examples/foundational/55a-update-settings-deepgram-flux-stt.py index 0a507aaed..cd55f3e37 100644 --- a/examples/foundational/55a-update-settings-deepgram-flux-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-flux-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService, DeepgramFluxSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py b/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py index b6f2142bc..af080e9db 100644 --- a/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py @@ -28,7 +28,7 @@ from pipecat.services.deepgram.sagemaker.stt import ( DeepgramSageMakerSTTService, DeepgramSageMakerSTTSettings, ) -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -69,7 +69,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55a-update-settings-deepgram-stt.py b/examples/foundational/55a-update-settings-deepgram-stt.py index b914d8085..0519799f0 100644 --- a/examples/foundational/55a-update-settings-deepgram-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-stt.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55b-update-settings-azure-stt.py b/examples/foundational/55b-update-settings-azure-stt.py index c54b1a0d8..c10f79de4 100644 --- a/examples/foundational/55b-update-settings-azure-stt.py +++ b/examples/foundational/55b-update-settings-azure-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.stt import AzureSTTService, AzureSTTSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55c-update-settings-google-stt.py b/examples/foundational/55c-update-settings-google-stt.py index 23b312f5f..9c67a8039 100644 --- a/examples/foundational/55c-update-settings-google-stt.py +++ b/examples/foundational/55c-update-settings-google-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55d-update-settings-assemblyai-stt.py b/examples/foundational/55d-update-settings-assemblyai-stt.py index 9cd5641fd..1b8ca5eda 100644 --- a/examples/foundational/55d-update-settings-assemblyai-stt.py +++ b/examples/foundational/55d-update-settings-assemblyai-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call demonstrating dynamic keyterms updates. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Try saying difficult names like 'Xiomara', 'Saoirse', or 'Krzystof' to test transcription accuracy.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call demonstrating dynamic keyterms updates. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Try saying difficult names like 'Xiomara', 'Saoirse', or 'Krzystof' to test transcription accuracy.", + ), ) context = LLMContext() diff --git a/examples/foundational/55e-update-settings-gladia-stt.py b/examples/foundational/55e-update-settings-gladia-stt.py index 6cc3fc92a..24e0dfa6f 100644 --- a/examples/foundational/55e-update-settings-gladia-stt.py +++ b/examples/foundational/55e-update-settings-gladia-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py b/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py index ef1e44b61..b1f35de13 100644 --- a/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py +++ b/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py @@ -27,7 +27,7 @@ from pipecat.services.elevenlabs.stt import ( ElevenLabsRealtimeSTTService, ElevenLabsRealtimeSTTSettings, ) -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55g-update-settings-elevenlabs-stt.py b/examples/foundational/55g-update-settings-elevenlabs-stt.py index c3fb9eac9..9896a1652 100644 --- a/examples/foundational/55g-update-settings-elevenlabs-stt.py +++ b/examples/foundational/55g-update-settings-elevenlabs-stt.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.elevenlabs.stt import ElevenLabsSTTService, ElevenLabsSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55h-update-settings-speechmatics-stt.py b/examples/foundational/55h-update-settings-speechmatics-stt.py index 7a0f493a8..01f653c7e 100644 --- a/examples/foundational/55h-update-settings-speechmatics-stt.py +++ b/examples/foundational/55h-update-settings-speechmatics-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -69,7 +69,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55i-update-settings-whisper-api-stt.py b/examples/foundational/55i-update-settings-whisper-api-stt.py index 6b957a0be..d2c81b0bc 100644 --- a/examples/foundational/55i-update-settings-whisper-api-stt.py +++ b/examples/foundational/55i-update-settings-whisper-api-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.openai.stt import OpenAISTTService from pipecat.services.whisper.base_stt import BaseWhisperSTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55j-update-settings-sarvam-stt.py b/examples/foundational/55j-update-settings-sarvam-stt.py index 57ebccab5..982b22b57 100644 --- a/examples/foundational/55j-update-settings-sarvam-stt.py +++ b/examples/foundational/55j-update-settings-sarvam-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.sarvam.stt import SarvamSTTService, SarvamSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55k-update-settings-soniox-stt.py b/examples/foundational/55k-update-settings-soniox-stt.py index ac339e3c1..5fdf0fd82 100644 --- a/examples/foundational/55k-update-settings-soniox-stt.py +++ b/examples/foundational/55k-update-settings-soniox-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.soniox.stt import SonioxSTTService, SonioxSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55l-update-settings-aws-transcribe-stt.py b/examples/foundational/55l-update-settings-aws-transcribe-stt.py index 5594f21d9..07a923616 100644 --- a/examples/foundational/55l-update-settings-aws-transcribe-stt.py +++ b/examples/foundational/55l-update-settings-aws-transcribe-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.stt import AWSTranscribeSTTService, AWSTranscribeSTTSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55m-update-settings-cartesia-stt.py b/examples/foundational/55m-update-settings-cartesia-stt.py index f1a984d9b..e8fc79e94 100644 --- a/examples/foundational/55m-update-settings-cartesia-stt.py +++ b/examples/foundational/55m-update-settings-cartesia-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService, CartesiaSTTSettings from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55n-update-settings-cartesia-http-tts.py b/examples/foundational/55n-update-settings-cartesia-http-tts.py index a58a8a778..9cd935692 100644 --- a/examples/foundational/55n-update-settings-cartesia-http-tts.py +++ b/examples/foundational/55n-update-settings-cartesia-http-tts.py @@ -28,7 +28,7 @@ from pipecat.services.cartesia.tts import ( GenerationConfig, ) from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55n-update-settings-cartesia-tts.py b/examples/foundational/55n-update-settings-cartesia-tts.py index e729c53f2..37ec2e903 100644 --- a/examples/foundational/55n-update-settings-cartesia-tts.py +++ b/examples/foundational/55n-update-settings-cartesia-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings, GenerationConfig from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55o-update-settings-elevenlabs-http-tts.py b/examples/foundational/55o-update-settings-elevenlabs-http-tts.py index c6160d1c2..c8c2af4ab 100644 --- a/examples/foundational/55o-update-settings-elevenlabs-http-tts.py +++ b/examples/foundational/55o-update-settings-elevenlabs-http-tts.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService, ElevenLabsHttpTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55o-update-settings-elevenlabs-tts.py b/examples/foundational/55o-update-settings-elevenlabs-tts.py index 104dd314f..71ff8c0af 100644 --- a/examples/foundational/55o-update-settings-elevenlabs-tts.py +++ b/examples/foundational/55o-update-settings-elevenlabs-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55p-update-settings-openai-tts.py b/examples/foundational/55p-update-settings-openai-tts.py index e108f4949..9a1402a1c 100644 --- a/examples/foundational/55p-update-settings-openai-tts.py +++ b/examples/foundational/55p-update-settings-openai-tts.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55q-update-settings-deepgram-http-tts.py b/examples/foundational/55q-update-settings-deepgram-http-tts.py index 653e2bd63..dd5220c3f 100644 --- a/examples/foundational/55q-update-settings-deepgram-http-tts.py +++ b/examples/foundational/55q-update-settings-deepgram-http-tts.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramHttpTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55q-update-settings-deepgram-sagemaker-tts.py b/examples/foundational/55q-update-settings-deepgram-sagemaker-tts.py index 6cd396d04..b913375bb 100644 --- a/examples/foundational/55q-update-settings-deepgram-sagemaker-tts.py +++ b/examples/foundational/55q-update-settings-deepgram-sagemaker-tts.py @@ -27,7 +27,7 @@ from pipecat.services.deepgram.sagemaker.tts import ( DeepgramSageMakerTTSSettings, ) from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55q-update-settings-deepgram-tts.py b/examples/foundational/55q-update-settings-deepgram-tts.py index 86d37374a..7164c7b58 100644 --- a/examples/foundational/55q-update-settings-deepgram-tts.py +++ b/examples/foundational/55q-update-settings-deepgram-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55r-update-settings-azure-http-tts.py b/examples/foundational/55r-update-settings-azure-http-tts.py index d6b870cc7..148e97f1a 100644 --- a/examples/foundational/55r-update-settings-azure-http-tts.py +++ b/examples/foundational/55r-update-settings-azure-http-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.tts import AzureHttpTTSService, AzureTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55r-update-settings-azure-tts.py b/examples/foundational/55r-update-settings-azure-tts.py index a564a7267..d23d41a89 100644 --- a/examples/foundational/55r-update-settings-azure-tts.py +++ b/examples/foundational/55r-update-settings-azure-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.tts import AzureTTSService, AzureTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55s-update-settings-google-http-tts.py b/examples/foundational/55s-update-settings-google-http-tts.py index 146d5039e..c573bee6f 100644 --- a/examples/foundational/55s-update-settings-google-http-tts.py +++ b/examples/foundational/55s-update-settings-google-http-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.tts import GoogleHttpTTSService, GoogleHttpTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55s-update-settings-google-stream-tts.py b/examples/foundational/55s-update-settings-google-stream-tts.py index 445ab537b..b13cbd063 100644 --- a/examples/foundational/55s-update-settings-google-stream-tts.py +++ b/examples/foundational/55s-update-settings-google-stream-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.tts import GoogleStreamTTSSettings, GoogleTTSService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55u-update-settings-rime-http-tts.py b/examples/foundational/55u-update-settings-rime-http-tts.py index 8515b796e..0c00913e7 100644 --- a/examples/foundational/55u-update-settings-rime-http-tts.py +++ b/examples/foundational/55u-update-settings-rime-http-tts.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.rime.tts import RimeHttpTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55u-update-settings-rime-tts.py b/examples/foundational/55u-update-settings-rime-tts.py index 72c63af8c..cb8e09876 100644 --- a/examples/foundational/55u-update-settings-rime-tts.py +++ b/examples/foundational/55u-update-settings-rime-tts.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.rime.tts import RimeTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55v-update-settings-lmnt-tts.py b/examples/foundational/55v-update-settings-lmnt-tts.py index d0651c84e..48b0f8d43 100644 --- a/examples/foundational/55v-update-settings-lmnt-tts.py +++ b/examples/foundational/55v-update-settings-lmnt-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.lmnt.tts import LmntTTSService, LmntTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55w-update-settings-fish-tts.py b/examples/foundational/55w-update-settings-fish-tts.py index ff95838f7..8243f82f2 100644 --- a/examples/foundational/55w-update-settings-fish-tts.py +++ b/examples/foundational/55w-update-settings-fish-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.fish.tts import FishAudioTTSService, FishAudioTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55x-update-settings-minimax-tts.py b/examples/foundational/55x-update-settings-minimax-tts.py index 66ce52071..fc74bca4c 100644 --- a/examples/foundational/55x-update-settings-minimax-tts.py +++ b/examples/foundational/55x-update-settings-minimax-tts.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.minimax.tts import MiniMaxHttpTTSService, MiniMaxTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55y-update-settings-groq-tts.py b/examples/foundational/55y-update-settings-groq-tts.py index 73e4ac778..632907eaf 100644 --- a/examples/foundational/55y-update-settings-groq-tts.py +++ b/examples/foundational/55y-update-settings-groq-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.groq.tts import GroqTTSService, GroqTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55z-update-settings-hume-tts.py b/examples/foundational/55z-update-settings-hume-tts.py index d01dc78bf..855610b6b 100644 --- a/examples/foundational/55z-update-settings-hume-tts.py +++ b/examples/foundational/55z-update-settings-hume-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.hume.tts import HumeTTSService, HumeTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55za-update-settings-neuphonic-http-tts.py b/examples/foundational/55za-update-settings-neuphonic-http-tts.py index 6c3e510a1..7435b135d 100644 --- a/examples/foundational/55za-update-settings-neuphonic-http-tts.py +++ b/examples/foundational/55za-update-settings-neuphonic-http-tts.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService, NeuphonicTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55za-update-settings-neuphonic-tts.py b/examples/foundational/55za-update-settings-neuphonic-tts.py index e79ac666f..c0566e86b 100644 --- a/examples/foundational/55za-update-settings-neuphonic-tts.py +++ b/examples/foundational/55za-update-settings-neuphonic-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.neuphonic.tts import NeuphonicTTSService, NeuphonicTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zb-update-settings-inworld-http-tts.py b/examples/foundational/55zb-update-settings-inworld-http-tts.py index ccba1238c..4a2e2a2bc 100644 --- a/examples/foundational/55zb-update-settings-inworld-http-tts.py +++ b/examples/foundational/55zb-update-settings-inworld-http-tts.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.inworld.tts import InworldHttpTTSService, InworldTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zb-update-settings-inworld-tts.py b/examples/foundational/55zb-update-settings-inworld-tts.py index e60e65036..7fcaf67bd 100644 --- a/examples/foundational/55zb-update-settings-inworld-tts.py +++ b/examples/foundational/55zb-update-settings-inworld-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.inworld.tts import InworldTTSService, InworldTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zc-update-settings-gemini-tts.py b/examples/foundational/55zc-update-settings-gemini-tts.py index 99a91d176..2d2f15cda 100644 --- a/examples/foundational/55zc-update-settings-gemini-tts.py +++ b/examples/foundational/55zc-update-settings-gemini-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.tts import GeminiTTSService, GeminiTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zd-update-settings-aws-polly-tts.py b/examples/foundational/55zd-update-settings-aws-polly-tts.py index 3b1c1d734..1f6ce56b2 100644 --- a/examples/foundational/55zd-update-settings-aws-polly-tts.py +++ b/examples/foundational/55zd-update-settings-aws-polly-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55ze-update-settings-sarvam-http-tts.py b/examples/foundational/55ze-update-settings-sarvam-http-tts.py index ffcf086c6..811ffceb8 100644 --- a/examples/foundational/55ze-update-settings-sarvam-http-tts.py +++ b/examples/foundational/55ze-update-settings-sarvam-http-tts.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.sarvam.tts import SarvamHttpTTSService, SarvamHttpTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55ze-update-settings-sarvam-tts.py b/examples/foundational/55ze-update-settings-sarvam-tts.py index 44301578f..b36e6f81f 100644 --- a/examples/foundational/55ze-update-settings-sarvam-tts.py +++ b/examples/foundational/55ze-update-settings-sarvam-tts.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.sarvam.tts import SarvamTTSService, SarvamTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zf-update-settings-camb-tts.py b/examples/foundational/55zf-update-settings-camb-tts.py index f8058141d..493ad0917 100644 --- a/examples/foundational/55zf-update-settings-camb-tts.py +++ b/examples/foundational/55zf-update-settings-camb-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.camb.tts import CambTTSService, CambTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zh-update-settings-resembleai-tts.py b/examples/foundational/55zh-update-settings-resembleai-tts.py index 8428357b5..2c5ef3b25 100644 --- a/examples/foundational/55zh-update-settings-resembleai-tts.py +++ b/examples/foundational/55zh-update-settings-resembleai-tts.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.resembleai.tts import ResembleAITTSService, ResembleAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zi-update-settings-azure-llm.py b/examples/foundational/55zi-update-settings-azure-llm.py index b7fe5d745..5093ba560 100644 --- a/examples/foundational/55zi-update-settings-azure-llm.py +++ b/examples/foundational/55zi-update-settings-azure-llm.py @@ -63,8 +63,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AzureLLMService( api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), - settings=AzureLLMSettings(model=os.getenv("AZURE_CHATGPT_MODEL")), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AzureLLMSettings( + model=os.getenv("AZURE_CHATGPT_MODEL"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zi-update-settings-openai-llm.py b/examples/foundational/55zi-update-settings-openai-llm.py index 123fc7a04..6af897217 100644 --- a/examples/foundational/55zi-update-settings-openai-llm.py +++ b/examples/foundational/55zi-update-settings-openai-llm.py @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zj-update-settings-anthropic-llm.py b/examples/foundational/55zj-update-settings-anthropic-llm.py index d44102f2d..8417d0dcd 100644 --- a/examples/foundational/55zj-update-settings-anthropic-llm.py +++ b/examples/foundational/55zj-update-settings-anthropic-llm.py @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=AnthropicLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zk-update-settings-google-llm.py b/examples/foundational/55zk-update-settings-google-llm.py index d1222e422..94b15c886 100644 --- a/examples/foundational/55zk-update-settings-google-llm.py +++ b/examples/foundational/55zk-update-settings-google-llm.py @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GoogleLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zk-update-settings-google-vertex-llm.py b/examples/foundational/55zk-update-settings-google-vertex-llm.py index aa9452d09..1158c4635 100644 --- a/examples/foundational/55zk-update-settings-google-vertex-llm.py +++ b/examples/foundational/55zk-update-settings-google-vertex-llm.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMSettings -from pipecat.services.google.llm_vertex import GoogleVertexLLMService +from pipecat.services.google.llm_vertex import GoogleVertexLLMService, GoogleVertexLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), location=os.getenv("GOOGLE_CLOUD_LOCATION"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GoogleVertexLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py index 3d5d93b6a..f4f8f8815 100644 --- a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py +++ b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py @@ -64,8 +64,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): settings=AWSBedrockLLMSettings( model="us.anthropic.claude-haiku-4-5-20251001-v1:0", temperature=0.8, + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) context = LLMContext() diff --git a/examples/foundational/55zq-update-settings-fal-stt.py b/examples/foundational/55zq-update-settings-fal-stt.py index 96f916d81..0811523f0 100644 --- a/examples/foundational/55zq-update-settings-fal-stt.py +++ b/examples/foundational/55zq-update-settings-fal-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.fal.stt import FalSTTService, FalSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zr-update-settings-gradium-stt.py b/examples/foundational/55zr-update-settings-gradium-stt.py index 0b3085125..952f2bb26 100644 --- a/examples/foundational/55zr-update-settings-gradium-stt.py +++ b/examples/foundational/55zr-update-settings-gradium-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py b/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py index 55a6719be..b46096e0b 100644 --- a/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py +++ b/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.nvidia.stt import NvidiaSegmentedSTTService, NvidiaSegmentedSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zt-update-settings-nvidia-stt.py b/examples/foundational/55zt-update-settings-nvidia-stt.py index 2f15895d2..2efa824c3 100644 --- a/examples/foundational/55zt-update-settings-nvidia-stt.py +++ b/examples/foundational/55zt-update-settings-nvidia-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.nvidia.stt import NvidiaSTTService, NvidiaSTTSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zu-update-settings-openai-realtime-stt.py b/examples/foundational/55zu-update-settings-openai-realtime-stt.py index 7cc31085b..9f0e1dc89 100644 --- a/examples/foundational/55zu-update-settings-openai-realtime-stt.py +++ b/examples/foundational/55zu-update-settings-openai-realtime-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zv-update-settings-asyncai-http-tts.py b/examples/foundational/55zv-update-settings-asyncai-http-tts.py index 2063cda3a..29a774fae 100644 --- a/examples/foundational/55zv-update-settings-asyncai-http-tts.py +++ b/examples/foundational/55zv-update-settings-asyncai-http-tts.py @@ -26,7 +26,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.asyncai.tts import AsyncAIHttpTTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zv-update-settings-asyncai-tts.py b/examples/foundational/55zv-update-settings-asyncai-tts.py index 10cace018..b9c35ebbd 100644 --- a/examples/foundational/55zv-update-settings-asyncai-tts.py +++ b/examples/foundational/55zv-update-settings-asyncai-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.asyncai.tts import AsyncAITTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zw-update-settings-gradium-tts.py b/examples/foundational/55zw-update-settings-gradium-tts.py index 5c33e090a..52f7c73c5 100644 --- a/examples/foundational/55zw-update-settings-gradium-tts.py +++ b/examples/foundational/55zw-update-settings-gradium-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.gradium.tts import GradiumTTSService, GradiumTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zx-update-settings-cerebras-llm.py b/examples/foundational/55zx-update-settings-cerebras-llm.py index dc09cdae7..c6d27d8e5 100644 --- a/examples/foundational/55zx-update-settings-cerebras-llm.py +++ b/examples/foundational/55zx-update-settings-cerebras-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings -from pipecat.services.cerebras.llm import CerebrasLLMService +from pipecat.services.cerebras.llm import CerebrasLLMService, CerebrasLLMSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = CerebrasLLMService( api_key=os.getenv("CEREBRAS_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=CerebrasLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zy-update-settings-deepseek-llm.py b/examples/foundational/55zy-update-settings-deepseek-llm.py index fe6e18185..23e314f8b 100644 --- a/examples/foundational/55zy-update-settings-deepseek-llm.py +++ b/examples/foundational/55zy-update-settings-deepseek-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepseek.llm import DeepSeekLLMService +from pipecat.services.deepseek.llm import DeepSeekLLMService, DeepSeekLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = DeepSeekLLMService( api_key=os.getenv("DEEPSEEK_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=DeepSeekLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zz-update-settings-fireworks-llm.py b/examples/foundational/55zz-update-settings-fireworks-llm.py index 56d29cfac..9ea0c9343 100644 --- a/examples/foundational/55zz-update-settings-fireworks-llm.py +++ b/examples/foundational/55zz-update-settings-fireworks-llm.py @@ -62,8 +62,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = FireworksLLMService( api_key=os.getenv("FIREWORKS_API_KEY"), - settings=FireworksLLMSettings(model="accounts/fireworks/models/gpt-oss-20b"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=FireworksLLMSettings( + model="accounts/fireworks/models/gpt-oss-20b", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zza-update-settings-grok-llm.py b/examples/foundational/55zza-update-settings-grok-llm.py index c40f40ac6..ca537a705 100644 --- a/examples/foundational/55zza-update-settings-grok-llm.py +++ b/examples/foundational/55zza-update-settings-grok-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.grok.llm import GrokLLMService +from pipecat.services.grok.llm import GrokLLMService, GrokLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GrokLLMService( api_key=os.getenv("GROK_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GrokLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzb-update-settings-groq-llm.py b/examples/foundational/55zzb-update-settings-groq-llm.py index 35cec306f..3f2ffdb79 100644 --- a/examples/foundational/55zzb-update-settings-groq-llm.py +++ b/examples/foundational/55zzb-update-settings-groq-llm.py @@ -62,8 +62,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - settings=GroqLLMSettings(model="meta-llama/llama-4-maverick-17b-128e-instruct"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GroqLLMSettings( + model="meta-llama/llama-4-maverick-17b-128e-instruct", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzc-update-settings-mistral-llm.py b/examples/foundational/55zzc-update-settings-mistral-llm.py index f6fa824d4..b9d591146 100644 --- a/examples/foundational/55zzc-update-settings-mistral-llm.py +++ b/examples/foundational/55zzc-update-settings-mistral-llm.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.mistral.llm import MistralLLMService +from pipecat.services.mistral.llm import MistralLLMService, MistralLLMSettings from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = MistralLLMService( api_key=os.getenv("MISTRAL_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=MistralLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzd-update-settings-nvidia-llm.py b/examples/foundational/55zzd-update-settings-nvidia-llm.py index 68d168461..389b51f06 100644 --- a/examples/foundational/55zzd-update-settings-nvidia-llm.py +++ b/examples/foundational/55zzd-update-settings-nvidia-llm.py @@ -62,8 +62,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = NvidiaLLMService( api_key=os.getenv("NVIDIA_API_KEY"), - settings=NvidiaLLMSettings(model="meta/llama-3.1-405b-instruct"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=NvidiaLLMSettings( + model="meta/llama-3.1-405b-instruct", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zze-update-settings-ollama-llm.py b/examples/foundational/55zze-update-settings-ollama-llm.py index 8a3a5f973..d413267a3 100644 --- a/examples/foundational/55zze-update-settings-ollama-llm.py +++ b/examples/foundational/55zze-update-settings-ollama-llm.py @@ -61,8 +61,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OLLamaLLMService( - settings=OllamaLLMSettings(model="llama3.2"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OllamaLLMSettings( + model="llama3.2", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) # Update to the model you're running locally context = LLMContext() diff --git a/examples/foundational/55zzf-update-settings-openrouter-llm.py b/examples/foundational/55zzf-update-settings-openrouter-llm.py index c31a7c43c..c34d885f1 100644 --- a/examples/foundational/55zzf-update-settings-openrouter-llm.py +++ b/examples/foundational/55zzf-update-settings-openrouter-llm.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings -from pipecat.services.openrouter.llm import OpenRouterLLMService +from pipecat.services.openrouter.llm import OpenRouterLLMService, OpenRouterLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenRouterLLMService( api_key=os.getenv("OPENROUTER_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenRouterLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzh-update-settings-qwen-llm.py b/examples/foundational/55zzh-update-settings-qwen-llm.py index dd95308ec..584cb23ea 100644 --- a/examples/foundational/55zzh-update-settings-qwen-llm.py +++ b/examples/foundational/55zzh-update-settings-qwen-llm.py @@ -62,8 +62,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = QwenLLMService( api_key=os.getenv("QWEN_API_KEY"), - settings=QwenLLMSettings(model="qwen2.5-72b-instruct"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=QwenLLMSettings( + model="qwen2.5-72b-instruct", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzi-update-settings-sambanova-llm.py b/examples/foundational/55zzi-update-settings-sambanova-llm.py index cececc078..dc246f2cd 100644 --- a/examples/foundational/55zzi-update-settings-sambanova-llm.py +++ b/examples/foundational/55zzi-update-settings-sambanova-llm.py @@ -25,7 +25,7 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings -from pipecat.services.sambanova.llm import SambaNovaLLMService +from pipecat.services.sambanova.llm import SambaNovaLLMService, SambaNovaLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = SambaNovaLLMService( api_key=os.getenv("SAMBANOVA_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=SambaNovaLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzj-update-settings-together-llm.py b/examples/foundational/55zzj-update-settings-together-llm.py index c3cfafea2..bd855bcff 100644 --- a/examples/foundational/55zzj-update-settings-together-llm.py +++ b/examples/foundational/55zzj-update-settings-together-llm.py @@ -62,8 +62,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = TogetherLLMService( api_key=os.getenv("TOGETHER_API_KEY"), - settings=TogetherLLMSettings(model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=TogetherLLMSettings( + model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzl-update-settings-nvidia-tts.py b/examples/foundational/55zzl-update-settings-nvidia-tts.py index 5bc89bd58..e667a9ca3 100644 --- a/examples/foundational/55zzl-update-settings-nvidia-tts.py +++ b/examples/foundational/55zzl-update-settings-nvidia-tts.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.nvidia.tts import NvidiaTTSService, NvidiaTTSSettings -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzm-update-settings-speechmatics-tts.py b/examples/foundational/55zzm-update-settings-speechmatics-tts.py index d9eaaec86..2e8bb46a6 100644 --- a/examples/foundational/55zzm-update-settings-speechmatics-tts.py +++ b/examples/foundational/55zzm-update-settings-speechmatics-tts.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.speechmatics.tts import SpeechmaticsTTSService, SpeechmaticsTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/55zzn-update-settings-groq-stt.py b/examples/foundational/55zzn-update-settings-groq-stt.py index 7a8551be2..d6dac9e1f 100644 --- a/examples/foundational/55zzn-update-settings-groq-stt.py +++ b/examples/foundational/55zzn-update-settings-groq-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.groq.stt import GroqSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.whisper.base_stt import BaseWhisperSTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=OpenAILLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) context = LLMContext() diff --git a/examples/foundational/56-lemonslice-transport.py b/examples/foundational/56-lemonslice-transport.py index 6085f3b00..8dc400841 100644 --- a/examples/foundational/56-lemonslice-transport.py +++ b/examples/foundational/56-lemonslice-transport.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.transports.lemonslice.transport import ( LemonSliceNewSessionRequest, LemonSliceParams, @@ -57,7 +57,9 @@ async def main(): llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + settings=GroqLLMSettings( + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ), ) tts = ElevenLabsTTSService( diff --git a/src/pipecat/services/anthropic/llm.py b/src/pipecat/services/anthropic/llm.py index 170c7e425..369c2a4ed 100644 --- a/src/pipecat/services/anthropic/llm.py +++ b/src/pipecat/services/anthropic/llm.py @@ -223,7 +223,6 @@ class AnthropicLLMService(LLMService): client=None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, - system_instruction: Optional[str] = None, **kwargs, ): """Initialize the Anthropic LLM service. @@ -246,12 +245,12 @@ class AnthropicLLMService(LLMService): client: Optional custom Anthropic client instance. retry_timeout_secs: Request timeout in seconds for retry logic. retry_on_timeout: Whether to retry the request once if it times out. - system_instruction: Optional system instruction to use as the system prompt. **kwargs: Additional arguments passed to parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults default_settings = AnthropicLLMSettings( model="claude-sonnet-4-6", + system_instruction=None, max_tokens=4096, enable_prompt_caching=False, temperature=NOT_GIVEN, @@ -309,9 +308,8 @@ class AnthropicLLMService(LLMService): ) # if the client is provided, use it and remove it, otherwise create a new one self._retry_timeout_secs = retry_timeout_secs self._retry_on_timeout = retry_on_timeout - self._system_instruction = system_instruction - if self._system_instruction: - logger.debug(f"{self}: Using system instruction: {self._system_instruction}") + if self._settings.system_instruction: + logger.debug(f"{self}: Using system instruction: {self._settings.system_instruction}") def can_generate_metrics(self) -> bool: """Check if this service can generate usage metrics. @@ -445,13 +443,13 @@ class AnthropicLLMService(LLMService): params: AnthropicLLMInvocationParams = adapter.get_llm_invocation_params( context, enable_prompt_caching=self._settings.enable_prompt_caching ) - if self._system_instruction: + if self._settings.system_instruction: if params["system"] is not NOT_GIVEN: logger.warning( f"{self}: Both system_instruction and a system message in context are" " set. Using system_instruction." ) - params["system"] = self._system_instruction + params["system"] = self._settings.system_instruction return params # Anthropic-specific context diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index 3b0392a0e..34a0dd780 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -788,7 +788,6 @@ class AWSBedrockLLMService(LLMService): client_config: Optional[Config] = None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, - system_instruction: Optional[str] = None, **kwargs, ): """Initialize the AWS Bedrock LLM service. @@ -819,12 +818,12 @@ class AWSBedrockLLMService(LLMService): client_config: Custom boto3 client configuration. retry_timeout_secs: Request timeout in seconds for retry logic. retry_on_timeout: Whether to retry the request once if it times out. - system_instruction: Optional system instruction to use as the system prompt. **kwargs: Additional arguments passed to parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults default_settings = AWSBedrockLLMSettings( model="us.amazon.nova-lite-v1:0", + system_instruction=None, max_tokens=None, temperature=None, top_p=None, @@ -889,11 +888,10 @@ class AWSBedrockLLMService(LLMService): self._retry_timeout_secs = retry_timeout_secs self._retry_on_timeout = retry_on_timeout - self._system_instruction = system_instruction logger.info(f"Using AWS Bedrock model: {self._settings.model}") - if self._system_instruction: - logger.debug(f"{self}: Using system instruction: {self._system_instruction}") + if self._settings.system_instruction: + logger.debug(f"{self}: Using system instruction: {self._settings.system_instruction}") def can_generate_metrics(self) -> bool: """Check if the service can generate usage metrics. @@ -1074,13 +1072,13 @@ class AWSBedrockLLMService(LLMService): if isinstance(context, LLMContext): adapter: AWSBedrockLLMAdapter = self.get_llm_adapter() params: AWSBedrockLLMInvocationParams = adapter.get_llm_invocation_params(context) - if self._system_instruction: + if self._settings.system_instruction: if params["system"]: logger.warning( f"{self}: Both system_instruction and a system message in context are" " set. Using system_instruction." ) - params["system"] = [{"text": self._system_instruction}] + params["system"] = [{"text": self._settings.system_instruction}] return params # AWS Bedrock-specific context diff --git a/src/pipecat/services/cerebras/llm.py b/src/pipecat/services/cerebras/llm.py index d98a2d7a4..c3b56ff29 100644 --- a/src/pipecat/services/cerebras/llm.py +++ b/src/pipecat/services/cerebras/llm.py @@ -111,4 +111,12 @@ class CerebrasLLMService(OpenAILLMService): params.update(params_from_context) params.update(self._settings.extra) + + # Prepend system instruction if set + if self._settings.system_instruction: + messages = params.get("messages", []) + params["messages"] = [ + {"role": "system", "content": self._settings.system_instruction} + ] + messages + return params diff --git a/src/pipecat/services/fireworks/llm.py b/src/pipecat/services/fireworks/llm.py index 86665cc48..ccc9107f6 100644 --- a/src/pipecat/services/fireworks/llm.py +++ b/src/pipecat/services/fireworks/llm.py @@ -112,4 +112,12 @@ class FireworksLLMService(OpenAILLMService): params.update(params_from_context) params.update(self._settings.extra) + + # Prepend system instruction if set + if self._settings.system_instruction: + messages = params.get("messages", []) + params["messages"] = [ + {"role": "system", "content": self._settings.system_instruction} + ] + messages + return params diff --git a/src/pipecat/services/google/llm.py b/src/pipecat/services/google/llm.py index 49e6d2366..980d2d576 100644 --- a/src/pipecat/services/google/llm.py +++ b/src/pipecat/services/google/llm.py @@ -809,6 +809,9 @@ class GoogleLLMService(LLMService): deprecated parameters and *settings* are provided, *settings* values take precedence. system_instruction: System instruction/prompt for the model. + + .. deprecated:: 0.0.105 + Use ``settings=GoogleLLMSettings(system_instruction=...)`` instead. tools: List of available tools/functions. tool_config: Configuration for tool usage. http_options: HTTP options for the client. @@ -817,6 +820,7 @@ class GoogleLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleLLMSettings( model="gemini-2.5-flash", + system_instruction=None, max_tokens=4096, temperature=None, top_k=None, @@ -834,6 +838,9 @@ class GoogleLLMService(LLMService): if model is not None: _warn_deprecated_param("model", GoogleLLMSettings, "model") default_settings.model = model + if system_instruction is not None: + _warn_deprecated_param("system_instruction", GoogleLLMSettings, "system_instruction") + default_settings.system_instruction = system_instruction # 3. Apply params overrides — only if settings not provided if params is not None: @@ -854,7 +861,6 @@ class GoogleLLMService(LLMService): super().__init__(settings=default_settings, **kwargs) self._api_key = api_key - self._system_instruction = system_instruction self._http_options = update_google_client_http_options(http_options) self._tools = tools self._tool_config = tool_config @@ -993,10 +999,10 @@ class GoogleLLMService(LLMService): messages = params_from_context["messages"] if ( params_from_context["system_instruction"] - and self._system_instruction != params_from_context["system_instruction"] + and self._settings.system_instruction != params_from_context["system_instruction"] ): logger.debug(f"System instruction changed: {params_from_context['system_instruction']}") - self._system_instruction = params_from_context["system_instruction"] + self._settings.system_instruction = params_from_context["system_instruction"] tools = [] if params_from_context["tools"]: @@ -1009,7 +1015,9 @@ class GoogleLLMService(LLMService): # Build generation parameters generation_params = self._build_generation_params( - system_instruction=self._system_instruction, tools=tools, tool_config=tool_config + system_instruction=self._settings.system_instruction, + tools=tools, + tool_config=tool_config, ) # possibly modify generation_params (in place) to set thinking to off by default diff --git a/src/pipecat/services/google/llm_vertex.py b/src/pipecat/services/google/llm_vertex.py index 27f168042..42d96333c 100644 --- a/src/pipecat/services/google/llm_vertex.py +++ b/src/pipecat/services/google/llm_vertex.py @@ -142,6 +142,9 @@ class GoogleVertexLLMService(GoogleLLMService): deprecated parameters and *settings* are provided, *settings* values take precedence. system_instruction: System instruction/prompt for the model. + + .. deprecated:: 0.0.105 + Use ``settings=GoogleVertexLLMSettings(system_instruction=...)`` instead. tools: List of available tools/functions. tool_config: Configuration for tool usage. http_options: HTTP options for the client. @@ -195,6 +198,7 @@ class GoogleVertexLLMService(GoogleLLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = GoogleVertexLLMSettings( model="gemini-2.5-flash", + system_instruction=None, max_tokens=4096, temperature=None, top_k=None, @@ -212,6 +216,11 @@ class GoogleVertexLLMService(GoogleLLMService): if model is not None: _warn_deprecated_param("model", GoogleVertexLLMSettings, "model") default_settings.model = model + if system_instruction is not None: + _warn_deprecated_param( + "system_instruction", GoogleVertexLLMSettings, "system_instruction" + ) + default_settings.system_instruction = system_instruction # 3. Apply params overrides — only if settings not provided if params is not None: @@ -234,7 +243,6 @@ class GoogleVertexLLMService(GoogleLLMService): super().__init__( api_key="dummy", settings=default_settings, - system_instruction=system_instruction, tools=tools, tool_config=tool_config, http_options=http_options, diff --git a/src/pipecat/services/mistral/llm.py b/src/pipecat/services/mistral/llm.py index 801c02f9e..647a56bca 100644 --- a/src/pipecat/services/mistral/llm.py +++ b/src/pipecat/services/mistral/llm.py @@ -231,4 +231,11 @@ class MistralLLMService(OpenAILLMService): # Add any extra parameters params.update(self._settings.extra) + # Prepend system instruction if set + if self._settings.system_instruction: + messages = params.get("messages", []) + params["messages"] = [ + {"role": "system", "content": self._settings.system_instruction} + ] + messages + return params diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index cf4101305..5e59a5129 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -121,7 +121,6 @@ class BaseOpenAILLMService(LLMService): settings: Optional[OpenAILLMSettings] = None, retry_timeout_secs: Optional[float] = 5.0, retry_on_timeout: Optional[bool] = False, - system_instruction: Optional[str] = None, **kwargs, ): """Initialize the BaseOpenAILLMService. @@ -147,12 +146,12 @@ class BaseOpenAILLMService(LLMService): parameters, ``settings`` values take precedence. retry_timeout_secs: Request timeout in seconds. Defaults to 5.0 seconds. retry_on_timeout: Whether to retry the request once if it times out. - system_instruction: Optional system instruction to prepend to messages. **kwargs: Additional arguments passed to the parent LLMService. """ # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAILLMSettings( model="gpt-4o", + system_instruction=None, frequency_penalty=NOT_GIVEN, presence_penalty=NOT_GIVEN, seed=NOT_GIVEN, @@ -193,7 +192,6 @@ class BaseOpenAILLMService(LLMService): self._service_tier = service_tier self._retry_timeout_secs = retry_timeout_secs self._retry_on_timeout = retry_on_timeout - self._system_instruction = system_instruction self._full_model_name: str = "" self._client = self.create_client( api_key=api_key, @@ -204,8 +202,8 @@ class BaseOpenAILLMService(LLMService): **kwargs, ) - if self._system_instruction: - logger.debug(f"{self}: Using system instruction: {self._system_instruction}") + if self._settings.system_instruction: + logger.debug(f"{self}: Using system instruction: {self._settings.system_instruction}") def create_client( self, @@ -329,7 +327,7 @@ class BaseOpenAILLMService(LLMService): params.update(self._settings.extra) # Prepend system instruction from constructor, replacing any context system message - if self._system_instruction: + if self._settings.system_instruction: messages = params.get("messages", []) if messages and messages[0].get("role") == "system": logger.warning( @@ -337,7 +335,7 @@ class BaseOpenAILLMService(LLMService): " Using system_instruction." ) params["messages"] = [ - {"role": "system", "content": self._system_instruction} + {"role": "system", "content": self._settings.system_instruction} ] + messages return params diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index f2e3ad00a..ab1384a4c 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -102,6 +102,7 @@ class OpenAILLMService(BaseOpenAILLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAILLMSettings( model="gpt-4.1", + system_instruction=None, frequency_penalty=NOT_GIVEN, presence_penalty=NOT_GIVEN, seed=NOT_GIVEN, diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index 9969020c5..137fdeeb9 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -114,6 +114,13 @@ class PerplexityLLMService(OpenAILLMService): if self._settings.max_tokens is not None: params["max_tokens"] = self._settings.max_tokens + # Prepend system instruction if set + if self._settings.system_instruction: + messages = params.get("messages", []) + params["messages"] = [ + {"role": "system", "content": self._settings.system_instruction} + ] + messages + return params async def _process_context(self, context: OpenAILLMContext | LLMContext): diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index cdd2139da..0c92db098 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -128,6 +128,14 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore params.update(params_from_context) params.update(self._settings.extra) + + # Prepend system instruction if set + if self._settings.system_instruction: + messages = params.get("messages", []) + params["messages"] = [ + {"role": "system", "content": self._settings.system_instruction} + ] + messages + return params @traced_llm # type: ignore diff --git a/src/pipecat/services/settings.py b/src/pipecat/services/settings.py index d9ec5bc7b..c9a120972 100644 --- a/src/pipecat/services/settings.py +++ b/src/pipecat/services/settings.py @@ -395,6 +395,7 @@ class LLMSettings(ServiceSettings): Parameters: model: LLM model identifier. + system_instruction: System instruction/prompt for the model. temperature: Sampling temperature. max_tokens: Maximum tokens to generate. top_p: Nucleus sampling probability. @@ -411,6 +412,7 @@ class LLMSettings(ServiceSettings): and prompts for incomplete turns. """ + system_instruction: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) max_tokens: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) top_p: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) From a1641f37625a6a85af5a9ee2a51f51b5296bcb52 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Thu, 5 Mar 2026 15:33:41 -0500 Subject: [PATCH 16/17] Add `system_instruction` to realtime service settings Add `system_instruction=None` to `default_settings` for OpenAIRealtimeLLMService, GrokRealtimeLLMService, UltravoxRealtimeLLMService, AWSNovaSonicLLMService (Azure inherits from OpenAI), and OpenAIRealtimeBetaLLMService (Azure Beta inherits from OpenAI Beta). Deprecate `system_instruction` init arg in AWSNovaSonicLLMService in favor of `settings=AWSNovaSonicLLMSettings(system_instruction=...)`. Use `self._settings.system_instruction` directly instead of storing a separate `self._system_instruction`. Deprecation of `params` and `session_properties` in favor of `settings` for realtime services will be tackled in future work. --- src/pipecat/services/aws/nova_sonic/llm.py | 14 +++++++++++--- src/pipecat/services/grok/realtime/llm.py | 1 + src/pipecat/services/openai/realtime/llm.py | 1 + .../services/openai_realtime_beta/openai.py | 1 + src/pipecat/services/ultravox/llm.py | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/aws/nova_sonic/llm.py b/src/pipecat/services/aws/nova_sonic/llm.py index 9103ebdfd..fd13fe56e 100644 --- a/src/pipecat/services/aws/nova_sonic/llm.py +++ b/src/pipecat/services/aws/nova_sonic/llm.py @@ -261,6 +261,9 @@ class AWSNovaSonicLLMService(LLMService): deprecated top-level parameters, the ``settings`` values take precedence. system_instruction: System-level instruction for the model. + + .. deprecated:: 0.0.105 + Use ``settings=AWSNovaSonicLLMSettings(system_instruction=...)`` instead. tools: Available tools/functions for the model to use. send_transcription_frames: Whether to emit transcription frames. @@ -273,6 +276,7 @@ class AWSNovaSonicLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = AWSNovaSonicLLMSettings( model="amazon.nova-2-sonic-v1:0", + system_instruction=None, voice="matthew", temperature=0.7, max_tokens=1024, @@ -293,6 +297,11 @@ class AWSNovaSonicLLMService(LLMService): if voice_id != "matthew": _warn_deprecated_param("voice_id", AWSNovaSonicLLMSettings, "voice") default_settings.voice = voice_id + if system_instruction is not None: + _warn_deprecated_param( + "system_instruction", AWSNovaSonicLLMSettings, "system_instruction" + ) + default_settings.system_instruction = system_instruction # 3. Apply params overrides — only if settings not provided if params is not None: @@ -325,7 +334,6 @@ class AWSNovaSonicLLMService(LLMService): self._output_sample_rate = _audio_params.output_sample_rate self._output_sample_size = _audio_params.output_sample_size self._output_channel_count = _audio_params.output_channel_count - self._system_instruction = system_instruction self._tools = tools # Validate endpointing_sensitivity parameter @@ -625,11 +633,11 @@ class AWSNovaSonicLLMService(LLMService): await self._send_prompt_start_event(tools) # Send system instruction. - # Instruction from context takes priority over self._system_instruction. + # Instruction from context takes priority over self._settings.system_instruction. system_instruction = ( llm_connection_params["system_instruction"] if llm_connection_params["system_instruction"] - else self._system_instruction + else self._settings.system_instruction ) logger.debug(f"Using system instruction: {system_instruction}") if system_instruction: diff --git a/src/pipecat/services/grok/realtime/llm.py b/src/pipecat/services/grok/realtime/llm.py index 638477b5e..074b44c5d 100644 --- a/src/pipecat/services/grok/realtime/llm.py +++ b/src/pipecat/services/grok/realtime/llm.py @@ -144,6 +144,7 @@ class GrokRealtimeLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = GrokRealtimeLLMSettings( model=None, + system_instruction=None, temperature=None, max_tokens=None, top_p=None, diff --git a/src/pipecat/services/openai/realtime/llm.py b/src/pipecat/services/openai/realtime/llm.py index 761d7244b..b5d9dc8e2 100644 --- a/src/pipecat/services/openai/realtime/llm.py +++ b/src/pipecat/services/openai/realtime/llm.py @@ -170,6 +170,7 @@ class OpenAIRealtimeLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAIRealtimeLLMSettings( model="gpt-realtime-1.5", + system_instruction=None, temperature=None, max_tokens=None, top_p=None, diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index 67a892e6f..a3f8e47fc 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -158,6 +158,7 @@ class OpenAIRealtimeBetaLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = OpenAIRealtimeBetaLLMSettings( model="gpt-4o-realtime-preview-2025-06-03", + system_instruction=None, temperature=None, max_tokens=None, top_p=None, diff --git a/src/pipecat/services/ultravox/llm.py b/src/pipecat/services/ultravox/llm.py index 094d22827..eccc1a864 100644 --- a/src/pipecat/services/ultravox/llm.py +++ b/src/pipecat/services/ultravox/llm.py @@ -189,6 +189,7 @@ class UltravoxRealtimeLLMService(LLMService): # 1. Initialize default_settings with hardcoded defaults default_settings = UltravoxRealtimeLLMSettings( model=None, + system_instruction=None, temperature=None, max_tokens=None, top_p=None, From 5b270fec8e1cdcf4001c4b7060a118129308fc5a Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Thu, 5 Mar 2026 16:09:24 -0500 Subject: [PATCH 17/17] In AWS Nova Sonic examples, migrate to newer pattern of passing in `settings` with `voice` and `system_instruction`, in favor of passing in `voice_id` as a direct init arg and the system instruction as the first message in the context --- .../20e-persistent-context-aws-nova-sonic.py | 10 +++++----- examples/foundational/40-aws-nova-sonic.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/foundational/20e-persistent-context-aws-nova-sonic.py b/examples/foundational/20e-persistent-context-aws-nova-sonic.py index 69ffb86b6..7efa2678c 100644 --- a/examples/foundational/20e-persistent-context-aws-nova-sonic.py +++ b/examples/foundational/20e-persistent-context-aws-nova-sonic.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService +from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService, AWSNovaSonicLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -222,9 +222,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), region=os.getenv("AWS_REGION"), # as of 2025-05-06, us-east-1 is the only supported region - voice_id="tiffany", # matthew, tiffany, amy - # you could choose to pass instruction here rather than via context - # system_instruction=system_instruction, + settings=AWSNovaSonicLLMSettings( + voice="tiffany", # matthew, tiffany, amy + system_instruction=system_instruction, + ), # you could choose to pass tools here rather than via context # tools=tools ) @@ -236,7 +237,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): context = LLMContext( messages=[ - {"role": "system", "content": f"{system_instruction}"}, {"role": "user", "content": "Hello!"}, ], tools=tools, diff --git a/examples/foundational/40-aws-nova-sonic.py b/examples/foundational/40-aws-nova-sonic.py index 1bfa6063e..0bb670d4b 100644 --- a/examples/foundational/40-aws-nova-sonic.py +++ b/examples/foundational/40-aws-nova-sonic.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService +from pipecat.services.aws.nova_sonic.llm import AWSNovaSonicLLMService, AWSNovaSonicLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -130,9 +130,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - ap-northeast-1 region=os.getenv("AWS_REGION"), session_token=os.getenv("AWS_SESSION_TOKEN"), - voice_id="tiffany", - # you could choose to pass instruction here rather than via context - # system_instruction=system_instruction + settings=AWSNovaSonicLLMSettings( + voice="tiffany", + system_instruction=system_instruction, + ), # you could choose to pass tools here rather than via context # tools=tools ) @@ -147,7 +148,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Set up context and context management. context = LLMContext( messages=[ - {"role": "system", "content": f"{system_instruction}"}, { "role": "user", "content": "Tell me a fun fact!",