chore: import upstream snapshot with attribution
Continuous Integration / Pre-commit Linter (push) Has been cancelled
Continuous Integration / Mypy Check (Python 3.10) (push) Has been cancelled
Continuous Integration / Mypy Check (Python 3.11) (push) Has been cancelled
Continuous Integration / Mypy Check (Python 3.12) (push) Has been cancelled
Continuous Integration / Mypy Check (Python 3.13) (push) Has been cancelled
Continuous Integration / Unit Tests (Python 3.10) (push) Has been cancelled
Continuous Integration / Unit Tests (Python 3.11) (push) Has been cancelled
Continuous Integration / Unit Tests (Python 3.12) (push) Has been cancelled
Continuous Integration / Unit Tests (Python 3.13) (push) Has been cancelled
Continuous Integration / Unit Tests (Python 3.14) (push) Has been cancelled
Continuous Integration / A2A v0.3 Tests (Python 3.10) (push) Has been cancelled
Continuous Integration / A2A v0.3 Tests (Python 3.11) (push) Has been cancelled
Continuous Integration / A2A v0.3 Tests (Python 3.12) (push) Has been cancelled
Copybara PR Handler / close-imported-pr (push) Has been cancelled
Continuous Integration / A2A v0.3 Tests (Python 3.13) (push) Has been cancelled
Continuous Integration / A2A v0.3 Tests (Python 3.14) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:25:13 +08:00
commit ec2b666284
2231 changed files with 491535 additions and 0 deletions
@@ -0,0 +1,76 @@
# Files Retrieval Agent
A sample agent that demonstrates using `FilesRetrieval` with the
`gemini-embedding-2-preview` embedding model for retrieval-augmented
generation (RAG) over local files.
## What it does
This agent indexes local text files from the `data/` directory using
`FilesRetrieval` (backed by LlamaIndex's `VectorStoreIndex` and Google's
`gemini-embedding-2-preview` embedding model), then answers user questions
by retrieving relevant documents before generating a response.
## Prerequisites
- Python 3.10+
- `google-genai >= 1.64.0` (required for `gemini-embedding-2-preview`
support via the Vertex AI `embedContent` endpoint)
- `llama-index-embeddings-google-genai >= 0.3.0`
Install dependencies:
```bash
uv sync --all-extras
```
## Authentication
Configure one of the following:
**Google AI API:**
```bash
export GOOGLE_API_KEY="your-api-key"
```
**Vertex AI:**
```bash
export GOOGLE_GENAI_USE_ENTERPRISE=1
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="us-central1"
```
Note: `gemini-embedding-2-preview` is currently only available in
`us-central1`.
## Usage
```bash
cd contributing/samples
# Interactive CLI
adk run files_retrieval_agent
# Web UI
adk web .
```
## Example queries
- "What agent types does ADK support?"
- "How does FilesRetrieval work?"
- "What tools are available in ADK?"
## File structure
```
files_retrieval_agent/
├── __init__.py
├── agent.py # Agent definition with FilesRetrieval tool
├── data/
│ ├── adk_overview.txt # ADK architecture overview
│ └── tools_guide.txt # ADK tools documentation
└── README.md
```
@@ -0,0 +1,15 @@
# Copyright 2026 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,53 @@
# Copyright 2026 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.
"""Sample agent using FilesRetrieval with gemini-embedding-2-preview.
This agent indexes local text files and answers questions about them
using retrieval-augmented generation.
Usage:
cd contributing/samples
adk run files_retrieval_agent
# or
adk web .
"""
import os
from google.adk.agents.llm_agent import Agent
from google.adk.tools.retrieval.files_retrieval import FilesRetrieval
DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
files_retrieval = FilesRetrieval(
name="search_documents",
description=(
"Search through local ADK documentation files to find relevant"
" information. Use this tool when the user asks questions about ADK"
" features, architecture, or tools."
),
input_dir=DATA_DIR,
)
root_agent = Agent(
name="files_retrieval_agent",
instruction=(
"You are a helpful assistant that answers questions about the Agent"
" Development Kit (ADK). Use the search_documents tool to find"
" relevant information before answering. Always base your answers"
" on the retrieved documents."
),
tools=[files_retrieval],
)
@@ -0,0 +1,23 @@
Agent Development Kit (ADK) Overview
ADK is a Python framework for building AI agents powered by large language models.
It provides a structured way to create agents that can reason, use tools, and
collaborate with other agents.
Key Features:
- Multi-agent orchestration with sequential, parallel, and loop patterns
- Built-in tool support including function tools, retrieval, and code execution
- Session management for maintaining conversation state
- Memory services for long-term recall across sessions
- Support for multiple LLM backends including Gemini, Anthropic, and Ollama
Architecture:
The core abstractions are Agent, Runner, Tool, Session, and Memory.
The Runner orchestrates the reason-act loop, processing user turns and
streaming events back to the caller.
Agent Types:
- LlmAgent: Main agent with LLM integration
- SequentialAgent: Runs sub-agents in sequence
- ParallelAgent: Runs sub-agents in parallel
- LoopAgent: Runs sub-agents in a loop
@@ -0,0 +1,28 @@
ADK Tools Guide
Tools are capabilities that agents can invoke during their reasoning process.
ADK supports several types of tools:
1. Function Tools
Define Python functions and pass them directly to an agent.
The function signature and docstring become the tool schema.
2. Retrieval Tools
- FilesRetrieval: Index and search local files using embeddings.
Uses gemini-embedding-2-preview by default.
- VertexAiRagRetrieval: Search Vertex AI RAG corpora.
3. Code Execution
Agents can generate and execute code in a sandboxed environment.
4. Third-Party Tool Integration
- LangchainTool: Wraps LangChain tools for use in ADK.
- CrewaiTool: Wraps CrewAI tools for use in ADK.
5. MCP Tools
Connect to Model Context Protocol servers for external tool access.
Tool Configuration:
Tools can be configured with authentication, rate limiting, and custom
schemas. The ToolContext provides access to session state, artifacts,
and other contextual information during tool execution.