Files

27 lines
828 B
Python
Raw Permalink Normal View History

"""Project-local SmallWebRTC specialization for the OpenAI event channel."""
from __future__ import annotations
from typing import Any
from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection
class OpenAIRealtimeWebRTCConnection(SmallWebRTCConnection):
"""Prevent Pipecat's private signalling envelope from leaking to clients."""
data_channel_label = "oai-events"
def _setup_listeners(self):
super()._setup_listeners()
@self._pc.on("datachannel")
def require_openai_event_channel(channel):
if channel.label != self.data_channel_label:
channel.close()
def send_app_message(self, message: Any):
if isinstance(message, dict) and message.get("type") == "signalling":
return
super().send_app_message(message)