8000 update bigquery agent and oauth calendar agent according to new tools… · Syntax404-coder/adk-python@d19927b · GitHub
[go: up one dir, main page]

Skip to content

Commit d19927b

Browse files
seanzhougooglecopybara-github
authored andcommitted
update bigquery agent and oauth calendar agent according to new toolset interface
PiperOrigin-RevId: 757949732
1 parent 6a04ff8 commit d19927b

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

contributing/samples/bigquery_agent/agent.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@
2626
oauth_client_secret = os.getenv("OAUTH_CLIENT_SECRET")
2727
bigquery_tool_set.configure_auth(oauth_client_id, oauth_client_secret)
2828

29-
bigquery_datasets_list = bigquery_tool_set.get_tool("bigquery_datasets_list")
30-
bigquery_datasets_get = bigquery_tool_set.get_tool("bigquery_datasets_get")
31-
bigquery_datasets_insert = bigquery_tool_set.get_tool(
32-
"bigquery_datasets_insert"
29+
tools_to_expose = [
30+
"bigquery_datasets_list",
31+
"bigquery_datasets_get",
32+
"bigquery_datasets_insert",
33+
"bigquery_tables_list",
34+
"bigquery_tables_get",
35+
"bigquery_tables_insert",
36+
]
37+
bigquery_tool_set.set_tool_filter(
38+
lambda tool, ctx=None: tool.name in tools_to_expose
3339
)
3440

35-
bigquery_tables_list = bigquery_tool_set.get_tool("bigquery_tables_list")
36-
bigquery_tables_get = bigquery_tool_set.get_tool("bigquery_tables_get")
37-
bigquery_tables_insert = bigquery_tool_set.get_tool("bigquery_tables_insert")
38-
39-
4041
root_agent = Agent(
4142
model="gemini-2.0-flash",
4243
name="bigquery_agent",
@@ -73,12 +74,5 @@
7374
{userInfo?}
7475
</User>
7576
""",
76-
tools=[
77-
bigquery_datasets_list,
78-
bigquery_datasets_get,
79-
bigquery_datasets_insert,
80-
bigquery_tables_list,
81-
bigquery_tables_get,
82-
bigquery_tables_insert,
83-
],
77+
tools=[bigquery_tool_set],
8478
)

contributing/samples/oauth_calendar_agent/agent.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
calendar_tool_set.configure_auth(
4646
client_id=oauth_client_id, client_secret=oauth_client_secret
4747
)
48-
49-
get_calendar_events = calendar_tool_set.get_tool("calendar_events_get")
50-
# list_calendar_events = calendar_tool_set.get_tool("calendar_events_list")
51-
# you can replace below customized list_calendar_events tool with above ADK
52-
# build-in google calendar tool which is commented for now to acheive same
53-
# effect.
48+
calendar_tool_set.set_tool_filter(
49+
# you can also replace below customized `list_calendar_events` with build-in
50+
# google calendar tool by adding `calendar_events_list` in the filter list
51+
lambda tool, ctx=None: tool.name
52+
in ["calendar_events_get"]
53+
)
5454

5555

5656
def list_calendar_events(
@@ -210,6 +210,6 @@ def update_time(callback_context: CallbackContext):
210210
211211
Currnet time: {_time}
212212
""",
213-
tools=[list_calendar_events, get_calendar_events],
213+
tools=[list_calendar_events, calendar_tool_set],
214214
before_agent_callback=update_time,
215215
)

0 commit comments

Comments
 (0)
0