Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


# Use one of the model constants defined earlier
MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash"
MODEL_GEMINI_FLASH = "gemini-flash-latest"


# @title Define the get_weather Tool
Expand Down Expand Up @@ -60,7 +60,7 @@ def get_weather(city: str) -> dict:

root_agent = Agent(
name="weather_agent_v1",
model=MODEL_GEMINI_2_0_FLASH, # Can be a string for Gemini or a LiteLlm object
model=MODEL_GEMINI_FLASH, # Can be a string for Gemini or a LiteLlm object
description="Provides weather information for specific cities.",
instruction="You are a helpful weather assistant. "
"When the user asks for the weather in a specific city, "
Expand All @@ -70,12 +70,12 @@ def get_weather(city: str) -> dict:
tools=[get_weather], # Pass the function directly
)

# Sample queries to test the agent:
# Sample queries to test the agent:

# # Agent will give weather information for the specified cities.
# # What's the weather in Tokyo?
# # What is the weather like in London?
# # Tell me the weather in New York?

# # Agent will not have information for the specified city.
# # How about Paris?
# # How about Paris?
26 changes: 13 additions & 13 deletions examples/python/tutorial/agent_team/adk-tutorial/step_3/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import Optional

# Use one of the model constants defined earlier
MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash"
MODEL_GEMINI_FLASH = "gemini-flash-latest"


# @title Define the get_weather Tool
Expand Down Expand Up @@ -51,9 +51,9 @@ def get_weather(city: str) -> dict:
return mock_weather_db[city_normalized]
else:
return {"status": "error", "error_message": f"Sorry, I don't have weather information for '{city}'."}
def say_hello(name: Optional[str] = None) -> str:


def say_hello(name: Optional[str] = None) -> str:
"""Provides a simple greeting. If a name is provided, it will be used.

Args:
Expand Down Expand Up @@ -83,8 +83,8 @@ def say_goodbye() -> str:
try:
greeting_agent = Agent(
# Using a potentially different/cheaper model for a simple task
model = MODEL_GEMINI_2_0_FLASH,
# model=LiteLlm(model=MODEL_GPT_4O), # If you would like to experiment with other models
model = MODEL_GEMINI_FLASH,
# model=LiteLlm(model=MODEL_GPT_4O), # If you would like to experiment with other models
name="greeting_agent",
instruction="You are the Greeting Agent. Your ONLY task is to provide a friendly greeting to the user. "
"Use the 'say_hello' tool to generate the greeting. "
Expand All @@ -102,7 +102,7 @@ def say_goodbye() -> str:
try:
farewell_agent = Agent(
# Can use the same or a different model
model = MODEL_GEMINI_2_0_FLASH,
model = MODEL_GEMINI_FLASH,
# model=LiteLlm(model=MODEL_GPT_4O), # If you would like to experiment with other models
name="farewell_agent",
instruction="You are the Farewell Agent. Your ONLY task is to provide a polite goodbye message. "
Expand All @@ -115,11 +115,11 @@ def say_goodbye() -> str:
print(f"✅ Agent '{farewell_agent.name}' created using model '{farewell_agent.model}'.")
except Exception as e:
print(f"❌ Could not create Farewell agent. Check API Key ({farewell_agent.model}). Error: {e}")


root_agent = Agent(
name="weather_agent_v2", # Give it a new version name
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_FLASH,
description="The main coordinator agent. Handles weather requests and delegates greetings/farewells to specialists.",
instruction="You are the main Weather Agent coordinating a team. Your primary responsibility is to provide weather information. "
"Use the 'get_weather' tool ONLY for specific weather requests (e.g., 'weather in London'). "
Expand All @@ -134,15 +134,15 @@ def say_goodbye() -> str:
sub_agents=[greeting_agent, farewell_agent]
)

# Sample queries to test the agent:
# Sample queries to test the agent:

# # Agent will give weather information for the specified cities.
# # What's the weather in Tokyo?
# # What is the weather like in London?
# # Tell me the weather in New York?

# # Agent will not have information for the specified city.
# # How about Paris?
# # How about Paris?

# # Agent will delegate greetings to the greeting_agent.
# # Hi there!
Expand All @@ -152,4 +152,4 @@ def say_goodbye() -> str:
# # Agent will delegate farewells to the farewell_agent.
# # Bye!
# # See you later!
# # Thanks, bye!
# # Thanks, bye!
16 changes: 8 additions & 8 deletions examples/python/tutorial/agent_team/adk-tutorial/step_5/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


# Use one of the model constants defined earlier
MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash"
MODEL_GEMINI_FLASH = "gemini-flash-latest"


def get_weather_stateful(city: str, tool_context: ToolContext) -> dict:
Expand Down Expand Up @@ -76,7 +76,7 @@ def get_weather_stateful(city: str, tool_context: ToolContext) -> dict:
return {"status": "error", "error_message": error_msg}


def say_hello(name: Optional[str] = None) -> str:
def say_hello(name: Optional[str] = None) -> str:
"""Provides a simple greeting. If a name is provided, it will be used.

Args:
Expand Down Expand Up @@ -149,7 +149,7 @@ def block_keyword_guardrail(
try:
# Use a defined model constant
greeting_agent = Agent(
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_FLASH,
name="greeting_agent", # Keep original name for consistency
instruction="You are the Greeting Agent. Your ONLY task is to provide a friendly greeting using the 'say_hello' tool. Do nothing else.",
description="Handles simple greetings and hellos using the 'say_hello' tool.",
Expand All @@ -163,7 +163,7 @@ def block_keyword_guardrail(
try:
# Use a defined model constant
farewell_agent = Agent(
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_FLASH,
name="farewell_agent", # Keep original name
instruction="You are the Farewell Agent. Your ONLY task is to provide a polite goodbye message using the 'say_goodbye' tool. Do not perform any other actions.",
description="Handles simple farewells and goodbyes using the 'say_goodbye' tool.",
Expand All @@ -176,7 +176,7 @@ def block_keyword_guardrail(

root_agent = Agent(
name="weather_agent_v5_model_guardrail", # New version name for clarity
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_FLASH,
description="Main agent: Handles weather, delegates greetings/farewells, includes input keyword guardrail.",
instruction="You are the main Weather Agent. Provide weather using 'get_weather_stateful'. "
"Delegate simple greetings to 'greeting_agent' and farewells to 'farewell_agent'. "
Expand All @@ -187,15 +187,15 @@ def block_keyword_guardrail(
before_model_callback=block_keyword_guardrail # <<< Assign the guardrail callback
)

# Sample queries to test the agent:
# Sample queries to test the agent:

# # Agent will give weather information for the specified cities.
# # What's the weather in Tokyo?
# # What is the weather like in London?
# # Tell me the weather in New York?

# # Agent will not have information for the specified city.
# # How about Paris?
# # How about Paris?

# # Agent will delegate greetings to the greeting_agent.
# # Hi there!
Expand All @@ -210,4 +210,4 @@ def block_keyword_guardrail(
# # Agent will block any request containing the keyword "BLOCK".
# # What's the weather in BLOCK tokyo?
# # tell me the weather in BLOCK london
# # how about BLOCK new york?
# # how about BLOCK new york?
14 changes: 7 additions & 7 deletions examples/python/tutorial/agent_team/adk-tutorial/step_6/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from typing import Optional, Dict, Any # For type hints

# Use one of the model constants defined earlier
MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash"
MODEL_GEMINI_2_5_FLASH = "gemini-2.5-flash"


def get_weather_stateful(city: str, tool_context: ToolContext) -> dict:
Expand Down Expand Up @@ -77,7 +77,7 @@ def get_weather_stateful(city: str, tool_context: ToolContext) -> dict:
return {"status": "error", "error_message": error_msg}


def say_hello(name: Optional[str] = None) -> str:
def say_hello(name: Optional[str] = None) -> str:
"""Provides a simple greeting. If a name is provided, it will be used.

Args:
Expand Down Expand Up @@ -191,7 +191,7 @@ def block_paris_tool_guardrail(
try:
# Use a defined model constant
greeting_agent = Agent(
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_2_5_FLASH,
name="greeting_agent", # Keep original name for consistency
instruction="You are the Greeting Agent. Your ONLY task is to provide a friendly greeting using the 'say_hello' tool. Do nothing else.",
description="Handles simple greetings and hellos using the 'say_hello' tool.",
Expand All @@ -205,7 +205,7 @@ def block_paris_tool_guardrail(
try:
# Use a defined model constant
farewell_agent = Agent(
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_2_5_FLASH,
name="farewell_agent", # Keep original name
instruction="You are the Farewell Agent. Your ONLY task is to provide a polite goodbye message using the 'say_goodbye' tool. Do not perform any other actions.",
description="Handles simple farewells and goodbyes using the 'say_goodbye' tool.",
Expand All @@ -218,7 +218,7 @@ def block_paris_tool_guardrail(

root_agent = Agent(
name="weather_agent_v6_tool_guardrail", # New version name
model=MODEL_GEMINI_2_0_FLASH,
model=MODEL_GEMINI_2_5_FLASH,
description="Main agent: Handles weather, delegates, includes input AND tool guardrails.",
instruction="You are the main Weather Agent. Provide weather using 'get_weather_stateful'. "
"Delegate greetings to 'greeting_agent' and farewells to 'farewell_agent'. "
Expand All @@ -230,15 +230,15 @@ def block_paris_tool_guardrail(
before_tool_callback=block_paris_tool_guardrail # <<< Add tool guardrail
)

# Sample queries to test the agent:
# Sample queries to test the agent:

# # Agent will give weather information for the specified cities.
# # What's the weather in Tokyo?
# # What is the weather like in London?
# # Tell me the weather in New York?

# # Agent will not have information for the specified city.
# # How about Paris?
# # How about Paris?

# # Agent will delegate greetings to the greeting_agent.
# # Hi there!
Expand Down