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
4 changes: 3 additions & 1 deletion samples/python/src/common/function_call_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from google import genai
from google.genai import types

from common.system_utils import LLM_MODEL


DataPartContent = dict[str, Any]
Tool = Callable[[list[DataPartContent], TaskUpdater, Task | None], Any]
Expand Down Expand Up @@ -81,7 +83,7 @@ def determine_tool_to_use(self, prompt: str) -> str:
"""

response = self._client.models.generate_content(
model="gemini-2.5-flash",
model=LLM_MODEL,
contents=prompt,
config=self._config,
)
Expand Down
4 changes: 2 additions & 2 deletions samples/python/src/common/retrying_llm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def _retry_async(
author=ctx.agent.name,
invocation_id=ctx.invocation_id,
error_message=(
"Maximum retries exhausted. The remote Gemini server failed to"
"Maximum retries exhausted. The remote LLM server failed to"
" respond. Please try again later."
),
)
Expand All @@ -51,7 +51,7 @@ async def _retry_async(
yield Event(
author=ctx.agent.name,
invocation_id=ctx.invocation_id,
error_message="Gemini server error. Retrying...",
error_message="LLM server error. Retrying...",
custom_metadata={"error": str(e)},
)
async for event in self._retry_async(ctx, retries_left - 1):
Expand Down
4 changes: 4 additions & 0 deletions samples/python/src/common/system_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

"""Helper functions related to the system."""

import os

LLM_MODEL = os.environ.get("MODEL", "gemini-2.5-flash")

DEBUG_MODE_INSTRUCTIONS = """
This is really important! If the agent or user asks you to be verbose or if debug_mode is True, do the following:
1. If this is the the start of a new task, explain who you are, what you are going to do, what tools you use, and what agents you delegate to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from ap2.types.payment_request import PaymentRequest
from common import message_utils
from common.system_utils import DEBUG_MODE_INSTRUCTIONS
from common.system_utils import LLM_MODEL


async def find_items_workflow(
Expand All @@ -68,7 +69,7 @@ async def find_items_workflow(
""" % DEBUG_MODE_INSTRUCTIONS

llm_response = llm_client.models.generate_content(
model="gemini-2.5-flash",
model=LLM_MODEL,
contents=prompt,
config={
"response_mime_type": "application/json",
Expand Down
3 changes: 2 additions & 1 deletion samples/python/src/roles/shopping_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
from .subagents.shopper.agent import shopper
from common.retrying_llm_agent import RetryingLlmAgent
from common.system_utils import DEBUG_MODE_INSTRUCTIONS
from common.system_utils import LLM_MODEL


root_agent = RetryingLlmAgent(
max_retries=5,
model="gemini-2.5-flash",
model=LLM_MODEL,
name="root_agent",
instruction="""
You are a shopping agent responsible for helping users find and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
from . import tools
from common.retrying_llm_agent import RetryingLlmAgent
from common.system_utils import DEBUG_MODE_INSTRUCTIONS
from common.system_utils import LLM_MODEL


payment_method_collector = RetryingLlmAgent(
model="gemini-2.5-flash",
model=LLM_MODEL,
name="payment_method_collector",
max_retries=5,
instruction="""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
from . import tools
from common.retrying_llm_agent import RetryingLlmAgent
from common.system_utils import DEBUG_MODE_INSTRUCTIONS
from common.system_utils import LLM_MODEL

shipping_address_collector = RetryingLlmAgent(
model="gemini-2.5-flash",
model=LLM_MODEL,
name="shipping_address_collector",
max_retries=5,
instruction="""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
from . import tools
from common.retrying_llm_agent import RetryingLlmAgent
from common.system_utils import DEBUG_MODE_INSTRUCTIONS
from common.system_utils import LLM_MODEL


shopper = RetryingLlmAgent(
model="gemini-2.5-flash",
model=LLM_MODEL,
name="shopper",
max_retries=5,
instruction="""
Expand Down