update messages to force invoke tool use

This commit is contained in:
Yu An 2025-03-11 11:07:07 +00:00
parent 41c40954d7
commit 84c765ee5f
No known key found for this signature in database
GPG key ID: CA8730513B2107E7

View file

@ -221,8 +221,7 @@ agent = Agent(
client, client,
model="meta-llama/Llama-3.2-3B-Instruct", model="meta-llama/Llama-3.2-3B-Instruct",
instructions=( instructions=(
"You are a highly knowledgeable and helpful web search assistant. " "You are a web search assistant, must use websearch tool to look up the most current and precise information available. "
"Whenever you encounter a query, make sure to use the websearch tools to look up the most current and precise information available. "
), ),
tools=["builtin::websearch"], tools=["builtin::websearch"],
) )
@ -230,7 +229,7 @@ agent = Agent(
session_id = agent.create_session("websearch-session") session_id = agent.create_session("websearch-session")
response = agent.create_turn( response = agent.create_turn(
messages=[{"role": "user", "content": "How US performed in the olympics?"}], messages=[{"role": "user", "content": "How US performed in the latest olympics?"}],
session_id=session_id, session_id=session_id,
) )
for log in EventLogger().log(response): for log in EventLogger().log(response):
@ -252,14 +251,14 @@ client = LlamaStackClient(
agent = Agent( agent = Agent(
client, client,
model="meta-llama/Llama-3.2-3B-Instruct", model="meta-llama/Llama-3.2-3B-Instruct",
instructions="You are a helpful wolfram_alpha assistant, use wolfram_alpha tool as external source validation.", instructions="You are a helpful wolfram_alpha assistant, must use wolfram_alpha tool as external source validation.",
tools=["builtin::wolfram_alpha"], tools=["builtin::wolfram_alpha"],
) )
session_id = agent.create_session("wolframa-alpha-session") session_id = agent.create_session("wolframa-alpha-session")
response = agent.create_turn( response = agent.create_turn(
messages=[{"role": "user", "content": "Tell me 10 densest elemental metals"}], messages=[{"role": "user", "content": "solve x^2 + 2x + 1 = 0"}],
session_id=session_id, session_id=session_id,
) )
for log in EventLogger().log(response): for log in EventLogger().log(response):