From 41f817bf04d0c96217f2fce6adb2f0962f9cc4e5 Mon Sep 17 00:00:00 2001 From: vipyne Date: Wed, 15 Oct 2025 13:02:44 -0500 Subject: [PATCH] only import whatsapp deps if using whatsapp runner --- src/pipecat/runner/run.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/pipecat/runner/run.py b/src/pipecat/runner/run.py index a7af52e18..c5c9dc9db 100644 --- a/src/pipecat/runner/run.py +++ b/src/pipecat/runner/run.py @@ -289,19 +289,6 @@ def _add_lifespan_to_app(app: FastAPI, new_lifespan): def _setup_whatsapp_routes(app: FastAPI): """Set up WebRTC-specific routes.""" - try: - from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI - - from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection - from pipecat.transports.smallwebrtc.request_handler import ( - SmallWebRTCRequest, - SmallWebRTCRequestHandler, - ) - from pipecat.transports.whatsapp.api import WhatsAppWebhookRequest - from pipecat.transports.whatsapp.client import WhatsAppClient - except ImportError as e: - logger.error(f"WebRTC transport dependencies not installed: {e}") - return WHATSAPP_TOKEN = os.getenv("WHATSAPP_TOKEN") WHATSAPP_PHONE_NUMBER_ID = os.getenv("WHATSAPP_PHONE_NUMBER_ID") @@ -320,6 +307,14 @@ def _setup_whatsapp_routes(app: FastAPI): ) return + # only import WhatsApp dependencies if appropriate env vars are present + try: + from pipecat.transports.whatsapp.api import WhatsAppWebhookRequest + from pipecat.transports.whatsapp.client import WhatsAppClient + except ImportError as e: + logger.error(f"WhatsApp transport dependencies not installed: {e}") + return + # Global WhatsApp client instance whatsapp_client: Optional[WhatsAppClient] = None