feat: implement OpenAI-compatible Realtime API with authentication and management features
- Added support for public Realtime API, including new routes for managing API keys and handling WebRTC connections. - Introduced RealtimeApiKey model and associated CRUD operations for admin management of API keys. - Implemented authentication mechanisms for API keys and client secrets. - Enhanced environment configuration with new secrets for Realtime API. - Created OpenAIRealtime session management and event processing for real-time interactions. - Updated schemas and settings to accommodate new features and ensure compatibility with existing systems.
This commit is contained in:
42
backend/services/realtime/protocol.py
Normal file
42
backend/services/realtime/protocol.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Neutral extension point between a transport protocol and the voice pipeline."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Literal, Protocol
|
||||
|
||||
from pipecat.frames.frames import Frame, SystemFrame
|
||||
from pipecat.processors.frame_processor import FrameProcessor
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PipelineProtocolRuntime:
|
||||
"""Operations a wire-protocol adapter may request from a running pipeline."""
|
||||
|
||||
queue_frame: Callable[[Frame], Awaitable[None]]
|
||||
set_external_turn_control: Callable[[bool], Awaitable[None]]
|
||||
set_response_interruption: Callable[[bool], Awaitable[None]]
|
||||
commit_audio: Callable[[], Awaitable[None]]
|
||||
clear_audio: Callable[[], Awaitable[None]]
|
||||
request_response: Callable[[], Awaitable[None]]
|
||||
cancel_response: Callable[[], Awaitable[None]]
|
||||
|
||||
|
||||
@dataclass
|
||||
class RealtimeProviderControlFrame(SystemFrame):
|
||||
"""Ordered control sent to a speech-to-speech provider after prior input."""
|
||||
|
||||
action: Literal["commit_audio", "clear_audio", "request_response"]
|
||||
|
||||
|
||||
class PipelineProtocolAdapter(Protocol):
|
||||
"""A protocol adapter only translates frames; it does not own the assistant."""
|
||||
|
||||
def input_processors(self) -> list[FrameProcessor]: ...
|
||||
|
||||
def inference_processors(self) -> list[FrameProcessor]: ...
|
||||
|
||||
def output_processors(self) -> list[FrameProcessor]: ...
|
||||
|
||||
async def bind(self, runtime: PipelineProtocolRuntime) -> None: ...
|
||||
Reference in New Issue
Block a user