This commit is contained in:
Ben Cherry
2025-07-10 17:26:30 -07:00
parent b8eabc59ac
commit 2420b92dc7
2 changed files with 25 additions and 3 deletions
+8 -3
View File
@@ -48,11 +48,15 @@ async def test_weather_tool() -> None:
result = await session.run(user_input="What's the weather in Tokyo?")
# Test that the agent calls the weather tool with the correct arguments
result.expect.next_event().is_function_call(name="lookup_weather", arguments={"location": "Tokyo"})
result.expect.next_event().is_function_call(
name="lookup_weather", arguments={"location": "Tokyo"}
)
# Test that the tool invocation works and returns the correct output
# To mock the tool output instead, see https://docs.livekit.io/agents/build/testing/#mock-tools
result.expect.next_event().is_function_call_output(output="sunny with a temperature of 70 degrees.")
result.expect.next_event().is_function_call_output(
output="sunny with a temperature of 70 degrees."
)
# Evaluate the agent's response for accurate weather information
await (
@@ -89,7 +93,8 @@ async def test_weather_unavailable() -> None:
)
result.expect.next_event().is_function_call_output()
await result.expect.next_event(type="message").judge(
llm, intent="Should inform the user that an error occurred and/or the weather is is currently unavailable."
llm,
intent="Should inform the user that an error occurred and/or the weather is is currently unavailable.",
)
# leaving this commented, some LLMs may occasionally try to retry.