You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
chore: Fixes the sample of example_tool
The `Example` objects should be strong typed. PiperOrigin-RevId: 770476132
This commit is contained in:
committed by
Copybara-Service
parent
fc65873d7c
commit
b08bdbcd7f
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user