Updates to cloud examples: cloud-simple so it can be deployed and use Krisp
This commit is contained in:
@@ -14,6 +14,7 @@ from pipecat.pipeline.pipeline import Pipeline
|
||||
from pipecat.pipeline.runner import PipelineRunner
|
||||
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||
from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor
|
||||
from pipecat.runner.cloud import SmallWebRTCSessionArguments
|
||||
from pipecat.services.cartesia.tts import CartesiaTTSService
|
||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||
@@ -53,9 +54,12 @@ async def run_bot(transport):
|
||||
context = OpenAILLMContext(messages)
|
||||
context_aggregator = llm.create_context_aggregator(context)
|
||||
|
||||
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))
|
||||
|
||||
pipeline = Pipeline(
|
||||
[
|
||||
transport.input(),
|
||||
rtvi,
|
||||
stt,
|
||||
context_aggregator.user(),
|
||||
llm,
|
||||
@@ -71,6 +75,7 @@ async def run_bot(transport):
|
||||
enable_metrics=True,
|
||||
enable_usage_metrics=True,
|
||||
),
|
||||
observers=[RTVIObserver(rtvi)],
|
||||
)
|
||||
|
||||
@transport.event_handler("on_client_connected")
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Optional
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from loguru import logger
|
||||
@@ -14,7 +16,9 @@ from pipecat.pipeline.pipeline import Pipeline
|
||||
from pipecat.pipeline.runner import PipelineRunner
|
||||
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||
from pipecat.runner.cloud import SmallWebRTCSessionArguments
|
||||
|
||||
# from pipecat.runner.cloud import SmallWebRTCSessionArguments # Need a release of Pipecat to use this
|
||||
from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor
|
||||
from pipecat.services.cartesia.tts import CartesiaTTSService
|
||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||
from pipecat.services.openai.llm import OpenAILLMService
|
||||
@@ -30,6 +34,26 @@ except ImportError:
|
||||
load_dotenv(override=True)
|
||||
|
||||
|
||||
# For now, we'll just define SmallWebRTCSessionArguments here directly since Pipecat
|
||||
# isn't released with the pipecat.runner.cloud module yet.
|
||||
# This saves us from having to build a Docker container from my branch or main to
|
||||
# deploy to PCC.
|
||||
@dataclass
|
||||
class SmallWebRTCSessionArguments:
|
||||
"""Small WebRTC session arguments for local development.
|
||||
|
||||
This will be replaced by pipecatcloud.agent.SmallWebRTCSessionArguments
|
||||
when WebRTC support is added to Pipecat Cloud.
|
||||
"""
|
||||
|
||||
webrtc_connection: Any
|
||||
session_id: Optional[str] = None
|
||||
|
||||
|
||||
# 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")
|
||||
@@ -53,9 +77,12 @@ async def run_bot(transport):
|
||||
context = OpenAILLMContext(messages)
|
||||
context_aggregator = llm.create_context_aggregator(context)
|
||||
|
||||
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))
|
||||
|
||||
pipeline = Pipeline(
|
||||
[
|
||||
transport.input(),
|
||||
rtvi,
|
||||
stt,
|
||||
context_aggregator.user(),
|
||||
llm,
|
||||
@@ -71,6 +98,7 @@ async def run_bot(transport):
|
||||
enable_metrics=True,
|
||||
enable_usage_metrics=True,
|
||||
),
|
||||
observers=[RTVIObserver(rtvi)],
|
||||
)
|
||||
|
||||
@transport.event_handler("on_client_connected")
|
||||
@@ -94,12 +122,18 @@ async def bot(session_args: DailySessionArguments | SmallWebRTCSessionArguments)
|
||||
if isinstance(session_args, DailySessionArguments):
|
||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||
|
||||
if not IS_LOCAL_RUN:
|
||||
from pipecat.audio.filters.krisp_filter import KrispFilter
|
||||
|
||||
transport = DailyTransport(
|
||||
session_args.room_url,
|
||||
session_args.token,
|
||||
"Pipecat Bot",
|
||||
params=DailyParams(
|
||||
audio_in_enabled=True,
|
||||
audio_in_filter=None
|
||||
if IS_LOCAL_RUN
|
||||
else KrispFilter(), # Only use Krisp in production
|
||||
audio_out_enabled=True,
|
||||
vad_analyzer=SileroVADAnalyzer(),
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ agent_name = "cloud-simple-bot"
|
||||
image = "your_dockerhub_username/cloud-simple-bot:0.1"
|
||||
image_credentials = "dockerhub-access"
|
||||
secret_set = "cloud-simple-bot-secrets"
|
||||
enable_krisp = true
|
||||
|
||||
[scaling]
|
||||
min_agents = 0
|
||||
|
||||
Reference in New Issue
Block a user