This repository contains a Google Agent Development Kit (ADK) implementation of a Retrieval Augmented Generation (RAG) agent using Google Cloud Vertex AI.
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
- A Google Cloud account with billing enabled
- A Google Cloud project with the Vertex AI API enabled
- Appropriate access to create and manage Vertex AI resources
- Python 3.9+ environment
Before running the agent, you need to set up authentication with Google Cloud:
-
Install Google Cloud CLI:
- Visit Google Cloud SDK for installation instructions for your OS
-
Initialize the Google Cloud CLI:
gcloud init
This will guide you through logging in and selecting your project.
-
Set up Application Default Credentials:
gcloud auth application-default login
This will open a browser window for authentication and store credentials in:
~/.config/gcloud/application_default_credentials.json -
Verify Authentication:
gcloud auth list gcloud config list
-
Enable Required APIs (if not already enabled):
gcloud services enable aiplatform.googleapis.com
-
Set up a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
The agent provides the following functionality through its tools:
Allows you to ask questions and get answers from your document corpus:
- Automatically retrieves relevant information from the specified corpus
- Generates informative responses based on the retrieved content
Shows all available document corpora in your project:
- Displays corpus names and basic information
- Helps you understand what data collections are available
Create a new empty document corpus:
- Specify a custom name for your corpus
- Sets up the corpus with recommended embedding model configuration
- Prepares the corpus for document ingestion
Add documents to existing corpora or create new ones:
- Supports Google Drive URLs and GCS (Google Cloud Storage) paths
- Automatically creates new corpora if they don't exist
Provides detailed information about a specific corpus:
- Shows document count, file metadata, and creation time
- Useful for understanding corpus contents and structure
Removes corpora that are no longer needed:
- Requires confirmation to prevent accidental deletion
- Permanently removes the corpus and all associated files
If you encounter issues:
-
Authentication Problems:
- Run
gcloud auth application-default loginagain - Check if your service account has the necessary permissions
- Run
-
API Errors:
- Ensure the Vertex AI API is enabled:
gcloud services enable aiplatform.googleapis.com - Verify your project has billing enabled
- Ensure the Vertex AI API is enabled:
-
Quota Issues:
- Check your Google Cloud Console for any quota limitations
- Request quota increases if needed
-
Missing Dependencies:
- Ensure all requirements are installed:
pip install -r requirements.txt
- Ensure all requirements are installed: