From 79be0695ddcb6b71d888344ed5efb1e52ae5e0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Thu, 28 Aug 2025 15:30:23 -0700 Subject: [PATCH] make sure warnings are always displayed --- src/pipecat/audio/utils.py | 16 ++++--- .../processors/aggregators/llm_response.py | 47 ++++++++++++------- src/pipecat/processors/frame_processor.py | 14 +++--- src/pipecat/runner/daily.py | 12 +++-- src/pipecat/services/__init__.py | 4 +- src/pipecat/services/cartesia/tts.py | 24 ++++++---- src/pipecat/services/fish/tts.py | 14 +++--- src/pipecat/services/gladia/stt.py | 31 +++++++----- src/pipecat/services/google/llm_openai.py | 14 +++--- src/pipecat/services/playht/tts.py | 15 +++--- src/pipecat/services/sarvam/tts.py | 15 +++--- src/pipecat/services/speechmatics/stt.py | 3 +- src/pipecat/services/tts_service.py | 12 +++-- 13 files changed, 130 insertions(+), 91 deletions(-) diff --git a/src/pipecat/audio/utils.py b/src/pipecat/audio/utils.py index 84f73ebad..41aecf907 100644 --- a/src/pipecat/audio/utils.py +++ b/src/pipecat/audio/utils.py @@ -41,13 +41,15 @@ def create_default_resampler(**kwargs) -> BaseAudioResampler: """ import warnings - warnings.warn( - "`create_default_resampler` is deprecated. " - "Use `create_stream_resampler` for real-time processing scenarios or " - "`create_file_resampler` for batch processing of complete audio files.", - DeprecationWarning, - stacklevel=2, - ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "`create_default_resampler` is deprecated. " + "Use `create_stream_resampler` for real-time processing scenarios or " + "`create_file_resampler` for batch processing of complete audio files.", + DeprecationWarning, + stacklevel=2, + ) return SOXRAudioResampler(**kwargs) diff --git a/src/pipecat/processors/aggregators/llm_response.py b/src/pipecat/processors/aggregators/llm_response.py index 485ffe6aa..d058a4334 100644 --- a/src/pipecat/processors/aggregators/llm_response.py +++ b/src/pipecat/processors/aggregators/llm_response.py @@ -12,7 +12,6 @@ LLM processing, and text-to-speech components in conversational AI pipelines. """ import asyncio -import warnings from abc import abstractmethod from dataclasses import dataclass from typing import Dict, List, Literal, Optional, Set @@ -326,11 +325,15 @@ class LLMContextResponseAggregator(BaseLLMResponseAggregator): Returns: LLMContextFrame containing the current context. """ - warnings.warn( - "get_context_frame() is deprecated and will be removed in a future version. To trigger an LLM response, use LLMRunFrame instead.", - DeprecationWarning, - stacklevel=2, - ) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "get_context_frame() is deprecated and will be removed in a future version. To trigger an LLM response, use LLMRunFrame instead.", + DeprecationWarning, + stacklevel=2, + ) return self._get_context_frame() def _get_context_frame(self) -> OpenAILLMContextFrame: @@ -1035,12 +1038,16 @@ class LLMUserResponseAggregator(LLMUserContextAggregator): params: Configuration parameters for aggregation behavior. **kwargs: Additional arguments passed to parent class. """ - warnings.warn( - "LLMUserResponseAggregator is deprecated and will be removed in a future version. " - "Use LLMUserContextAggregator or another LLM-specific subclass instead.", - DeprecationWarning, - stacklevel=2, - ) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "LLMUserResponseAggregator is deprecated and will be removed in a future version. " + "Use LLMUserContextAggregator or another LLM-specific subclass instead.", + DeprecationWarning, + stacklevel=2, + ) super().__init__(context=OpenAILLMContext(messages), params=params, **kwargs) async def _process_aggregation(self): @@ -1078,12 +1085,16 @@ class LLMAssistantResponseAggregator(LLMAssistantContextAggregator): params: Configuration parameters for aggregation behavior. **kwargs: Additional arguments passed to parent class. """ - warnings.warn( - "LLMAssistantResponseAggregator is deprecated and will be removed in a future version. " - "Use LLMAssistantContextAggregator or another LLM-specific subclass instead.", - DeprecationWarning, - stacklevel=2, - ) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "LLMAssistantResponseAggregator is deprecated and will be removed in a future version. " + "Use LLMAssistantContextAggregator or another LLM-specific subclass instead.", + DeprecationWarning, + stacklevel=2, + ) super().__init__(context=OpenAILLMContext(messages), params=params, **kwargs) async def push_aggregation(self): diff --git a/src/pipecat/processors/frame_processor.py b/src/pipecat/processors/frame_processor.py index ab82f7aa1..b20b655f7 100644 --- a/src/pipecat/processors/frame_processor.py +++ b/src/pipecat/processors/frame_processor.py @@ -452,12 +452,14 @@ class FrameProcessor(BaseObject): """ import warnings - warnings.warn( - "`FrameProcessor.wait_for_task()` is deprecated. " - "Use `await task` or `await asyncio.wait_for(task, timeout)` instead.", - DeprecationWarning, - stacklevel=2, - ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "`FrameProcessor.wait_for_task()` is deprecated. " + "Use `await task` or `await asyncio.wait_for(task, timeout)` instead.", + DeprecationWarning, + stacklevel=2, + ) if timeout: await asyncio.wait_for(task, timeout) diff --git a/src/pipecat/runner/daily.py b/src/pipecat/runner/daily.py index 33e3d8066..397a08cc2 100644 --- a/src/pipecat/runner/daily.py +++ b/src/pipecat/runner/daily.py @@ -122,11 +122,13 @@ async def configure_with_args(aiohttp_session: aiohttp.ClientSession, parser=Non """ import warnings - warnings.warn( - "configure_with_args is deprecated. Use configure() instead.", - DeprecationWarning, - stacklevel=2, - ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "configure_with_args is deprecated. Use configure() instead.", + DeprecationWarning, + stacklevel=2, + ) room_url, token = await configure(aiohttp_session) return (room_url, token, None) diff --git a/src/pipecat/services/__init__.py b/src/pipecat/services/__init__.py index 0df8d028f..c28257891 100644 --- a/src/pipecat/services/__init__.py +++ b/src/pipecat/services/__init__.py @@ -11,11 +11,11 @@ _warned_modules = set() def _warn_deprecated_access(globals: Dict[str, Any], attr, old: str, new: str): - import warnings - # Only warn once per old->new module pair module_key = (old, new) if module_key not in _warned_modules: + import warnings + with warnings.catch_warnings(): warnings.simplefilter("always") warnings.warn( diff --git a/src/pipecat/services/cartesia/tts.py b/src/pipecat/services/cartesia/tts.py index f8f148a38..5efda600c 100644 --- a/src/pipecat/services/cartesia/tts.py +++ b/src/pipecat/services/cartesia/tts.py @@ -271,11 +271,13 @@ class CartesiaTTSService(AudioContextWordTTSService): voice_config["id"] = self._voice_id if self._settings["emotion"]: - warnings.warn( - "The 'emotion' parameter in __experimental_controls is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) + 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"] = {} if self._settings["emotion"]: voice_config["__experimental_controls"]["emotion"] = self._settings["emotion"] @@ -606,11 +608,13 @@ class CartesiaHttpTTSService(TTSService): voice_config = {"mode": "id", "id": self._voice_id} if self._settings["emotion"]: - warnings.warn( - "The 'emotion' parameter in voice.__experimental_controls is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) + 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() diff --git a/src/pipecat/services/fish/tts.py b/src/pipecat/services/fish/tts.py index 53f6cb171..305c14884 100644 --- a/src/pipecat/services/fish/tts.py +++ b/src/pipecat/services/fish/tts.py @@ -120,12 +120,14 @@ class FishAudioTTSService(InterruptibleTTSService): if model: import warnings - warnings.warn( - "Parameter 'model' is deprecated and will be removed in a future version. " - "Use 'reference_id' instead.", - DeprecationWarning, - stacklevel=2, - ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "Parameter 'model' is deprecated and will be removed in a future version. " + "Use 'reference_id' instead.", + DeprecationWarning, + stacklevel=2, + ) reference_id = model self._api_key = api_key diff --git a/src/pipecat/services/gladia/stt.py b/src/pipecat/services/gladia/stt.py index 316edd91c..ca3600643 100644 --- a/src/pipecat/services/gladia/stt.py +++ b/src/pipecat/services/gladia/stt.py @@ -13,7 +13,6 @@ supporting multiple languages, custom vocabulary, and various audio processing o import asyncio import base64 import json -import warnings from typing import Any, AsyncGenerator, Dict, Literal, Optional import aiohttp @@ -173,12 +172,16 @@ class _InputParamsDescriptor: """Descriptor for backward compatibility with deprecation warning.""" def __get__(self, obj, objtype=None): - warnings.warn( - "GladiaSTTService.InputParams is deprecated and will be removed in a future version. " - "Import and use GladiaInputParams directly instead.", - DeprecationWarning, - stacklevel=2, - ) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "GladiaSTTService.InputParams is deprecated and will be removed in a future version. " + "Import and use GladiaInputParams directly instead.", + DeprecationWarning, + stacklevel=2, + ) return GladiaInputParams @@ -234,12 +237,14 @@ class GladiaSTTService(STTService): # Warn about deprecated language parameter if it's used if params.language is not None: - warnings.warn( - "The 'language' parameter is deprecated and will be removed in a future version. " - "Use 'language_config' instead.", - DeprecationWarning, - stacklevel=2, - ) + 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, + ) self._api_key = api_key self._region = region diff --git a/src/pipecat/services/google/llm_openai.py b/src/pipecat/services/google/llm_openai.py index 2c64f050f..83d90e4ac 100644 --- a/src/pipecat/services/google/llm_openai.py +++ b/src/pipecat/services/google/llm_openai.py @@ -65,12 +65,14 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): """ import warnings - warnings.warn( - "GoogleLLMOpenAIBetaService is deprecated and will be removed in a future version. " - "Use GoogleLLMService instead for better integration with Google's native API.", - DeprecationWarning, - stacklevel=2, - ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "GoogleLLMOpenAIBetaService is deprecated and will be removed in a future version. " + "Use GoogleLLMService instead for better integration with Google's native API.", + DeprecationWarning, + stacklevel=2, + ) super().__init__(api_key=api_key, base_url=base_url, model=model, **kwargs) diff --git a/src/pipecat/services/playht/tts.py b/src/pipecat/services/playht/tts.py index 3c03e8335..aa92df055 100644 --- a/src/pipecat/services/playht/tts.py +++ b/src/pipecat/services/playht/tts.py @@ -14,7 +14,6 @@ import io import json import struct import uuid -import warnings from typing import AsyncGenerator, Optional import aiohttp @@ -455,11 +454,15 @@ class PlayHTHttpTTSService(TTSService): # Warn about deprecated protocol parameter if explicitly provided if protocol: - warnings.warn( - "The 'protocol' parameter is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "The 'protocol' parameter is deprecated and will be removed in a future version.", + DeprecationWarning, + stacklevel=2, + ) params = params or PlayHTHttpTTSService.InputParams() diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 642113158..b7579b26b 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -9,7 +9,6 @@ import asyncio import base64 import json -import warnings from typing import Any, AsyncGenerator, Mapping, Optional import aiohttp @@ -356,11 +355,15 @@ class SarvamTTSService(InterruptibleTTSService): ) params = params or SarvamTTSService.InputParams() if aiohttp_session is not None: - warnings.warn( - "The 'aiohttp_session' parameter is deprecated and will be removed in a future version. ", - DeprecationWarning, - stacklevel=2, - ) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "The 'aiohttp_session' parameter is deprecated and will be removed in a future version. ", + DeprecationWarning, + stacklevel=2, + ) # WebSocket endpoint URL self._websocket_url = f"{url}?model={model}" self._api_key = api_key diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index 7ac4c6f2a..7136bbb0c 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -10,7 +10,6 @@ import asyncio import datetime import os import re -import warnings from dataclasses import dataclass, field from enum import Enum from typing import Any, AsyncGenerator @@ -1107,6 +1106,8 @@ def _check_deprecated_args(kwargs: dict, params: SpeechmaticsSTTService.InputPar # Show deprecation warnings def _deprecation_warning(old: str, new: str | None = None): + import warnings + with warnings.catch_warnings(): warnings.simplefilter("always") if new: diff --git a/src/pipecat/services/tts_service.py b/src/pipecat/services/tts_service.py index 9e34adf25..93800338b 100644 --- a/src/pipecat/services/tts_service.py +++ b/src/pipecat/services/tts_service.py @@ -276,11 +276,13 @@ class TTSService(AIService): """ import warnings - warnings.warn( - "`TTSService.say()` is deprecated. Push a `TTSSpeakFrame` instead.", - DeprecationWarning, - stacklevel=2, - ) + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "`TTSService.say()` is deprecated. Push a `TTSSpeakFrame` instead.", + DeprecationWarning, + stacklevel=2, + ) await self.queue_frame(TTSSpeakFrame(text))