Update examples

This commit is contained in:
Mark Backman
2026-03-04 22:55:51 -05:00
parent 197885773f
commit 039a8f6c7d
207 changed files with 1241 additions and 852 deletions

View File

@@ -36,9 +36,9 @@ from pipecat.processors.aggregators.llm_response_universal import (
)
from pipecat.runner.types import RunnerArguments
from pipecat.runner.utils import create_transport
from pipecat.services.cartesia.tts import CartesiaTTSService
from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings
from pipecat.services.deepgram.stt import DeepgramSTTService
from pipecat.services.google import GoogleLLMService
from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings
from pipecat.services.llm_service import FunctionCallParams
from pipecat.services.openai.llm import OpenAILLMService
from pipecat.transports.base_transport import BaseTransport, TransportParams
@@ -93,16 +93,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
tts = CartesiaTTSService(
api_key=os.getenv("CARTESIA_API_KEY"),
voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady
settings=CartesiaTTSSettings(
voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady
),
)
system_prompt = """You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your
capabilities in a succinct way. Your output will be spoken aloud, so avoid
special characters that can't easily be spoken, such as emojis or bullet points.
Respond to what the user said in a creative and helpful way.
You have access to tools to get the current weather - use them when relevant.
When you see a <context_summary> block, it contains a compressed summary
of earlier conversation. Use it as reference but don't mention it to the user.
"""
# Primary LLM for conversation (could be any provider)
llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"))
llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt)
# Dedicated cheap/fast LLM for summarization only
summarization_llm = GoogleLLMService(
api_key=os.getenv("GOOGLE_API_KEY"),
model="gemini-2.5-flash",
settings=GoogleLLMSettings(
model="gemini-2.5-flash",
),
)
# Register tool functions
@@ -126,22 +139,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
)
tools = ToolsSchema(standard_tools=[weather_function])
messages = [
{
"role": "system",
"content": (
"You are a helpful LLM in a WebRTC call. Your goal is to demonstrate "
"your capabilities in a succinct way. Your output will be spoken aloud, "
"so avoid special characters that can't easily be spoken. Respond to what "
"the user said in a creative and helpful way. You have access to tools to "
"get the current weather - use them when relevant.\n\n"
"When you see a <context_summary> block, it contains a compressed summary "
"of earlier conversation. Use it as reference but don't mention it to the user."
),
},
]
context = LLMContext(messages, tools=tools)
context = LLMContext(tools=tools)
# Create aggregators with custom summarization
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
@@ -211,7 +209,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
async def on_client_connected(transport, client):
logger.info("Client connected")
# Kick off the conversation.
messages.append({"role": "system", "content": "Please introduce yourself to the user."})
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
await task.queue_frames([LLMRunFrame()])
@transport.event_handler("on_client_disconnected")