diff --git a/examples/foundational/01-say-one-thing-piper.py b/examples/foundational/01-say-one-thing-piper.py index 5093a9612..40990eea3 100644 --- a/examples/foundational/01-say-one-thing-piper.py +++ b/examples/foundational/01-say-one-thing-piper.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os import aiohttp @@ -15,6 +14,8 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.piper.tts import PiperTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -33,7 +34,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -49,12 +50,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si async def on_client_connected(transport, client): await task.queue_frames([TTSSpeakFrame(f"Hello there!"), EndFrame()]) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/01-say-one-thing-rime.py b/examples/foundational/01-say-one-thing-rime.py index 67542e596..1c2bbd940 100644 --- a/examples/foundational/01-say-one-thing-rime.py +++ b/examples/foundational/01-say-one-thing-rime.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os import aiohttp @@ -15,6 +14,8 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.rime.tts import RimeHttpTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -32,7 +33,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -50,12 +51,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si async def on_client_connected(transport, client): await task.queue_frames([TTSSpeakFrame(f"Hello there!"), EndFrame()]) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/01-say-one-thing.py b/examples/foundational/01-say-one-thing.py index 4a34a3c3d..1366b8d37 100644 --- a/examples/foundational/01-say-one-thing.py +++ b/examples/foundational/01-say-one-thing.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -14,6 +13,8 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -32,7 +33,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tts = CartesiaTTSService( @@ -47,12 +48,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si async def on_client_connected(transport, client): await task.queue_frames([TTSSpeakFrame(f"Hello there!"), EndFrame()]) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/01b-livekit-audio.py b/examples/foundational/01b-livekit-audio.py index 1b5c1b45a..75b73f280 100644 --- a/examples/foundational/01b-livekit-audio.py +++ b/examples/foundational/01b-livekit-audio.py @@ -4,20 +4,18 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import os import sys -import aiohttp from dotenv import load_dotenv -from livekit import api from loguru import logger from pipecat.frames.frames import TextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.livekit import configure from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.transports.services.livekit import LiveKitParams, LiveKitTransport @@ -27,57 +25,8 @@ logger.remove(0) logger.add(sys.stderr, level="DEBUG") -def generate_token(room_name: str, participant_name: str, api_key: str, api_secret: str) -> str: - token = api.AccessToken(api_key, api_secret) - token.with_identity(participant_name).with_name(participant_name).with_grants( - api.VideoGrants( - room_join=True, - room=room_name, - ) - ) - - return token.to_jwt() - - -async def configure_livekit(): - parser = argparse.ArgumentParser(description="LiveKit AI SDK Bot Sample") - parser.add_argument( - "-r", "--room", type=str, required=False, help="Name of the LiveKit room to join" - ) - parser.add_argument("-u", "--url", type=str, required=False, help="URL of the LiveKit server") - - args, unknown = parser.parse_known_args() - - room_name = args.room or os.getenv("LIVEKIT_ROOM_NAME") - url = args.url or os.getenv("LIVEKIT_URL") - api_key = os.getenv("LIVEKIT_API_KEY") - api_secret = os.getenv("LIVEKIT_API_SECRET") - - if not room_name: - raise Exception( - "No LiveKit room specified. Use the -r/--room option from the command line, or set LIVEKIT_ROOM_NAME in your environment." - ) - - if not url: - raise Exception( - "No LiveKit server URL specified. Use the -u/--url option from the command line, or set LIVEKIT_URL in your environment." - ) - - if not api_key or not api_secret: - raise Exception( - "LIVEKIT_API_KEY and LIVEKIT_API_SECRET must be set in environment variables." - ) - - token = generate_token(room_name, "Say One Thing", api_key, api_secret) - - user_token = generate_token(room_name, "User", api_key, api_secret) - logger.info(f"User token: {user_token}") - - return (url, token, room_name) - - async def main(): - (url, token, room_name) = await configure_livekit() + (url, token, room_name) = await configure() transport = LiveKitTransport( url=url, diff --git a/examples/foundational/01c-fastpitch.py b/examples/foundational/01c-fastpitch.py index 0795097fb..effb563b2 100644 --- a/examples/foundational/01c-fastpitch.py +++ b/examples/foundational/01c-fastpitch.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -14,6 +13,8 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.riva.tts import FastPitchTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -32,7 +33,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tts = FastPitchTTSService(api_key=os.getenv("NVIDIA_API_KEY")) @@ -44,12 +45,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si async def on_client_connected(transport, client): await task.queue_frames([TTSSpeakFrame(f"Hello there!"), EndFrame()]) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/02-llm-say-one-thing.py b/examples/foundational/02-llm-say-one-thing.py index b76385d7d..b11db1b3f 100644 --- a/examples/foundational/02-llm-say-one-thing.py +++ b/examples/foundational/02-llm-say-one-thing.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -14,6 +13,8 @@ from pipecat.frames.frames import EndFrame, LLMMessagesFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -33,7 +34,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tts = CartesiaTTSService( @@ -57,12 +58,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si async def on_client_connected(transport, client): await task.queue_frames([LLMMessagesFrame(messages), EndFrame()]) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/03-still-frame.py b/examples/foundational/03-still-frame.py index 106250e11..3ff4cef7a 100644 --- a/examples/foundational/03-still-frame.py +++ b/examples/foundational/03-still-frame.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os import aiohttp @@ -15,6 +14,8 @@ from pipecat.frames.frames import TextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.fal.image import FalImageGenService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.services.daily import DailyParams @@ -39,7 +40,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -62,12 +63,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/03b-still-frame-imagen.py b/examples/foundational/03b-still-frame-imagen.py index 0414fe8de..dc4c3f584 100644 --- a/examples/foundational/03b-still-frame-imagen.py +++ b/examples/foundational/03b-still-frame-imagen.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -14,6 +13,8 @@ from pipecat.frames.frames import TextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.google.image import GoogleImageGenService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.services.daily import DailyParams @@ -38,7 +39,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") imagegen = GoogleImageGenService( @@ -65,12 +66,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/04a-transports-daily.py b/examples/foundational/04a-transports-daily.py index f5ac4586a..c1771a0ab 100644 --- a/examples/foundational/04a-transports-daily.py +++ b/examples/foundational/04a-transports-daily.py @@ -13,11 +13,11 @@ from dotenv import load_dotenv from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.daily_runner import configure 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.daily import configure from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.services.daily import DailyLogLevel, DailyParams, DailyTransport diff --git a/examples/foundational/04b-transports-livekit.py b/examples/foundational/04b-transports-livekit.py index b7c4887c3..6594021de 100644 --- a/examples/foundational/04b-transports-livekit.py +++ b/examples/foundational/04b-transports-livekit.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import json import os @@ -12,7 +11,6 @@ import sys from deepgram import LiveOptions from dotenv import load_dotenv -from livekit import api from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer @@ -27,6 +25,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.runner.livekit import configure from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -38,72 +37,8 @@ logger.remove(0) logger.add(sys.stderr, level="DEBUG") -def generate_token(room_name: str, participant_name: str, api_key: str, api_secret: str) -> str: - token = api.AccessToken(api_key, api_secret) - token.with_identity(participant_name).with_name(participant_name).with_grants( - api.VideoGrants( - room_join=True, - room=room_name, - ) - ) - - return token.to_jwt() - - -def generate_token_with_agent( - room_name: str, participant_name: str, api_key: str, api_secret: str -) -> str: - token = api.AccessToken(api_key, api_secret) - token.with_identity(participant_name).with_name(participant_name).with_grants( - api.VideoGrants( - room_join=True, - room=room_name, - agent=True, # This is the only difference, this makes livekit client know agent has joined - ) - ) - - return token.to_jwt() - - -async def configure_livekit(): - parser = argparse.ArgumentParser(description="LiveKit AI SDK Bot Sample") - parser.add_argument( - "-r", "--room", type=str, required=False, help="Name of the LiveKit room to join" - ) - parser.add_argument("-u", "--url", type=str, required=False, help="URL of the LiveKit server") - - args, unknown = parser.parse_known_args() - - room_name = args.room or os.getenv("LIVEKIT_ROOM_NAME") - url = args.url or os.getenv("LIVEKIT_URL") - api_key = os.getenv("LIVEKIT_API_KEY") - api_secret = os.getenv("LIVEKIT_API_SECRET") - - if not room_name: - raise Exception( - "No LiveKit room specified. Use the -r/--room option from the command line, or set LIVEKIT_ROOM_NAME in your environment." - ) - - if not url: - raise Exception( - "No LiveKit server URL specified. Use the -u/--url option from the command line, or set LIVEKIT_URL in your environment." - ) - - if not api_key or not api_secret: - raise Exception( - "LIVEKIT_API_KEY and LIVEKIT_API_SECRET must be set in environment variables." - ) - - token = generate_token_with_agent(room_name, "Say One Thing", api_key, api_secret) - - user_token = generate_token(room_name, "User", api_key, api_secret) - logger.info(f"User token: {user_token}") - - return url, token, room_name - - async def main(): - (url, token, room_name) = await configure_livekit() + (url, token, room_name) = await configure() transport = LiveKitTransport( url=url, diff --git a/examples/foundational/05-sync-speech-and-image.py b/examples/foundational/05-sync-speech-and-image.py index d4c816714..68860db42 100644 --- a/examples/foundational/05-sync-speech-and-image.py +++ b/examples/foundational/05-sync-speech-and-image.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dataclasses import dataclass @@ -25,6 +24,8 @@ from pipecat.pipeline.sync_parallel_pipeline import SyncParallelPipeline from pipecat.pipeline.task import PipelineTask from pipecat.processors.aggregators.sentence import SentenceAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaHttpTTSService from pipecat.services.fal.image import FalImageGenService from pipecat.services.openai.llm import OpenAILLMService @@ -82,7 +83,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): """Run the Calendar Month Narration bot using WebRTC transport. Args: @@ -169,11 +170,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await task.cancel() # Run the pipeline - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/06-listen-and-respond.py b/examples/foundational/06-listen-and-respond.py index b660459cf..cf9d9336d 100644 --- a/examples/foundational/06-listen-and-respond.py +++ b/examples/foundational/06-listen-and-respond.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -23,6 +22,8 @@ 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.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -75,7 +76,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -132,11 +133,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/06a-image-sync.py b/examples/foundational/06a-image-sync.py index d8b2e7c04..9003e74f2 100644 --- a/examples/foundational/06a-image-sync.py +++ b/examples/foundational/06a-image-sync.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -23,6 +22,8 @@ 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.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -90,7 +91,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -149,11 +150,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07-interruptible-cartesia-http.py b/examples/foundational/07-interruptible-cartesia-http.py index eff98b1e7..dc3b74c75 100644 --- a/examples/foundational/07-interruptible-cartesia-http.py +++ b/examples/foundational/07-interruptible-cartesia-http.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -15,6 +14,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaHttpTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -101,12 +102,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07-interruptible.py b/examples/foundational/07-interruptible.py index b69aaba92..26fcc108d 100644 --- a/examples/foundational/07-interruptible.py +++ b/examples/foundational/07-interruptible.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -15,6 +14,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -46,7 +47,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -100,12 +101,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07a-interruptible-speechmatics-vad.py b/examples/foundational/07a-interruptible-speechmatics-vad.py index f2138c591..962b9e7df 100644 --- a/examples/foundational/07a-interruptible-speechmatics-vad.py +++ b/examples/foundational/07a-interruptible-speechmatics-vad.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -17,6 +16,8 @@ from pipecat.processors.aggregators.llm_response import ( LLMUserAggregatorParams, ) from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.tts import ElevenLabsTTSService from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): """Speechmatics STT Service Example This example demonstrates using Speechmatics Speech-to-Text service with speaker diarization and intelligent speaker management. Key features: @@ -159,12 +160,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07a-interruptible-speechmatics.py b/examples/foundational/07a-interruptible-speechmatics.py index 55003f964..5b2ce1b43 100644 --- a/examples/foundational/07a-interruptible-speechmatics.py +++ b/examples/foundational/07a-interruptible-speechmatics.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -18,6 +17,8 @@ from pipecat.processors.aggregators.llm_response import ( LLMUserAggregatorParams, ) from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.tts import ElevenLabsTTSService from pipecat.services.openai.base_llm import BaseOpenAILLMService from pipecat.services.openai.llm import OpenAILLMService @@ -51,7 +52,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): """Run example using Speechmatics STT. This example will use diarization within our STT service and output the words spoken by @@ -142,12 +143,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07aa-interruptible-soniox.py b/examples/foundational/07aa-interruptible-soniox.py index a879821a2..eb9100cf1 100644 --- a/examples/foundational/07aa-interruptible-soniox.py +++ b/examples/foundational/07aa-interruptible-soniox.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.soniox.stt import SonioxSTTService @@ -43,7 +45,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = SonioxSTTService( @@ -98,12 +100,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07ab-interruptible-inworld-http.py b/examples/foundational/07ab-interruptible-inworld-http.py index 5d559ba5a..0f84e0ac5 100644 --- a/examples/foundational/07ab-interruptible-inworld-http.py +++ b/examples/foundational/07ab-interruptible-inworld-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.inworld.tts import InworldTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -113,12 +115,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07ac-interruptible-asyncai-http.py b/examples/foundational/07ac-interruptible-asyncai-http.py index 63710db14..9337d9ba1 100644 --- a/examples/foundational/07ac-interruptible-asyncai-http.py +++ b/examples/foundational/07ac-interruptible-asyncai-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.asyncai.tts import AsyncAIHttpTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -105,12 +107,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07ac-interruptible-asyncai.py b/examples/foundational/07ac-interruptible-asyncai.py index a27a8ed2b..6226c9a24 100644 --- a/examples/foundational/07ac-interruptible-asyncai.py +++ b/examples/foundational/07ac-interruptible-asyncai.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.asyncai.tts import AsyncAITTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -101,12 +103,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07b-interruptible-langchain.py b/examples/foundational/07b-interruptible-langchain.py index 55bfa6cdf..c6833888c 100644 --- a/examples/foundational/07b-interruptible-langchain.py +++ b/examples/foundational/07b-interruptible-langchain.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -65,7 +65,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -133,12 +133,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07c-interruptible-deepgram-vad.py b/examples/foundational/07c-interruptible-deepgram-vad.py index 86cb363e2..dcfeffc38 100644 --- a/examples/foundational/07c-interruptible-deepgram-vad.py +++ b/examples/foundational/07c-interruptible-deepgram-vad.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from deepgram import LiveOptions @@ -21,6 +21,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -50,7 +52,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService( @@ -112,12 +114,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07c-interruptible-deepgram.py b/examples/foundational/07c-interruptible-deepgram.py index cce7c245d..dc9c3a9b4 100644 --- a/examples/foundational/07c-interruptible-deepgram.py +++ b/examples/foundational/07c-interruptible-deepgram.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -98,12 +100,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07d-interruptible-elevenlabs-http.py b/examples/foundational/07d-interruptible-elevenlabs-http.py index 6b4a5b55c..03a5ab0d4 100644 --- a/examples/foundational/07d-interruptible-elevenlabs-http.py +++ b/examples/foundational/07d-interruptible-elevenlabs-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -105,12 +107,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07d-interruptible-elevenlabs.py b/examples/foundational/07d-interruptible-elevenlabs.py index 491f15c4d..c6de4ae3a 100644 --- a/examples/foundational/07d-interruptible-elevenlabs.py +++ b/examples/foundational/07d-interruptible-elevenlabs.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -101,12 +103,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07e-interruptible-playht-http.py b/examples/foundational/07e-interruptible-playht-http.py index d628714c2..4b871c518 100644 --- a/examples/foundational/07e-interruptible-playht-http.py +++ b/examples/foundational/07e-interruptible-playht-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.playht.tts import PlayHTHttpTTSService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -101,12 +103,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07e-interruptible-playht.py b/examples/foundational/07e-interruptible-playht.py index d5b24dc49..7eb68de12 100644 --- a/examples/foundational/07e-interruptible-playht.py +++ b/examples/foundational/07e-interruptible-playht.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.playht.tts import PlayHTTTSService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -103,12 +105,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07f-interruptible-azure.py b/examples/foundational/07f-interruptible-azure.py index 1e8e7d7f3..cd4ed783a 100644 --- a/examples/foundational/07f-interruptible-azure.py +++ b/examples/foundational/07f-interruptible-azure.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.azure.llm import AzureLLMService from pipecat.services.azure.stt import AzureSTTService from pipecat.services.azure.tts import AzureTTSService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = AzureSTTService( @@ -107,12 +109,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07g-interruptible-openai.py b/examples/foundational/07g-interruptible-openai.py index fb85c1af4..6b8bffa15 100644 --- a/examples/foundational/07g-interruptible-openai.py +++ b/examples/foundational/07g-interruptible-openai.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.stt import OpenAISTTService from pipecat.services.openai.tts import OpenAITTSService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = OpenAISTTService( @@ -102,12 +104,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07h-interruptible-openpipe.py b/examples/foundational/07h-interruptible-openpipe.py index 719067b21..0abc5e4f4 100644 --- a/examples/foundational/07h-interruptible-openpipe.py +++ b/examples/foundational/07h-interruptible-openpipe.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import time @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openpipe.llm import OpenPipeLLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -106,12 +108,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07i-interruptible-xtts.py b/examples/foundational/07i-interruptible-xtts.py index 32dddd965..367a698d6 100644 --- a/examples/foundational/07i-interruptible-xtts.py +++ b/examples/foundational/07i-interruptible-xtts.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.xtts.tts import XTTSService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -104,12 +106,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07j-interruptible-gladia.py b/examples/foundational/07j-interruptible-gladia.py index 4cf7b2f04..2244cbf63 100644 --- a/examples/foundational/07j-interruptible-gladia.py +++ b/examples/foundational/07j-interruptible-gladia.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.gladia.config import GladiaInputParams, LanguageConfig from pipecat.services.gladia.stt import GladiaSTTService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = GladiaSTTService( @@ -109,11 +111,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07k-interruptible-lmnt.py b/examples/foundational/07k-interruptible-lmnt.py index 3d4616276..8d3f3181d 100644 --- a/examples/foundational/07k-interruptible-lmnt.py +++ b/examples/foundational/07k-interruptible-lmnt.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.lmnt.tts import LmntTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -97,12 +99,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07l-interruptible-groq.py b/examples/foundational/07l-interruptible-groq.py index 6acccee63..b67eaefd1 100644 --- a/examples/foundational/07l-interruptible-groq.py +++ b/examples/foundational/07l-interruptible-groq.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.llm_response import LLMUserAggregatorParams from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.groq.llm import GroqLLMService from pipecat.services.groq.stt import GroqSTTService from pipecat.services.groq.tts import GroqTTSService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = GroqSTTService(api_key=os.getenv("GROQ_API_KEY")) @@ -102,12 +104,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07m-interruptible-aws.py b/examples/foundational/07m-interruptible-aws.py index 5cd1a579a..9e442771d 100644 --- a/examples/foundational/07m-interruptible-aws.py +++ b/examples/foundational/07m-interruptible-aws.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse from dotenv import load_dotenv from loguru import logger @@ -14,6 +13,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.aws.llm import AWSBedrockLLMService from pipecat.services.aws.stt import AWSTranscribeSTTService from pipecat.services.aws.tts import AWSPollyTTSService @@ -45,7 +46,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = AWSTranscribeSTTService() @@ -104,12 +105,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07n-interruptible-google.py b/examples/foundational/07n-interruptible-google.py index 319c97f78..0a0d05024 100644 --- a/examples/foundational/07n-interruptible-google.py +++ b/examples/foundational/07n-interruptible-google.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.google.llm import GoogleLLMService from pipecat.services.google.stt import GoogleSTTService from pipecat.services.google.tts import GoogleTTSService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = GoogleSTTService( @@ -110,12 +112,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07o-interruptible-assemblyai.py b/examples/foundational/07o-interruptible-assemblyai.py index 2a1a8da8d..a857eefb8 100644 --- a/examples/foundational/07o-interruptible-assemblyai.py +++ b/examples/foundational/07o-interruptible-assemblyai.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.stt import AssemblyAISTTService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = AssemblyAISTTService( @@ -103,12 +105,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07p-interruptible-krisp.py b/examples/foundational/07p-interruptible-krisp.py index 167749e77..28cc18f83 100644 --- a/examples/foundational/07p-interruptible-krisp.py +++ b/examples/foundational/07p-interruptible-krisp.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -50,7 +52,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -101,12 +103,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07q-interruptible-rime-http.py b/examples/foundational/07q-interruptible-rime-http.py index 7790a1c82..f24d1cf2d 100644 --- a/examples/foundational/07q-interruptible-rime-http.py +++ b/examples/foundational/07q-interruptible-rime-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.rime.tts import RimeHttpTTSService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -106,12 +108,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07q-interruptible-rime.py b/examples/foundational/07q-interruptible-rime.py index fb5e453fd..ab13b249b 100644 --- a/examples/foundational/07q-interruptible-rime.py +++ b/examples/foundational/07q-interruptible-rime.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.rime.tts import RimeTTSService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -100,12 +102,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07r-interruptible-riva-nim.py b/examples/foundational/07r-interruptible-riva-nim.py index 7092f6633..2026ff4b8 100644 --- a/examples/foundational/07r-interruptible-riva-nim.py +++ b/examples/foundational/07r-interruptible-riva-nim.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.nim.llm import NimLLMService from pipecat.services.riva.stt import RivaSTTService from pipecat.services.riva.tts import RivaTTSService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = RivaSTTService(api_key=os.getenv("NVIDIA_API_KEY")) @@ -97,12 +99,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07s-interruptible-google-audio-in.py b/examples/foundational/07s-interruptible-google-audio-in.py index 67701c53b..48ee9f486 100644 --- a/examples/foundational/07s-interruptible-google-audio-in.py +++ b/examples/foundational/07s-interruptible-google-audio-in.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dataclasses import dataclass @@ -29,6 +29,8 @@ 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.frame_processor import FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.google.llm import GoogleLLMService from pipecat.services.google.tts import GoogleTTSService from pipecat.transcriptions.language import Language @@ -211,7 +213,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") llm = GoogleLLMService( @@ -278,12 +280,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07t-interruptible-fish.py b/examples/foundational/07t-interruptible-fish.py index 69babfc05..b5afe8945 100644 --- a/examples/foundational/07t-interruptible-fish.py +++ b/examples/foundational/07t-interruptible-fish.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.fish.tts import FishAudioTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -101,12 +103,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07u-interruptible-ultravox.py b/examples/foundational/07u-interruptible-ultravox.py index b81f43461..7ea5d87b5 100644 --- a/examples/foundational/07u-interruptible-ultravox.py +++ b/examples/foundational/07u-interruptible-ultravox.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -14,6 +14,8 @@ from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.ultravox.stt import UltravoxSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +59,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tts = CartesiaTTSService( @@ -91,12 +93,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07v-interruptible-neuphonic-http.py b/examples/foundational/07v-interruptible-neuphonic-http.py index 7c6389a13..a90ee574a 100644 --- a/examples/foundational/07v-interruptible-neuphonic-http.py +++ b/examples/foundational/07v-interruptible-neuphonic-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -105,12 +107,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07v-interruptible-neuphonic.py b/examples/foundational/07v-interruptible-neuphonic.py index 34aee1977..9a456ed6c 100644 --- a/examples/foundational/07v-interruptible-neuphonic.py +++ b/examples/foundational/07v-interruptible-neuphonic.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.neuphonic.tts import NeuphonicTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -100,12 +102,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07w-interruptible-fal.py b/examples/foundational/07w-interruptible-fal.py index 2ef942ad2..ec2783d27 100644 --- a/examples/foundational/07w-interruptible-fal.py +++ b/examples/foundational/07w-interruptible-fal.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.fal.stt import FalSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = FalSTTService( @@ -103,12 +105,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07x-interruptible-local.py b/examples/foundational/07x-interruptible-local.py index 48725d9bd..21ac2df86 100644 --- a/examples/foundational/07x-interruptible-local.py +++ b/examples/foundational/07x-interruptible-local.py @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService diff --git a/examples/foundational/07y-interruptible-minimax.py b/examples/foundational/07y-interruptible-minimax.py index 97bb655d3..d65fcf724 100644 --- a/examples/foundational/07y-interruptible-minimax.py +++ b/examples/foundational/07y-interruptible-minimax.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.minimax.tts import MiniMaxHttpTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -49,7 +51,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -107,12 +109,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/07z-interruptible-sarvam.py b/examples/foundational/07z-interruptible-sarvam.py index 2fdf1634a..3c7c2351f 100644 --- a/examples/foundational/07z-interruptible-sarvam.py +++ b/examples/foundational/07z-interruptible-sarvam.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.sarvam.tts import SarvamTTSService @@ -49,7 +51,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session @@ -106,12 +108,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/08-bots-arguing.py b/examples/foundational/08-bots-arguing.py index ffb642d64..b052ef08a 100644 --- a/examples/foundational/08-bots-arguing.py +++ b/examples/foundational/08-bots-arguing.py @@ -4,12 +4,12 @@ import os from typing import Tuple import aiohttp -from daily_runner import configure from dotenv import load_dotenv from pipecat.frames.frames import AudioFrame, EndFrame, ImageFrame, LLMMessagesFrame, TextFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.processors.aggregators import SentenceAggregator +from pipecat.runner.daily import configure from pipecat.services.azure import AzureLLMService, AzureTTSService from pipecat.services.elevenlabs import ElevenLabsTTSService from pipecat.services.fal import FalImageGenService diff --git a/examples/foundational/09-mirror.py b/examples/foundational/09-mirror.py index 67c21945c..c5aec0676 100644 --- a/examples/foundational/09-mirror.py +++ b/examples/foundational/09-mirror.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse from dotenv import load_dotenv from loguru import logger @@ -20,6 +19,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.services.daily import DailyParams @@ -71,7 +72,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") pipeline = Pipeline([transport.input(), MirrorProcessor(), transport.output()]) @@ -90,12 +91,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/09a-local-mirror.py b/examples/foundational/09a-local-mirror.py index 5cbde5700..24b98b4ec 100644 --- a/examples/foundational/09a-local-mirror.py +++ b/examples/foundational/09a-local-mirror.py @@ -4,14 +4,12 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import tkinter as tk from dotenv import load_dotenv from loguru import logger -from pipecat.examples.run import maybe_capture_participant_camera from pipecat.frames.frames import ( Frame, InputAudioRawFrame, @@ -23,6 +21,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport, maybe_capture_participant_camera from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.local.tk import TkLocalTransport, TkTransportParams from pipecat.transports.services.daily import DailyParams @@ -75,7 +75,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tk_root = tk.Tk() @@ -115,12 +115,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await asyncio.gather(runner.run(task), run_tk()) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/10-wake-phrase.py b/examples/foundational/10-wake-phrase.py index fb72e6a2a..c85cc7601 100644 --- a/examples/foundational/10-wake-phrase.py +++ b/examples/foundational/10-wake-phrase.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -17,6 +16,8 @@ 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.filters.wake_check_filter import WakeCheckFilter +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -48,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -104,12 +105,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/11-sound-effects.py b/examples/foundational/11-sound-effects.py index 3ca4f8855..28eb91e59 100644 --- a/examples/foundational/11-sound-effects.py +++ b/examples/foundational/11-sound-effects.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os import wave @@ -27,6 +26,8 @@ from pipecat.processors.aggregators.openai_llm_context import ( ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.logger import FrameLogger +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -100,7 +101,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -156,12 +157,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/12-describe-video.py b/examples/foundational/12-describe-video.py index c7edd67c4..c795ac69c 100644 --- a/examples/foundational/12-describe-video.py +++ b/examples/foundational/12-describe-video.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from typing import Optional @@ -12,7 +11,6 @@ from dotenv import load_dotenv from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera from pipecat.frames.frames import Frame, TextFrame, UserImageRequestFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -20,6 +18,12 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.aggregators.user_response import UserResponseAggregator from pipecat.processors.aggregators.vision_image_frame import VisionImageFrameAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.moondream.vision import MoondreamService @@ -66,7 +70,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") user_response = UserResponseAggregator() @@ -119,12 +123,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/12a-describe-video-gemini-flash.py b/examples/foundational/12a-describe-video-gemini-flash.py index 1c762e067..fcac48e22 100644 --- a/examples/foundational/12a-describe-video-gemini-flash.py +++ b/examples/foundational/12a-describe-video-gemini-flash.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from typing import Optional @@ -12,7 +11,6 @@ from dotenv import load_dotenv from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera from pipecat.frames.frames import Frame, TextFrame, UserImageRequestFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -20,6 +18,12 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.user_response import UserResponseAggregator from pipecat.processors.aggregators.vision_image_frame import VisionImageFrameAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -66,7 +70,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") user_response = UserResponseAggregator() @@ -125,12 +129,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/12b-describe-video-gpt-4o.py b/examples/foundational/12b-describe-video-gpt-4o.py index c5492c022..d9c176d4a 100644 --- a/examples/foundational/12b-describe-video-gpt-4o.py +++ b/examples/foundational/12b-describe-video-gpt-4o.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from typing import Optional @@ -12,7 +11,6 @@ from dotenv import load_dotenv from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera from pipecat.frames.frames import Frame, TextFrame, UserImageRequestFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -20,6 +18,12 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.user_response import UserResponseAggregator from pipecat.processors.aggregators.vision_image_frame import VisionImageFrameAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -66,7 +70,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") user_response = UserResponseAggregator() @@ -125,12 +129,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/12c-describe-video-anthropic.py b/examples/foundational/12c-describe-video-anthropic.py index 34b7d6bed..941a4f0e6 100644 --- a/examples/foundational/12c-describe-video-anthropic.py +++ b/examples/foundational/12c-describe-video-anthropic.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from typing import Optional @@ -12,7 +11,6 @@ from dotenv import load_dotenv from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera from pipecat.frames.frames import Frame, TextFrame, UserImageRequestFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner @@ -20,6 +18,12 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.user_response import UserResponseAggregator from pipecat.processors.aggregators.vision_image_frame import VisionImageFrameAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -66,7 +70,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") user_response = UserResponseAggregator() @@ -125,12 +129,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13-whisper-transcription.py b/examples/foundational/13-whisper-transcription.py index 8a5b951a8..82a1bbf0b 100644 --- a/examples/foundational/13-whisper-transcription.py +++ b/examples/foundational/13-whisper-transcription.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse from dotenv import load_dotenv from loguru import logger @@ -15,6 +14,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.whisper.stt import WhisperSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -50,7 +51,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = WhisperSTTService() @@ -66,12 +67,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13b-deepgram-transcription.py b/examples/foundational/13b-deepgram-transcription.py index ae8953f0a..7eba63b29 100644 --- a/examples/foundational/13b-deepgram-transcription.py +++ b/examples/foundational/13b-deepgram-transcription.py @@ -41,7 +41,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService( @@ -60,12 +60,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13c-gladia-transcription.py b/examples/foundational/13c-gladia-transcription.py index 2e4f5b375..d64e36825 100644 --- a/examples/foundational/13c-gladia-transcription.py +++ b/examples/foundational/13c-gladia-transcription.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -15,6 +14,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gladia import GladiaSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -41,7 +42,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = GladiaSTTService( @@ -60,12 +61,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13c-gladia-translation.py b/examples/foundational/13c-gladia-translation.py index 74e9437c0..9b7f8ab6f 100644 --- a/examples/foundational/13c-gladia-translation.py +++ b/examples/foundational/13c-gladia-translation.py @@ -50,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = GladiaSTTService( @@ -81,12 +81,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13d-assemblyai-transcription.py b/examples/foundational/13d-assemblyai-transcription.py index de22b9bb6..8ada794cb 100644 --- a/examples/foundational/13d-assemblyai-transcription.py +++ b/examples/foundational/13d-assemblyai-transcription.py @@ -41,7 +41,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = AssemblyAISTTService( @@ -59,12 +59,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13e-whisper-mlx.py b/examples/foundational/13e-whisper-mlx.py index d06788570..2c9a12b29 100644 --- a/examples/foundational/13e-whisper-mlx.py +++ b/examples/foundational/13e-whisper-mlx.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import time from dotenv import load_dotenv @@ -17,6 +16,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.whisper.stt import MLXModel, WhisperSTTServiceMLX from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -71,7 +72,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = WhisperSTTServiceMLX(model=MLXModel.LARGE_V3_TURBO) @@ -93,12 +94,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13f-cartesia-transcription.py b/examples/foundational/13f-cartesia-transcription.py index 147d5fb3e..7d301733d 100644 --- a/examples/foundational/13f-cartesia-transcription.py +++ b/examples/foundational/13f-cartesia-transcription.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -15,6 +14,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -41,7 +42,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = CartesiaSTTService( @@ -60,12 +61,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13g-sambanova-transcription.py b/examples/foundational/13g-sambanova-transcription.py index bff8aa4d4..073d81cb7 100644 --- a/examples/foundational/13g-sambanova-transcription.py +++ b/examples/foundational/13g-sambanova-transcription.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os import time @@ -18,6 +17,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.sambanova.stt import SambaNovaSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -72,7 +73,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = SambaNovaSTTService( @@ -97,12 +98,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13h-speechmatics-transcription.py b/examples/foundational/13h-speechmatics-transcription.py index ea75702e6..173d0641c 100644 --- a/examples/foundational/13h-speechmatics-transcription.py +++ b/examples/foundational/13h-speechmatics-transcription.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -15,6 +14,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.speechmatics.stt import SpeechmaticsSTTService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -42,7 +43,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): """Run example using Speechmatics STT. This example will use diarization within our STT service and output the words spoken by @@ -80,12 +81,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/13i-soniox-transcription.py b/examples/foundational/13i-soniox-transcription.py index 957067284..d6195248b 100644 --- a/examples/foundational/13i-soniox-transcription.py +++ b/examples/foundational/13i-soniox-transcription.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -16,6 +15,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.soniox.stt import SonioxSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -48,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = SonioxSTTService( @@ -71,7 +72,13 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14-function-calling.py b/examples/foundational/14-function-calling.py index b8fddd227..4b523052c 100644 --- a/examples/foundational/14-function-calling.py +++ b/examples/foundational/14-function-calling.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -18,6 +17,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -59,7 +60,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -150,12 +151,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14a-function-calling-anthropic.py b/examples/foundational/14a-function-calling-anthropic.py index cb0766262..8685a79c5 100644 --- a/examples/foundational/14a-function-calling-anthropic.py +++ b/examples/foundational/14a-function-calling-anthropic.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -17,6 +17,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -59,7 +61,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -143,12 +145,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14b-function-calling-anthropic-video.py b/examples/foundational/14b-function-calling-anthropic-video.py index b9d9b2f71..9d3287621 100644 --- a/examples/foundational/14b-function-calling-anthropic-video.py +++ b/examples/foundational/14b-function-calling-anthropic-video.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import os @@ -14,11 +14,16 @@ from loguru import logger from pipecat.adapters.schemas.function_schema import FunctionSchema from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera 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.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -78,7 +83,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -194,12 +199,18 @@ If you need to use a tool, simply use the tool. Do not tell the user the tool yo logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14c-function-calling-together.py b/examples/foundational/14c-function-calling-together.py index e1fc55eb3..34900f2c1 100644 --- a/examples/foundational/14c-function-calling-together.py +++ b/examples/foundational/14c-function-calling-together.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -135,12 +137,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14d-function-calling-video.py b/examples/foundational/14d-function-calling-video.py index a6f21922d..2d023498b 100644 --- a/examples/foundational/14d-function-calling-video.py +++ b/examples/foundational/14d-function-calling-video.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import os @@ -14,11 +14,16 @@ from loguru import logger from pipecat.adapters.schemas.function_schema import FunctionSchema from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera 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.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -78,7 +83,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -183,12 +188,18 @@ indicate you should use the get_image tool are: logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14e-function-calling-google.py b/examples/foundational/14e-function-calling-google.py index 92ebe4135..98ca1f4f7 100644 --- a/examples/foundational/14e-function-calling-google.py +++ b/examples/foundational/14e-function-calling-google.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import os @@ -14,12 +14,17 @@ from loguru import logger from pipecat.adapters.schemas.function_schema import FunctionSchema from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera from pipecat.frames.frames import TTSSpeakFrame 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.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -83,7 +88,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -205,12 +210,18 @@ indicate you should use the get_image tool are: logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14f-function-calling-groq.py b/examples/foundational/14f-function-calling-groq.py index d527642d0..aff92b173 100644 --- a/examples/foundational/14f-function-calling-groq.py +++ b/examples/foundational/14f-function-calling-groq.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -19,6 +19,8 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.llm_response import LLMUserAggregatorParams from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.groq.llm import GroqLLMService from pipecat.services.groq.stt import GroqSTTService @@ -56,7 +58,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = GroqSTTService(api_key=os.getenv("GROQ_API_KEY"), model="distil-whisper-large-v3-en") @@ -137,12 +139,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14g-function-calling-grok.py b/examples/foundational/14g-function-calling-grok.py index 00aa32aa2..87abb3657 100644 --- a/examples/foundational/14g-function-calling-grok.py +++ b/examples/foundational/14g-function-calling-grok.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -17,6 +17,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.grok.llm import GrokLLMService @@ -54,7 +56,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -127,12 +129,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14h-function-calling-azure.py b/examples/foundational/14h-function-calling-azure.py index cf8480c75..bafa03f0c 100644 --- a/examples/foundational/14h-function-calling-azure.py +++ b/examples/foundational/14h-function-calling-azure.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.azure.llm import AzureLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -136,12 +138,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14i-function-calling-fireworks.py b/examples/foundational/14i-function-calling-fireworks.py index 0921d73d6..f492f7a92 100644 --- a/examples/foundational/14i-function-calling-fireworks.py +++ b/examples/foundational/14i-function-calling-fireworks.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.fireworks.llm import FireworksLLMService @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -135,12 +137,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14j-function-calling-nim.py b/examples/foundational/14j-function-calling-nim.py index 6aa101ee8..9f1e1c563 100644 --- a/examples/foundational/14j-function-calling-nim.py +++ b/examples/foundational/14j-function-calling-nim.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -133,12 +135,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14k-function-calling-cerebras.py b/examples/foundational/14k-function-calling-cerebras.py index 5a6bcf91c..f037bb8e1 100644 --- a/examples/foundational/14k-function-calling-cerebras.py +++ b/examples/foundational/14k-function-calling-cerebras.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.cerebras.llm import CerebrasLLMService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -142,12 +144,18 @@ Start by asking me for my location. Then, use 'get_weather_current' to give me a logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14l-function-calling-deepseek.py b/examples/foundational/14l-function-calling-deepseek.py index 814a4147d..a46bdc688 100644 --- a/examples/foundational/14l-function-calling-deepseek.py +++ b/examples/foundational/14l-function-calling-deepseek.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepseek.llm import DeepSeekLLMService @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -142,12 +144,18 @@ Start by asking me for my location. Then, use 'get_weather_current' to give me a logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14m-function-calling-openrouter.py b/examples/foundational/14m-function-calling-openrouter.py index aac0923ca..4f4ec6ee6 100644 --- a/examples/foundational/14m-function-calling-openrouter.py +++ b/examples/foundational/14m-function-calling-openrouter.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.azure.tts import AzureTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -136,12 +138,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14n-function-calling-perplexity.py b/examples/foundational/14n-function-calling-perplexity.py index 144c3a3df..d752c5f24 100644 --- a/examples/foundational/14n-function-calling-perplexity.py +++ b/examples/foundational/14n-function-calling-perplexity.py @@ -11,7 +11,6 @@ currently support function calling. The example shows basic chat completion func using Perplexity's API while maintaining compatibility with the OpenAI interface. """ -import argparse import os from dotenv import load_dotenv @@ -22,6 +21,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.perplexity.llm import PerplexityLLMService @@ -53,7 +54,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -106,12 +107,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14o-function-calling-gemini-openai-format.py b/examples/foundational/14o-function-calling-gemini-openai-format.py index 7d236bf4c..8f4451f29 100644 --- a/examples/foundational/14o-function-calling-gemini-openai-format.py +++ b/examples/foundational/14o-function-calling-gemini-openai-format.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService from pipecat.services.google.llm_openai import GoogleLLMOpenAIBetaService @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -132,12 +134,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14p-function-calling-gemini-vertex-ai.py b/examples/foundational/14p-function-calling-gemini-vertex-ai.py index 1fc6b0fc4..a60396c4f 100644 --- a/examples/foundational/14p-function-calling-gemini-vertex-ai.py +++ b/examples/foundational/14p-function-calling-gemini-vertex-ai.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService from pipecat.services.google.llm_vertex import GoogleVertexLLMService @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -138,12 +140,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14q-function-calling-qwen.py b/examples/foundational/14q-function-calling-qwen.py index 7cf2182c0..881e96c7f 100644 --- a/examples/foundational/14q-function-calling-qwen.py +++ b/examples/foundational/14q-function-calling-qwen.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -55,7 +57,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -134,12 +136,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14r-function-calling-aws.py b/examples/foundational/14r-function-calling-aws.py index a14c37cf9..453c7b843 100644 --- a/examples/foundational/14r-function-calling-aws.py +++ b/examples/foundational/14r-function-calling-aws.py @@ -4,8 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse -import os from dotenv import load_dotenv from loguru import logger @@ -17,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.aws.llm import AWSBedrockLLMService from pipecat.services.aws.stt import AWSTranscribeSTTService from pipecat.services.aws.tts import AWSPollyTTSService @@ -58,7 +58,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = AWSTranscribeSTTService() @@ -151,12 +151,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14s-function-calling-sambanova.py b/examples/foundational/14s-function-calling-sambanova.py index dd11af527..0a6be8419 100644 --- a/examples/foundational/14s-function-calling-sambanova.py +++ b/examples/foundational/14s-function-calling-sambanova.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -19,6 +19,8 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.llm_response import LLMUserAggregatorParams from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.sambanova.llm import SambaNovaLLMService @@ -56,7 +58,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = SambaNovaSTTService( @@ -141,12 +143,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14t-function-calling-direct.py b/examples/foundational/14t-function-calling-direct.py index 7778461f6..82349a105 100644 --- a/examples/foundational/14t-function-calling-direct.py +++ b/examples/foundational/14t-function-calling-direct.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -17,6 +17,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -71,7 +73,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -135,12 +137,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/14u-function-calling-ollama.py b/examples/foundational/14u-function-calling-ollama.py index 39220b791..011ea01b8 100644 --- a/examples/foundational/14u-function-calling-ollama.py +++ b/examples/foundational/14u-function-calling-ollama.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -60,7 +62,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -151,12 +153,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/15-switch-voices.py b/examples/foundational/15-switch-voices.py index ce2a358af..fc3aba0de 100644 --- a/examples/foundational/15-switch-voices.py +++ b/examples/foundational/15-switch-voices.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.filters.function_filter import FunctionFilter +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -76,7 +78,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -172,12 +174,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/15a-switch-languages.py b/examples/foundational/15a-switch-languages.py index 61cc2e3bd..767810deb 100644 --- a/examples/foundational/15a-switch-languages.py +++ b/examples/foundational/15a-switch-languages.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from deepgram import LiveOptions @@ -19,6 +19,8 @@ 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.filters.function_filter import FunctionFilter +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -71,7 +73,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService( @@ -160,12 +162,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/16-gpu-container-local-bot.py b/examples/foundational/16-gpu-container-local-bot.py index fe8437be0..326789693 100644 --- a/examples/foundational/16-gpu-container-local-bot.py +++ b/examples/foundational/16-gpu-container-local-bot.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -15,6 +15,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService from pipecat.services.openai.llm import OpenAILLMService @@ -46,7 +48,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -137,12 +139,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/17-detect-user-idle.py b/examples/foundational/17-detect-user-idle.py index bb6975829..32ec83cb6 100644 --- a/examples/foundational/17-detect-user-idle.py +++ b/examples/foundational/17-detect-user-idle.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -17,6 +17,8 @@ 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.user_idle_processor import UserIdleProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -134,12 +136,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/18-gstreamer-filesrc.py b/examples/foundational/18-gstreamer-filesrc.py index 94cbaed84..ca3f88d10 100644 --- a/examples/foundational/18-gstreamer-filesrc.py +++ b/examples/foundational/18-gstreamer-filesrc.py @@ -13,11 +13,16 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.gstreamer.pipeline_source import GStreamerPipelineSource +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.services.daily import DailyParams load_dotenv(override=True) +parser = argparse.ArgumentParser(description="Pipecat Video Streaming Bot") +parser.add_argument("-i", "--input", type=str, required=True, help="Input video file") +args = parser.parse_args() # We store functions so objects (e.g. SileroVADAnalyzer) don't get # instantiated. The function will be called when the desired transport gets @@ -40,7 +45,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, args: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport, args: argparse.Namespace): logger.info(f"Starting bot with video input: {args.input}") gst = GStreamerPipelineSource( @@ -60,15 +65,18 @@ async def run_example(transport: BaseTransport, args: argparse.Namespace, handle task = PipelineTask(pipeline) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) + + if __name__ == "__main__": - from pipecat.examples.run import main + from pipecat.runner.run import main - parser = argparse.ArgumentParser(description="Pipecat Bot Runner") - parser.add_argument("-i", "--input", type=str, required=True, help="Input video file") - - main(run_example, parser=parser, transport_params=transport_params) + main() diff --git a/examples/foundational/18a-gstreamer-videotestsrc.py b/examples/foundational/18a-gstreamer-videotestsrc.py index 91b7535bd..b5e9718c3 100644 --- a/examples/foundational/18a-gstreamer-videotestsrc.py +++ b/examples/foundational/18a-gstreamer-videotestsrc.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse from dotenv import load_dotenv from loguru import logger @@ -13,6 +12,8 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.processors.gstreamer.pipeline_source import GStreamerPipelineSource +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.services.daily import DailyParams @@ -37,7 +38,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot with video test source") gst = GStreamerPipelineSource( @@ -56,12 +57,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si task = PipelineTask(pipeline) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/19-openai-realtime-beta.py b/examples/foundational/19-openai-realtime-beta.py index 71b20eb0f..d3fda06e3 100644 --- a/examples/foundational/19-openai-realtime-beta.py +++ b/examples/foundational/19-openai-realtime-beta.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from datetime import datetime @@ -20,6 +20,8 @@ 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.transcript_processor import TranscriptProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai_realtime_beta import ( InputAudioNoiseReduction, @@ -106,7 +108,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") session_properties = SessionProperties( @@ -211,12 +213,18 @@ Remember, your responses should be short. Just one or two sentences, usually.""" line = f"{timestamp}{msg.role}: {msg.content}" logger.info(f"Transcript: {line}") - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/19a-azure-realtime-beta.py b/examples/foundational/19a-azure-realtime-beta.py index 81017188c..832b5948c 100644 --- a/examples/foundational/19a-azure-realtime-beta.py +++ b/examples/foundational/19a-azure-realtime-beta.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from datetime import datetime @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai_realtime_beta import ( AzureRealtimeBetaLLMService, @@ -103,7 +105,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") session_properties = SessionProperties( @@ -195,12 +197,18 @@ Remember, your responses should be short. Just one or two sentences, usually.""" logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/20a-persistent-context-openai.py b/examples/foundational/20a-persistent-context-openai.py index 9dd6ba42c..aa3a2bfef 100644 --- a/examples/foundational/20a-persistent-context-openai.py +++ b/examples/foundational/20a-persistent-context-openai.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import glob import json import os @@ -21,6 +20,8 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import ( OpenAILLMContext, ) +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -186,7 +187,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") global tts @@ -239,12 +240,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/20b-persistent-context-openai-realtime.py b/examples/foundational/20b-persistent-context-openai-realtime.py index 2315254cb..6108be89c 100644 --- a/examples/foundational/20b-persistent-context-openai-realtime.py +++ b/examples/foundational/20b-persistent-context-openai-realtime.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import glob import json @@ -21,6 +20,8 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import ( OpenAILLMContext, ) +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai_realtime_beta import ( @@ -174,7 +175,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -249,12 +250,18 @@ Remember, your responses should be short. Just one or two sentences, usually.""" logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/20c-persistent-context-anthropic.py b/examples/foundational/20c-persistent-context-anthropic.py index 1c5f2c5a0..cdd61a836 100644 --- a/examples/foundational/20c-persistent-context-anthropic.py +++ b/examples/foundational/20c-persistent-context-anthropic.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import glob import json import os @@ -21,6 +20,8 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import ( OpenAILLMContext, ) +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -181,7 +182,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") global tts @@ -238,12 +239,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/20d-persistent-context-gemini.py b/examples/foundational/20d-persistent-context-gemini.py index c9489539d..8abfac484 100644 --- a/examples/foundational/20d-persistent-context-gemini.py +++ b/examples/foundational/20d-persistent-context-gemini.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import glob import json import os @@ -15,13 +14,18 @@ from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.audio.vad.vad_analyzer import VADParams -from pipecat.examples.run import get_transport_client_id, maybe_capture_participant_camera 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.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + get_transport_client_id, + maybe_capture_participant_camera, +) from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -237,7 +241,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -297,12 +301,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/20e-persistent-context-aws-nova-sonic.py b/examples/foundational/20e-persistent-context-aws-nova-sonic.py index 7fa4c7e54..e48e8661a 100644 --- a/examples/foundational/20e-persistent-context-aws-nova-sonic.py +++ b/examples/foundational/20e-persistent-context-aws-nova-sonic.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import glob import json @@ -21,6 +20,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.aws_nova_sonic.aws import AWSNovaSonicLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -191,7 +192,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Specify initial system instruction. @@ -262,12 +263,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/21-tavus-transport.py b/examples/foundational/21-tavus-transport.py index 8c6bb03fc..e1d6e5689 100644 --- a/examples/foundational/21-tavus-transport.py +++ b/examples/foundational/21-tavus-transport.py @@ -17,6 +17,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService diff --git a/examples/foundational/21a-tavus-video-service.py b/examples/foundational/21a-tavus-video-service.py index 532cce847..636e1b8c6 100644 --- a/examples/foundational/21a-tavus-video-service.py +++ b/examples/foundational/21a-tavus-video-service.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -50,7 +52,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -118,12 +120,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/22-natural-conversation.py b/examples/foundational/22-natural-conversation.py index e3662ac85..7ed5fd654 100644 --- a/examples/foundational/22-natural-conversation.py +++ b/examples/foundational/22-natural-conversation.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -21,6 +21,8 @@ from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.processors.filters.null_filter import NullFilter from pipecat.processors.filters.wake_notifier_filter import WakeNotifierFilter from pipecat.processors.user_idle_processor import UserIdleProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -54,7 +56,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -164,12 +166,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/22b-natural-conversation-proposal.py b/examples/foundational/22b-natural-conversation-proposal.py index 74f280124..3bd3dfd22 100644 --- a/examples/foundational/22b-natural-conversation-proposal.py +++ b/examples/foundational/22b-natural-conversation-proposal.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import os import time @@ -42,6 +41,8 @@ from pipecat.processors.aggregators.openai_llm_context import ( from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.user_idle_processor import UserIdleProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -223,7 +224,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -384,12 +385,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/22c-natural-conversation-mixed-llms.py b/examples/foundational/22c-natural-conversation-mixed-llms.py index 00d799cc8..bd1c0b411 100644 --- a/examples/foundational/22c-natural-conversation-mixed-llms.py +++ b/examples/foundational/22c-natural-conversation-mixed-llms.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import os import time @@ -42,6 +41,8 @@ from pipecat.processors.aggregators.openai_llm_context import ( from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.user_idle_processor import UserIdleProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -427,7 +428,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -600,12 +601,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/22d-natural-conversation-gemini-audio.py b/examples/foundational/22d-natural-conversation-gemini-audio.py index 0d053febf..ef57a27c9 100644 --- a/examples/foundational/22d-natural-conversation-gemini-audio.py +++ b/examples/foundational/22d-natural-conversation-gemini-audio.py @@ -647,7 +647,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tts = CartesiaTTSService( @@ -774,12 +774,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/23-bot-background-sound.py b/examples/foundational/23-bot-background-sound.py index a74b81f65..e0f70384c 100644 --- a/examples/foundational/23-bot-background-sound.py +++ b/examples/foundational/23-bot-background-sound.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import os @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -68,7 +70,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) tts = CartesiaTTSService( @@ -130,12 +132,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/24-stt-mute-filter.py b/examples/foundational/24-stt-mute-filter.py index a39314e92..63db5309d 100644 --- a/examples/foundational/24-stt-mute-filter.py +++ b/examples/foundational/24-stt-mute-filter.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import os @@ -19,6 +19,8 @@ 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.filters.stt_mute_filter import STTMuteConfig, STTMuteFilter, STTMuteStrategy +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepgram.tts import DeepgramTTSService from pipecat.services.llm_service import FunctionCallParams @@ -60,7 +62,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -146,12 +148,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/25-google-audio-in.py b/examples/foundational/25-google-audio-in.py index 00c2c0941..f5dcf66dc 100644 --- a/examples/foundational/25-google-audio-in.py +++ b/examples/foundational/25-google-audio-in.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dataclasses import dataclass @@ -32,6 +31,8 @@ from pipecat.processors.aggregators.openai_llm_context import ( OpenAILLMContextFrame, ) from pipecat.processors.frame_processor import FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.google.llm import GoogleLLMContext, GoogleLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -291,7 +292,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") tts = CartesiaTTSService( @@ -373,12 +374,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26-gemini-multimodal-live.py b/examples/foundational/26-gemini-multimodal-live.py index 7d9a19995..2f80658a7 100644 --- a/examples/foundational/26-gemini-multimodal-live.py +++ b/examples/foundational/26-gemini-multimodal-live.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -16,6 +15,8 @@ from pipecat.frames.frames import LLMMessagesAppendFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -53,7 +54,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create the Gemini Multimodal Live LLM service @@ -113,11 +114,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await task.cancel() # Run the pipeline - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26a-gemini-multimodal-live-transcription.py b/examples/foundational/26a-gemini-multimodal-live-transcription.py index a919f6297..e4ed7f16f 100644 --- a/examples/foundational/26a-gemini-multimodal-live-transcription.py +++ b/examples/foundational/26a-gemini-multimodal-live-transcription.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.transcript_processor import TranscriptProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -60,7 +62,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") llm = GeminiMultimodalLiveLLMService( @@ -132,12 +134,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si line = f"{timestamp}{msg.role}: {msg.content}" logger.info(f"Transcript: {line}") - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26b-gemini-multimodal-live-function-calling.py b/examples/foundational/26b-gemini-multimodal-live-function-calling.py index c21559b12..56a2c0745 100644 --- a/examples/foundational/26b-gemini-multimodal-live-function-calling.py +++ b/examples/foundational/26b-gemini-multimodal-live-function-calling.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from datetime import datetime @@ -19,6 +19,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -88,7 +90,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") weather_function = FunctionSchema( @@ -167,12 +169,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26c-gemini-multimodal-live-video.py b/examples/foundational/26c-gemini-multimodal-live-video.py index 50c283aae..5978ac2b4 100644 --- a/examples/foundational/26c-gemini-multimodal-live-video.py +++ b/examples/foundational/26c-gemini-multimodal-live-video.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import os @@ -13,11 +13,16 @@ from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.audio.vad.vad_analyzer import VADParams -from pipecat.examples.run import maybe_capture_participant_camera, maybe_capture_participant_screen 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.types import RunnerArguments +from pipecat.runner.utils import ( + create_transport, + maybe_capture_participant_camera, + maybe_capture_participant_screen, +) from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.services.daily import DailyParams @@ -51,7 +56,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): llm = GeminiMultimodalLiveLLMService( api_key=os.getenv("GOOGLE_API_KEY"), voice_id="Aoede", # Puck, Charon, Kore, Fenrir, Aoede @@ -105,12 +110,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26d-gemini-multimodal-live-text.py b/examples/foundational/26d-gemini-multimodal-live-text.py index f5d0f3630..e6c682b2f 100644 --- a/examples/foundational/26d-gemini-multimodal-live-text.py +++ b/examples/foundational/26d-gemini-multimodal-live-text.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.gemini_multimodal_live.gemini import ( GeminiMultimodalLiveLLMService, @@ -74,7 +76,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") llm = GeminiMultimodalLiveLLMService( @@ -135,12 +137,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26e-gemini-multimodal-google-search.py b/examples/foundational/26e-gemini-multimodal-google-search.py index 907634694..ab9b40f1f 100644 --- a/examples/foundational/26e-gemini-multimodal-google-search.py +++ b/examples/foundational/26e-gemini-multimodal-google-search.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.network.fastapi_websocket import FastAPIWebsocketParams @@ -76,7 +78,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Initialize the Gemini Multimodal Live model @@ -126,12 +128,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/26f-gemini-multimodal-live-files-api.py b/examples/foundational/26f-gemini-multimodal-live-files-api.py index fd53fe9b6..7e8943d52 100644 --- a/examples/foundational/26f-gemini-multimodal-live-files-api.py +++ b/examples/foundational/26f-gemini-multimodal-live-files-api.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os import tempfile @@ -17,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gemini_multimodal_live.gemini import ( GeminiMultimodalLiveLLMService, ) @@ -87,7 +88,7 @@ async def create_sample_file(): return f.name -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting File API bot") # Create a sample file to upload @@ -218,8 +219,14 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.error(f"Error removing temporary file: {e}") +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) + + if __name__ == "__main__": - from pipecat.examples.run import main + from pipecat.runner.run import main upload_example_file = input(""" @@ -235,4 +242,4 @@ if __name__ == "__main__": else: print(f"Using default file") - main(run_example, transport_params=transport_params) + main() diff --git a/examples/foundational/26g-gemini-multimodal-live-groundingMetadata.py b/examples/foundational/26g-gemini-multimodal-live-groundingMetadata.py index e5f3aacd2..841362af9 100644 --- a/examples/foundational/26g-gemini-multimodal-live-groundingMetadata.py +++ b/examples/foundational/26g-gemini-multimodal-live-groundingMetadata.py @@ -1,4 +1,3 @@ -import argparse import os from dotenv import load_dotenv @@ -13,6 +12,8 @@ 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.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.gemini_multimodal_live.gemini import GeminiMultimodalLiveLLMService from pipecat.services.google.frames import LLMSearchResponseFrame from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -95,7 +96,7 @@ class GroundingMetadataProcessor(FrameProcessor): await self.push_frame(frame, direction) -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting Gemini Live Grounding Metadata Test Bot") # Create tools using ToolsSchema with custom tools for Gemini @@ -155,7 +156,13 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/27-simli-layer.py b/examples/foundational/27-simli-layer.py index 40f6b0c3d..97eba7bba 100644 --- a/examples/foundational/27-simli-layer.py +++ b/examples/foundational/27-simli-layer.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -50,7 +52,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -108,11 +110,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/28-transcription-processor.py b/examples/foundational/28-transcription-processor.py index 82ca13bbc..43d9ed11d 100644 --- a/examples/foundational/28-transcription-processor.py +++ b/examples/foundational/28-transcription-processor.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from typing import List, Optional @@ -18,6 +17,8 @@ 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.transcript_processor import TranscriptProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -111,7 +112,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -176,11 +177,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/29-turn-tracking-observer.py b/examples/foundational/29-turn-tracking-observer.py index 3467f044c..5b6344f44 100644 --- a/examples/foundational/29-turn-tracking-observer.py +++ b/examples/foundational/29-turn-tracking-observer.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -47,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -116,12 +118,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/30-observer.py b/examples/foundational/30-observer.py index 161031415..6f069e454 100644 --- a/examples/foundational/30-observer.py +++ b/examples/foundational/30-observer.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -96,7 +96,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -161,12 +161,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/32-gemini-grounding-metadata.py b/examples/foundational/32-gemini-grounding-metadata.py index e4729bfd5..3e27bb344 100644 --- a/examples/foundational/32-gemini-grounding-metadata.py +++ b/examples/foundational/32-gemini-grounding-metadata.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import sys from pathlib import Path @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService, LLMSearchResponseFrame @@ -89,7 +91,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -148,11 +150,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/33-gemini-rag.py b/examples/foundational/33-gemini-rag.py index dcb4c9a8c..d0509c357 100644 --- a/examples/foundational/33-gemini-rag.py +++ b/examples/foundational/33-gemini-rag.py @@ -47,7 +47,6 @@ Customization options: - change the function calling logic """ -import argparse import json import os import time @@ -61,6 +60,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -176,7 +177,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -255,11 +256,17 @@ Your response will be turned into speech so use only simple words and punctuatio logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/34-audio-recording.py b/examples/foundational/34-audio-recording.py index 692904d0d..74070f049 100644 --- a/examples/foundational/34-audio-recording.py +++ b/examples/foundational/34-audio-recording.py @@ -46,7 +46,6 @@ Note: handling merged and separate audio tracks respectively. """ -import argparse import datetime import io import os @@ -62,6 +61,8 @@ 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.audio.audio_buffer_processor import AudioBufferProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -108,7 +109,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"), audio_passthrough=True) @@ -189,11 +190,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si bot_filename = f"recordings/bot_{timestamp}.wav" await save_audio_file(bot_audio, bot_filename, sample_rate, 1) - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/35-pattern-pair-voice-switching.py b/examples/foundational/35-pattern-pair-voice-switching.py index 07860f98b..7b1df655c 100644 --- a/examples/foundational/35-pattern-pair-voice-switching.py +++ b/examples/foundational/35-pattern-pair-voice-switching.py @@ -44,8 +44,6 @@ Note: such as formatting instructions, command recognition, or structured data extraction. """ -import argparse -import asyncio import os from dotenv import load_dotenv @@ -56,6 +54,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -96,7 +96,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create pattern pair aggregator for voice switching @@ -227,11 +227,17 @@ Remember: Use narrator voice for EVERYTHING except the actual quoted dialogue."" logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/36-user-email-gathering.py b/examples/foundational/36-user-email-gathering.py index 528200182..1df1de518 100644 --- a/examples/foundational/36-user-email-gathering.py +++ b/examples/foundational/36-user-email-gathering.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -54,7 +56,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -145,11 +147,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/37-mem0.py b/examples/foundational/37-mem0.py index b7ceb885e..34ef51461 100644 --- a/examples/foundational/37-mem0.py +++ b/examples/foundational/37-mem0.py @@ -41,7 +41,6 @@ Requirements: The bot runs as part of a pipeline that processes audio frames and manages the conversation flow. """ -import argparse import os from typing import Union @@ -54,6 +53,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.elevenlabs.tts import ElevenLabsTTSService from pipecat.services.mem0.memory import Mem0MemoryService @@ -145,7 +146,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): """Main bot execution function. Sets up and runs the bot pipeline including: @@ -286,11 +287,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/38-smart-turn-fal.py b/examples/foundational/38-smart-turn-fal.py index a3fac43ab..d98d500e5 100644 --- a/examples/foundational/38-smart-turn-fal.py +++ b/examples/foundational/38-smart-turn-fal.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -59,7 +61,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -113,12 +115,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/38a-smart-turn-local-coreml.py b/examples/foundational/38a-smart-turn-local-coreml.py index 043e2e0bd..adc61d8d2 100644 --- a/examples/foundational/38a-smart-turn-local-coreml.py +++ b/examples/foundational/38a-smart-turn-local-coreml.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -75,7 +77,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -129,12 +131,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/38b-smart-turn-local.py b/examples/foundational/38b-smart-turn-local.py index 7541603ba..f32a32713 100644 --- a/examples/foundational/38b-smart-turn-local.py +++ b/examples/foundational/38b-smart-turn-local.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -75,7 +77,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -129,12 +131,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/39-mcp-stdio.py b/examples/foundational/39-mcp-stdio.py index 634ed8393..f53d1abf2 100644 --- a/examples/foundational/39-mcp-stdio.py +++ b/examples/foundational/39-mcp-stdio.py @@ -4,13 +4,11 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import asyncio import io import os import re import shutil -import sys import aiohttp from dotenv import load_dotenv @@ -29,6 +27,8 @@ 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.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -103,7 +103,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session for API calls @@ -186,12 +186,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/39a-mcp-run-sse.py b/examples/foundational/39a-mcp-run-sse.py index fbbcbcc6a..449eb9986 100644 --- a/examples/foundational/39a-mcp-run-sse.py +++ b/examples/foundational/39a-mcp-run-sse.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -118,12 +120,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/39b-multiple-mcp.py b/examples/foundational/39b-multiple-mcp.py index 7d1396834..8fa6774aa 100644 --- a/examples/foundational/39b-multiple-mcp.py +++ b/examples/foundational/39b-multiple-mcp.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import asyncio import io import os @@ -30,6 +30,8 @@ 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.frame_processor import FrameDirection, FrameProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService @@ -104,7 +106,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Create an HTTP session for API calls @@ -197,12 +199,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/39c-mcp-run-http.py b/examples/foundational/39c-mcp-run-http.py index 6c39da75c..144e29044 100644 --- a/examples/foundational/39c-mcp-run-http.py +++ b/examples/foundational/39c-mcp-run-http.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from dotenv import load_dotenv @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -48,7 +50,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -122,12 +124,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/40-aws-nova-sonic.py b/examples/foundational/40-aws-nova-sonic.py index ecfc4c1fb..673c8dfd5 100644 --- a/examples/foundational/40-aws-nova-sonic.py +++ b/examples/foundational/40-aws-nova-sonic.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os from datetime import datetime @@ -18,6 +18,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.aws_nova_sonic import AWSNovaSonicLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -83,7 +85,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") # Specify initial system instruction. @@ -168,11 +170,17 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await task.cancel() # Run the pipeline - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/41a-text-only-webrtc.py b/examples/foundational/41a-text-only-webrtc.py index f0a795d74..71a8c9e50 100644 --- a/examples/foundational/41a-text-only-webrtc.py +++ b/examples/foundational/41a-text-only-webrtc.py @@ -4,10 +4,8 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os -import aiohttp from dotenv import load_dotenv from loguru import logger @@ -27,10 +25,11 @@ from pipecat.processors.frameworks.rtvi import ( RTVIProcessor, RTVIServerMessageFrame, ) +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.openai import OpenAIContextAggregatorPair from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams -from pipecat.transports.services.daily import DailyParams load_dotenv(override=True) @@ -79,7 +78,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) @@ -151,7 +150,13 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/41b-text-and-audio-webrtc.py b/examples/foundational/41b-text-and-audio-webrtc.py index 205ab57f3..1169df880 100644 --- a/examples/foundational/41b-text-and-audio-webrtc.py +++ b/examples/foundational/41b-text-and-audio-webrtc.py @@ -4,10 +4,8 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os -import aiohttp from dotenv import load_dotenv from loguru import logger @@ -28,12 +26,13 @@ from pipecat.processors.frameworks.rtvi import ( RTVIProcessor, RTVIServerMessageFrame, ) +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai import OpenAIContextAggregatorPair from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams -from pipecat.transports.services.daily import DailyParams load_dotenv(override=True) @@ -89,7 +88,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -167,7 +166,13 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/42-interruption-config.py b/examples/foundational/42-interruption-config.py index 7f83b7023..3e206dfea 100644 --- a/examples/foundational/42-interruption-config.py +++ b/examples/foundational/42-interruption-config.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse import os from dotenv import load_dotenv @@ -17,6 +16,8 @@ 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.transcript_processor import TranscriptProcessor +from pipecat.runner.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService @@ -48,7 +49,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -112,12 +113,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si for message in frame.messages: logger.info(f"Transcription [{message.role}]: {message.content}") - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main() diff --git a/examples/foundational/43a-heygen-video-service.py b/examples/foundational/43a-heygen-video-service.py index 7dfa5dd28..619d6ab09 100644 --- a/examples/foundational/43a-heygen-video-service.py +++ b/examples/foundational/43a-heygen-video-service.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD 2-Clause License # -import argparse + import os import aiohttp @@ -16,6 +16,8 @@ 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.types import RunnerArguments +from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService @@ -50,7 +52,7 @@ transport_params = { } -async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool): +async def run_bot(transport: BaseTransport): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) @@ -112,12 +114,18 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_si logger.info(f"Client disconnected") await task.cancel() - runner = PipelineRunner(handle_sigint=handle_sigint) + runner = PipelineRunner(handle_sigint=False) await runner.run(task) -if __name__ == "__main__": - from pipecat.examples.run import main +async def bot(runner_args: RunnerArguments): + """Main bot entry point compatible with Pipecat Cloud.""" + transport = await create_transport(runner_args, transport_params) + await run_bot(transport) - main(run_example, transport_params=transport_params) + +if __name__ == "__main__": + from pipecat.runner.run import main + + main()