Revert "Add is_local_development utility for a cleaner API to determine if running locally"

This reverts commit 471311b18f.
This commit is contained in:
Mark Backman
2025-07-30 20:45:53 -04:00
parent 471311b18f
commit e33ca26e2d
4 changed files with 16 additions and 29 deletions

View File

@@ -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(),
),

View File

@@ -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(),
),

View File

@@ -94,6 +94,7 @@ except ImportError as e:
load_dotenv(override=True)
os.environ["LOCAL_RUN"] = "1"
def _get_bot_module():

View File

@@ -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