diff --git a/pyrightconfig.json b/pyrightconfig.json index 7176ab774..17359ed4a 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -10,7 +10,8 @@ "src/pipecat/observers", "src/pipecat/extensions", "src/pipecat/turns", - "src/pipecat/pipeline" + "src/pipecat/pipeline", + "src/pipecat/runner" ], "exclude": [ "**/*_pb2.py", diff --git a/src/pipecat/runner/daily.py b/src/pipecat/runner/daily.py index bc80f0641..168b2353d 100644 --- a/src/pipecat/runner/daily.py +++ b/src/pipecat/runner/daily.py @@ -228,7 +228,7 @@ async def configure( room_properties.enable_dialout = True # Add SIP configuration if enabled - if sip_enabled: + if sip_enabled and sip_caller_phone: sip_params = DailyRoomSipParams( display_name=sip_caller_phone, video=sip_enable_video, diff --git a/src/pipecat/runner/run.py b/src/pipecat/runner/run.py index c6d43fbbd..ca296bd78 100644 --- a/src/pipecat/runner/run.py +++ b/src/pipecat/runner/run.py @@ -156,6 +156,8 @@ def _get_bot_module(): spec = importlib.util.spec_from_file_location( module_name, os.path.join(cwd, filename) ) + if spec is None or spec.loader is None: + continue module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) @@ -386,29 +388,24 @@ def _add_lifespan_to_app(app: FastAPI, new_lifespan): def _setup_whatsapp_routes(app: FastAPI, args: argparse.Namespace): """Set up WhatsApp-specific routes.""" - WHATSAPP_APP_SECRET = os.getenv("WHATSAPP_APP_SECRET") - WHATSAPP_PHONE_NUMBER_ID = os.getenv("WHATSAPP_PHONE_NUMBER_ID") - WHATSAPP_TOKEN = os.getenv("WHATSAPP_TOKEN") - WHATSAPP_WEBHOOK_VERIFICATION_TOKEN = os.getenv("WHATSAPP_WEBHOOK_VERIFICATION_TOKEN") - - if not all( - [ - WHATSAPP_APP_SECRET, - WHATSAPP_PHONE_NUMBER_ID, - WHATSAPP_TOKEN, - WHATSAPP_WEBHOOK_VERIFICATION_TOKEN, - ] - ): + required_vars = [ + "WHATSAPP_APP_SECRET", + "WHATSAPP_PHONE_NUMBER_ID", + "WHATSAPP_TOKEN", + "WHATSAPP_WEBHOOK_VERIFICATION_TOKEN", + ] + missing = [v for v in required_vars if not os.getenv(v)] + if missing: logger.error( - """Missing required environment variables for WhatsApp transport: - WHATSAPP_APP_SECRET - WHATSAPP_PHONE_NUMBER_ID - WHATSAPP_TOKEN - WHATSAPP_WEBHOOK_VERIFICATION_TOKEN - """ + f"Missing required environment variables for WhatsApp transport: {', '.join(missing)}" ) return + WHATSAPP_APP_SECRET = os.environ["WHATSAPP_APP_SECRET"] + WHATSAPP_PHONE_NUMBER_ID = os.environ["WHATSAPP_PHONE_NUMBER_ID"] + WHATSAPP_TOKEN = os.environ["WHATSAPP_TOKEN"] + WHATSAPP_WEBHOOK_VERIFICATION_TOKEN = os.environ["WHATSAPP_WEBHOOK_VERIFICATION_TOKEN"] + try: from pipecat.transports.smallwebrtc.connection import SmallWebRTCConnection from pipecat.transports.whatsapp.api import WhatsAppWebhookRequest diff --git a/src/pipecat/runner/types.py b/src/pipecat/runner/types.py index 055824a22..b009b3350 100644 --- a/src/pipecat/runner/types.py +++ b/src/pipecat/runner/types.py @@ -122,4 +122,4 @@ class LiveKitRunnerArguments(RunnerArguments): room_name: str url: str - token: str | None = None + token: str diff --git a/src/pipecat/runner/utils.py b/src/pipecat/runner/utils.py index 7a4b3034c..84316a743 100644 --- a/src/pipecat/runner/utils.py +++ b/src/pipecat/runner/utils.py @@ -416,9 +416,9 @@ def _get_transport_params(transport_key: str, transport_params: dict[str, Callab async def _create_telephony_transport( websocket: WebSocket, - params: Any | None = None, - transport_type: str = None, - call_data: dict = None, + params: Any, + transport_type: str, + call_data: dict, ) -> BaseTransport: """Create a telephony transport with pre-parsed WebSocket data. @@ -433,12 +433,6 @@ async def _create_telephony_transport( """ from pipecat.transports.websocket.fastapi import FastAPIWebsocketTransport - if params is None: - raise ValueError( - "FastAPIWebsocketParams must be provided. " - "The serializer and add_wav_header will be set automatically." - ) - # Always set add_wav_header to False for telephony params.add_wav_header = False