google-adk 0.5.0__tar.gz → 1.0.0__tar.gz
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-0.5.0 → google_adk-1.0.0}/PKG-INFO +7 -5
- {google_adk-0.5.0 → google_adk-1.0.0}/pyproject.toml +17 -7
- google_adk-1.0.0/src/google/adk/agents/base_agent.py +389 -0
- google_adk-0.5.0/src/google/adk/agents/base_agent.py → google_adk-1.0.0/src/google/adk/agents/base_agent.py.orig +8 -21
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/callback_context.py +0 -5
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/llm_agent.py +122 -30
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/loop_agent.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/parallel_agent.py +7 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/readonly_context.py +7 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/run_config.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/sequential_agent.py +31 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/transcription_entry.py +4 -2
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/artifacts/gcs_artifact_service.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/artifacts/in_memory_artifact_service.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/auth/auth_credential.py +6 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/auth/auth_preprocessor.py +7 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/auth/auth_tool.py +3 -4
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/agent_graph.py +5 -5
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/browser/index.html +2 -2
- google_adk-0.5.0/src/google/adk/cli/browser/main-ULN5R5I5.js → google_adk-1.0.0/src/google/adk/cli/browser/main-QOEMUXM4.js +44 -45
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/cli.py +7 -7
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/cli_deploy.py +7 -2
- google_adk-1.0.0/src/google/adk/cli/cli_eval.py +357 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/cli_tools_click.py +147 -64
- google_adk-1.0.0/src/google/adk/cli/fast_api.py +1004 -0
- google_adk-0.5.0/src/google/adk/cli/fast_api.py → google_adk-1.0.0/src/google/adk/cli/fast_api.py.orig +11 -11
- google_adk-1.0.0/src/google/adk/cli/utils/common.py +23 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/utils/evals.py +83 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/utils/logs.py +13 -5
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/__init__.py +3 -1
- google_adk-1.0.0/src/google/adk/code_executors/built_in_code_executor.py +52 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/evaluation/__init__.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/evaluation/agent_evaluator.py +168 -128
- google_adk-1.0.0/src/google/adk/evaluation/eval_case.py +102 -0
- google_adk-1.0.0/src/google/adk/evaluation/eval_set.py +37 -0
- google_adk-1.0.0/src/google/adk/evaluation/eval_sets_manager.py +42 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/evaluation/evaluation_generator.py +88 -113
- google_adk-1.0.0/src/google/adk/evaluation/evaluator.py +56 -0
- google_adk-1.0.0/src/google/adk/evaluation/local_eval_sets_manager.py +264 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/evaluation/response_evaluator.py +106 -2
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/evaluation/trajectory_evaluator.py +83 -2
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/events/event.py +6 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/events/event_actions.py +6 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/examples/example_util.py +3 -2
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/_code_execution.py +9 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/audio_transcriber.py +4 -3
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/base_llm_flow.py +54 -15
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/functions.py +9 -8
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/instructions.py +13 -5
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/single_flow.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/memory/__init__.py +1 -1
- google_adk-1.0.0/src/google/adk/memory/_utils.py +23 -0
- google_adk-1.0.0/src/google/adk/memory/base_memory_service.py +78 -0
- google_adk-1.0.0/src/google/adk/memory/in_memory_memory_service.py +94 -0
- google_adk-1.0.0/src/google/adk/memory/memory_entry.py +37 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/memory/vertex_ai_rag_memory_service.py +38 -15
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/anthropic_llm.py +16 -9
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/gemini_llm_connection.py +11 -11
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/google_llm.py +9 -2
- google_adk-1.0.0/src/google/adk/models/google_llm.py.orig +305 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/lite_llm.py +77 -21
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/llm_response.py +14 -2
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/registry.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/runners.py +65 -41
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/__init__.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/base_session_service.py +6 -33
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/database_session_service.py +58 -65
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/in_memory_session_service.py +106 -24
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/session.py +3 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/vertex_ai_session_service.py +23 -45
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/telemetry.py +3 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/__init__.py +4 -7
- google_adk-0.5.0/src/google/adk/tools/built_in_code_execution_tool.py → google_adk-1.0.0/src/google/adk/tools/_built_in_code_execution_tool.py +11 -0
- google_adk-1.0.0/src/google/adk/tools/_memory_entry_utils.py +30 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/agent_tool.py +9 -9
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/apihub_tool/apihub_toolset.py +55 -74
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/application_integration_tool/application_integration_toolset.py +107 -85
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/application_integration_tool/clients/connections_client.py +20 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/application_integration_tool/clients/integration_client.py +6 -6
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/application_integration_tool/integration_connector_tool.py +69 -26
- google_adk-1.0.0/src/google/adk/tools/base_toolset.py +58 -0
- google_adk-1.0.0/src/google/adk/tools/enterprise_search_tool.py +65 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/function_parameter_parse_util.py +2 -2
- google_adk-1.0.0/src/google/adk/tools/google_api_tool/__init__.py +35 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/google_api_tool/google_api_tool.py +11 -5
- google_adk-1.0.0/src/google/adk/tools/google_api_tool/google_api_toolset.py +126 -0
- google_adk-1.0.0/src/google/adk/tools/google_api_tool/google_api_toolsets.py +102 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/google_api_tool/googleapi_to_openapi_converter.py +40 -42
- google_adk-1.0.0/src/google/adk/tools/langchain_tool.py +133 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/load_memory_tool.py +14 -5
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/mcp_tool/__init__.py +3 -2
- google_adk-1.0.0/src/google/adk/tools/mcp_tool/mcp_session_manager.py +327 -0
- google_adk-0.5.0/src/google/adk/tools/mcp_tool/mcp_session_manager.py → google_adk-1.0.0/src/google/adk/tools/mcp_tool/mcp_session_manager.py.orig +147 -15
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/mcp_tool/mcp_tool.py +12 -12
- google_adk-1.0.0/src/google/adk/tools/mcp_tool/mcp_toolset.py +226 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +32 -7
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py +31 -31
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/preload_memory_tool.py +27 -18
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/retrieval/__init__.py +1 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +1 -1
- google_adk-1.0.0/src/google/adk/tools/toolbox_toolset.py +79 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/transfer_to_agent_tool.py +0 -1
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/version.py +1 -1
- google_adk-0.5.0/src/google/adk/agents/remote_agent.py +0 -50
- google_adk-0.5.0/src/google/adk/cli/cli_eval.py +0 -284
- google_adk-0.5.0/src/google/adk/cli/fast_api.py.orig +0 -728
- google_adk-0.5.0/src/google/adk/memory/in_memory_memory_service.py +0 -62
- google_adk-0.5.0/src/google/adk/tools/google_api_tool/__init__.py +0 -87
- google_adk-0.5.0/src/google/adk/tools/google_api_tool/google_api_tool_set.py +0 -110
- google_adk-0.5.0/src/google/adk/tools/google_api_tool/google_api_tool_sets.py +0 -112
- google_adk-0.5.0/src/google/adk/tools/langchain_tool.py +0 -86
- google_adk-0.5.0/src/google/adk/tools/mcp_tool/mcp_toolset.py +0 -266
- google_adk-0.5.0/src/google/adk/tools/toolbox_tool.py +0 -46
- {google_adk-0.5.0 → google_adk-1.0.0}/LICENSE +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/README.md +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/active_streaming_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/invocation_context.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/langgraph_agent.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/agents/live_request_queue.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/artifacts/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/artifacts/base_artifact_service.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/auth/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/auth/auth_handler.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/auth/auth_schemes.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/__main__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/browser/adk_favicon.svg +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/browser/assets/audio-processor.js +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/browser/assets/config/runtime-config.json +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/browser/styles-4VDSPQ37.css +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/cli_create.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/utils/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/cli/utils/envs.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/base_code_executor.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/code_execution_utils.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/code_executor_context.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/container_code_executor.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/unsafe_local_code_executor.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/code_executors/vertex_ai_code_executor.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/evaluation/evaluation_constants.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/events/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/examples/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/examples/base_example_provider.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/examples/example.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/examples/vertex_ai_example_store.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/_base_llm_processor.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/_nl_planning.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/agent_transfer.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/auto_flow.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/basic.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/contents.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/flows/llm_flows/identity.py +0 -0
- /google_adk-0.5.0/src/google/adk/memory/base_memory_service.py → /google_adk-1.0.0/src/google/adk/memory/base_memory_service.py.orig +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/base_llm.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/base_llm_connection.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/models/llm_request.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/planners/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/planners/base_planner.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/planners/built_in_planner.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/planners/plan_re_act_planner.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/_session_util.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/sessions/state.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/_automatic_function_calling_util.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/apihub_tool/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/apihub_tool/clients/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/apihub_tool/clients/apihub_client.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/apihub_tool/clients/secret_client.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/application_integration_tool/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/base_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/crewai_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/example_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/exit_loop_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/function_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/get_user_choice_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/google_search_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/load_artifacts_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/load_web_page.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/long_running_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/mcp_tool/conversion_utils.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/auth_helpers.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/base_credential_exchanger.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/common/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/common/common.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/__init__.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/retrieval/base_retrieval_tool.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/retrieval/files_retrieval.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/retrieval/llama_index_retrieval.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/tool_context.py +0 -0
- {google_adk-0.5.0 → google_adk-1.0.0}/src/google/adk/tools/vertex_ai_search_tool.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: google-adk
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0
|
4
4
|
Summary: Agent Development Kit
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
6
6
|
Requires-Python: >=3.9
|
@@ -11,10 +11,10 @@ Classifier: Intended Audience :: Science/Research
|
|
11
11
|
Classifier: Programming Language :: Python
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
13
13
|
Classifier: Programming Language :: Python :: 3.9
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
17
14
|
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
18
|
Classifier: Operating System :: OS Independent
|
19
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
20
|
Classifier: License :: OSI Approved :: Apache Software License
|
@@ -27,7 +27,7 @@ Requires-Dist: google-cloud-aiplatform>=1.87.0
|
|
27
27
|
Requires-Dist: google-cloud-secret-manager>=2.22.0
|
28
28
|
Requires-Dist: google-cloud-speech>=2.30.0
|
29
29
|
Requires-Dist: google-cloud-storage>=2.18.0, <3.0.0
|
30
|
-
Requires-Dist: google-genai>=1.
|
30
|
+
Requires-Dist: google-genai>=1.14.0
|
31
31
|
Requires-Dist: graphviz>=0.20.2
|
32
32
|
Requires-Dist: mcp>=1.5.0;python_version>='3.10'
|
33
33
|
Requires-Dist: opentelemetry-api>=1.31.0
|
@@ -43,6 +43,7 @@ Requires-Dist: flit>=3.10.0 ; extra == "dev"
|
|
43
43
|
Requires-Dist: isort>=6.0.0 ; extra == "dev"
|
44
44
|
Requires-Dist: pyink>=24.10.0 ; extra == "dev"
|
45
45
|
Requires-Dist: pylint>=2.6.0 ; extra == "dev"
|
46
|
+
Requires-Dist: mypy>=1.15.0 ; extra == "dev"
|
46
47
|
Requires-Dist: autodoc_pydantic ; extra == "docs"
|
47
48
|
Requires-Dist: furo ; extra == "docs"
|
48
49
|
Requires-Dist: myst-parser ; extra == "docs"
|
@@ -60,6 +61,7 @@ Requires-Dist: langgraph>=0.2.60 ; extra == "extensions"
|
|
60
61
|
Requires-Dist: litellm>=1.63.11 ; extra == "extensions"
|
61
62
|
Requires-Dist: llama-index-readers-file>=0.4.0 ; extra == "extensions"
|
62
63
|
Requires-Dist: lxml>=5.3.0 ; extra == "extensions"
|
64
|
+
Requires-Dist: toolbox-core>=0.1.0 ; extra == "extensions"
|
63
65
|
Requires-Dist: anthropic>=0.43.0 ; extra == "test"
|
64
66
|
Requires-Dist: langchain-community>=0.3.17 ; extra == "test"
|
65
67
|
Requires-Dist: langgraph>=0.2.60 ; extra == "test"
|
@@ -15,10 +15,10 @@ classifiers = [ # List of https://pypi.org/classifiers/
|
|
15
15
|
"Programming Language :: Python",
|
16
16
|
"Programming Language :: Python :: 3",
|
17
17
|
"Programming Language :: Python :: 3.9",
|
18
|
-
"Programming Language :: Python :: 3.13",
|
19
|
-
"Programming Language :: Python :: 3.12",
|
20
|
-
"Programming Language :: Python :: 3.11",
|
21
18
|
"Programming Language :: Python :: 3.10",
|
19
|
+
"Programming Language :: Python :: 3.11",
|
20
|
+
"Programming Language :: Python :: 3.12",
|
21
|
+
"Programming Language :: Python :: 3.13",
|
22
22
|
"Operating System :: OS Independent",
|
23
23
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
24
24
|
"License :: OSI Approved :: Apache Software License",
|
@@ -31,9 +31,9 @@ dependencies = [
|
|
31
31
|
"google-api-python-client>=2.157.0", # Google API client discovery
|
32
32
|
"google-cloud-aiplatform>=1.87.0", # For VertexAI integrations, e.g. example store.
|
33
33
|
"google-cloud-secret-manager>=2.22.0", # Fetching secrets in RestAPI Tool
|
34
|
-
"google-cloud-speech>=2.30.0", # For
|
34
|
+
"google-cloud-speech>=2.30.0", # For Audio Transcription
|
35
35
|
"google-cloud-storage>=2.18.0, <3.0.0", # For GCS Artifact service
|
36
|
-
"google-genai>=1.
|
36
|
+
"google-genai>=1.14.0", # Google GenAI SDK
|
37
37
|
"graphviz>=0.20.2", # Graphviz for graph rendering
|
38
38
|
"mcp>=1.5.0;python_version>='3.10'", # For MCP Toolset
|
39
39
|
"opentelemetry-api>=1.31.0", # OpenTelemetry
|
@@ -66,6 +66,7 @@ dev = [
|
|
66
66
|
"isort>=6.0.0",
|
67
67
|
"pyink>=24.10.0",
|
68
68
|
"pylint>=2.6.0",
|
69
|
+
"mypy>=1.15.0",
|
69
70
|
# go/keep-sorted end
|
70
71
|
]
|
71
72
|
|
@@ -83,7 +84,8 @@ test = [
|
|
83
84
|
"langchain-community>=0.3.17",
|
84
85
|
"langgraph>=0.2.60", # For LangGraphAgent
|
85
86
|
"litellm>=1.63.11", # For LiteLLM tests
|
86
|
-
"llama-index-readers-file>=0.4.0", #
|
87
|
+
"llama-index-readers-file>=0.4.0", # For retrieval tests
|
88
|
+
|
87
89
|
"pytest-asyncio>=0.25.0",
|
88
90
|
"pytest-mock>=3.14.0",
|
89
91
|
"pytest-xdist>=3.6.1",
|
@@ -108,8 +110,9 @@ extensions = [
|
|
108
110
|
"docker>=7.0.0", # For ContainerCodeExecutor
|
109
111
|
"langgraph>=0.2.60", # For LangGraphAgent
|
110
112
|
"litellm>=1.63.11", # For LiteLLM support
|
111
|
-
"llama-index-readers-file>=0.4.0", #
|
113
|
+
"llama-index-readers-file>=0.4.0", # For retrieval using LlamaIndex.
|
112
114
|
"lxml>=5.3.0", # For load_web_page tool.
|
115
|
+
"toolbox-core>=0.1.0", # For tools.toolbox_toolset.ToolboxToolset
|
113
116
|
]
|
114
117
|
|
115
118
|
|
@@ -146,9 +149,16 @@ name = "google.adk"
|
|
146
149
|
[tool.isort]
|
147
150
|
profile = "google"
|
148
151
|
single_line_exclusions = []
|
152
|
+
known_third_party = ["google.adk"]
|
149
153
|
|
150
154
|
|
151
155
|
[tool.pytest.ini_options]
|
152
156
|
testpaths = ["tests"]
|
153
157
|
asyncio_default_fixture_loop_scope = "function"
|
154
158
|
asyncio_mode = "auto"
|
159
|
+
|
160
|
+
[tool.mypy]
|
161
|
+
exclude = "tests/"
|
162
|
+
plugins = ["pydantic.mypy"]
|
163
|
+
strict = true
|
164
|
+
disable_error_code = ["import-not-found", "import-untyped", "unused-ignore"]
|
@@ -0,0 +1,389 @@
|
|
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 __future__ import annotations
|
16
|
+
|
17
|
+
import inspect
|
18
|
+
from typing import Any
|
19
|
+
from typing import AsyncGenerator
|
20
|
+
from typing import Awaitable
|
21
|
+
from typing import Callable
|
22
|
+
from typing import final
|
23
|
+
from typing import Optional
|
24
|
+
from typing import TYPE_CHECKING
|
25
|
+
from typing import Union
|
26
|
+
|
27
|
+
from google.genai import types
|
28
|
+
from opentelemetry import trace
|
29
|
+
from pydantic import BaseModel
|
30
|
+
from pydantic import ConfigDict
|
31
|
+
from pydantic import Field
|
32
|
+
from pydantic import field_validator
|
33
|
+
from typing_extensions import override
|
34
|
+
from typing_extensions import TypeAlias
|
35
|
+
|
36
|
+
from ..events.event import Event
|
37
|
+
from .callback_context import CallbackContext
|
38
|
+
|
39
|
+
if TYPE_CHECKING:
|
40
|
+
from .invocation_context import InvocationContext
|
41
|
+
|
42
|
+
tracer = trace.get_tracer('gcp.vertex.agent')
|
43
|
+
|
44
|
+
_SingleAgentCallback: TypeAlias = Callable[
|
45
|
+
[CallbackContext],
|
46
|
+
Union[Awaitable[Optional[types.Content]], Optional[types.Content]],
|
47
|
+
]
|
48
|
+
|
49
|
+
BeforeAgentCallback: TypeAlias = Union[
|
50
|
+
_SingleAgentCallback,
|
51
|
+
list[_SingleAgentCallback],
|
52
|
+
]
|
53
|
+
|
54
|
+
AfterAgentCallback: TypeAlias = Union[
|
55
|
+
_SingleAgentCallback,
|
56
|
+
list[_SingleAgentCallback],
|
57
|
+
]
|
58
|
+
|
59
|
+
|
60
|
+
class BaseAgent(BaseModel):
|
61
|
+
"""Base class for all agents in Agent Development Kit."""
|
62
|
+
|
63
|
+
model_config = ConfigDict(
|
64
|
+
arbitrary_types_allowed=True,
|
65
|
+
extra='forbid',
|
66
|
+
)
|
67
|
+
"""The pydantic model config."""
|
68
|
+
|
69
|
+
name: str
|
70
|
+
"""The agent's name.
|
71
|
+
|
72
|
+
Agent name must be a Python identifier and unique within the agent tree.
|
73
|
+
Agent name cannot be "user", since it's reserved for end-user's input.
|
74
|
+
"""
|
75
|
+
|
76
|
+
description: str = ''
|
77
|
+
"""Description about the agent's capability.
|
78
|
+
|
79
|
+
The model uses this to determine whether to delegate control to the agent.
|
80
|
+
One-line description is enough and preferred.
|
81
|
+
"""
|
82
|
+
|
83
|
+
parent_agent: Optional[BaseAgent] = Field(default=None, init=False)
|
84
|
+
"""The parent agent of this agent.
|
85
|
+
|
86
|
+
Note that an agent can ONLY be added as sub-agent once.
|
87
|
+
|
88
|
+
If you want to add one agent twice as sub-agent, consider to create two agent
|
89
|
+
instances with identical config, but with different name and add them to the
|
90
|
+
agent tree.
|
91
|
+
"""
|
92
|
+
sub_agents: list[BaseAgent] = Field(default_factory=list)
|
93
|
+
"""The sub-agents of this agent."""
|
94
|
+
|
95
|
+
before_agent_callback: Optional[BeforeAgentCallback] = None
|
96
|
+
"""Callback or list of callbacks to be invoked before the agent run.
|
97
|
+
|
98
|
+
When a list of callbacks is provided, the callbacks will be called in the
|
99
|
+
order they are listed until a callback does not return None.
|
100
|
+
|
101
|
+
Args:
|
102
|
+
callback_context: MUST be named 'callback_context' (enforced).
|
103
|
+
|
104
|
+
Returns:
|
105
|
+
Optional[types.Content]: The content to return to the user.
|
106
|
+
When the content is present, the agent run will be skipped and the
|
107
|
+
provided content will be returned to user.
|
108
|
+
"""
|
109
|
+
after_agent_callback: Optional[AfterAgentCallback] = None
|
110
|
+
"""Callback or list of callbacks to be invoked after the agent run.
|
111
|
+
|
112
|
+
When a list of callbacks is provided, the callbacks will be called in the
|
113
|
+
order they are listed until a callback does not return None.
|
114
|
+
|
115
|
+
Args:
|
116
|
+
callback_context: MUST be named 'callback_context' (enforced).
|
117
|
+
|
118
|
+
Returns:
|
119
|
+
Optional[types.Content]: The content to return to the user.
|
120
|
+
When the content is present, the provided content will be used as agent
|
121
|
+
response and appended to event history as agent response.
|
122
|
+
"""
|
123
|
+
|
124
|
+
@final
|
125
|
+
async def run_async(
|
126
|
+
self,
|
127
|
+
parent_context: InvocationContext,
|
128
|
+
) -> AsyncGenerator[Event, None]:
|
129
|
+
"""Entry method to run an agent via text-based conversation.
|
130
|
+
|
131
|
+
Args:
|
132
|
+
parent_context: InvocationContext, the invocation context of the parent
|
133
|
+
agent.
|
134
|
+
|
135
|
+
Yields:
|
136
|
+
Event: the events generated by the agent.
|
137
|
+
"""
|
138
|
+
|
139
|
+
with tracer.start_as_current_span(f'agent_run [{self.name}]'):
|
140
|
+
ctx = self._create_invocation_context(parent_context)
|
141
|
+
|
142
|
+
if event := await self.__handle_before_agent_callback(ctx):
|
143
|
+
yield event
|
144
|
+
if ctx.end_invocation:
|
145
|
+
return
|
146
|
+
|
147
|
+
async for event in self._run_async_impl(ctx):
|
148
|
+
yield event
|
149
|
+
|
150
|
+
if ctx.end_invocation:
|
151
|
+
return
|
152
|
+
|
153
|
+
if event := await self.__handle_after_agent_callback(ctx):
|
154
|
+
yield event
|
155
|
+
|
156
|
+
@final
|
157
|
+
async def run_live(
|
158
|
+
self,
|
159
|
+
parent_context: InvocationContext,
|
160
|
+
) -> AsyncGenerator[Event, None]:
|
161
|
+
"""Entry method to run an agent via video/audio-based conversation.
|
162
|
+
|
163
|
+
Args:
|
164
|
+
parent_context: InvocationContext, the invocation context of the parent
|
165
|
+
agent.
|
166
|
+
|
167
|
+
Yields:
|
168
|
+
Event: the events generated by the agent.
|
169
|
+
"""
|
170
|
+
with tracer.start_as_current_span(f'agent_run [{self.name}]'):
|
171
|
+
ctx = self._create_invocation_context(parent_context)
|
172
|
+
# TODO(hangfei): support before/after_agent_callback
|
173
|
+
|
174
|
+
async for event in self._run_live_impl(ctx):
|
175
|
+
yield event
|
176
|
+
|
177
|
+
async def _run_async_impl(
|
178
|
+
self, ctx: InvocationContext
|
179
|
+
) -> AsyncGenerator[Event, None]:
|
180
|
+
"""Core logic to run this agent via text-based conversation.
|
181
|
+
|
182
|
+
Args:
|
183
|
+
ctx: InvocationContext, the invocation context for this agent.
|
184
|
+
|
185
|
+
Yields:
|
186
|
+
Event: the events generated by the agent.
|
187
|
+
"""
|
188
|
+
raise NotImplementedError(
|
189
|
+
f'_run_async_impl for {type(self)} is not implemented.'
|
190
|
+
)
|
191
|
+
yield # AsyncGenerator requires having at least one yield statement
|
192
|
+
|
193
|
+
async def _run_live_impl(
|
194
|
+
self, ctx: InvocationContext
|
195
|
+
) -> AsyncGenerator[Event, None]:
|
196
|
+
"""Core logic to run this agent via video/audio-based conversation.
|
197
|
+
|
198
|
+
Args:
|
199
|
+
ctx: InvocationContext, the invocation context for this agent.
|
200
|
+
|
201
|
+
Yields:
|
202
|
+
Event: the events generated by the agent.
|
203
|
+
"""
|
204
|
+
raise NotImplementedError(
|
205
|
+
f'_run_live_impl for {type(self)} is not implemented.'
|
206
|
+
)
|
207
|
+
yield # AsyncGenerator requires having at least one yield statement
|
208
|
+
|
209
|
+
@property
|
210
|
+
def root_agent(self) -> BaseAgent:
|
211
|
+
"""Gets the root agent of this agent."""
|
212
|
+
root_agent = self
|
213
|
+
while root_agent.parent_agent is not None:
|
214
|
+
root_agent = root_agent.parent_agent
|
215
|
+
return root_agent
|
216
|
+
|
217
|
+
def find_agent(self, name: str) -> Optional[BaseAgent]:
|
218
|
+
"""Finds the agent with the given name in this agent and its descendants.
|
219
|
+
|
220
|
+
Args:
|
221
|
+
name: The name of the agent to find.
|
222
|
+
|
223
|
+
Returns:
|
224
|
+
The agent with the matching name, or None if no such agent is found.
|
225
|
+
"""
|
226
|
+
if self.name == name:
|
227
|
+
return self
|
228
|
+
return self.find_sub_agent(name)
|
229
|
+
|
230
|
+
def find_sub_agent(self, name: str) -> Optional[BaseAgent]:
|
231
|
+
"""Finds the agent with the given name in this agent's descendants.
|
232
|
+
|
233
|
+
Args:
|
234
|
+
name: The name of the agent to find.
|
235
|
+
|
236
|
+
Returns:
|
237
|
+
The agent with the matching name, or None if no such agent is found.
|
238
|
+
"""
|
239
|
+
for sub_agent in self.sub_agents:
|
240
|
+
if result := sub_agent.find_agent(name):
|
241
|
+
return result
|
242
|
+
return None
|
243
|
+
|
244
|
+
def _create_invocation_context(
|
245
|
+
self, parent_context: InvocationContext
|
246
|
+
) -> InvocationContext:
|
247
|
+
"""Creates a new invocation context for this agent."""
|
248
|
+
invocation_context = parent_context.model_copy(update={'agent': self})
|
249
|
+
if parent_context.branch:
|
250
|
+
invocation_context.branch = f'{parent_context.branch}.{self.name}'
|
251
|
+
return invocation_context
|
252
|
+
|
253
|
+
@property
|
254
|
+
def canonical_before_agent_callbacks(self) -> list[_SingleAgentCallback]:
|
255
|
+
"""The resolved self.before_agent_callback field as a list of _SingleAgentCallback.
|
256
|
+
|
257
|
+
This method is only for use by Agent Development Kit.
|
258
|
+
"""
|
259
|
+
if not self.before_agent_callback:
|
260
|
+
return []
|
261
|
+
if isinstance(self.before_agent_callback, list):
|
262
|
+
return self.before_agent_callback
|
263
|
+
return [self.before_agent_callback]
|
264
|
+
|
265
|
+
@property
|
266
|
+
def canonical_after_agent_callbacks(self) -> list[_SingleAgentCallback]:
|
267
|
+
"""The resolved self.after_agent_callback field as a list of _SingleAgentCallback.
|
268
|
+
|
269
|
+
This method is only for use by Agent Development Kit.
|
270
|
+
"""
|
271
|
+
if not self.after_agent_callback:
|
272
|
+
return []
|
273
|
+
if isinstance(self.after_agent_callback, list):
|
274
|
+
return self.after_agent_callback
|
275
|
+
return [self.after_agent_callback]
|
276
|
+
|
277
|
+
async def __handle_before_agent_callback(
|
278
|
+
self, ctx: InvocationContext
|
279
|
+
) -> Optional[Event]:
|
280
|
+
"""Runs the before_agent_callback if it exists.
|
281
|
+
|
282
|
+
Returns:
|
283
|
+
Optional[Event]: an event if callback provides content or changed state.
|
284
|
+
"""
|
285
|
+
ret_event = None
|
286
|
+
|
287
|
+
if not self.canonical_before_agent_callbacks:
|
288
|
+
return ret_event
|
289
|
+
|
290
|
+
callback_context = CallbackContext(ctx)
|
291
|
+
|
292
|
+
for callback in self.canonical_before_agent_callbacks:
|
293
|
+
before_agent_callback_content = callback(
|
294
|
+
callback_context=callback_context
|
295
|
+
)
|
296
|
+
if inspect.isawaitable(before_agent_callback_content):
|
297
|
+
before_agent_callback_content = await before_agent_callback_content
|
298
|
+
if before_agent_callback_content:
|
299
|
+
ret_event = Event(
|
300
|
+
invocation_id=ctx.invocation_id,
|
301
|
+
author=self.name,
|
302
|
+
branch=ctx.branch,
|
303
|
+
content=before_agent_callback_content,
|
304
|
+
actions=callback_context._event_actions,
|
305
|
+
)
|
306
|
+
ctx.end_invocation = True
|
307
|
+
return ret_event
|
308
|
+
|
309
|
+
if callback_context.state.has_delta():
|
310
|
+
ret_event = Event(
|
311
|
+
invocation_id=ctx.invocation_id,
|
312
|
+
author=self.name,
|
313
|
+
branch=ctx.branch,
|
314
|
+
actions=callback_context._event_actions,
|
315
|
+
)
|
316
|
+
|
317
|
+
return ret_event
|
318
|
+
|
319
|
+
async def __handle_after_agent_callback(
|
320
|
+
self, invocation_context: InvocationContext
|
321
|
+
) -> Optional[Event]:
|
322
|
+
"""Runs the after_agent_callback if it exists.
|
323
|
+
|
324
|
+
Returns:
|
325
|
+
Optional[Event]: an event if callback provides content or changed state.
|
326
|
+
"""
|
327
|
+
ret_event = None
|
328
|
+
|
329
|
+
if not self.canonical_after_agent_callbacks:
|
330
|
+
return ret_event
|
331
|
+
|
332
|
+
callback_context = CallbackContext(invocation_context)
|
333
|
+
|
334
|
+
for callback in self.canonical_after_agent_callbacks:
|
335
|
+
after_agent_callback_content = callback(callback_context=callback_context)
|
336
|
+
if inspect.isawaitable(after_agent_callback_content):
|
337
|
+
after_agent_callback_content = await after_agent_callback_content
|
338
|
+
if after_agent_callback_content:
|
339
|
+
ret_event = Event(
|
340
|
+
invocation_id=invocation_context.invocation_id,
|
341
|
+
author=self.name,
|
342
|
+
branch=invocation_context.branch,
|
343
|
+
content=after_agent_callback_content,
|
344
|
+
actions=callback_context._event_actions,
|
345
|
+
)
|
346
|
+
return ret_event
|
347
|
+
|
348
|
+
if callback_context.state.has_delta():
|
349
|
+
ret_event = Event(
|
350
|
+
invocation_id=invocation_context.invocation_id,
|
351
|
+
author=self.name,
|
352
|
+
branch=invocation_context.branch,
|
353
|
+
content=after_agent_callback_content,
|
354
|
+
actions=callback_context._event_actions,
|
355
|
+
)
|
356
|
+
|
357
|
+
return ret_event
|
358
|
+
|
359
|
+
@override
|
360
|
+
def model_post_init(self, __context: Any) -> None:
|
361
|
+
self.__set_parent_agent_for_sub_agents()
|
362
|
+
|
363
|
+
@field_validator('name', mode='after')
|
364
|
+
@classmethod
|
365
|
+
def __validate_name(cls, value: str):
|
366
|
+
if not value.isidentifier():
|
367
|
+
raise ValueError(
|
368
|
+
f'Found invalid agent name: `{value}`.'
|
369
|
+
' Agent name must be a valid identifier. It should start with a'
|
370
|
+
' letter (a-z, A-Z) or an underscore (_), and can only contain'
|
371
|
+
' letters, digits (0-9), and underscores.'
|
372
|
+
)
|
373
|
+
if value == 'user':
|
374
|
+
raise ValueError(
|
375
|
+
"Agent name cannot be `user`. `user` is reserved for end-user's"
|
376
|
+
' input.'
|
377
|
+
)
|
378
|
+
return value
|
379
|
+
|
380
|
+
def __set_parent_agent_for_sub_agents(self) -> BaseAgent:
|
381
|
+
for sub_agent in self.sub_agents:
|
382
|
+
if sub_agent.parent_agent is not None:
|
383
|
+
raise ValueError(
|
384
|
+
f'Agent `{sub_agent.name}` already has a parent agent, current'
|
385
|
+
f' parent: `{sub_agent.parent_agent.name}`, trying to add:'
|
386
|
+
f' `{self.name}`'
|
387
|
+
)
|
388
|
+
sub_agent.parent_agent = self
|
389
|
+
return self
|
@@ -14,8 +14,7 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
import
|
18
|
-
from typing import Any, Awaitable, Union
|
17
|
+
from typing import Any
|
19
18
|
from typing import AsyncGenerator
|
20
19
|
from typing import Callable
|
21
20
|
from typing import final
|
@@ -38,15 +37,10 @@ if TYPE_CHECKING:
|
|
38
37
|
|
39
38
|
tracer = trace.get_tracer('gcp.vertex.agent')
|
40
39
|
|
41
|
-
BeforeAgentCallback = Callable[
|
42
|
-
[CallbackContext],
|
43
|
-
Union[Awaitable[Optional[types.Content]], Optional[types.Content]],
|
44
|
-
]
|
40
|
+
BeforeAgentCallback = Callable[[CallbackContext], Optional[types.Content]]
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
Union[Awaitable[Optional[types.Content]], Optional[types.Content]],
|
49
|
-
]
|
42
|
+
|
43
|
+
AfterAgentCallback = Callable[[CallbackContext], Optional[types.Content]]
|
50
44
|
|
51
45
|
|
52
46
|
class BaseAgent(BaseModel):
|
@@ -56,7 +50,6 @@ class BaseAgent(BaseModel):
|
|
56
50
|
arbitrary_types_allowed=True,
|
57
51
|
extra='forbid',
|
58
52
|
)
|
59
|
-
"""The pydantic model config."""
|
60
53
|
|
61
54
|
name: str
|
62
55
|
"""The agent's name.
|
@@ -125,7 +118,7 @@ class BaseAgent(BaseModel):
|
|
125
118
|
with tracer.start_as_current_span(f'agent_run [{self.name}]'):
|
126
119
|
ctx = self._create_invocation_context(parent_context)
|
127
120
|
|
128
|
-
if event :=
|
121
|
+
if event := self.__handle_before_agent_callback(ctx):
|
129
122
|
yield event
|
130
123
|
if ctx.end_invocation:
|
131
124
|
return
|
@@ -136,7 +129,7 @@ class BaseAgent(BaseModel):
|
|
136
129
|
if ctx.end_invocation:
|
137
130
|
return
|
138
131
|
|
139
|
-
if event :=
|
132
|
+
if event := self.__handle_after_agent_callback(ctx):
|
140
133
|
yield event
|
141
134
|
|
142
135
|
@final
|
@@ -236,7 +229,7 @@ class BaseAgent(BaseModel):
|
|
236
229
|
invocation_context.branch = f'{parent_context.branch}.{self.name}'
|
237
230
|
return invocation_context
|
238
231
|
|
239
|
-
|
232
|
+
def __handle_before_agent_callback(
|
240
233
|
self, ctx: InvocationContext
|
241
234
|
) -> Optional[Event]:
|
242
235
|
"""Runs the before_agent_callback if it exists.
|
@@ -254,9 +247,6 @@ class BaseAgent(BaseModel):
|
|
254
247
|
callback_context=callback_context
|
255
248
|
)
|
256
249
|
|
257
|
-
if inspect.isawaitable(before_agent_callback_content):
|
258
|
-
before_agent_callback_content = await before_agent_callback_content
|
259
|
-
|
260
250
|
if before_agent_callback_content:
|
261
251
|
ret_event = Event(
|
262
252
|
invocation_id=ctx.invocation_id,
|
@@ -278,7 +268,7 @@ class BaseAgent(BaseModel):
|
|
278
268
|
|
279
269
|
return ret_event
|
280
270
|
|
281
|
-
|
271
|
+
def __handle_after_agent_callback(
|
282
272
|
self, invocation_context: InvocationContext
|
283
273
|
) -> Optional[Event]:
|
284
274
|
"""Runs the after_agent_callback if it exists.
|
@@ -296,9 +286,6 @@ class BaseAgent(BaseModel):
|
|
296
286
|
callback_context=callback_context
|
297
287
|
)
|
298
288
|
|
299
|
-
if inspect.isawaitable(after_agent_callback_content):
|
300
|
-
after_agent_callback_content = await after_agent_callback_content
|
301
|
-
|
302
289
|
if after_agent_callback_content or callback_context.state.has_delta():
|
303
290
|
ret_event = Event(
|
304
291
|
invocation_id=invocation_context.invocation_id,
|
@@ -60,11 +60,6 @@ class CallbackContext(ReadonlyContext):
|
|
60
60
|
"""
|
61
61
|
return self._state
|
62
62
|
|
63
|
-
@property
|
64
|
-
def user_content(self) -> Optional[types.Content]:
|
65
|
-
"""The user content that started this invocation. READONLY field."""
|
66
|
-
return self._invocation_context.user_content
|
67
|
-
|
68
63
|
async def load_artifact(
|
69
64
|
self, filename: str, version: Optional[int] = None
|
70
65
|
) -> Optional[types.Part]:
|