From 089e703e1f2c6011b9655108fe74895edb0ff1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Thu, 25 Sep 2025 14:22:34 -0700 Subject: [PATCH] LiveKitTransport: deprecate LiveKitTransportMessage(Urgent)Frame --- CHANGELOG.md | 6 ++- src/pipecat/transports/livekit/transport.py | 60 ++++++++++++++++++--- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7868b186..7a0918b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,9 +34,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +- `LiveKitTransportMessageFrame` and `LiveKitTransportMessageUrgentFrame` are + deprecated, use `LiveKitOutputTransportMessageFrame` and + `LiveKitOutputTransportMessageUrgentFrame` respectively instead. + - `TransportMessageFrame` and `TransportMessageUrgentFrame` are deprecated, use `OutputTransportMessageFrame` and `OutputTransportMessageUrgentFrame` - respectively. + respectively instead. - `InputTransportMessageUrgentFrame` is deprecated, use `InputTransportMessageFrame` instead. diff --git a/src/pipecat/transports/livekit/transport.py b/src/pipecat/transports/livekit/transport.py index cb06464f0..f1b8d9088 100644 --- a/src/pipecat/transports/livekit/transport.py +++ b/src/pipecat/transports/livekit/transport.py @@ -68,7 +68,7 @@ DTMF_CODE_MAP = { @dataclass -class LiveKitTransportMessageFrame(OutputTransportMessageFrame): +class LiveKitOutputTransportMessageFrame(OutputTransportMessageFrame): """Frame for transport messages in LiveKit rooms. Parameters: @@ -79,7 +79,7 @@ class LiveKitTransportMessageFrame(OutputTransportMessageFrame): @dataclass -class LiveKitTransportMessageUrgentFrame(OutputTransportMessageUrgentFrame): +class LiveKitOutputTransportMessageUrgentFrame(OutputTransportMessageUrgentFrame): """Frame for urgent transport messages in LiveKit rooms. Parameters: @@ -89,6 +89,50 @@ class LiveKitTransportMessageUrgentFrame(OutputTransportMessageUrgentFrame): participant_id: Optional[str] = None +@dataclass +class LiveKitTransportMessageFrame(LiveKitOutputTransportMessageFrame): + """Frame for transport messages in LiveKit rooms. + + Parameters: + participant_id: Optional ID of the participant this message is for/from. + """ + + def __post_init__(self): + super().__post_init__() + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "LiveKitTransportMessageFrame is deprecated and will be removed in a future version. " + "Instead, use LiveKitOutputTransportMessageFrame.", + DeprecationWarning, + stacklevel=2, + ) + + +@dataclass +class LiveKitTransportMessageUrgentFrame(LiveKitOutputTransportMessageUrgentFrame): + """Frame for urgent transport messages in LiveKit rooms. + + Parameters: + participant_id: Optional ID of the participant this message is for/from. + """ + + def __post_init__(self): + super().__post_init__() + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "LiveKitTransportMessageUrgentFrame is deprecated and will be removed in a future version. " + "Instead, use LiveKitOutputTransportMessageUrgentFrame.", + DeprecationWarning, + stacklevel=2, + ) + + class LiveKitParams(TransportParams): """Configuration parameters for LiveKit transport. @@ -677,7 +721,7 @@ class LiveKitInputTransport(BaseInputTransport): message: The message data to send. sender: ID of the message sender. """ - frame = LiveKitTransportMessageUrgentFrame(message=message, participant_id=sender) + frame = LiveKitOutputTransportMessageUrgentFrame(message=message, participant_id=sender) await self.push_frame(frame) async def _audio_in_task_handler(self): @@ -848,7 +892,9 @@ class LiveKitOutputTransport(BaseOutputTransport): if isinstance(message, dict): # fix message encoding for dict-like messages, e.g. RTVI messages. message = json.dumps(message, ensure_ascii=False) - if isinstance(frame, (LiveKitTransportMessageFrame, LiveKitTransportMessageUrgentFrame)): + if isinstance( + frame, (LiveKitOutputTransportMessageFrame, LiveKitOutputTransportMessageUrgentFrame) + ): await self._client.send_data(message.encode(), frame.participant_id) else: await self._client.send_data(message.encode()) @@ -1107,7 +1153,9 @@ class LiveKitTransport(BaseTransport): participant_id: Optional specific participant to send to. """ if self._output: - frame = LiveKitTransportMessageFrame(message=message, participant_id=participant_id) + frame = LiveKitOutputTransportMessageFrame( + message=message, participant_id=participant_id + ) await self._output.send_message(frame) async def send_message_urgent(self, message: str, participant_id: Optional[str] = None): @@ -1118,7 +1166,7 @@ class LiveKitTransport(BaseTransport): participant_id: Optional specific participant to send to. """ if self._output: - frame = LiveKitTransportMessageUrgentFrame( + frame = LiveKitOutputTransportMessageUrgentFrame( message=message, participant_id=participant_id ) await self._output.send_message(frame)