Skip to content

Commit 3e2794c

Browse files
authored
Merge pull request #5 from pipecat-ai/mb/migrate-examples-to-runner
Replace examples runner with pipecat.runner.run
2 parents b8163fc + f11b35d commit 3e2794c

4 files changed

Lines changed: 48 additions & 20 deletions

File tree

aws-strands/black-box.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: BSD 2-Clause License
55
#
66

7-
import argparse
87
import asyncio
98
import os
109

@@ -17,6 +16,8 @@
1716
from pipecat.pipeline.runner import PipelineRunner
1817
from pipecat.pipeline.task import PipelineParams, PipelineTask
1918
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
19+
from pipecat.runner.types import RunnerArguments
20+
from pipecat.runner.utils import create_transport
2021
from pipecat.services.cartesia.tts import CartesiaTTSService
2122
from pipecat.services.deepgram.stt import DeepgramSTTService
2223
from pipecat.services.llm_service import FunctionCallParams
@@ -98,7 +99,7 @@ def get_current_weather_from_lat_long(lat: float, long: float) -> dict:
9899
}
99100

100101

101-
async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
102+
async def run_bot(transport: BaseTransport):
102103
logger.info(f"Starting bot")
103104

104105
strands_agent = Agent(
@@ -194,12 +195,18 @@ async def on_client_disconnected(transport, client):
194195
logger.info(f"Client disconnected")
195196
await task.cancel()
196197

197-
runner = PipelineRunner(handle_sigint=handle_sigint)
198+
runner = PipelineRunner(handle_sigint=False)
198199

199200
await runner.run(task)
200201

201202

203+
async def bot(runner_args: RunnerArguments):
204+
"""Main bot entry point compatible with Pipecat Cloud."""
205+
transport = await create_transport(runner_args, transport_params)
206+
await run_bot(transport)
207+
208+
202209
if __name__ == "__main__":
203-
from pipecat.examples.run import main
210+
from pipecat.runner.run import main
204211

205-
main(run_example, transport_params=transport_params)
212+
main()

aws-strands/explain-thinking.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: BSD 2-Clause License
55
#
66

7-
import argparse
87
import asyncio
98
import os
109
import time
@@ -18,6 +17,8 @@
1817
from pipecat.pipeline.runner import PipelineRunner
1918
from pipecat.pipeline.task import PipelineParams, PipelineTask
2019
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
20+
from pipecat.runner.types import RunnerArguments
21+
from pipecat.runner.utils import create_transport
2122
from pipecat.services.cartesia.tts import CartesiaTTSService
2223
from pipecat.services.deepgram.stt import DeepgramSTTService
2324
from pipecat.services.llm_service import FunctionCallParams
@@ -103,7 +104,7 @@ def get_current_weather_from_lat_long(lat: float, long: float) -> dict:
103104
}
104105

105106

106-
async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
107+
async def run_bot(transport: BaseTransport):
107108
logger.info(f"Starting bot")
108109

109110
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
@@ -236,12 +237,18 @@ async def on_client_disconnected(transport, client):
236237
logger.info(f"Client disconnected")
237238
await task.cancel()
238239

239-
runner = PipelineRunner(handle_sigint=handle_sigint)
240+
runner = PipelineRunner(handle_sigint=False)
240241

241242
await runner.run(task)
242243

243244

245+
async def bot(runner_args: RunnerArguments):
246+
"""Main bot entry point compatible with Pipecat Cloud."""
247+
transport = await create_transport(runner_args, transport_params)
248+
await run_bot(transport)
249+
250+
244251
if __name__ == "__main__":
245-
from pipecat.examples.run import main
252+
from pipecat.runner.run import main
246253

247-
main(run_example, transport_params=transport_params)
254+
main()

open-telemetry/jaeger/bot.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: BSD 2-Clause License
55
#
66

7-
import argparse
87
import os
98

109
from dotenv import load_dotenv
@@ -18,6 +17,8 @@
1817
from pipecat.pipeline.runner import PipelineRunner
1918
from pipecat.pipeline.task import PipelineParams, PipelineTask
2019
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
20+
from pipecat.runner.types import RunnerArguments
21+
from pipecat.runner.utils import create_transport
2122
from pipecat.services.cartesia.tts import CartesiaTTSService
2223
from pipecat.services.deepgram.stt import DeepgramSTTService
2324
from pipecat.services.llm_service import FunctionCallParams
@@ -74,7 +75,7 @@ async def fetch_weather_from_api(params: FunctionCallParams):
7475
}
7576

7677

77-
async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
78+
async def run_bot(transport: BaseTransport):
7879
logger.info(f"Starting bot")
7980

8081
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
@@ -158,12 +159,18 @@ async def on_client_disconnected(transport, client):
158159
logger.info(f"Client disconnected")
159160
await task.cancel()
160161

161-
runner = PipelineRunner(handle_sigint=handle_sigint)
162+
runner = PipelineRunner(handle_sigint=False)
162163

163164
await runner.run(task)
164165

165166

167+
async def bot(runner_args: RunnerArguments):
168+
"""Main bot entry point compatible with Pipecat Cloud."""
169+
transport = await create_transport(runner_args, transport_params)
170+
await run_bot(transport)
171+
172+
166173
if __name__ == "__main__":
167-
from pipecat.examples.run import main
174+
from pipecat.runner.run import main
168175

169-
main(run_example, transport_params=transport_params)
176+
main()

open-telemetry/langfuse/bot.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: BSD 2-Clause License
55
#
66

7-
import argparse
87
import os
98

109
from dotenv import load_dotenv
@@ -18,6 +17,8 @@
1817
from pipecat.pipeline.runner import PipelineRunner
1918
from pipecat.pipeline.task import PipelineParams, PipelineTask
2019
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
20+
from pipecat.runner.types import RunnerArguments
21+
from pipecat.runner.utils import create_transport
2122
from pipecat.services.cartesia.tts import CartesiaTTSService
2223
from pipecat.services.deepgram.stt import DeepgramSTTService
2324
from pipecat.services.llm_service import FunctionCallParams
@@ -71,7 +72,7 @@ async def fetch_weather_from_api(params: FunctionCallParams):
7172
}
7273

7374

74-
async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
75+
async def run_bot(transport: BaseTransport):
7576
logger.info(f"Starting bot")
7677

7778
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
@@ -155,12 +156,18 @@ async def on_client_disconnected(transport, client):
155156
logger.info(f"Client disconnected")
156157
await task.cancel()
157158

158-
runner = PipelineRunner(handle_sigint=handle_sigint)
159+
runner = PipelineRunner(handle_sigint=False)
159160

160161
await runner.run(task)
161162

162163

164+
async def bot(runner_args: RunnerArguments):
165+
"""Main bot entry point compatible with Pipecat Cloud."""
166+
transport = await create_transport(runner_args, transport_params)
167+
await run_bot(transport)
168+
169+
163170
if __name__ == "__main__":
164-
from pipecat.examples.run import main
171+
from pipecat.runner.run import main
165172

166-
main(run_example, transport_params=transport_params)
173+
main()

0 commit comments

Comments
 (0)