From e33ca26e2d08a2cff6c7f4f896705ee897b6758b Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 30 Jul 2025 20:45:53 -0400 Subject: [PATCH] Revert "Add is_local_development utility for a cleaner API to determine if running locally" This reverts commit 471311b18f26c7e459292fcc794abdbc230325b7. --- .../runner-examples/01-all-transport-bot.py | 16 +++++++--------- .../runner-examples/02-two-transport-bot.py | 17 ++++++++--------- src/pipecat/runner/run.py | 1 + src/pipecat/runner/utils.py | 11 ----------- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/examples/runner-examples/01-all-transport-bot.py b/examples/runner-examples/01-all-transport-bot.py index 78557bffb..6d884dc76 100644 --- a/examples/runner-examples/01-all-transport-bot.py +++ b/examples/runner-examples/01-all-transport-bot.py @@ -30,7 +30,6 @@ from pipecat.runner.types import ( DailyRunnerArguments, SmallWebRTCRunnerArguments, WebSocketRunnerArguments, - is_local_development, ) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -38,6 +37,9 @@ from pipecat.services.openai.llm import OpenAILLMService load_dotenv(override=True) +# Check if we're running locally +IS_LOCAL_RUN = os.environ.get("LOCAL_RUN", "0") == "1" + async def run_bot(transport): """Main bot logic that works with any transport.""" @@ -109,22 +111,18 @@ async def bot( if isinstance(session_args, DailyRunnerArguments): from pipecat.transports.services.daily import DailyParams, DailyTransport - is_local = is_local_development() - - if not is_local: + if not IS_LOCAL_RUN: from pipecat.audio.filters.krisp_filter import KrispFilter - krisp_filter = KrispFilter() - else: - krisp_filter = None - transport = DailyTransport( session_args.room_url, session_args.token, "Pipecat Bot", params=DailyParams( audio_in_enabled=True, - audio_in_filter=krisp_filter, + audio_in_filter=None + if IS_LOCAL_RUN + else KrispFilter(), # Only use Krisp in production audio_out_enabled=True, vad_analyzer=SileroVADAnalyzer(), ), diff --git a/examples/runner-examples/02-two-transport-bot.py b/examples/runner-examples/02-two-transport-bot.py index a74a5e51d..7d3e4d4ef 100644 --- a/examples/runner-examples/02-two-transport-bot.py +++ b/examples/runner-examples/02-two-transport-bot.py @@ -23,7 +23,6 @@ from pipecat.runner.types import ( DailyRunnerArguments, SmallWebRTCRunnerArguments, ) -from pipecat.runner.utils import is_local_development from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -31,6 +30,10 @@ from pipecat.services.openai.llm import OpenAILLMService load_dotenv(override=True) +# Check if we're running locally +IS_LOCAL_RUN = os.environ.get("LOCAL_RUN", "0") == "1" + + async def run_bot(transport): """Main bot logic that works with any transport.""" logger.info(f"Starting bot") @@ -99,22 +102,18 @@ async def bot(session_args: DailyRunnerArguments | SmallWebRTCRunnerArguments): if isinstance(session_args, DailyRunnerArguments): from pipecat.transports.services.daily import DailyParams, DailyTransport - is_local = is_local_development() - - if not is_local: + if not IS_LOCAL_RUN: from pipecat.audio.filters.krisp_filter import KrispFilter - krisp_filter = KrispFilter() - else: - krisp_filter = None - transport = DailyTransport( session_args.room_url, session_args.token, "Pipecat Bot", params=DailyParams( audio_in_enabled=True, - audio_in_filter=krisp_filter, + audio_in_filter=None + if IS_LOCAL_RUN + else KrispFilter(), # Only use Krisp in production audio_out_enabled=True, vad_analyzer=SileroVADAnalyzer(), ), diff --git a/src/pipecat/runner/run.py b/src/pipecat/runner/run.py index 8c137eecf..64e7808bc 100644 --- a/src/pipecat/runner/run.py +++ b/src/pipecat/runner/run.py @@ -94,6 +94,7 @@ except ImportError as e: load_dotenv(override=True) +os.environ["LOCAL_RUN"] = "1" def _get_bot_module(): diff --git a/src/pipecat/runner/utils.py b/src/pipecat/runner/utils.py index b2f5267d9..cd0781f78 100644 --- a/src/pipecat/runner/utils.py +++ b/src/pipecat/runner/utils.py @@ -32,7 +32,6 @@ Example:: import json import os import re -import sys from typing import Any, Callable, Dict, Optional from fastapi import WebSocket @@ -480,13 +479,3 @@ async def create_transport( else: raise ValueError(f"Unsupported session arguments type: {type(session_args)}") - - -def is_local_development() -> bool: - """Detect if running in local development environment. - - Returns True if the pipecat development runner is being used. - This works by detecting if pipecat.runner.run has been imported, - which only happens when running locally via the development runner. - """ - return "pipecat.runner.run" in sys.modules