A command-line interface tool that implements Retrieval-Augmented Generation (RAG) using Google's Gemini API. This tool allows you to ask questions about the content of text, PDF documents and Python Codebases.
- Process single documents or entire directories
- Supports
.txt
,.pdf
,.py
files - Uses Google's Gemini API for text generation
- Implements RAG pattern using FAISS vector store
- Interactive Q&A interface
- Ability to mention number of relevant chunks to extract depending upon the specifity of answer required (directly proportional)
- Python 3.8 or higher
- Google API key with access to Gemini API
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install langchain langchain-google-genai python-dotenv faiss-cpu pypdf
- Create a
.env
file in the project root:GOOGLE_API_KEY=your_api_key_here
python rag_cli.py path/to/your/document.txt
python rag_cli.py path/to/your/directory
After processing the document(s), you can:
- Type your questions about the document content or codebase
- Get AI-generated answers based on the document context
- Type 'quit' or 'exit' to end the session
-
Document Processing:
- Loads documents using LangChain's document loaders
- Splits documents into manageable chunks
-
Vector Store Creation:
- Creates embeddings using Google's embedding model
- Stores embeddings in a FAISS vector store
-
Query Processing:
- Retrieves relevant document chunks for each query
- Generates contextual answers using Gemini API
The tool includes comprehensive error handling for:
- Invalid API keys
- Missing files or directories
- Unsupported file types
- Password-protected PDFs
- API rate limits
- PDF processing ignores images
- Requires active internet connection
- Subject to Google API rate limits