Compare commits
1 Commits
mb/ui-work
...
jpt/smallw
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5602f613dc |
@@ -76,6 +76,7 @@ from loguru import logger
|
||||
|
||||
from pipecat.runner.types import (
|
||||
DailyRunnerArguments,
|
||||
SmallWebRTCPrebuiltArguments,
|
||||
SmallWebRTCRunnerArguments,
|
||||
WebSocketRunnerArguments,
|
||||
)
|
||||
@@ -151,7 +152,11 @@ async def _run_telephony_bot(websocket: WebSocket):
|
||||
|
||||
|
||||
def _create_server_app(
|
||||
transport_type: str, host: str = "localhost", proxy: str = None, esp32_mode: bool = False
|
||||
transport_type: str,
|
||||
host: str = "localhost",
|
||||
proxy: str = None,
|
||||
esp32_mode: bool = False,
|
||||
prebuilt_ui_config: SmallWebRTCPrebuiltArguments = None,
|
||||
):
|
||||
"""Create FastAPI app with transport-specific routes."""
|
||||
app = FastAPI()
|
||||
@@ -166,9 +171,9 @@ def _create_server_app(
|
||||
|
||||
# Set up transport-specific routes
|
||||
if transport_type == "webrtc":
|
||||
_setup_webrtc_routes(app, esp32_mode=esp32_mode, host=host)
|
||||
_setup_webrtc_routes(app, esp32_mode=esp32_mode, host=host, prebuilt_ui_config=prebuilt_ui_config)
|
||||
elif transport_type == "daily":
|
||||
_setup_daily_routes(app)
|
||||
_setup_daily_routes(app, prebuilt_ui_config=prebuilt_ui_config)
|
||||
elif transport_type in ["twilio", "telnyx", "plivo", "exotel"]:
|
||||
_setup_telephony_routes(app, transport_type, proxy)
|
||||
else:
|
||||
@@ -177,7 +182,12 @@ def _create_server_app(
|
||||
return app
|
||||
|
||||
|
||||
def _setup_webrtc_routes(app: FastAPI, esp32_mode: bool = False, host: str = "localhost"):
|
||||
def _setup_webrtc_routes(
|
||||
app: FastAPI,
|
||||
esp32_mode: bool = False,
|
||||
host: str = "localhost",
|
||||
prebuilt_ui_config: SmallWebRTCPrebuiltArguments = None,
|
||||
):
|
||||
"""Set up WebRTC-specific routes."""
|
||||
try:
|
||||
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
||||
@@ -191,7 +201,7 @@ def _setup_webrtc_routes(app: FastAPI, esp32_mode: bool = False, host: str = "lo
|
||||
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
||||
|
||||
# Mount the frontend
|
||||
app.mount("/client", SmallWebRTCPrebuiltUI)
|
||||
app.mount("/client", SmallWebRTCPrebuiltUI(config=prebuilt_ui_config))
|
||||
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def root_redirect():
|
||||
@@ -435,7 +445,7 @@ def _validate_and_clean_proxy(proxy: str) -> str:
|
||||
return proxy
|
||||
|
||||
|
||||
def main():
|
||||
def main(prebuilt_ui_config: SmallWebRTCPrebuiltArguments = None):
|
||||
"""Start the Pipecat development runner.
|
||||
|
||||
Parses command-line arguments and starts a FastAPI server configured
|
||||
@@ -533,7 +543,7 @@ def main():
|
||||
print()
|
||||
|
||||
# Create the app with transport-specific setup
|
||||
app = _create_server_app(args.transport, args.host, args.proxy, args.esp32)
|
||||
app = _create_server_app(args.transport, args.host, args.proxy, args.esp32, prebuilt_ui_config)
|
||||
|
||||
# Run the server
|
||||
uvicorn.run(app, host=args.host, port=args.port)
|
||||
|
||||
@@ -65,3 +65,67 @@ class SmallWebRTCRunnerArguments(RunnerArguments):
|
||||
"""
|
||||
|
||||
webrtc_connection: Any
|
||||
|
||||
|
||||
@dataclass
|
||||
class SmallWebRTCPrebuiltArguments:
|
||||
"""Arguments for Small WebRTC prebuilt console template.
|
||||
|
||||
Parameters:
|
||||
no_rtvi: Disables RTVI related functionality. Default: False
|
||||
server_rtvi_version: Specifies the RTVI version in use by the server. Default: None
|
||||
no_user_audio: Disables user audio input entirely. Default: False
|
||||
no_user_video: Disables user video input entirely. Default: False
|
||||
user_video_enabled: Enables user video input. Default: False
|
||||
user_audio_enabled: Enables user audio input. Default: True
|
||||
no_audio_output: Disables audio output for the bot. Default: False
|
||||
no_bot_audio: Disables audio visualization for the bot. Default: False
|
||||
no_bot_video: Disables video visualization for the bot. Default: True
|
||||
transport_type: Type of transport to use for the RTVI client. Default: "smallwebrtc"
|
||||
transport_options: Options for configuring the transport. Default: None
|
||||
connect_params: Parameters for connecting to the transport. Default: None
|
||||
client_options: Options for configuring the RTVI client. Default: None
|
||||
theme: Theme to use for the UI. Default: "system"
|
||||
no_theme_switch: Disables the theme switcher in the header. Default: False
|
||||
no_logo: Disables the logo in the header. Default: False
|
||||
no_session_info: Disables the session info panel. Default: False
|
||||
no_status_info: Disables the status info panel. Default: False
|
||||
title_text: Title displayed in the header. Default: "Pipecat Playground"
|
||||
assistant_label_text: Label for assistant messages. Default: "assistant"
|
||||
user_label_text: Label for user messages. Default: "user"
|
||||
system_label_text: Label for system messages. Default: "system"
|
||||
collapse_info_panel: Whether to collapse the info panel by default. Default: False
|
||||
collapse_media_panel: Whether to collapse the media panel by default. Default: False
|
||||
"""
|
||||
|
||||
# RTVI configuration
|
||||
no_rtvi: bool = False
|
||||
server_rtvi_version: Optional[str] = None
|
||||
|
||||
# Media configuration
|
||||
no_user_audio: bool = False
|
||||
no_user_video: bool = False
|
||||
user_video_enabled: bool = False
|
||||
user_audio_enabled: bool = True
|
||||
no_audio_output: bool = False
|
||||
no_bot_audio: bool = False
|
||||
no_bot_video: bool = True
|
||||
|
||||
# Client & transport configuration
|
||||
transport_type: str = "smallwebrtc"
|
||||
transport_options: Optional[Any] = None
|
||||
connect_params: Optional[Any] = None
|
||||
client_options: Optional[Any] = None
|
||||
|
||||
# UI configuration
|
||||
theme: str = "system"
|
||||
no_theme_switch: bool = False
|
||||
no_logo: bool = False
|
||||
no_session_info: bool = False
|
||||
no_status_info: bool = False
|
||||
title_text: str = "Pipecat Playground"
|
||||
assistant_label_text: str = "assistant"
|
||||
user_label_text: str = "user"
|
||||
system_label_text: str = "system"
|
||||
collapse_info_panel: bool = False
|
||||
collapse_media_panel: bool = False
|
||||
|
||||
Reference in New Issue
Block a user