diff --git a/CHANGELOG.md b/CHANGELOG.md index d77524a06..70716937b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed an issue where local SmartTurn was not being ran in a separate thread. +### Deprecated + +- `InputTransportMessageUrgentFrame` is deprecated, use + `InputTransportMessageFrame` instead. + ## [0.0.86] - 2025-09-24 ### Added diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index ffef7c99c..f075a6896 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -1106,20 +1106,43 @@ class TransportMessageUrgentFrame(SystemFrame): @dataclass -class InputTransportMessageUrgentFrame(TransportMessageUrgentFrame): +class InputTransportMessageFrame(SystemFrame): """Frame for transport messages received from external sources. - This frame wraps incoming transport messages to distinguish them from outgoing - urgent transport messages (TransportMessageUrgentFrame), preventing infinite - message loops in the transport layer. It inherits the message payload from - TransportMessageFrame while marking the message as having been received - rather than generated locally. - - Used by transport implementations to properly handle bidirectional message - flow without creating feedback loops. + Parameters: + message: The urgent transport message payload. """ - pass + message: Any + + def __str__(self): + return f"{self.name}(message: {self.message})" + + +@dataclass +class InputTransportMessageUrgentFrame(InputTransportMessageFrame): + """Frame for transport messages received from external sources. + + .. deprecated:: 0.0.87 + This frame is deprecated and will be removed in a future version. + Instead, use `InputTransportMessageFrame`. + + Parameters: + message: The urgent transport message payload. + """ + + def __post_init__(self): + super().__post_init__() + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "InputTransportMessageUrgentFrame is deprecated and will be removed in a future version. " + "Instead, use InputTransportMessageFrame.", + DeprecationWarning, + stacklevel=2, + ) @dataclass diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index 9389d819d..3202d66b0 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -42,6 +42,7 @@ from pipecat.frames.frames import ( Frame, FunctionCallResultFrame, InputAudioRawFrame, + InputTransportMessageUrgentFrame, InterimTranscriptionFrame, LLMConfigureOutputFrame, LLMContextFrame, @@ -1418,7 +1419,7 @@ class RTVIProcessor(FrameProcessor): elif isinstance(frame, ErrorFrame): await self._send_error_frame(frame) await self.push_frame(frame, direction) - elif isinstance(frame, TransportMessageUrgentFrame): + elif isinstance(frame, InputTransportMessageUrgentFrame): await self._handle_transport_message(frame) # All other system frames elif isinstance(frame, SystemFrame): @@ -1481,7 +1482,7 @@ class RTVIProcessor(FrameProcessor): await self._handle_message(message) self._message_queue.task_done() - async def _handle_transport_message(self, frame: TransportMessageUrgentFrame): + async def _handle_transport_message(self, frame: InputTransportMessageUrgentFrame): """Handle an incoming transport message frame.""" try: transport_message = frame.message diff --git a/src/pipecat/serializers/protobuf.py b/src/pipecat/serializers/protobuf.py index 867fa0674..8a70bc7eb 100644 --- a/src/pipecat/serializers/protobuf.py +++ b/src/pipecat/serializers/protobuf.py @@ -15,6 +15,7 @@ import pipecat.frames.protobufs.frames_pb2 as frame_protos from pipecat.frames.frames import ( Frame, InputAudioRawFrame, + InputTransportMessageFrame, OutputAudioRawFrame, TextFrame, TranscriptionFrame, @@ -138,7 +139,7 @@ class ProtobufFrameSerializer(FrameSerializer): if class_name == MessageFrame: try: msg = json.loads(args_dict["data"]) - instance = TransportMessageUrgentFrame(message=msg) + instance = InputTransportMessageFrame(message=msg) logger.debug(f"ProtobufFrameSerializer: Transport message {instance}") except Exception as e: logger.error(f"Error parsing MessageFrame data: {e}") diff --git a/src/pipecat/transports/base_output.py b/src/pipecat/transports/base_output.py index 9d1b2b3bb..e51d444e3 100644 --- a/src/pipecat/transports/base_output.py +++ b/src/pipecat/transports/base_output.py @@ -29,7 +29,6 @@ from pipecat.frames.frames import ( CancelFrame, EndFrame, Frame, - InputTransportMessageUrgentFrame, InterruptionFrame, MixerControlFrame, OutputAudioRawFrame, @@ -307,9 +306,7 @@ class BaseOutputTransport(FrameProcessor): elif isinstance(frame, InterruptionFrame): await self.push_frame(frame, direction) await self._handle_frame(frame) - elif isinstance(frame, TransportMessageUrgentFrame) and not isinstance( - frame, InputTransportMessageUrgentFrame - ): + elif isinstance(frame, TransportMessageUrgentFrame): await self.send_message(frame) elif isinstance(frame, OutputDTMFUrgentFrame): await self.write_dtmf(frame) diff --git a/src/pipecat/transports/daily/transport.py b/src/pipecat/transports/daily/transport.py index f61a799e8..1ffb1b231 100644 --- a/src/pipecat/transports/daily/transport.py +++ b/src/pipecat/transports/daily/transport.py @@ -30,7 +30,7 @@ from pipecat.frames.frames import ( ErrorFrame, Frame, InputAudioRawFrame, - InputTransportMessageUrgentFrame, + InputTransportMessageFrame, InterimTranscriptionFrame, OutputAudioRawFrame, OutputImageRawFrame, @@ -96,7 +96,7 @@ class DailyTransportMessageUrgentFrame(TransportMessageUrgentFrame): @dataclass -class DailyInputTransportMessageUrgentFrame(InputTransportMessageUrgentFrame): +class DailyInputTransportMessageFrame(InputTransportMessageFrame): """Frame for input urgent transport messages in Daily calls. Parameters: @@ -106,6 +106,31 @@ class DailyInputTransportMessageUrgentFrame(InputTransportMessageUrgentFrame): participant_id: Optional[str] = None +class DailyInputTransportMessageUrgentFrame(DailyInputTransportMessageFrame): + """Frame for input urgent transport messages in Daily calls. + + .. deprecated:: 0.0.87 + This frame is deprecated and will be removed in a future version. + Instead, use `DailyInputTransportMessageFrame`. + + 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( + "DailyInputTransportMessageUrgentFrame is deprecated and will be removed in a future version. " + "Instead, use DailyInputTransportMessageFrame.", + DeprecationWarning, + stacklevel=2, + ) + + @dataclass class DailyUpdateRemoteParticipantsFrame(ControlFrame): """Frame to update remote participants in Daily calls. @@ -1621,7 +1646,7 @@ class DailyInputTransport(BaseInputTransport): message: The message data to send. sender: ID of the message sender. """ - frame = DailyInputTransportMessageUrgentFrame(message=message, participant_id=sender) + frame = DailyInputTransportMessageFrame(message=message, participant_id=sender) await self.push_frame(frame) # diff --git a/src/pipecat/transports/smallwebrtc/transport.py b/src/pipecat/transports/smallwebrtc/transport.py index 4b2437be1..17b492d77 100644 --- a/src/pipecat/transports/smallwebrtc/transport.py +++ b/src/pipecat/transports/smallwebrtc/transport.py @@ -26,7 +26,7 @@ from pipecat.frames.frames import ( EndFrame, Frame, InputAudioRawFrame, - InputTransportMessageUrgentFrame, + InputTransportMessageFrame, OutputAudioRawFrame, OutputImageRawFrame, SpriteFrame, @@ -683,7 +683,7 @@ class SmallWebRTCInputTransport(BaseInputTransport): message: The application message to process. """ logger.debug(f"Received app message inside SmallWebRTCInputTransport {message}") - frame = InputTransportMessageUrgentFrame(message=message) + frame = InputTransportMessageFrame(message=message) await self.push_frame(frame) # Add this method similar to DailyInputTransport.request_participant_image