google-adk 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/adk/agents/run_config.py +4 -0
- google/adk/auth/auth_preprocessor.py +19 -16
- google/adk/cli/browser/index.html +1 -1
- google/adk/cli/browser/{main-SY2WYYGV.js → main-CU22TRPI.js} +30 -30
- google/adk/cli/cli.py +8 -8
- google/adk/cli/cli_deploy.py +2 -4
- google/adk/cli/cli_tools_click.py +6 -6
- google/adk/flows/llm_flows/contents.py +21 -1
- google/adk/flows/llm_flows/functions.py +3 -1
- google/adk/models/google_llm.py +0 -1
- google/adk/runners.py +13 -2
- google/adk/version.py +1 -1
- {google_adk-0.0.3.dist-info → google_adk-0.0.4.dist-info}/METADATA +4 -2
- google_adk-0.0.4.dist-info/RECORD +175 -0
- {google_adk-0.0.3.dist-info → google_adk-0.0.4.dist-info}/WHEEL +1 -1
- google_adk-0.0.4.dist-info/licenses/LICENSE +202 -0
- google/adk/._version.py +0 -0
- google/adk/docs/Makefile +0 -20
- google/adk/docs/build/doctrees/google-adk.doctree +0 -0
- google/adk/docs/build/html/_sources/google-adk.rst.txt +0 -98
- google/adk/docs/build/html/_sources/index.rst.txt +0 -7
- google/adk/docs/build/html/_static/autodoc_pydantic.css +0 -27
- google/adk/docs/build/html/_static/basic.css +0 -925
- google/adk/docs/build/html/_static/debug.css +0 -85
- google/adk/docs/build/html/_static/doctools.js +0 -156
- google/adk/docs/build/html/_static/documentation_options.js +0 -29
- google/adk/docs/build/html/_static/file.png +0 -0
- google/adk/docs/build/html/_static/language_data.js +0 -199
- google/adk/docs/build/html/_static/minus.png +0 -0
- google/adk/docs/build/html/_static/plus.png +0 -0
- google/adk/docs/build/html/_static/pygments.css +0 -274
- google/adk/docs/build/html/_static/scripts/furo-extensions.js +0 -16
- google/adk/docs/build/html/_static/scripts/furo.js +0 -19
- google/adk/docs/build/html/_static/scripts/furo.js.LICENSE.txt +0 -7
- google/adk/docs/build/html/_static/scripts/furo.js.map +0 -1
- google/adk/docs/build/html/_static/searchtools.js +0 -620
- google/adk/docs/build/html/_static/skeleton.css +0 -312
- google/adk/docs/build/html/_static/sphinx_highlight.js +0 -170
- google/adk/docs/build/html/_static/styles/furo-extensions.css +0 -18
- google/adk/docs/build/html/_static/styles/furo-extensions.css.map +0 -1
- google/adk/docs/build/html/_static/styles/furo.css +0 -18
- google/adk/docs/build/html/_static/styles/furo.css.map +0 -1
- google/adk/docs/build/html/genindex.html +0 -861
- google/adk/docs/build/html/google-adk.html +0 -5461
- google/adk/docs/build/html/index.html +0 -567
- google/adk/docs/build/html/objects.inv +0 -0
- google/adk/docs/build/html/py-modindex.html +0 -373
- google/adk/docs/build/html/search.html +0 -333
- google/adk/docs/build/html/searchindex.js +0 -17
- google/adk/docs/source/conf.py +0 -133
- google/adk/docs/source/google-adk.rst +0 -98
- google/adk/docs/source/index.rst +0 -7
- google/adk/tests/__init__.py +0 -14
- google/adk/tests/integration/.env.example +0 -10
- google/adk/tests/integration/__init__.py +0 -18
- google/adk/tests/integration/conftest.py +0 -119
- google/adk/tests/integration/fixture/__init__.py +0 -14
- google/adk/tests/integration/fixture/agent_with_config/__init__.py +0 -15
- google/adk/tests/integration/fixture/agent_with_config/agent.py +0 -88
- google/adk/tests/integration/fixture/callback_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/callback_agent/agent.py +0 -105
- google/adk/tests/integration/fixture/context_update_test/OWNERS +0 -1
- google/adk/tests/integration/fixture/context_update_test/__init__.py +0 -15
- google/adk/tests/integration/fixture/context_update_test/agent.py +0 -43
- google/adk/tests/integration/fixture/context_update_test/successful_test.session.json +0 -582
- google/adk/tests/integration/fixture/context_variable_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/context_variable_agent/agent.py +0 -115
- google/adk/tests/integration/fixture/customer_support_ma/__init__.py +0 -15
- google/adk/tests/integration/fixture/customer_support_ma/agent.py +0 -172
- google/adk/tests/integration/fixture/ecommerce_customer_service_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/ecommerce_customer_service_agent/agent.py +0 -338
- google/adk/tests/integration/fixture/ecommerce_customer_service_agent/order_query.test.json +0 -69
- google/adk/tests/integration/fixture/ecommerce_customer_service_agent/test_config.json +0 -6
- google/adk/tests/integration/fixture/flow_complex_spark/__init__.py +0 -15
- google/adk/tests/integration/fixture/flow_complex_spark/agent.py +0 -182
- google/adk/tests/integration/fixture/flow_complex_spark/sample.session.json +0 -190
- google/adk/tests/integration/fixture/hello_world_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/hello_world_agent/agent.py +0 -95
- google/adk/tests/integration/fixture/hello_world_agent/roll_die.test.json +0 -24
- google/adk/tests/integration/fixture/hello_world_agent/test_config.json +0 -6
- google/adk/tests/integration/fixture/home_automation_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/home_automation_agent/agent.py +0 -304
- google/adk/tests/integration/fixture/home_automation_agent/simple_test.test.json +0 -5
- google/adk/tests/integration/fixture/home_automation_agent/simple_test2.test.json +0 -5
- google/adk/tests/integration/fixture/home_automation_agent/test_config.json +0 -5
- google/adk/tests/integration/fixture/home_automation_agent/test_files/dependent_tool_calls.test.json +0 -18
- google/adk/tests/integration/fixture/home_automation_agent/test_files/memorizing_past_events/eval_data.test.json +0 -17
- google/adk/tests/integration/fixture/home_automation_agent/test_files/memorizing_past_events/test_config.json +0 -6
- google/adk/tests/integration/fixture/home_automation_agent/test_files/simple_multi_turn_conversation.test.json +0 -18
- google/adk/tests/integration/fixture/home_automation_agent/test_files/simple_test.test.json +0 -17
- google/adk/tests/integration/fixture/home_automation_agent/test_files/simple_test2.test.json +0 -5
- google/adk/tests/integration/fixture/home_automation_agent/test_files/test_config.json +0 -5
- google/adk/tests/integration/fixture/tool_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/tool_agent/agent.py +0 -218
- google/adk/tests/integration/fixture/tool_agent/files/Agent_test_plan.pdf +0 -0
- google/adk/tests/integration/fixture/trip_planner_agent/__init__.py +0 -15
- google/adk/tests/integration/fixture/trip_planner_agent/agent.py +0 -110
- google/adk/tests/integration/fixture/trip_planner_agent/initial.session.json +0 -13
- google/adk/tests/integration/fixture/trip_planner_agent/test_config.json +0 -5
- google/adk/tests/integration/fixture/trip_planner_agent/test_files/initial.session.json +0 -13
- google/adk/tests/integration/fixture/trip_planner_agent/test_files/test_config.json +0 -5
- google/adk/tests/integration/fixture/trip_planner_agent/test_files/trip_inquiry_sub_agent.test.json +0 -7
- google/adk/tests/integration/fixture/trip_planner_agent/trip_inquiry.test.json +0 -19
- google/adk/tests/integration/models/__init__.py +0 -14
- google/adk/tests/integration/models/test_google_llm.py +0 -65
- google/adk/tests/integration/test_callback.py +0 -70
- google/adk/tests/integration/test_context_variable.py +0 -67
- google/adk/tests/integration/test_evalute_agent_in_fixture.py +0 -76
- google/adk/tests/integration/test_multi_agent.py +0 -28
- google/adk/tests/integration/test_multi_turn.py +0 -42
- google/adk/tests/integration/test_single_agent.py +0 -23
- google/adk/tests/integration/test_sub_agent.py +0 -26
- google/adk/tests/integration/test_system_instruction.py +0 -177
- google/adk/tests/integration/test_tools.py +0 -287
- google/adk/tests/integration/test_with_test_file.py +0 -34
- google/adk/tests/integration/tools/__init__.py +0 -14
- google/adk/tests/integration/utils/__init__.py +0 -16
- google/adk/tests/integration/utils/asserts.py +0 -75
- google/adk/tests/integration/utils/test_runner.py +0 -97
- google/adk/tests/unittests/__init__.py +0 -14
- google/adk/tests/unittests/agents/__init__.py +0 -14
- google/adk/tests/unittests/agents/test_base_agent.py +0 -407
- google/adk/tests/unittests/agents/test_langgraph_agent.py +0 -191
- google/adk/tests/unittests/agents/test_llm_agent_callbacks.py +0 -138
- google/adk/tests/unittests/agents/test_llm_agent_fields.py +0 -231
- google/adk/tests/unittests/agents/test_loop_agent.py +0 -136
- google/adk/tests/unittests/agents/test_parallel_agent.py +0 -92
- google/adk/tests/unittests/agents/test_sequential_agent.py +0 -114
- google/adk/tests/unittests/artifacts/__init__.py +0 -14
- google/adk/tests/unittests/artifacts/test_artifact_service.py +0 -276
- google/adk/tests/unittests/auth/test_auth_handler.py +0 -575
- google/adk/tests/unittests/conftest.py +0 -73
- google/adk/tests/unittests/fast_api/__init__.py +0 -14
- google/adk/tests/unittests/fast_api/test_fast_api.py +0 -269
- google/adk/tests/unittests/flows/__init__.py +0 -14
- google/adk/tests/unittests/flows/llm_flows/__init__.py +0 -14
- google/adk/tests/unittests/flows/llm_flows/_test_examples.py +0 -142
- google/adk/tests/unittests/flows/llm_flows/test_agent_transfer.py +0 -311
- google/adk/tests/unittests/flows/llm_flows/test_functions_long_running.py +0 -244
- google/adk/tests/unittests/flows/llm_flows/test_functions_request_euc.py +0 -346
- google/adk/tests/unittests/flows/llm_flows/test_functions_sequential.py +0 -93
- google/adk/tests/unittests/flows/llm_flows/test_functions_simple.py +0 -258
- google/adk/tests/unittests/flows/llm_flows/test_identity.py +0 -66
- google/adk/tests/unittests/flows/llm_flows/test_instructions.py +0 -164
- google/adk/tests/unittests/flows/llm_flows/test_model_callbacks.py +0 -142
- google/adk/tests/unittests/flows/llm_flows/test_other_configs.py +0 -46
- google/adk/tests/unittests/flows/llm_flows/test_tool_callbacks.py +0 -269
- google/adk/tests/unittests/models/__init__.py +0 -14
- google/adk/tests/unittests/models/test_google_llm.py +0 -224
- google/adk/tests/unittests/models/test_litellm.py +0 -804
- google/adk/tests/unittests/models/test_models.py +0 -60
- google/adk/tests/unittests/sessions/__init__.py +0 -14
- google/adk/tests/unittests/sessions/test_session_service.py +0 -227
- google/adk/tests/unittests/sessions/test_vertex_ai_session_service.py +0 -246
- google/adk/tests/unittests/streaming/__init__.py +0 -14
- google/adk/tests/unittests/streaming/test_streaming.py +0 -50
- google/adk/tests/unittests/tools/__init__.py +0 -14
- google/adk/tests/unittests/tools/apihub_tool/clients/test_apihub_client.py +0 -499
- google/adk/tests/unittests/tools/apihub_tool/test_apihub_toolset.py +0 -204
- google/adk/tests/unittests/tools/application_integration_tool/clients/test_connections_client.py +0 -600
- google/adk/tests/unittests/tools/application_integration_tool/clients/test_integration_client.py +0 -630
- google/adk/tests/unittests/tools/application_integration_tool/test_application_integration_toolset.py +0 -345
- google/adk/tests/unittests/tools/google_api_tool/__init__.py +0 -13
- google/adk/tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py +0 -657
- google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_auto_auth_credential_exchanger.py +0 -145
- google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_base_auth_credential_exchanger.py +0 -68
- google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_oauth2_exchanger.py +0 -153
- google/adk/tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_service_account_exchanger.py +0 -196
- google/adk/tests/unittests/tools/openapi_tool/auth/test_auth_helper.py +0 -573
- google/adk/tests/unittests/tools/openapi_tool/common/test_common.py +0 -436
- google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test.yaml +0 -1367
- google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_spec_parser.py +0 -628
- google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_openapi_toolset.py +0 -139
- google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_operation_parser.py +0 -406
- google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_rest_api_tool.py +0 -966
- google/adk/tests/unittests/tools/openapi_tool/openapi_spec_parser/test_tool_auth_handler.py +0 -201
- google/adk/tests/unittests/tools/retrieval/__init__.py +0 -14
- google/adk/tests/unittests/tools/retrieval/test_vertex_ai_rag_retrieval.py +0 -147
- google/adk/tests/unittests/tools/test_agent_tool.py +0 -167
- google/adk/tests/unittests/tools/test_base_tool.py +0 -141
- google/adk/tests/unittests/tools/test_build_function_declaration.py +0 -277
- google/adk/tests/unittests/utils.py +0 -304
- google_adk-0.0.3.dist-info/RECORD +0 -340
- {google_adk-0.0.3.dist-info → google_adk-0.0.4.dist-info}/entry_points.txt +0 -0
@@ -1,110 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
# https://github.com/crewAIInc/crewAI-examples/tree/main/trip_planner
|
16
|
-
|
17
|
-
from google.adk import Agent
|
18
|
-
|
19
|
-
# Agent that selects the best city for the trip.
|
20
|
-
identify_agent = Agent(
|
21
|
-
name='identify_agent',
|
22
|
-
description='Select the best city based on weather, season, and prices.',
|
23
|
-
instruction="""
|
24
|
-
Analyze and select the best city for the trip based
|
25
|
-
on specific criteria such as weather patterns, seasonal
|
26
|
-
events, and travel costs. This task involves comparing
|
27
|
-
multiple cities, considering factors like current weather
|
28
|
-
conditions, upcoming cultural or seasonal events, and
|
29
|
-
overall travel expenses.
|
30
|
-
|
31
|
-
Your final answer must be a detailed
|
32
|
-
report on the chosen city, and everything you found out
|
33
|
-
about it, including the actual flight costs, weather
|
34
|
-
forecast and attractions.
|
35
|
-
|
36
|
-
Traveling from: {origin}
|
37
|
-
City Options: {cities}
|
38
|
-
Trip Date: {range}
|
39
|
-
Traveler Interests: {interests}
|
40
|
-
""",
|
41
|
-
)
|
42
|
-
|
43
|
-
# Agent that gathers information about the city.
|
44
|
-
gather_agent = Agent(
|
45
|
-
name='gather_agent',
|
46
|
-
description='Provide the BEST insights about the selected city',
|
47
|
-
instruction="""
|
48
|
-
As a local expert on this city you must compile an
|
49
|
-
in-depth guide for someone traveling there and wanting
|
50
|
-
to have THE BEST trip ever!
|
51
|
-
Gather information about key attractions, local customs,
|
52
|
-
special events, and daily activity recommendations.
|
53
|
-
Find the best spots to go to, the kind of place only a
|
54
|
-
local would know.
|
55
|
-
This guide should provide a thorough overview of what
|
56
|
-
the city has to offer, including hidden gems, cultural
|
57
|
-
hotspots, must-visit landmarks, weather forecasts, and
|
58
|
-
high level costs.
|
59
|
-
|
60
|
-
The final answer must be a comprehensive city guide,
|
61
|
-
rich in cultural insights and practical tips,
|
62
|
-
tailored to enhance the travel experience.
|
63
|
-
|
64
|
-
Trip Date: {range}
|
65
|
-
Traveling from: {origin}
|
66
|
-
Traveler Interests: {interests}
|
67
|
-
""",
|
68
|
-
)
|
69
|
-
|
70
|
-
# Agent that plans the trip.
|
71
|
-
plan_agent = Agent(
|
72
|
-
name='plan_agent',
|
73
|
-
description="""Create the most amazing travel itineraries with budget and
|
74
|
-
packing suggestions for the city""",
|
75
|
-
instruction="""
|
76
|
-
Expand this guide into a full 7-day travel
|
77
|
-
itinerary with detailed per-day plans, including
|
78
|
-
weather forecasts, places to eat, packing suggestions,
|
79
|
-
and a budget breakdown.
|
80
|
-
|
81
|
-
You MUST suggest actual places to visit, actual hotels
|
82
|
-
to stay and actual restaurants to go to.
|
83
|
-
|
84
|
-
This itinerary should cover all aspects of the trip,
|
85
|
-
from arrival to departure, integrating the city guide
|
86
|
-
information with practical travel logistics.
|
87
|
-
|
88
|
-
Your final answer MUST be a complete expanded travel plan,
|
89
|
-
formatted as markdown, encompassing a daily schedule,
|
90
|
-
anticipated weather conditions, recommended clothing and
|
91
|
-
items to pack, and a detailed budget, ensuring THE BEST
|
92
|
-
TRIP EVER. Be specific and give it a reason why you picked
|
93
|
-
each place, what makes them special!
|
94
|
-
|
95
|
-
Trip Date: {range}
|
96
|
-
Traveling from: {origin}
|
97
|
-
Traveler Interests: {interests}
|
98
|
-
""",
|
99
|
-
)
|
100
|
-
|
101
|
-
root_agent = Agent(
|
102
|
-
model='gemini-2.0-flash-001',
|
103
|
-
name='trip_planner',
|
104
|
-
description='Plan the best trip ever',
|
105
|
-
instruction="""
|
106
|
-
Your goal is to plan the best trip according to information listed above.
|
107
|
-
You describe why did you choose the city, list top 3
|
108
|
-
attactions and provide a detailed itinerary for each day.""",
|
109
|
-
sub_agents=[identify_agent, gather_agent, plan_agent],
|
110
|
-
)
|
@@ -1,13 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "test_id",
|
3
|
-
"app_name": "trip_planner_agent",
|
4
|
-
"user_id": "test_user",
|
5
|
-
"state": {
|
6
|
-
"origin": "San Francisco",
|
7
|
-
"interests": "Food, Shopping, Museums",
|
8
|
-
"range": "1000 miles",
|
9
|
-
"cities": ""
|
10
|
-
},
|
11
|
-
"events": [],
|
12
|
-
"last_update_time": 1741218714.258285
|
13
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "test_id",
|
3
|
-
"app_name": "trip_planner_agent",
|
4
|
-
"user_id": "test_user",
|
5
|
-
"state": {
|
6
|
-
"origin": "San Francisco",
|
7
|
-
"interests": "Food, Shopping, Museums",
|
8
|
-
"range": "1000 miles",
|
9
|
-
"cities": ""
|
10
|
-
},
|
11
|
-
"events": [],
|
12
|
-
"last_update_time": 1741218714.258285
|
13
|
-
}
|
google/adk/tests/integration/fixture/trip_planner_agent/test_files/trip_inquiry_sub_agent.test.json
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"query": "Based on my interests, where should I go, Yosemite national park or Los Angeles?",
|
4
|
-
"expected_tool_use": [],
|
5
|
-
"reference": "Given your interests in food, shopping, and museums, Los Angeles would be a better choice than Yosemite National Park. Yosemite is primarily focused on outdoor activities and natural landscapes, while Los Angeles offers a diverse range of culinary experiences, shopping districts, and world-class museums. I will now gather information to create an in-depth guide for your trip to Los Angeles.\n"
|
6
|
-
}
|
7
|
-
]
|
@@ -1,19 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"query": "Hi, who are you? What can you do?",
|
4
|
-
"expected_tool_use": [],
|
5
|
-
"reference": "I am trip_planner, and my goal is to plan the best trip ever. I can describe why a city was chosen, list its top attractions, and provide a detailed itinerary for each day of the trip.\n"
|
6
|
-
},
|
7
|
-
{
|
8
|
-
"query": "I want to travel from San Francisco to an European country in fall next year. I am considering London and Paris. What is your advice?",
|
9
|
-
"expected_tool_use": [
|
10
|
-
{
|
11
|
-
"tool_name": "transfer_to_agent",
|
12
|
-
"tool_input": {
|
13
|
-
"agent_name": "indentify_agent"
|
14
|
-
}
|
15
|
-
}
|
16
|
-
],
|
17
|
-
"reference": "Okay, I can help you analyze London and Paris to determine which city is better for your trip next fall. I will consider weather patterns, seasonal events, travel costs (including flights from San Francisco), and your interests (food, shopping, and museums). After gathering this information, I'll provide a detailed report on my chosen city.\n"
|
18
|
-
}
|
19
|
-
]
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from google.adk.models import LlmRequest
|
16
|
-
from google.adk.models import LlmResponse
|
17
|
-
from google.adk.models.google_llm import Gemini
|
18
|
-
from google.genai import types
|
19
|
-
from google.genai.types import Content
|
20
|
-
from google.genai.types import Part
|
21
|
-
import pytest
|
22
|
-
|
23
|
-
|
24
|
-
@pytest.fixture
|
25
|
-
def gemini_llm():
|
26
|
-
return Gemini(model="gemini-1.5-flash")
|
27
|
-
|
28
|
-
|
29
|
-
@pytest.fixture
|
30
|
-
def llm_request():
|
31
|
-
return LlmRequest(
|
32
|
-
model="gemini-1.5-flash",
|
33
|
-
contents=[Content(role="user", parts=[Part.from_text(text="Hello")])],
|
34
|
-
config=types.GenerateContentConfig(
|
35
|
-
temperature=0.1,
|
36
|
-
response_modalities=[types.Modality.TEXT],
|
37
|
-
system_instruction="You are a helpful assistant",
|
38
|
-
),
|
39
|
-
)
|
40
|
-
|
41
|
-
|
42
|
-
@pytest.mark.asyncio
|
43
|
-
async def test_generate_content_async(gemini_llm, llm_request):
|
44
|
-
async for response in gemini_llm.generate_content_async(llm_request):
|
45
|
-
assert isinstance(response, LlmResponse)
|
46
|
-
assert response.content.parts[0].text
|
47
|
-
|
48
|
-
|
49
|
-
@pytest.mark.asyncio
|
50
|
-
async def test_generate_content_async_stream(gemini_llm, llm_request):
|
51
|
-
responses = [
|
52
|
-
resp
|
53
|
-
async for resp in gemini_llm.generate_content_async(
|
54
|
-
llm_request, stream=True
|
55
|
-
)
|
56
|
-
]
|
57
|
-
text = ""
|
58
|
-
for i in range(len(responses) - 1):
|
59
|
-
assert responses[i].partial is True
|
60
|
-
assert responses[i].content.parts[0].text
|
61
|
-
text += responses[i].content.parts[0].text
|
62
|
-
|
63
|
-
# Last message should be accumulated text
|
64
|
-
assert responses[-1].content.parts[0].text == text
|
65
|
-
assert not responses[-1].partial
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from pytest import mark
|
16
|
-
|
17
|
-
from ..unittests.utils import simplify_events
|
18
|
-
from .fixture import callback_agent
|
19
|
-
from .utils import assert_agent_says
|
20
|
-
from .utils import TestRunner
|
21
|
-
|
22
|
-
|
23
|
-
@mark.parametrize(
|
24
|
-
"agent_runner",
|
25
|
-
[{"agent": callback_agent.agent.before_agent_callback_agent}],
|
26
|
-
indirect=True,
|
27
|
-
)
|
28
|
-
def test_before_agent_call(agent_runner: TestRunner):
|
29
|
-
agent_runner.run("Hi.")
|
30
|
-
|
31
|
-
# Assert the response content
|
32
|
-
assert_agent_says(
|
33
|
-
"End invocation event before agent call.",
|
34
|
-
agent_name="before_agent_callback_agent",
|
35
|
-
agent_runner=agent_runner,
|
36
|
-
)
|
37
|
-
|
38
|
-
|
39
|
-
@mark.parametrize(
|
40
|
-
"agent_runner",
|
41
|
-
[{"agent": callback_agent.agent.before_model_callback_agent}],
|
42
|
-
indirect=True,
|
43
|
-
)
|
44
|
-
def test_before_model_call(agent_runner: TestRunner):
|
45
|
-
agent_runner.run("Hi.")
|
46
|
-
|
47
|
-
# Assert the response content
|
48
|
-
assert_agent_says(
|
49
|
-
"End invocation event before model call.",
|
50
|
-
agent_name="before_model_callback_agent",
|
51
|
-
agent_runner=agent_runner,
|
52
|
-
)
|
53
|
-
|
54
|
-
|
55
|
-
# TODO: re-enable vertex by removing below line after fixing.
|
56
|
-
@mark.parametrize("llm_backend", ["GOOGLE_AI"], indirect=True)
|
57
|
-
@mark.parametrize(
|
58
|
-
"agent_runner",
|
59
|
-
[{"agent": callback_agent.agent.after_model_callback_agent}],
|
60
|
-
indirect=True,
|
61
|
-
)
|
62
|
-
def test_after_model_call(agent_runner: TestRunner):
|
63
|
-
events = agent_runner.run("Hi.")
|
64
|
-
|
65
|
-
# Assert the response content
|
66
|
-
simplified_events = simplify_events(events)
|
67
|
-
assert simplified_events[0][0] == "after_model_callback_agent"
|
68
|
-
assert simplified_events[0][1].endswith(
|
69
|
-
"Update response event after model call."
|
70
|
-
)
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
import json
|
16
|
-
|
17
|
-
import pytest
|
18
|
-
|
19
|
-
# Skip until fixed.
|
20
|
-
pytest.skip(allow_module_level=True)
|
21
|
-
|
22
|
-
from .fixture import context_variable_agent
|
23
|
-
from .utils import TestRunner
|
24
|
-
|
25
|
-
|
26
|
-
@pytest.mark.parametrize(
|
27
|
-
"agent_runner",
|
28
|
-
[{"agent": context_variable_agent.agent.state_variable_echo_agent}],
|
29
|
-
indirect=True,
|
30
|
-
)
|
31
|
-
def test_context_variable_missing(agent_runner: TestRunner):
|
32
|
-
with pytest.raises(KeyError) as e_info:
|
33
|
-
agent_runner.run("Hi echo my customer id.")
|
34
|
-
assert "customerId" in str(e_info.value)
|
35
|
-
|
36
|
-
|
37
|
-
@pytest.mark.parametrize(
|
38
|
-
"agent_runner",
|
39
|
-
[{"agent": context_variable_agent.agent.state_variable_update_agent}],
|
40
|
-
indirect=True,
|
41
|
-
)
|
42
|
-
def test_context_variable_update(agent_runner: TestRunner):
|
43
|
-
_call_function_and_assert(
|
44
|
-
agent_runner,
|
45
|
-
"update_fc",
|
46
|
-
["RRRR", "3.141529", ["apple", "banana"], [1, 3.14, "hello"]],
|
47
|
-
"successfully",
|
48
|
-
)
|
49
|
-
|
50
|
-
|
51
|
-
def _call_function_and_assert(
|
52
|
-
agent_runner: TestRunner, function_name: str, params, expected
|
53
|
-
):
|
54
|
-
param_section = (
|
55
|
-
" with params"
|
56
|
-
f" {params if isinstance(params, str) else json.dumps(params)}"
|
57
|
-
if params is not None
|
58
|
-
else ""
|
59
|
-
)
|
60
|
-
agent_runner.run(
|
61
|
-
f"Call {function_name}{param_section} and show me the result"
|
62
|
-
)
|
63
|
-
|
64
|
-
model_response_event = agent_runner.get_events()[-1]
|
65
|
-
assert model_response_event.author == "context_variable_update_agent"
|
66
|
-
assert model_response_event.content.role == "model"
|
67
|
-
assert expected in model_response_event.content.parts[0].text.strip()
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
"""Evaluate all agents in fixture folder if evaluation test files exist."""
|
16
|
-
|
17
|
-
import os
|
18
|
-
|
19
|
-
from google.adk.evaluation import AgentEvaluator
|
20
|
-
import pytest
|
21
|
-
|
22
|
-
def agent_eval_artifacts_in_fixture():
|
23
|
-
"""Get all agents from fixture folder."""
|
24
|
-
agent_eval_artifacts = []
|
25
|
-
fixture_dir = os.path.join(os.path.dirname(__file__), 'fixture')
|
26
|
-
for agent_name in os.listdir(fixture_dir):
|
27
|
-
agent_dir = os.path.join(fixture_dir, agent_name)
|
28
|
-
if not os.path.isdir(agent_dir):
|
29
|
-
continue
|
30
|
-
for filename in os.listdir(agent_dir):
|
31
|
-
# Evaluation test files end with test.json
|
32
|
-
if not filename.endswith('test.json'):
|
33
|
-
continue
|
34
|
-
initial_session_file = (
|
35
|
-
f'tests/integration/fixture/{agent_name}/initial.session.json'
|
36
|
-
)
|
37
|
-
agent_eval_artifacts.append((
|
38
|
-
f'tests.integration.fixture.{agent_name}',
|
39
|
-
f'tests/integration/fixture/{agent_name}/{filename}',
|
40
|
-
initial_session_file
|
41
|
-
if os.path.exists(initial_session_file)
|
42
|
-
else None,
|
43
|
-
))
|
44
|
-
|
45
|
-
# This method gets invoked twice, sorting helps ensure that both the
|
46
|
-
# invocations have the same view.
|
47
|
-
agent_eval_artifacts = sorted(
|
48
|
-
agent_eval_artifacts, key=lambda item: f'{item[0]}|{item[1]}'
|
49
|
-
)
|
50
|
-
return agent_eval_artifacts
|
51
|
-
|
52
|
-
|
53
|
-
@pytest.mark.parametrize(
|
54
|
-
'agent_name, evalfile, initial_session_file',
|
55
|
-
agent_eval_artifacts_in_fixture(),
|
56
|
-
ids=[agent_name for agent_name, _, _ in agent_eval_artifacts_in_fixture()],
|
57
|
-
)
|
58
|
-
def test_evaluate_agents_long_running_4_runs_per_eval_item(
|
59
|
-
agent_name, evalfile, initial_session_file
|
60
|
-
):
|
61
|
-
"""Test agents evaluation in fixture folder.
|
62
|
-
|
63
|
-
After querying the fixture folder, we have 5 eval items. For each eval item
|
64
|
-
we use 4 runs.
|
65
|
-
|
66
|
-
A single eval item is a session that can have multiple queries in it.
|
67
|
-
"""
|
68
|
-
AgentEvaluator.evaluate(
|
69
|
-
agent_module=agent_name,
|
70
|
-
eval_dataset_file_path_or_dir=evalfile,
|
71
|
-
initial_session_file=initial_session_file,
|
72
|
-
# Using a slightly higher value helps us manange the variances that may
|
73
|
-
# happen in each eval.
|
74
|
-
# This, of course, comes at a cost of incrased test run times.
|
75
|
-
num_runs=4,
|
76
|
-
)
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from google.adk.evaluation import AgentEvaluator
|
16
|
-
|
17
|
-
|
18
|
-
def test_eval_agent():
|
19
|
-
AgentEvaluator.evaluate(
|
20
|
-
agent_module="tests.integration.fixture.trip_planner_agent",
|
21
|
-
eval_dataset_file_path_or_dir=(
|
22
|
-
"tests/integration/fixture/trip_planner_agent/trip_inquiry.test.json"
|
23
|
-
),
|
24
|
-
initial_session_file=(
|
25
|
-
"tests/integration/fixture/trip_planner_agent/initial.session.json"
|
26
|
-
),
|
27
|
-
num_runs=4,
|
28
|
-
)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from google.adk.evaluation import AgentEvaluator
|
16
|
-
|
17
|
-
|
18
|
-
def test_simple_multi_turn_conversation():
|
19
|
-
"""Test a simple multi-turn conversation."""
|
20
|
-
AgentEvaluator.evaluate(
|
21
|
-
agent_module="tests.integration.fixture.home_automation_agent",
|
22
|
-
eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/test_files/simple_multi_turn_conversation.test.json",
|
23
|
-
num_runs=4,
|
24
|
-
)
|
25
|
-
|
26
|
-
|
27
|
-
def test_dependent_tool_calls():
|
28
|
-
"""Test subsequent tool calls that are dependent on previous tool calls."""
|
29
|
-
AgentEvaluator.evaluate(
|
30
|
-
agent_module="tests.integration.fixture.home_automation_agent",
|
31
|
-
eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/test_files/dependent_tool_calls.test.json",
|
32
|
-
num_runs=4,
|
33
|
-
)
|
34
|
-
|
35
|
-
|
36
|
-
def test_memorizing_past_events():
|
37
|
-
"""Test memorizing past events."""
|
38
|
-
AgentEvaluator.evaluate(
|
39
|
-
agent_module="tests.integration.fixture.home_automation_agent",
|
40
|
-
eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/test_files/memorizing_past_events/eval_data.test.json",
|
41
|
-
num_runs=4,
|
42
|
-
)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from google.adk.evaluation import AgentEvaluator
|
16
|
-
|
17
|
-
|
18
|
-
def test_eval_agent():
|
19
|
-
AgentEvaluator.evaluate(
|
20
|
-
agent_module="tests.integration.fixture.home_automation_agent",
|
21
|
-
eval_dataset_file_path_or_dir="tests/integration/fixture/home_automation_agent/simple_test.test.json",
|
22
|
-
num_runs=4,
|
23
|
-
)
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# Copyright 2025 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
from google.adk.evaluation import AgentEvaluator
|
16
|
-
|
17
|
-
|
18
|
-
def test_eval_agent():
|
19
|
-
"""Test hotel sub agent in a multi-agent system."""
|
20
|
-
AgentEvaluator.evaluate(
|
21
|
-
agent_module="tests.integration.fixture.trip_planner_agent",
|
22
|
-
eval_dataset_file_path_or_dir="tests/integration/fixture/trip_planner_agent/test_files/trip_inquiry_sub_agent.test.json",
|
23
|
-
initial_session_file="tests/integration/fixture/trip_planner_agent/test_files/initial.session.json",
|
24
|
-
agent_name="identify_agent",
|
25
|
-
num_runs=4,
|
26
|
-
)
|