diff --git a/contributing/samples/hello_world_ma/agent.py b/contributing/samples/hello_world_ma/agent.py index 98e79a39..a6bf78a9 100755 --- a/contributing/samples/hello_world_ma/agent.py +++ b/contributing/samples/hello_world_ma/agent.py @@ -15,6 +15,7 @@ import random from google.adk.agents import Agent +from google.adk.examples.example import Example from google.adk.tools.example_tool import ExampleTool from google.genai import types @@ -66,43 +67,47 @@ def check_prime(nums: list[int]) -> str: ) -example_tool = ExampleTool([ - { - "input": { - "role": "user", - "parts": [{"text": "Roll a 6-sided die."}], - }, - "output": [ - {"role": "model", "parts": [{"text": "I rolled a 4 for you."}]} - ], - }, - { - "input": { - "role": "user", - "parts": [{"text": "Is 7 a prime number?"}], - }, - "output": [{ - "role": "model", - "parts": [{"text": "Yes, 7 is a prime number."}], - }], - }, - { - "input": { - "role": "user", - "parts": [{"text": "Roll a 10-sided die and check if it's prime."}], - }, - "output": [ - { - "role": "model", - "parts": [{"text": "I rolled an 8 for you."}], - }, - { - "role": "model", - "parts": [{"text": "8 is not a prime number."}], - }, - ], - }, -]) +example_tool = ExampleTool( + examples=[ + Example( + input=types.UserContent( + parts=[types.Part(text="Roll a 6-sided die.")] + ), + output=[ + types.ModelContent( + parts=[types.Part(text="I rolled a 4 for you.")] + ) + ], + ), + Example( + input=types.UserContent( + parts=[types.Part(text="Is 7 a prime number?")] + ), + output=[ + types.ModelContent( + parts=[types.Part(text="Yes, 7 is a prime number.")] + ) + ], + ), + Example( + input=types.UserContent( + parts=[ + types.Part( + text="Roll a 10-sided die and check if it's prime." + ) + ] + ), + output=[ + types.ModelContent( + parts=[types.Part(text="I rolled an 8 for you.")] + ), + types.ModelContent( + parts=[types.Part(text="8 is not a prime number.")] + ), + ], + ), + ] +) prime_agent = Agent( name="prime_agent",