Update foundational examples to use "user" role

Use system_instruction on LLM service constructors instead of adding
system messages to LLMContext. Messages added to context now use
"user" role.
This commit is contained in:
Aleix Conchillo Flaqué
2026-03-05 16:17:32 -08:00
parent 18494658c3
commit 593b75bc8b
179 changed files with 271 additions and 335 deletions

View File

@@ -197,11 +197,11 @@ Your response will be turned into speech so use only simple words and punctuatio
"""
llm = GoogleLLMService(
api_key=os.getenv("GOOGLE_API_KEY"),
settings=GoogleLLMSettings(
model=VOICE_MODEL,
system_instruction=system_prompt,
),
api_key=os.getenv("GOOGLE_API_KEY"),
)
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])
messages = [
{"role": "user", "content": "Greet the user."},
]
context = LLMContext(messages, tools)
context = LLMContext(tools=tools)
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
context,
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):
logger.info(f"Client connected")
# 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()])
@transport.event_handler("on_client_disconnected")