From 510a0f5ef56c6a575f1d069034fd74097bacb726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Fri, 7 Feb 2025 09:19:43 -0800 Subject: [PATCH] rtvi: deprecate RTVI.observer() --- CHANGELOG.md | 3 +++ examples/simple-chatbot/server/bot-gemini.py | 4 ++-- examples/simple-chatbot/server/bot-openai.py | 4 ++-- src/pipecat/processors/frameworks/rtvi.py | 9 +++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f84bdba1..7f7cbbaa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +- `RTVI.observer()` is now deprecated, instantiate an `RTVIObserver` directly + instead. + - All RTVI frame processors (e.g. `RTVISpeakingProcessor`, `RTVIBotLLMProcessor`) are now deprecated, instantiate an `RTVIObserver` instead. diff --git a/examples/simple-chatbot/server/bot-gemini.py b/examples/simple-chatbot/server/bot-gemini.py index a7e7717ce..ecf38f159 100644 --- a/examples/simple-chatbot/server/bot-gemini.py +++ b/examples/simple-chatbot/server/bot-gemini.py @@ -40,7 +40,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIProcessor +from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.transports.services.daily import DailyParams, DailyTransport @@ -176,7 +176,7 @@ async def main(): allow_interruptions=True, enable_metrics=True, enable_usage_metrics=True, - observers=[rtvi.observer()], + observers=[RTVIObserver(rtvi)], ), ) await task.queue_frame(quiet_frame) diff --git a/examples/simple-chatbot/server/bot-openai.py b/examples/simple-chatbot/server/bot-openai.py index 0d30a5d87..51c421c7d 100644 --- a/examples/simple-chatbot/server/bot-openai.py +++ b/examples/simple-chatbot/server/bot-openai.py @@ -40,7 +40,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIProcessor +from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor from pipecat.services.elevenlabs import ElevenLabsTTSService from pipecat.services.openai import OpenAILLMService from pipecat.transports.services.daily import DailyParams, DailyTransport @@ -202,7 +202,7 @@ async def main(): allow_interruptions=True, enable_metrics=True, enable_usage_metrics=True, - observers=[rtvi.observer()], + observers=[RTVIObserver(rtvi)], ), ) await task.queue_frame(quiet_frame) diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index e405faac5..b5965c64b 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -812,6 +812,15 @@ class RTVIProcessor(FrameProcessor): self._register_event_handler("on_client_ready") def observer(self) -> RTVIObserver: + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "'RTVI.observer()' is deprecated, instantiate an 'RTVIObserver' directly instead.", + DeprecationWarning, + ) + return RTVIObserver(self) def register_action(self, action: RTVIAction):