A Retrieval Augmented Generation (RAG) agent built with Google's Agent Development Kit (ADK) and Vertex AI. Query your documents using natural language and get AI-powered answers.
The Vertex AI RAG Agent allows you to:
- Query document corpora with natural language questions
- List available document corpora
- Create new document corpora
- Add new documents to existing corpora
- Get detailed information about specific corpora
- Delete corpora when they're no longer needed
flowchart TB
User["👤 User"]
Agent["🤖 RAG Agent"]
Tools["🔧 Python Tools"]
VertexRAG["☁️ Vertex AI RAG API"]
User --> Agent
Agent --> Tools
Agent --> VertexRAG
- ✅ Google Cloud Account with billing enabled
- ✅ Google Cloud Project with Vertex AI API enabled
- ✅ Python 3.9+ and gcloud CLI installed
- ✅ IAM permissions for Vertex AI resources
1. Authenticate with Google Cloud
gcloud auth application-default login
gcloud services enable aiplatform.googleapis.com2. Install Dependencies
pip install -r requirements.txt3. Configure Your Project
Create a .env file with your project details:
cp .env.example .envEdit .env:
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_CLOUD_LOCATION=us-central14. Run the Agent
adk webDone! 🎉 Your RAG agent is ready.
| Tool | Purpose |
|---|---|
🔍 rag_query |
Query documents with natural language |
📋 list_corpora |
List all document collections |
➕ create_corpus |
Create a new document collection |
📄 add_data |
Add documents from Drive/GCS |
ℹ️ get_corpus_info |
Get corpus details |
🗑️ delete_document |
Remove specific documents |
🗑️ delete_corpus |
Delete entire corpus |
Start the agent interface:
# Web interface (recommended)
adk web
# Command line interface
adk run1. Create and Query a Knowledge Base
Create a corpus called 'product_docs'
Add these documents to product_docs:
- https://drive.google.com/file/d/abc123/view
- gs://my-bucket/docs/manual.pdf
What are the main features of the product?
2. Search Across Documents
What does the documentation say about installation?
3. Manage Your Collections
List all available corpora
Show me details about the product_docs corpus
Delete the old_corpus corpus
- 📚 Knowledge Base - Company documentation search
- 🔬 Research Assistant - Query academic papers
- 💬 Customer Support - Answer questions from support docs
- 📋 Legal Analysis - Search contracts and legal documents
Customize RAG settings in rag_agent/config.py:
| Setting | Description | Default |
|---|---|---|
DEFAULT_CHUNK_SIZE |
Token size for document chunks | 512 |
DEFAULT_CHUNK_OVERLAP |
Overlap between chunks | 100 |
DEFAULT_TOP_K |
Number of results to retrieve | 3 |
DEFAULT_DISTANCE_THRESHOLD |
Similarity threshold | 0.5 |
DEFAULT_EMBEDDING_MODEL |
Embedding model to use | text-embedding-005 |
Uses Google Cloud Application Default Credentials (ADC). Run gcloud auth application-default login before starting the agent.
Required IAM Permissions:
aiplatform.ragCorpora.*(create, delete, get, list, update)storage.objects.get(for GCS access)drive.files.read(for Google Drive access)
- Vertex AI RAG Docs - Official Vertex AI documentation
- Google ADK Docs - Agent Development Kit documentation