Merge pull request #3931 from pipecat-ai/aleix/examples-always-use-user-role
Update foundational examples to use system_instruction
This commit is contained in:
1
changelog/3931.other.md
Normal file
1
changelog/3931.other.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Updated foundational examples and eval scripts to use `"user"` role instead of `"system"` when adding messages to `LLMContext`, since system prompts should be set via `system_instruction` on the LLM service.
|
||||||
@@ -60,7 +60,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
@transport.event_handler("on_client_connected")
|
@transport.event_handler("on_client_connected")
|
||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
context = LLMContext()
|
context = LLMContext()
|
||||||
context.add_message({"role": "system", "content": "Say hello to the world."})
|
context.add_message({"role": "user", "content": "Say hello to the world."})
|
||||||
await task.queue_frames([LLMContextFrame(context), EndFrame()])
|
await task.queue_frames([LLMContextFrame(context), EndFrame()])
|
||||||
|
|
||||||
runner = PipelineRunner(handle_sigint=runner_args.handle_sigint)
|
runner = PipelineRunner(handle_sigint=runner_args.handle_sigint)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async def run_example(webrtc_connection: SmallWebRTCConnection):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ async def main():
|
|||||||
await transport.capture_participant_transcription(participant["id"])
|
await transport.capture_participant_transcription(participant["id"])
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
]:
|
]:
|
||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Describe a nature photograph suitable for use in a calendar, for the month of {month}. Include only the image description with no preamble. Limit the description to one sentence, please.",
|
"content": f"Describe a nature photograph suitable for use in a calendar, for the month of {month}. Include only the image description with no preamble. Limit the description to one sentence, please.",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ async def main():
|
|||||||
async def get_month_data(month):
|
async def get_month_data(month):
|
||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Describe a nature photograph suitable for use in a calendar, for the month of {month}. Include only the image description with no preamble. Limit the description to one sentence, please.",
|
"content": f"Describe a nature photograph suitable for use in a calendar, for the month of {month}. Include only the image description with no preamble. Limit the description to one sentence, please.",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"role": "system", "content": "Say a short hello to the user."})
|
context.add_message({"role": "user", "content": "Say a short hello to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"role": "system", "content": "Say a short hello to the user."})
|
context.add_message({"role": "user", "content": "Say a short hello to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation with a styled introduction
|
# Kick off the conversation with a styled introduction
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation
|
# Kick off the conversation
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "You are an AI assistant. You can help with a variety of tasks. Introduce yourself and ask the user what they would like to know.",
|
"content": "You are an AI assistant. You can help with a variety of tasks. Introduce yourself and ask the user what they would like to know.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -218,11 +218,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
api_key=os.getenv("GOOGLE_API_KEY"),
|
api_key=os.getenv("GOOGLE_API_KEY"),
|
||||||
settings=GoogleLLMSettings(
|
settings=GoogleLLMSettings(
|
||||||
model="gemini-2.5-flash",
|
model="gemini-2.5-flash",
|
||||||
|
system_instruction=system_message,
|
||||||
|
# force a certain amount of thinking if you want it
|
||||||
|
# thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096)
|
||||||
),
|
),
|
||||||
# force a certain amount of thinking if you want it
|
|
||||||
# params=GoogleLLMService.InputParams(
|
|
||||||
# thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096)
|
|
||||||
# ),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
tts = GoogleTTSService(
|
tts = GoogleTTSService(
|
||||||
@@ -234,18 +233,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"),
|
credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"),
|
||||||
)
|
)
|
||||||
|
|
||||||
messages = [
|
context = LLMContext()
|
||||||
{
|
|
||||||
"role": "system",
|
|
||||||
"content": system_message,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": "Start by saying hello.",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
context = LLMContext(messages)
|
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||||
@@ -281,7 +269,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# 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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ async def main():
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
runner = PipelineRunner()
|
runner = PipelineRunner()
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
# Optionally, you can wait for 30 seconds and then change the voice.
|
# Optionally, you can wait for 30 seconds and then change the voice.
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info("Client connected")
|
logger.info("Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info("Client connected")
|
logger.info("Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{"role": "system", "content": "Please introduce yourself to the user."}
|
{"role": "user", "content": "Please introduce yourself to the user."}
|
||||||
)
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
await audiobuffer.start_recording()
|
await audiobuffer.start_recording()
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@audiobuffer.event_handler("on_audio_data")
|
@audiobuffer.event_handler("on_audio_data")
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
"💡 Word timestamps are enabled! Watch the console for TTSTextFrame logs showing each word with its PTS."
|
"💡 Word timestamps are enabled! Watch the console for TTSTextFrame logs showing each word with its PTS."
|
||||||
)
|
)
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
@transport.event_handler("on_client_connected")
|
@transport.event_handler("on_client_connected")
|
||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info("Client connected")
|
logger.info("Client connected")
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected: {client}")
|
logger.info(f"Client connected: {client}")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "Please introduce yourself. Tell the user they should say 'Hey Robot' before talking to you.",
|
"content": "Please introduce yourself. Tell the user they should say 'Hey Robot' before talking to you.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
|
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user and let them know the voices you can do. Your initial responses should be as if you were a {tts.current_voice}.",
|
"content": f"Please introduce yourself to the user and let them know the voices you can do. Your initial responses should be as if you were a {tts.current_voice}.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user and let them know the languages you speak. Your initial responses should be in {tts.current_language}.",
|
"content": f"Please introduce yourself to the user and let them know the languages you speak. Your initial responses should be in {tts.current_language}.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
# Handle "latency-ping" messages. The client will send app messages that look like
|
# Handle "latency-ping" messages. The client will send app messages that look like
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ class IdleHandler:
|
|||||||
if self._retry_count == 1:
|
if self._retry_count == 1:
|
||||||
# First attempt: Add a gentle prompt to the conversation
|
# First attempt: Add a gentle prompt to the conversation
|
||||||
message = {
|
message = {
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "The user has been quiet. Politely and briefly ask if they're still there.",
|
"content": "The user has been quiet. Politely and briefly ask if they're still there.",
|
||||||
}
|
}
|
||||||
await aggregator.push_frame(LLMMessagesAppendFrame([message], run_llm=True))
|
await aggregator.push_frame(LLMMessagesAppendFrame([message], run_llm=True))
|
||||||
elif self._retry_count == 2:
|
elif self._retry_count == 2:
|
||||||
# Second attempt: More direct prompt
|
# Second attempt: More direct prompt
|
||||||
message = {
|
message = {
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "The user is still inactive. Ask if they'd like to continue our conversation.",
|
"content": "The user is still inactive. Ask if they'd like to continue our conversation.",
|
||||||
}
|
}
|
||||||
await aggregator.push_frame(LLMMessagesAppendFrame([message], run_llm=True))
|
await aggregator.push_frame(LLMMessagesAppendFrame([message], run_llm=True))
|
||||||
@@ -209,7 +209,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
logger.info(f"Disabling idle detection")
|
logger.info(f"Disabling idle detection")
|
||||||
|
|||||||
@@ -95,12 +95,7 @@ async def load_conversation(params: FunctionCallParams):
|
|||||||
await params.result_callback({"success": False, "error": str(e)})
|
await params.result_callback({"success": False, "error": str(e)})
|
||||||
|
|
||||||
|
|
||||||
messages = [
|
system_instruction = "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."
|
||||||
{
|
|
||||||
"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, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
weather_function = FunctionSchema(
|
weather_function = FunctionSchema(
|
||||||
name="get_current_weather",
|
name="get_current_weather",
|
||||||
@@ -185,7 +180,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"))
|
llm = OpenAILLMService(
|
||||||
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
|
system_instruction=system_instruction,
|
||||||
|
)
|
||||||
|
|
||||||
# you can either register a single function for all function calls, or specific functions
|
# you can either register a single function for all function calls, or specific functions
|
||||||
# llm.register_function(None, fetch_weather_from_api)
|
# llm.register_function(None, fetch_weather_from_api)
|
||||||
@@ -194,7 +192,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
llm.register_function("get_saved_conversation_filenames", get_saved_conversation_filenames)
|
llm.register_function("get_saved_conversation_filenames", get_saved_conversation_filenames)
|
||||||
llm.register_function("load_conversation", load_conversation)
|
llm.register_function("load_conversation", load_conversation)
|
||||||
|
|
||||||
context = LLMContext(messages, tools)
|
context = LLMContext(tools=tools)
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ from pipecat.services.openai_realtime_beta import (
|
|||||||
SessionProperties,
|
SessionProperties,
|
||||||
TurnDetection,
|
TurnDetection,
|
||||||
)
|
)
|
||||||
from pipecat.services.openai_realtime_beta.events import AudioConfiguration, AudioInput
|
|
||||||
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
from pipecat.transports.base_transport import BaseTransport, TransportParams
|
||||||
from pipecat.transports.daily.transport import DailyParams
|
from pipecat.transports.daily.transport import DailyParams
|
||||||
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
|
||||||
@@ -182,16 +181,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
||||||
|
|
||||||
session_properties = SessionProperties(
|
session_properties = SessionProperties(
|
||||||
audio=AudioConfiguration(
|
input_audio_transcription=InputAudioTranscription(),
|
||||||
input=AudioInput(
|
# Set openai TurnDetection parameters. Not setting this at all will turn
|
||||||
transcription=InputAudioTranscription(),
|
# it on by default
|
||||||
# Set openai TurnDetection parameters. Not setting this at all will turn it
|
turn_detection=TurnDetection(silence_duration_ms=1000),
|
||||||
# on by default
|
# Or set to False to disable openai turn detection and use transport VAD
|
||||||
turn_detection=TurnDetection(silence_duration_ms=1000),
|
# turn_detection=False,
|
||||||
# Or set to False to disable openai turn detection and use transport VAD
|
|
||||||
# turn_detection=False,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
# tools=tools,
|
# tools=tools,
|
||||||
instructions="""Your knowledge cutoff is 2023-10. You are a helpful and friendly AI.
|
instructions="""Your knowledge cutoff is 2023-10. You are a helpful and friendly AI.
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import (
|
|||||||
)
|
)
|
||||||
from pipecat.runner.types import RunnerArguments
|
from pipecat.runner.types import RunnerArguments
|
||||||
from pipecat.runner.utils import create_transport
|
from pipecat.runner.utils import create_transport
|
||||||
from pipecat.services.anthropic.llm import AnthropicLLMService
|
from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings
|
||||||
from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings
|
from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings
|
||||||
from pipecat.services.deepgram.stt import DeepgramSTTService
|
from pipecat.services.deepgram.stt import DeepgramSTTService
|
||||||
from pipecat.services.llm_service import FunctionCallParams
|
from pipecat.services.llm_service import FunctionCallParams
|
||||||
@@ -38,7 +38,6 @@ load_dotenv(override=True)
|
|||||||
|
|
||||||
|
|
||||||
BASE_FILENAME = "/tmp/pipecat_conversation_"
|
BASE_FILENAME = "/tmp/pipecat_conversation_"
|
||||||
tts = None
|
|
||||||
|
|
||||||
|
|
||||||
async def fetch_weather_from_api(params: FunctionCallParams):
|
async def fetch_weather_from_api(params: FunctionCallParams):
|
||||||
@@ -82,7 +81,6 @@ async def save_conversation(params: FunctionCallParams):
|
|||||||
|
|
||||||
|
|
||||||
async def load_conversation(params: FunctionCallParams):
|
async def load_conversation(params: FunctionCallParams):
|
||||||
global tts
|
|
||||||
filename = params.arguments["filename"]
|
filename = params.arguments["filename"]
|
||||||
logger.debug(f"loading conversation from {filename}")
|
logger.debug(f"loading conversation from {filename}")
|
||||||
try:
|
try:
|
||||||
@@ -96,18 +94,7 @@ async def load_conversation(params: FunctionCallParams):
|
|||||||
await params.result_callback({"success": False, "error": str(e)})
|
await params.result_callback({"success": False, "error": str(e)})
|
||||||
|
|
||||||
|
|
||||||
# Test message munging ...
|
system_instruction = "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 succinct, creative and helpful way. Prefer responses that are one sentence long unless you are asked for a longer or more detailed response."
|
||||||
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, such as emojis or bullet points. Respond to what the user said in a succinct, creative and helpful way. Prefer responses that are one sentence long unless you are asked for a longer or more detailed response.",
|
|
||||||
},
|
|
||||||
{"role": "user", "content": "Start the call by saying the word 'hello'. Say only that word."},
|
|
||||||
# {"role": "user", "content": ""},
|
|
||||||
# {"role": "assistant", "content": []},
|
|
||||||
# {"role": "user", "content": "Tell me"},
|
|
||||||
# {"role": "user", "content": "a joke"},
|
|
||||||
]
|
|
||||||
|
|
||||||
weather_function = FunctionSchema(
|
weather_function = FunctionSchema(
|
||||||
name="get_current_weather",
|
name="get_current_weather",
|
||||||
@@ -183,8 +170,6 @@ transport_params = {
|
|||||||
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
||||||
logger.info(f"Starting bot")
|
logger.info(f"Starting bot")
|
||||||
|
|
||||||
global tts
|
|
||||||
|
|
||||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
||||||
|
|
||||||
tts = CartesiaTTSService(
|
tts = CartesiaTTSService(
|
||||||
@@ -194,7 +179,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"))
|
llm = AnthropicLLMService(
|
||||||
|
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
||||||
|
settings=AnthropicLLMSettings(system_instruction=system_instruction),
|
||||||
|
)
|
||||||
|
|
||||||
# you can either register a single function for all function calls, or specific functions
|
# you can either register a single function for all function calls, or specific functions
|
||||||
# llm.register_function(None, fetch_weather_from_api)
|
# llm.register_function(None, fetch_weather_from_api)
|
||||||
@@ -203,7 +191,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
llm.register_function("get_saved_conversation_filenames", get_saved_conversation_filenames)
|
llm.register_function("get_saved_conversation_filenames", get_saved_conversation_filenames)
|
||||||
llm.register_function("load_conversation", load_conversation)
|
llm.register_function("load_conversation", load_conversation)
|
||||||
|
|
||||||
context = LLMContext(messages, tools)
|
context = LLMContext(tools=tools)
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||||
@@ -234,6 +222,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
|
context.add_message(
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "Start the call by saying the word 'hello'. Say only that word.",
|
||||||
|
}
|
||||||
|
)
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -122,11 +122,7 @@ async def load_conversation(params: FunctionCallParams):
|
|||||||
await params.result_callback({"success": False, "error": str(e)})
|
await params.result_callback({"success": False, "error": str(e)})
|
||||||
|
|
||||||
|
|
||||||
# Test message munging ...
|
system_instruction = """You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your
|
||||||
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
|
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
|
can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative
|
||||||
and helpful way.
|
and helpful way.
|
||||||
@@ -151,13 +147,7 @@ indicate you should use the get_image tool are:
|
|||||||
- Tell me about what you see.
|
- Tell me about what you see.
|
||||||
- Tell me something interesting about what you see.
|
- Tell me something interesting about what you see.
|
||||||
- What's happening in the video?
|
- What's happening in the video?
|
||||||
""",
|
"""
|
||||||
},
|
|
||||||
# {"role": "user", "content": ""},
|
|
||||||
# {"role": "assistant", "content": []},
|
|
||||||
# {"role": "user", "content": "Tell me"},
|
|
||||||
# {"role": "user", "content": "a joke"},
|
|
||||||
]
|
|
||||||
|
|
||||||
weather_function = FunctionSchema(
|
weather_function = FunctionSchema(
|
||||||
name="get_current_weather",
|
name="get_current_weather",
|
||||||
@@ -262,7 +252,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"))
|
llm = GoogleLLMService(
|
||||||
|
api_key=os.getenv("GOOGLE_API_KEY"),
|
||||||
|
system_instruction=system_instruction,
|
||||||
|
)
|
||||||
|
|
||||||
# you can either register a single function for all function calls, or specific functions
|
# you can either register a single function for all function calls, or specific functions
|
||||||
# llm.register_function(None, fetch_weather_from_api)
|
# llm.register_function(None, fetch_weather_from_api)
|
||||||
@@ -272,7 +265,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
llm.register_function("load_conversation", load_conversation)
|
llm.register_function("load_conversation", load_conversation)
|
||||||
llm.register_function("get_image", get_image)
|
llm.register_function("get_image", get_image)
|
||||||
|
|
||||||
context = LLMContext(messages, tools)
|
context = LLMContext(tools=tools)
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||||
@@ -308,9 +301,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
client_id = get_transport_client_id(transport, client)
|
client_id = get_transport_client_id(transport, client)
|
||||||
|
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
messages.append(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
"content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -235,12 +235,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
llm.register_function("get_saved_conversation_filenames", get_saved_conversation_filenames)
|
llm.register_function("get_saved_conversation_filenames", get_saved_conversation_filenames)
|
||||||
llm.register_function("load_conversation", load_conversation)
|
llm.register_function("load_conversation", load_conversation)
|
||||||
|
|
||||||
context = LLMContext(
|
context = LLMContext(tools=tools)
|
||||||
messages=[
|
|
||||||
{"role": "user", "content": "Hello!"},
|
|
||||||
],
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(context)
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(context)
|
||||||
|
|
||||||
pipeline = Pipeline(
|
pipeline = Pipeline(
|
||||||
@@ -266,6 +261,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
|
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
# HACK: if using the older Nova Sonic (pre-2) model, you need this special way of
|
# HACK: if using the older Nova Sonic (pre-2) model, you need this special way of
|
||||||
# triggering the first assistant response. Note that this trigger requires a special
|
# triggering the first assistant response. Note that this trigger requires a special
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ async def main():
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "Start by greeting the user and ask how you can help.",
|
"content": "Start by greeting the user and ask how you can help.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "Start by greeting the user and ask how you can help.",
|
"content": "Start by greeting the user and ask how you can help.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.info(f"Re-enabling background sound and starting bot...")
|
logger.info(f"Re-enabling background sound and starting bot...")
|
||||||
await task.queue_frame(MixerEnableFrame(True))
|
await task.queue_frame(MixerEnableFrame(True))
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation with a weather-related prompt
|
# Kick off the conversation with a weather-related prompt
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "Ask the user what city they'd like to know the weather for.",
|
"content": "Ask the user what city they'd like to know the weather for.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -131,13 +131,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# than as arguments to GeminiLiveLLMService, but note that doing so will
|
# than as arguments to GeminiLiveLLMService, but note that doing so will
|
||||||
# trigger a (fast) reconnection when the GeminiLiveLLMService first
|
# trigger a (fast) reconnection when the GeminiLiveLLMService first
|
||||||
# receives the context (i.e. when we send the LLMRunFrame below).
|
# receives the context (i.e. when we send the LLMRunFrame below).
|
||||||
context = LLMContext(
|
context = LLMContext()
|
||||||
[
|
|
||||||
# {"role": "system", "content": system_instruction},
|
|
||||||
{"role": "user", "content": "Say hello."},
|
|
||||||
],
|
|
||||||
# tools,
|
|
||||||
)
|
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(
|
user_params=LLMUserAggregatorParams(
|
||||||
@@ -172,6 +166,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
|
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Start conversation - empty prompt to let LLM follow system instructions
|
# Start conversation - empty prompt to let LLM follow system instructions
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -197,11 +197,11 @@ Your response will be turned into speech so use only simple words and punctuatio
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
llm = GoogleLLMService(
|
llm = GoogleLLMService(
|
||||||
|
api_key=os.getenv("GOOGLE_API_KEY"),
|
||||||
settings=GoogleLLMSettings(
|
settings=GoogleLLMSettings(
|
||||||
model=VOICE_MODEL,
|
model=VOICE_MODEL,
|
||||||
system_instruction=system_prompt,
|
system_instruction=system_prompt,
|
||||||
),
|
),
|
||||||
api_key=os.getenv("GOOGLE_API_KEY"),
|
|
||||||
)
|
)
|
||||||
llm.register_function("query_knowledge_base", query_knowledge_base)
|
llm.register_function("query_knowledge_base", query_knowledge_base)
|
||||||
|
|
||||||
@@ -218,11 +218,7 @@ Your response will be turned into speech so use only simple words and punctuatio
|
|||||||
)
|
)
|
||||||
tools = ToolsSchema(standard_tools=[query_function])
|
tools = ToolsSchema(standard_tools=[query_function])
|
||||||
|
|
||||||
messages = [
|
context = LLMContext(tools=tools)
|
||||||
{"role": "user", "content": "Greet the user."},
|
|
||||||
]
|
|
||||||
|
|
||||||
context = LLMContext(messages, tools)
|
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||||
@@ -252,6 +248,7 @@ Your response will be turned into speech so use only simple words and punctuatio
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Start conversation - empty prompt to let LLM follow system instructions
|
# Start conversation - empty prompt to let LLM follow system instructions
|
||||||
|
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation
|
# Kick off the conversation
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
system = f"""
|
system_prompt = f"""
|
||||||
You are a helpful LLM in a WebRTC call.
|
You are a helpful LLM in a WebRTC call.
|
||||||
Your goal is to demonstrate your capabilities in a succinct way.
|
Your goal is to demonstrate your capabilities in a succinct way.
|
||||||
You have access to tools to search the Rijksmuseum collection.
|
You have access to tools to search the Rijksmuseum collection.
|
||||||
@@ -158,7 +158,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
llm = AnthropicLLMService(
|
llm = AnthropicLLMService(
|
||||||
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
||||||
settings=AnthropicLLMSettings(
|
settings=AnthropicLLMSettings(
|
||||||
system_instruction=system,
|
system_instruction=system_prompt,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"), model="gemini-2.0-flash")
|
system_prompt = f"""
|
||||||
|
You are a helpful LLM in a WebRTC call.
|
||||||
|
Your goal is to answer questions about the user's GitHub repositories and account.
|
||||||
|
You have access to a number of tools provided by Github. Use any and all tools to help users.
|
||||||
|
Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points.
|
||||||
|
Don't overexplain what you are doing.
|
||||||
|
Just respond with short sentences when you are carrying out tool calls.
|
||||||
|
"""
|
||||||
|
|
||||||
|
llm = GoogleLLMService(
|
||||||
|
api_key=os.getenv("GOOGLE_API_KEY"),
|
||||||
|
system_instruction=system_prompt,
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Github MCP docs: https://github.com/github/github-mcp-server
|
# Github MCP docs: https://github.com/github/github-mcp-server
|
||||||
@@ -87,18 +99,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
logger.error(f"error registering tools")
|
logger.error(f"error registering tools")
|
||||||
logger.exception("error trace:")
|
logger.exception("error trace:")
|
||||||
|
|
||||||
system = f"""
|
context = LLMContext(tools=tools)
|
||||||
You are a helpful LLM in a WebRTC call.
|
|
||||||
Your goal is to answer questions about the user's GitHub repositories and account.
|
|
||||||
You have access to a number of tools provided by Github. Use any and all tools to help users.
|
|
||||||
Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points.
|
|
||||||
Don't overexplain what you are doing.
|
|
||||||
Just respond with short sentences when you are carrying out tool calls.
|
|
||||||
"""
|
|
||||||
|
|
||||||
messages = [{"role": "system", "content": system}]
|
|
||||||
|
|
||||||
context = LLMContext(messages, tools)
|
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
|
||||||
context,
|
context,
|
||||||
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()),
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
system = f"""
|
system_prompt = f"""
|
||||||
You are a helpful LLM in a WebRTC call.
|
You are a helpful LLM in a WebRTC call.
|
||||||
Your goal is to demonstrate your capabilities in a succinct way.
|
Your goal is to demonstrate your capabilities in a succinct way.
|
||||||
You have access to tools to search the Rijksmuseum collection and the user's GitHub repositories and account.
|
You have access to tools to search the Rijksmuseum collection and the user's GitHub repositories and account.
|
||||||
@@ -142,7 +142,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
llm = AnthropicLLMService(
|
llm = AnthropicLLMService(
|
||||||
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
api_key=os.getenv("ANTHROPIC_API_KEY"),
|
||||||
settings=AnthropicLLMSettings(
|
settings=AnthropicLLMSettings(
|
||||||
system_instruction=system,
|
system_instruction=system_prompt,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -146,15 +146,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Set up context and context management.
|
# Set up context and context management.
|
||||||
context = LLMContext(
|
context = LLMContext(tools=tools)
|
||||||
messages=[
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": "Tell me a fun fact!",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
tools=tools,
|
|
||||||
)
|
|
||||||
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(context)
|
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(context)
|
||||||
|
|
||||||
# Build the pipeline
|
# Build the pipeline
|
||||||
@@ -183,6 +175,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
|
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
|
||||||
await task.queue_frames([LLMRunFrame()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
# HACK: if using the older Nova Sonic (pre-2) model, you need this special way of
|
# HACK: if using the older Nova Sonic (pre-2) model, you need this special way of
|
||||||
# triggering the first assistant response. Note that this trigger requires a special
|
# triggering the first assistant response. Note that this trigger requires a special
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ async def main():
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "Start by saying 'Hello' and then a short greeting.",
|
"content": "Start by saying 'Hello' and then a short greeting.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message(
|
context.add_message(
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "user",
|
||||||
"content": "Start by saying 'Hello' and then a short greeting.",
|
"content": "Start by saying 'Hello' and then a short greeting.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"role": "system", "content": "Please introduce yourself to the user."})
|
context.add_message({"role": "user", "content": "Please introduce yourself to the user."})
|
||||||
# Custom frames are pushed in order so they can be used for synchronization purposes.
|
# Custom frames are pushed in order so they can be used for synchronization purposes.
|
||||||
await task.queue_frames([CustomBeforeProcessFrame(), LLMRunFrame(), CustomAfterPushFrame()])
|
await task.queue_frames([CustomBeforeProcessFrame(), LLMRunFrame(), CustomAfterPushFrame()])
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info(f"Client connected")
|
logger.info(f"Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
@@ -116,15 +116,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
services=[tts_cartesia, tts_deepgram], strategy_type=ServiceSwitcherStrategyManual
|
services=[tts_cartesia, tts_deepgram], strategy_type=ServiceSwitcherStrategyManual
|
||||||
)
|
)
|
||||||
|
|
||||||
system = "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."
|
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."
|
||||||
|
|
||||||
llm_openai = OpenAILLMService(
|
llm_openai = OpenAILLMService(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
api_key=os.getenv("OPENAI_API_KEY"),
|
||||||
settings=OpenAILLMSettings(system_instruction=system),
|
settings=OpenAILLMSettings(system_instruction=system_prompt),
|
||||||
)
|
)
|
||||||
llm_google = GoogleLLMService(
|
llm_google = GoogleLLMService(
|
||||||
api_key=os.getenv("GOOGLE_API_KEY"),
|
api_key=os.getenv("GOOGLE_API_KEY"),
|
||||||
settings=GoogleLLMSettings(system_instruction=system),
|
settings=GoogleLLMSettings(system_instruction=system_prompt),
|
||||||
)
|
)
|
||||||
llm_switcher = LLMSwitcher(
|
llm_switcher = LLMSwitcher(
|
||||||
llms=[llm_openai, llm_google], strategy_type=ServiceSwitcherStrategyManual
|
llms=[llm_openai, llm_google], strategy_type=ServiceSwitcherStrategyManual
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
|
|||||||
async def on_client_connected(transport, client):
|
async def on_client_connected(transport, client):
|
||||||
logger.info("Client connected")
|
logger.info("Client connected")
|
||||||
# Kick off the conversation.
|
# Kick off the conversation.
|
||||||
context.add_message({"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()])
|
await task.queue_frames([LLMRunFrame()])
|
||||||
|
|
||||||
@transport.event_handler("on_client_disconnected")
|
@transport.event_handler("on_client_disconnected")
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user