You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
Compare commits
242 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fda34ea9ff | |||
| 609b3a572c | |||
| 2a8ca06c3e | |||
| 3489bb598d | |||
| ed63cd86eb | |||
| 447798d573 | |||
| 958c18db2b | |||
| 83ba6419cd | |||
| d232e6216d | |||
| c7ce987676 | |||
| bf27f22a95 | |||
| 7fc09b2c64 | |||
| c4cd1802bf | |||
| 3cd4cd3ecf | |||
| 2a07eefc27 | |||
| d83ee1a6f2 | |||
| 3611e9fe09 | |||
| 97bf28bad6 | |||
| d6c6bb4b24 | |||
| 46282eeb0d | |||
| f4c7d788b0 | |||
| 15109c6879 | |||
| d40df2edf2 | |||
| a66f12273c | |||
| 5d2a876ca8 | |||
| 0c4f52699b | |||
| 618c824994 | |||
| 16d9696012 | |||
| 03fe909ada | |||
| b79400162d | |||
| c024ac5762 | |||
| 19ca61d241 | |||
| 7c2df7e4f6 | |||
| d43c80b718 | |||
| be0786ea88 | |||
| 6b89ceb49a | |||
| 694eca08e5 | |||
| 55cb36edfe | |||
| 74a331f1fb | |||
| 98c8a71d67 | |||
| b0fb3536e5 | |||
| 1a43cf0f60 | |||
| a380d70ac7 | |||
| a134ba6f7a | |||
| 7067c0319d | |||
| 756a326033 | |||
| 0e284f45ff | |||
| 8076b2294f | |||
| f1a92e9674 | |||
| 717993b14f | |||
| d212e50c10 | |||
| 79681e3513 | |||
| 33921d524f | |||
| 92c37496d3 | |||
| b9b2c3fb54 | |||
| b4c4f88c22 | |||
| 68de9adc18 | |||
| 0026edc1c9 | |||
| d3910e7b8c | |||
| 30e10c87c5 | |||
| fe618c3d93 | |||
| a63ea2735c | |||
| ff8a3c9b43 | |||
| a2263b1808 | |||
| e0851a1e57 | |||
| 09f30afe10 | |||
| 4542af5650 | |||
| 505d936007 | |||
| d7af2b2815 | |||
| 41b33d4a0a | |||
| 09cb128cf9 | |||
| b2a2b11776 | |||
| 1773cdab96 | |||
| 1807e73472 | |||
| 98f504cebe | |||
| 9928cafe32 | |||
| c5a0437745 | |||
| e060344e39 | |||
| 1561b0f15c | |||
| 62a543bd58 | |||
| cbdb5fc507 | |||
| 98727b4698 | |||
| 76700d790b | |||
| fe01103b74 | |||
| 53b14325ce | |||
| b299241b56 | |||
| 68f0fca832 | |||
| bb00c9519d | |||
| 00798af881 | |||
| 7d809eb9d9 | |||
| f67ccf32c3 | |||
| 5115474f2b | |||
| de7c9c6509 | |||
| 9eef4464c6 | |||
| 1bfc7590b4 | |||
| 3f21a52853 | |||
| 74454170a3 | |||
| ae7d19a4c6 | |||
| 171b1145ee | |||
| 9932015f3b | |||
| 3f117391a5 | |||
| 0497fc578c | |||
| 3b5232c14f | |||
| 9e767b3fe1 | |||
| 2ad1f79422 | |||
| e278ca9541 | |||
| 9324801b75 | |||
| f592de4cc0 | |||
| 57de9634de | |||
| 729001fc0b | |||
| 0d7d7918b6 | |||
| 482099c925 | |||
| 021aaddf32 | |||
| 74b8841e62 | |||
| 186b5de826 | |||
| 03f167c1d3 | |||
| 93e8f020ed | |||
| a1ddf0b6cc | |||
| 801549f734 | |||
| f83504dffb | |||
| 11ca528090 | |||
| 76116c8008 | |||
| 939b45a1c8 | |||
| 015c667917 | |||
| 66a6f94fbc | |||
| 9e9dfa7472 | |||
| 5ee17a3268 | |||
| 370eed1c7a | |||
| 6e0ea01fcb | |||
| 2f006264ce | |||
| d0f117ebbc | |||
| dcb50effef | |||
| f384793649 | |||
| 05a853bc91 | |||
| 12507dc6cc | |||
| 755ce74550 | |||
| b72573c57d | |||
| eb076a9ee8 | |||
| fe5a5494e9 | |||
| f0e11c72ab | |||
| 770ecd8bb3 | |||
| e62e15e720 | |||
| a786f75968 | |||
| 01a21e40d0 | |||
| 69f7ed8d0e | |||
| ebfe8fe51c | |||
| cb000e5a94 | |||
| 01cf186299 | |||
| 04820cb0a7 | |||
| 509db3f9fb | |||
| 4d5760917d | |||
| d27fe90d37 | |||
| 1c23556225 | |||
| a71d9ea9a1 | |||
| fccd17df6f | |||
| 4c6820e78c | |||
| bdd678db31 | |||
| f298d07579 | |||
| c399c50be5 | |||
| 05917cabbd | |||
| 1804ca39a6 | |||
| 5b3204c356 | |||
| d161a2c3f7 | |||
| 95f994d7ca | |||
| 3ea9eca929 | |||
| 2214c1558f | |||
| 4a0751941b | |||
| 9c2358e2a5 | |||
| 3686608f8d | |||
| ada24d7171 | |||
| ee674ce0ef | |||
| 2cb74dd20e | |||
| 293f406148 | |||
| bc43a1196a | |||
| dc90c91ed1 | |||
| 22e4210b47 | |||
| b67182c50f | |||
| 71bd808a14 | |||
| b33bdb9a03 | |||
| fc40226ec0 | |||
| 14cf910ce6 | |||
| 00e0035c8a | |||
| 30947b48b8 | |||
| 825f5d4f2e | |||
| 6f00df3df0 | |||
| da55b5a943 | |||
| d046367826 | |||
| 9647426500 | |||
| 1f0fd7bfce | |||
| 66553b18c6 | |||
| 933f01b89f | |||
| d6cf660506 | |||
| 931fb338f8 | |||
| af978fe194 | |||
| 4def3f1bd3 | |||
| ff9de71869 | |||
| f6bdd555fb | |||
| cf06cc507a | |||
| 303af440ee | |||
| 82b8e304ec | |||
| 4188673b0f | |||
| 39f78dc28f | |||
| c4d5e3b298 | |||
| 08c9cf86c3 | |||
| dd8e9b71e5 | |||
| d740b93e03 | |||
| 2d84b13219 | |||
| 80813a75cf | |||
| d35b99e6dd | |||
| 722028801a | |||
| 57d1315533 | |||
| d19927b1bc | |||
| 6a04ff84ba | |||
| 27b229719e | |||
| 05a0c6b307 | |||
| df0892a7b8 | |||
| 660c2efa4d | |||
| 1237d5334f | |||
| 993f9971bb | |||
| 5462862795 | |||
| c39f24f072 | |||
| 847c8fd11a | |||
| f15f64af0f | |||
| 70a6bfae90 | |||
| 4c4cfb74ae | |||
| 812485fdfa | |||
| cdb4cac237 | |||
| 16014764b6 | |||
| 9a8c77e04a | |||
| 4c191ba6b9 | |||
| 2a0524692b | |||
| 166df01236 | |||
| c4ecef54bc | |||
| 415104743d | |||
| 33acb26565 | |||
| ac97fc638f | |||
| dc5c23c675 | |||
| 8c78945ec9 | |||
| 7dffb59096 | |||
| 4d7298e4f2 | |||
| 8963300518 | |||
| 2cbbf88135 |
@@ -7,7 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
** Please make sure you read the contribution guide and file the issues in the rigth place. **
|
||||
** Please make sure you read the contribution guide and file the issues in the right place. **
|
||||
[Contribution guide.](https://google.github.io/adk-docs/contributing-guide/)
|
||||
|
||||
**Describe the bug**
|
||||
|
||||
@@ -7,7 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
** Please make sure you read the contribution guide and file the issues in the rigth place. **
|
||||
** Please make sure you read the contribution guide and file the issues in the right place. **
|
||||
[Contribution guide.](https://google.github.io/adk-docs/contributing-guide/)
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
|
||||
@@ -1,5 +1,91 @@
|
||||
# Changelog
|
||||
|
||||
## 1.1.1
|
||||
|
||||
### Features
|
||||
* Add BigQuery first-party tools. See [here](https://github.com/google/adk-python/commit/d6c6bb4b2489a8b7a4713e4747c30d6df0c07961) for more details.
|
||||
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Features
|
||||
|
||||
* Extract agent loading logic from fast_api.py to a separate AgentLoader class and support more agent definition folder/file structure.
|
||||
* Added audio play in web UI.
|
||||
* Added input transcription support for live/streaming.
|
||||
* Added support for storing eval run history locally in adk eval cli.
|
||||
* Image artifacts can now be clicked directly in chat message to view.
|
||||
* Left side panel can now be resized.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Avoid duplicating log in stderr.
|
||||
* Align event filtering and ordering logic.
|
||||
* Add handling for None param.annotation.
|
||||
* Fixed several minor bugs regarding eval tab in web UI.
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* Updates mypy config in pyproject.toml.
|
||||
* Add google search agent in samples.
|
||||
* Update filtered schema parameters for Gemini API.
|
||||
* Adds autoformat.sh for formatting codebase.
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### âš BREAKING CHANGES
|
||||
|
||||
* Evaluation dataset schema is finalized with strong-type pydantic models.
|
||||
(previously saved eval file needs re-generation, for both adk eval cli and
|
||||
the eval tab in adk web UI).
|
||||
* `BuiltInCodeExecutor` (in code_executors package) replaces
|
||||
`BuiltInCodeExecutionTool` (previously in tools package).
|
||||
* All methods in services are now async, including session service, artifact
|
||||
service and memory service.
|
||||
* `list_events` and `close_session` methods are removed from session service.
|
||||
* agent.py file structure with MCP tools are now easier and simpler ([now](https://github.com/google/adk-python/blob/3b5232c14f48e1d5b170f3698d91639b079722c8/contributing/samples/mcp_stdio_server_agent/agent.py#L33) vs [before](https://github.com/google/adk-python/blob/a4adb739c0d86b9ae4587547d2653d568f6567f2/contributing/samples/mcp_agent/agent.py#L41)).
|
||||
Old format is not working anymore.
|
||||
* `Memory` schema and `MemoryService` is redesigned.
|
||||
* Mark various class attributes as private in the classes in the `tools` package.
|
||||
* Disabled session state injection if instruction provider is used.
|
||||
(so that you can have `{var_name}` in the instruction, which is required for code snippets)
|
||||
* Toolbox integration is revamped: tools/toolbox_tool.py → tools/toolbox_toolset.py.
|
||||
* Removes the experimental `remote_agent.py`. We'll redesign it and bring it back.
|
||||
|
||||
### Features
|
||||
|
||||
* Dev UI:
|
||||
* A brand new trace view for overall agent invocation.
|
||||
* A revamped evaluation tab and comparison view for checking eval results.
|
||||
* Introduced `BaseToolset` to allow dynamically add/remove tools for agents.
|
||||
* Revamped MCPToolset with the new BaseToolset interface.
|
||||
* Revamped GoogleApiTool, GoogleApiToolset and ApplicationIntegrationToolset with the new BaseToolset interface.
|
||||
* Resigned agent.py file structure when needing MCPToolset.
|
||||
* Added ToolboxToolset.
|
||||
* Redesigned strong-typed agent evaluation schema.
|
||||
* Allows users to create more cohesive eval sets.
|
||||
* Allows evals to be extended for non-text modality.
|
||||
* Allows for a structured interaction with the uber eval system.
|
||||
* Redesigned Memory schema and MemoryService interfaces.
|
||||
* Added token usage to LlmResponse.
|
||||
* Allowed specifying `--adk_version` in `adk deploy cloud_run` cli. Default is the current version.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fixed `adk deploy cloud_run` failing bug.
|
||||
* Fixed logs not being printed due to `google-auth` library.
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* Display full help text when adk cli receives invalid arguments.
|
||||
* `adk web` now binds `127.0.0.1` by default, instead of 0.0.0.0.
|
||||
* `InMemoryRunner` now takes `BaseAgent` in constructor.
|
||||
* Various docstring improvements.
|
||||
* Various UI tweaks.
|
||||
* Various bug fixes.
|
||||
* Update various contributing/samples for contributors to validate the implementation.
|
||||
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### âš BREAKING CHANGES
|
||||
|
||||
+27
-30
@@ -4,21 +4,21 @@ We'd love to accept your patches and contributions to this project.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Before you begin](#before-you-begin)
|
||||
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
|
||||
- [Before you begin](#before-you-begin)
|
||||
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
|
||||
- [Review our community guidelines](#review-our-community-guidelines)
|
||||
- [Contribution workflow](#contribution-workflow)
|
||||
- [Finding Issues to Work On](#finding-issues-to-work-on)
|
||||
- [Requirement for PRs](#requirement-for-prs)
|
||||
- [Large or Complex Changes](#large-or-complex-changes)
|
||||
- [Testing Requirements](#testing-requirements)
|
||||
- [Unit Tests](#unit-tests)
|
||||
- [End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
|
||||
- [Documentation](#documentation)
|
||||
- [Development Setup](#development-setup)
|
||||
- [Contribution workflow](#contribution-workflow)
|
||||
- [Finding Issues to Work On](#finding-issues-to-work-on)
|
||||
- [Requirement for PRs](#requirement-for-prs)
|
||||
- [Large or Complex Changes](#large-or-complex-changes)
|
||||
- [Testing Requirements](#testing-requirements)
|
||||
- [Unit Tests](#unit-tests)
|
||||
- [End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
|
||||
- [Documentation](#documentation)
|
||||
- [Development Setup](#development-setup)
|
||||
- [Code reviews](#code-reviews)
|
||||
|
||||
|
||||
|
||||
## Before you begin
|
||||
|
||||
### Sign our Contributor License Agreement
|
||||
@@ -44,13 +44,13 @@ This project follows
|
||||
|
||||
### Finding Issues to Work On
|
||||
|
||||
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help wanted`** (general contributions).
|
||||
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help wanted`** (general contributions).
|
||||
- For other issues, please kindly ask before contributing to avoid duplication.
|
||||
|
||||
|
||||
### Requirement for PRs
|
||||
|
||||
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
|
||||
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
|
||||
- Small, focused PRs. Keep changes minimal—one concern per PR.
|
||||
- For bug fixes or features, please provide logs or screenshot after the fix is applied to help reviewers better understand the fix.
|
||||
- Please include a `testing plan` section in your PR to talk about how you will test. This will save time for PR review. See `Testing Requirements` section for more details.
|
||||
@@ -72,12 +72,12 @@ Please add or update unit tests for your change. Please include a summary of pas
|
||||
|
||||
Requirements for unit tests:
|
||||
|
||||
- **Coverage:** Cover new features, edge cases, error conditions, and typical use cases.
|
||||
- **Location:** Add or update tests under `tests/unittests/`, following existing naming conventions (e.g., `test_<module>_<feature>.py`).
|
||||
- **Framework:** Use `pytest`. Tests should be:
|
||||
- Fast and isolated.
|
||||
- Written clearly with descriptive names.
|
||||
- Free of external dependencies (use mocks or fixtures as needed).
|
||||
- **Coverage:** Cover new features, edge cases, error conditions, and typical use cases.
|
||||
- **Location:** Add or update tests under `tests/unittests/`, following existing naming conventions (e.g., `test_<module>_<feature>.py`).
|
||||
- **Framework:** Use `pytest`. Tests should be:
|
||||
- Fast and isolated.
|
||||
- Written clearly with descriptive names.
|
||||
- Free of external dependencies (use mocks or fixtures as needed).
|
||||
- **Quality:** Aim for high readability and maintainability; include docstrings or comments for complex scenarios.
|
||||
|
||||
#### Manual End-to-End (E2E) Tests
|
||||
@@ -86,15 +86,15 @@ Manual E2E tests ensure integrated flows work as intended. Your tests should cov
|
||||
|
||||
Depending on your change:
|
||||
|
||||
- **ADK Web:**
|
||||
- Use the `adk web` to verify functionality.
|
||||
- Capture and attach relevant screenshots demonstrating the UI/UX changes or outputs.
|
||||
- **ADK Web:**
|
||||
- Use the `adk web` to verify functionality.
|
||||
- Capture and attach relevant screenshots demonstrating the UI/UX changes or outputs.
|
||||
- Label screenshots clearly in your PR description.
|
||||
|
||||
- **Runner:**
|
||||
- Provide the testing setup. For example, the agent definition, and the runner setup.
|
||||
- Execute the `runner` tool to reproduce workflows.
|
||||
- Include the command used and console output showing test results.
|
||||
- Execute the `runner` tool to reproduce workflows.
|
||||
- Include the command used and console output showing test results.
|
||||
- Highlight sections of the log that directly relate to your change.
|
||||
|
||||
### Documentation
|
||||
@@ -117,19 +117,16 @@ For any changes that impact user-facing documentation (guides, API reference, tu
|
||||
```shell
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
|
||||
**windows**
|
||||
```shell
|
||||
source .\.venv\Scripts\activate
|
||||
```
|
||||
|
||||
```shell
|
||||
pip install uv
|
||||
```
|
||||
|
||||
3. **Install dependencies:**
|
||||
|
||||
```shell
|
||||
pip install uv
|
||||
uv sync --all-extras
|
||||
```
|
||||
4. **Run unit tests:**
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
</h3>
|
||||
<h3 align="center">
|
||||
Important Links:
|
||||
<a href="https://google.github.io/adk-docs/">Docs</a> &
|
||||
<a href="https://github.com/google/adk-samples">Samples</a>.
|
||||
<a href="https://google.github.io/adk-docs/">Docs</a>,
|
||||
<a href="https://github.com/google/adk-samples">Samples</a>,
|
||||
<a href="https://github.com/google/adk-java">Java ADK</a> &
|
||||
<a href="https://github.com/google/adk-web">ADK Web</a>.
|
||||
</h3>
|
||||
</html>
|
||||
|
||||
@@ -38,6 +40,12 @@ Agent Development Kit (ADK) is a flexible and modular framework for developing a
|
||||
- **Deploy Anywhere**: Easily containerize and deploy agents on Cloud Run or
|
||||
scale seamlessly with Vertex AI Agent Engine.
|
||||
|
||||
## 🤖 Agent2Agent (A2A) Protocol and ADK Integration
|
||||
|
||||
For remote agent-to-agent communication, ADK integrates with the
|
||||
[A2A protocol](https://github.com/google/A2A/).
|
||||
See this [example](https://github.com/google/A2A/tree/main/samples/python/agents/google_adk)
|
||||
for how they can work together.
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
@@ -123,16 +131,9 @@ adk eval \
|
||||
samples_for_testing/hello_world/hello_world_eval_set_001.evalset.json
|
||||
```
|
||||
|
||||
## 🤖 A2A and ADK integration
|
||||
|
||||
For remote agent-to-agent communication, ADK integrates with the
|
||||
[A2A protocol](https://github.com/google/A2A/).
|
||||
See this [example](https://github.com/google/A2A/tree/main/samples/python/agents/google_adk)
|
||||
for how they can work together.
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our
|
||||
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our
|
||||
- [General contribution guideline and flow](https://google.github.io/adk-docs/contributing-guide/#questions).
|
||||
- Then if you want to contribute code, please read [Code Contributing Guidelines](./CONTRIBUTING.md) to get started.
|
||||
|
||||
@@ -140,10 +141,6 @@ We welcome contributions from the community! Whether it's bug reports, feature r
|
||||
|
||||
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Preview
|
||||
|
||||
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the [Service Specific Terms](https://cloud.google.com/terms/service-terms#1). Pre-GA features are available "as is" and might have limited support. For more information, see the [launch stage descriptions](https://cloud.google.com/products?hl=en#product-launch-stages).
|
||||
|
||||
---
|
||||
|
||||
*Happy Agent Building!*
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 463 KiB After Width: | Height: | Size: 413 KiB |
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Autoformat ADK codebase.
|
||||
|
||||
if ! command -v isort &> /dev/null
|
||||
then
|
||||
echo "isort not found, refer to CONTRIBUTING.md to set up dev environment first."
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! command -v pyink &> /dev/null
|
||||
then
|
||||
echo "pyink not found, refer to CONTRIBUTING.md to set up dev environment first."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo '---------------------------------------'
|
||||
echo '| Organizing imports for src/...'
|
||||
echo '---------------------------------------'
|
||||
|
||||
isort src/
|
||||
echo 'All done! ✨ 🍰 ✨'
|
||||
|
||||
echo '---------------------------------------'
|
||||
echo '| Organizing imports for tests/...'
|
||||
echo '---------------------------------------'
|
||||
|
||||
isort tests/
|
||||
echo 'All done! ✨ 🍰 ✨'
|
||||
|
||||
echo '---------------------------------------'
|
||||
echo '| Auto-formatting src/...'
|
||||
echo '---------------------------------------'
|
||||
|
||||
find -L src/ -type f -name "*.py" -exec pyink --config pyproject.toml {} +
|
||||
|
||||
echo '---------------------------------------'
|
||||
echo '| Auto-formatting tests/...'
|
||||
echo '---------------------------------------'
|
||||
|
||||
find -L tests/ -type f -name "*.py" -exec pyink --config pyproject.toml {} +
|
||||
@@ -20,7 +20,6 @@ from dotenv import load_dotenv
|
||||
from google.adk.agents.llm_agent import LlmAgent
|
||||
from google.adk.tools.application_integration_tool import ApplicationIntegrationToolset
|
||||
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
@@ -29,12 +28,12 @@ connection_project = os.getenv("CONNECTION_PROJECT")
|
||||
connection_location = os.getenv("CONNECTION_LOCATION")
|
||||
|
||||
|
||||
jira_tool = ApplicationIntegrationToolset(
|
||||
jira_toolset = ApplicationIntegrationToolset(
|
||||
project=connection_project,
|
||||
location=connection_location,
|
||||
connection=connection_name,
|
||||
entity_operations={"Issues": [], "Projects": []},
|
||||
tool_name="jira_issue_manager",
|
||||
tool_name_prefix="jira_issue_manager",
|
||||
)
|
||||
|
||||
root_agent = LlmAgent(
|
||||
@@ -46,5 +45,5 @@ root_agent = LlmAgent(
|
||||
If there is an error in the tool response, understand the error and try and see if you can fix the error and then and execute the tool again. For example if a variable or parameter is missing, try and see if you can find it in the request or user query or default it and then execute the tool again or check for other tools that could give you the details.
|
||||
If there are any math operations like count or max, min in the user request, call the tool to get the data and perform the math operations and then return the result in the response. For example for maximum, fetch the list and then do the math operation.
|
||||
""",
|
||||
tools=jira_tool.get_tools(),
|
||||
tools=[jira_toolset],
|
||||
)
|
||||
|
||||
@@ -24,7 +24,7 @@ async def log_query(tool_context: ToolContext, query: str):
|
||||
|
||||
|
||||
root_agent = Agent(
|
||||
model='gemini-2.0-flash-exp',
|
||||
model='gemini-2.0-flash',
|
||||
name='log_agent',
|
||||
description='Log user query.',
|
||||
instruction="""Always log the user query and reploy "kk, I've logged."
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# BigQuery Tools Sample
|
||||
|
||||
## Introduction
|
||||
|
||||
This sample agent demonstrates the BigQuery first-party tools in ADK,
|
||||
distributed via the `google.adk.tools.bigquery` module. These tools include:
|
||||
|
||||
1. `list_dataset_ids`
|
||||
|
||||
Fetches BigQuery dataset ids present in a GCP project.
|
||||
|
||||
1. `get_dataset_info`
|
||||
|
||||
Fetches metadata about a BigQuery dataset.
|
||||
|
||||
1. `list_table_ids`
|
||||
|
||||
Fetches table ids present in a BigQuery dataset.
|
||||
|
||||
1. `get_table_info`
|
||||
|
||||
Fetches metadata about a BigQuery table.
|
||||
|
||||
1. `execute_sql`
|
||||
|
||||
Runs a SQL query in BigQuery.
|
||||
|
||||
## How to use
|
||||
|
||||
Set up environment variables in your `.env` file for using
|
||||
[Google AI Studio](https://google.github.io/adk-docs/get-started/quickstart/#gemini---google-ai-studio)
|
||||
or
|
||||
[Google Cloud Vertex AI](https://google.github.io/adk-docs/get-started/quickstart/#gemini---google-cloud-vertex-ai)
|
||||
for the LLM service for your agent. For example, for using Google AI Studio you
|
||||
would set:
|
||||
|
||||
* GOOGLE_GENAI_USE_VERTEXAI=FALSE
|
||||
* GOOGLE_API_KEY={your api key}
|
||||
|
||||
### With Application Default Credentials
|
||||
|
||||
This mode is useful for quick development when the agent builder is the only
|
||||
user interacting with the agent. The tools are initialized with the default
|
||||
credentials present on the machine running the agent.
|
||||
|
||||
1. Create application default credentials on the machine where the agent would
|
||||
be running by following https://cloud.google.com/docs/authentication/provide-credentials-adc.
|
||||
|
||||
1. Set `RUN_WITH_ADC=True` in `agent.py` and run the agent
|
||||
|
||||
### With Interactive OAuth
|
||||
|
||||
1. Follow
|
||||
https://developers.google.com/identity/protocols/oauth2#1.-obtain-oauth-2.0-credentials-from-the-dynamic_data.setvar.console_name.
|
||||
to get your client id and client secret. Be sure to choose "web" as your client
|
||||
type.
|
||||
|
||||
1. Follow https://developers.google.com/workspace/guides/configure-oauth-consent to add scope "https://www.googleapis.com/auth/bigquery".
|
||||
|
||||
1. Follow https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred to add http://localhost/dev-ui/ to "Authorized redirect URIs".
|
||||
|
||||
Note: localhost here is just a hostname that you use to access the dev ui,
|
||||
replace it with the actual hostname you use to access the dev ui.
|
||||
|
||||
1. For 1st run, allow popup for localhost in Chrome.
|
||||
|
||||
1. Configure your `.env` file to add two more variables before running the agent:
|
||||
|
||||
* OAUTH_CLIENT_ID={your client id}
|
||||
* OAUTH_CLIENT_SECRET={your client secret}
|
||||
|
||||
Note: don't create a separate .env, instead put it to the same .env file that
|
||||
stores your Vertex AI or Dev ML credentials
|
||||
|
||||
1. Set `RUN_WITH_ADC=False` in `agent.py` and run the agent
|
||||
|
||||
## Sample prompts
|
||||
|
||||
* which weather datasets exist in bigquery public data?
|
||||
* tell me more about noaa_lightning
|
||||
* which tables exist in the ml_datasets dataset?
|
||||
* show more details about the penguins table
|
||||
* compute penguins population per island.
|
||||
Executable → Regular
@@ -0,0 +1,58 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
|
||||
from google.adk.agents import llm_agent
|
||||
from google.adk.tools.bigquery import BigQueryCredentialsConfig
|
||||
from google.adk.tools.bigquery import BigQueryToolset
|
||||
import google.auth
|
||||
|
||||
|
||||
RUN_WITH_ADC = False
|
||||
|
||||
|
||||
if RUN_WITH_ADC:
|
||||
# Initialize the tools to use the application default credentials.
|
||||
application_default_credentials, _ = google.auth.default()
|
||||
credentials_config = BigQueryCredentialsConfig(
|
||||
credentials=application_default_credentials
|
||||
)
|
||||
else:
|
||||
# Initiaze the tools to do interactive OAuth
|
||||
# The environment variables OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET
|
||||
# must be set
|
||||
credentials_config = BigQueryCredentialsConfig(
|
||||
client_id=os.getenv("OAUTH_CLIENT_ID"),
|
||||
client_secret=os.getenv("OAUTH_CLIENT_SECRET"),
|
||||
scopes=["https://www.googleapis.com/auth/bigquery"],
|
||||
)
|
||||
|
||||
bigquery_toolset = BigQueryToolset(credentials_config=credentials_config)
|
||||
|
||||
# The variable name `root_agent` determines what your root agent is for the
|
||||
# debug CLI
|
||||
root_agent = llm_agent.Agent(
|
||||
model="gemini-2.0-flash",
|
||||
name="hello_agent",
|
||||
description=(
|
||||
"Agent to answer questions about BigQuery data and models and execute"
|
||||
" SQL queries."
|
||||
),
|
||||
instruction="""\
|
||||
You are a data science agent with access to several BigQuery tools.
|
||||
Make use of those tools to answer the user's questions.
|
||||
""",
|
||||
tools=[bigquery_toolset],
|
||||
)
|
||||
@@ -16,7 +16,7 @@ import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from google.adk import Agent
|
||||
from google.adk.tools.google_api_tool import bigquery_tool_set
|
||||
from google.adk.tools.google_api_tool import BigQueryToolset
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
@@ -24,24 +24,25 @@ load_dotenv()
|
||||
# Access the variable
|
||||
oauth_client_id = os.getenv("OAUTH_CLIENT_ID")
|
||||
oauth_client_secret = os.getenv("OAUTH_CLIENT_SECRET")
|
||||
bigquery_tool_set.configure_auth(oauth_client_id, oauth_client_secret)
|
||||
|
||||
bigquery_datasets_list = bigquery_tool_set.get_tool("bigquery_datasets_list")
|
||||
bigquery_datasets_get = bigquery_tool_set.get_tool("bigquery_datasets_get")
|
||||
bigquery_datasets_insert = bigquery_tool_set.get_tool(
|
||||
"bigquery_datasets_insert"
|
||||
tools_to_expose = [
|
||||
"bigquery_datasets_list",
|
||||
"bigquery_datasets_get",
|
||||
"bigquery_datasets_insert",
|
||||
"bigquery_tables_list",
|
||||
"bigquery_tables_get",
|
||||
"bigquery_tables_insert",
|
||||
]
|
||||
bigquery_toolset = BigQueryToolset(
|
||||
client_id=oauth_client_id,
|
||||
client_secret=oauth_client_secret,
|
||||
tool_filter=tools_to_expose,
|
||||
)
|
||||
|
||||
bigquery_tables_list = bigquery_tool_set.get_tool("bigquery_tables_list")
|
||||
bigquery_tables_get = bigquery_tool_set.get_tool("bigquery_tables_get")
|
||||
bigquery_tables_insert = bigquery_tool_set.get_tool("bigquery_tables_insert")
|
||||
|
||||
|
||||
root_agent = Agent(
|
||||
model="gemini-2.0-flash",
|
||||
name="bigquery_agent",
|
||||
instruction="""
|
||||
You are a helpful Google BigQuery agent that help to manage users' data on Goolge BigQuery.
|
||||
You are a helpful Google BigQuery agent that help to manage users' data on Google BigQuery.
|
||||
Use the provided tools to conduct various operations on users' data in Google BigQuery.
|
||||
|
||||
Scenario 1:
|
||||
@@ -73,12 +74,5 @@ root_agent = Agent(
|
||||
{userInfo?}
|
||||
</User>
|
||||
""",
|
||||
tools=[
|
||||
bigquery_datasets_list,
|
||||
bigquery_datasets_get,
|
||||
bigquery_datasets_insert,
|
||||
bigquery_tables_list,
|
||||
bigquery_tables_get,
|
||||
bigquery_tables_insert,
|
||||
],
|
||||
tools=[bigquery_toolset],
|
||||
)
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from . import agent
|
||||
Executable
+198
@@ -0,0 +1,198 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import random
|
||||
|
||||
from google.adk import Agent
|
||||
from google.adk.planners import BuiltInPlanner
|
||||
from google.adk.planners import PlanReActPlanner
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
from google.genai import types
|
||||
|
||||
|
||||
def roll_die(sides: int, tool_context: ToolContext) -> int:
|
||||
"""Roll a die and return the rolled result.
|
||||
|
||||
Args:
|
||||
sides: The integer number of sides the die has.
|
||||
|
||||
Returns:
|
||||
An integer of the result of rolling the die.
|
||||
"""
|
||||
result = random.randint(1, sides)
|
||||
if not 'rolls' in tool_context.state:
|
||||
tool_context.state['rolls'] = []
|
||||
|
||||
tool_context.state['rolls'] = tool_context.state['rolls'] + [result]
|
||||
return result
|
||||
|
||||
|
||||
async def check_prime(nums: list[int]) -> str:
|
||||
"""Check if a given list of numbers are prime.
|
||||
|
||||
Args:
|
||||
nums: The list of numbers to check.
|
||||
|
||||
Returns:
|
||||
A str indicating which number is prime.
|
||||
"""
|
||||
primes = set()
|
||||
for number in nums:
|
||||
number = int(number)
|
||||
if number <= 1:
|
||||
continue
|
||||
is_prime = True
|
||||
for i in range(2, int(number**0.5) + 1):
|
||||
if number % i == 0:
|
||||
is_prime = False
|
||||
break
|
||||
if is_prime:
|
||||
primes.add(number)
|
||||
return (
|
||||
'No prime numbers found.'
|
||||
if not primes
|
||||
else f"{', '.join(str(num) for num in primes)} are prime numbers."
|
||||
)
|
||||
|
||||
|
||||
async def before_agent_callback(callback_context):
|
||||
print('@before_agent_callback')
|
||||
return None
|
||||
|
||||
|
||||
async def after_agent_callback(callback_context):
|
||||
print('@after_agent_callback')
|
||||
return None
|
||||
|
||||
|
||||
async def before_model_callback(callback_context, llm_request):
|
||||
print('@before_model_callback')
|
||||
return None
|
||||
|
||||
|
||||
async def after_model_callback(callback_context, llm_response):
|
||||
print('@after_model_callback')
|
||||
return None
|
||||
|
||||
|
||||
def after_agent_cb1(callback_context):
|
||||
print('@after_agent_cb1')
|
||||
|
||||
|
||||
def after_agent_cb2(callback_context):
|
||||
print('@after_agent_cb2')
|
||||
# ModelContent (or Content with role set to 'model') must be returned.
|
||||
# Otherwise, the event will be excluded from the context in the next turn.
|
||||
return types.ModelContent(
|
||||
parts=[
|
||||
types.Part(
|
||||
text='(stopped) after_agent_cb2',
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def after_agent_cb3(callback_context):
|
||||
print('@after_agent_cb3')
|
||||
|
||||
|
||||
def before_agent_cb1(callback_context):
|
||||
print('@before_agent_cb1')
|
||||
|
||||
|
||||
def before_agent_cb2(callback_context):
|
||||
print('@before_agent_cb2')
|
||||
|
||||
|
||||
def before_agent_cb3(callback_context):
|
||||
print('@before_agent_cb3')
|
||||
|
||||
|
||||
def before_tool_cb1(tool, args, tool_context):
|
||||
print('@before_tool_cb1')
|
||||
|
||||
|
||||
def before_tool_cb2(tool, args, tool_context):
|
||||
print('@before_tool_cb2')
|
||||
|
||||
|
||||
def before_tool_cb3(tool, args, tool_context):
|
||||
print('@before_tool_cb3')
|
||||
|
||||
|
||||
def after_tool_cb1(tool, args, tool_context, tool_response):
|
||||
print('@after_tool_cb1')
|
||||
|
||||
|
||||
def after_tool_cb2(tool, args, tool_context, tool_response):
|
||||
print('@after_tool_cb2')
|
||||
return {'test': 'after_tool_cb2', 'response': tool_response}
|
||||
|
||||
|
||||
def after_tool_cb3(tool, args, tool_context, tool_response):
|
||||
print('@after_tool_cb3')
|
||||
|
||||
|
||||
root_agent = Agent(
|
||||
model='gemini-2.0-flash',
|
||||
name='data_processing_agent',
|
||||
description=(
|
||||
'hello world agent that can roll a dice of 8 sides and check prime'
|
||||
' numbers.'
|
||||
),
|
||||
instruction="""
|
||||
You roll dice and answer questions about the outcome of the dice rolls.
|
||||
You can roll dice of different sizes.
|
||||
You can use multiple tools in parallel by calling functions in parallel(in one request and in one round).
|
||||
It is ok to discuss previous dice roles, and comment on the dice rolls.
|
||||
When you are asked to roll a die, you must call the roll_die tool with the number of sides. Be sure to pass in an integer. Do not pass in a string.
|
||||
You should never roll a die on your own.
|
||||
When checking prime numbers, call the check_prime tool with a list of integers. Be sure to pass in a list of integers. You should never pass in a string.
|
||||
You should not check prime numbers before calling the tool.
|
||||
When you are asked to roll a die and check prime numbers, you should always make the following two function calls:
|
||||
1. You should first call the roll_die tool to get a roll. Wait for the function response before calling the check_prime tool.
|
||||
2. After you get the function response from roll_die tool, you should call the check_prime tool with the roll_die result.
|
||||
2.1 If user asks you to check primes based on previous rolls, make sure you include the previous rolls in the list.
|
||||
3. When you respond, you must include the roll_die result from step 1.
|
||||
You should always perform the previous 3 steps when asking for a roll and checking prime numbers.
|
||||
You should not rely on the previous history on prime results.
|
||||
""",
|
||||
tools=[
|
||||
roll_die,
|
||||
check_prime,
|
||||
],
|
||||
# planner=BuiltInPlanner(
|
||||
# thinking_config=types.ThinkingConfig(
|
||||
# include_thoughts=True,
|
||||
# ),
|
||||
# ),
|
||||
generate_content_config=types.GenerateContentConfig(
|
||||
safety_settings=[
|
||||
types.SafetySetting( # avoid false alarm about rolling dice.
|
||||
category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
||||
threshold=types.HarmBlockThreshold.OFF,
|
||||
),
|
||||
]
|
||||
),
|
||||
before_agent_callback=[
|
||||
before_agent_cb1,
|
||||
before_agent_cb2,
|
||||
before_agent_cb3,
|
||||
],
|
||||
after_agent_callback=[after_agent_cb1, after_agent_cb2, after_agent_cb3],
|
||||
before_model_callback=before_model_callback,
|
||||
after_model_callback=after_model_callback,
|
||||
before_tool_callback=[before_tool_cb1, before_tool_cb2, before_tool_cb3],
|
||||
after_tool_callback=[after_tool_cb1, after_tool_cb2, after_tool_cb3],
|
||||
)
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
import warnings
|
||||
|
||||
import agent
|
||||
from dotenv import load_dotenv
|
||||
from google.adk import Runner
|
||||
from google.adk.artifacts import InMemoryArtifactService
|
||||
from google.adk.cli.utils import logs
|
||||
from google.adk.sessions import InMemorySessionService
|
||||
from google.adk.sessions import Session
|
||||
from google.genai import types
|
||||
|
||||
load_dotenv(override=True)
|
||||
warnings.filterwarnings('ignore', category=UserWarning)
|
||||
logs.log_to_tmp_folder()
|
||||
|
||||
|
||||
async def main():
|
||||
app_name = 'my_app'
|
||||
user_id_1 = 'user1'
|
||||
session_service = InMemorySessionService()
|
||||
artifact_service = InMemoryArtifactService()
|
||||
runner = Runner(
|
||||
app_name=app_name,
|
||||
agent=agent.root_agent,
|
||||
artifact_service=artifact_service,
|
||||
session_service=session_service,
|
||||
)
|
||||
session_11 = await session_service.create_session(
|
||||
app_name=app_name, user_id=user_id_1
|
||||
)
|
||||
|
||||
async def run_prompt(session: Session, new_message: str):
|
||||
content = types.Content(
|
||||
role='user', parts=[types.Part.from_text(text=new_message)]
|
||||
)
|
||||
print('** User says:', content.model_dump(exclude_none=True))
|
||||
async for event in runner.run_async(
|
||||
user_id=user_id_1,
|
||||
session_id=session.id,
|
||||
new_message=content,
|
||||
):
|
||||
if event.content.parts and event.content.parts[0].text:
|
||||
print(f'** {event.author}: {event.content.parts[0].text}')
|
||||
|
||||
start_time = time.time()
|
||||
print('Start time:', start_time)
|
||||
print('------------------------------------')
|
||||
await run_prompt(session_11, 'Hi')
|
||||
await run_prompt(session_11, 'Roll a die with 100 sides')
|
||||
await run_prompt(session_11, 'Roll a die again with 100 sides.')
|
||||
await run_prompt(session_11, 'What numbers did I got?')
|
||||
print(
|
||||
await artifact_service.list_artifact_keys(
|
||||
app_name=app_name, user_id=user_id_1, session_id=session_11.id
|
||||
)
|
||||
)
|
||||
end_time = time.time()
|
||||
print('------------------------------------')
|
||||
print('End time:', end_time)
|
||||
print('Total time:', end_time - start_time)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
@@ -15,7 +15,7 @@
|
||||
"""Data science agent."""
|
||||
|
||||
from google.adk.agents.llm_agent import Agent
|
||||
from google.adk.tools import built_in_code_execution
|
||||
from google.adk.code_executors.built_in_code_executor import BuiltInCodeExecutor
|
||||
|
||||
|
||||
def base_system_instruction():
|
||||
@@ -96,5 +96,5 @@ When plotting trends, you should make sure to sort and order the data by the x-a
|
||||
|
||||
|
||||
""",
|
||||
tools=[built_in_code_execution],
|
||||
code_executor=BuiltInCodeExecutor(),
|
||||
)
|
||||
|
||||
+1
-40
@@ -41,7 +41,7 @@ async def main():
|
||||
artifact_service=artifact_service,
|
||||
session_service=session_service,
|
||||
)
|
||||
session_11 = session_service.create_session(app_name, user_id_1)
|
||||
session_11 = await session_service.create_session(app_name, user_id_1)
|
||||
|
||||
async def run_prompt(session: Session, new_message: str):
|
||||
content = types.Content(
|
||||
@@ -69,44 +69,5 @@ async def main():
|
||||
print('Total time:', end_time - start_time)
|
||||
|
||||
|
||||
def main_sync():
|
||||
app_name = 'my_app'
|
||||
user_id_1 = 'user1'
|
||||
session_service = InMemorySessionService()
|
||||
artifact_service = InMemoryArtifactService()
|
||||
runner = Runner(
|
||||
app_name=app_name,
|
||||
agent=agent.root_agent,
|
||||
artifact_service=artifact_service,
|
||||
session_service=session_service,
|
||||
)
|
||||
session_11 = session_service.create_session(app_name, user_id_1)
|
||||
|
||||
def run_prompt(session: Session, new_message: str):
|
||||
content = types.Content(
|
||||
role='user', parts=[types.Part.from_text(text=new_message)]
|
||||
)
|
||||
print('** User says:', content.model_dump(exclude_none=True))
|
||||
for event in runner.run_sync(
|
||||
session=session,
|
||||
new_message=content,
|
||||
):
|
||||
if event.content.parts and event.content.parts[0].text:
|
||||
print(f'** {event.author}: {event.content.parts[0].text}')
|
||||
|
||||
start_time = time.time()
|
||||
print('Start time:', start_time)
|
||||
print('------------------------------------')
|
||||
run_prompt(session_11, 'Hi')
|
||||
run_prompt(session_11, 'Roll a die.')
|
||||
run_prompt(session_11, 'Roll a die again.')
|
||||
run_prompt(session_11, 'What numbers did I got?')
|
||||
end_time = time.time()
|
||||
print('------------------------------------')
|
||||
print('End time:', end_time)
|
||||
print('Total time:', end_time - start_time)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
main_sync()
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from . import agent
|
||||
@@ -0,0 +1,30 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from google.genai import Client
|
||||
|
||||
from google.adk import Agent
|
||||
from google.adk.tools import google_search
|
||||
|
||||
# Only Vertex AI supports image generation for now.
|
||||
client = Client()
|
||||
|
||||
root_agent = Agent(
|
||||
model='gemini-2.0-flash-001',
|
||||
name='root_agent',
|
||||
description="""an agent whose job it is to perform Google search queries and answer questions about the results.""",
|
||||
instruction="""You are an agent whose job is to perform Google search queries and answer questions about the results.
|
||||
""",
|
||||
tools=[google_search],
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user