A powerful RAG (Retrieval-Augmented Generation) system for querying codebases using natural language. This tool allows you to ask questions about any codebase and get AI-powered responses based on the actual code content.
- Clone and process GitHub repositories
- Extract code from multiple file types
- Generate embeddings using HuggingFace models
- Store and retrieve code snippets using Pinecone vector database
- Query codebase using natural language
- Get AI-powered responses using OpenRouter's LLM API
- Python 3.8+
- Pinecone API key
- OpenRouter API key
- Clone the repository:
git clone https://github.com/yourusername/CodeBase_RAG.git
cd CodeBase_RAG- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the root directory with your API keys:
PINECONE_API_KEY=your_pinecone_key
OPENROUTER_API_KEY=your_openrouter_key
- Run the main script:
python main.py-
The script will:
- Clone the specified GitHub repository
- Process all supported code files
- Generate embeddings and store them in Pinecone
- Allow you to query the codebase
-
Example query:
response = rag_system.perform_rag("How to improve this repo?")- Python (.py)
- JavaScript (.js)
- TypeScript (.ts, .tsx)
- Java (.java)
- C/C++ (.c, .cpp, .h)
- Go (.go)
- Rust (.rs)
- Vue (.vue)
- Swift (.swift)
- Jupyter Notebooks (.ipynb)
CodeBase_RAG/
├── config/
│ ├── __init__.py
│ └── settings.py # Configuration and constants
├── src/
│ ├── __init__.py
│ ├── repository.py # Repository operations
│ ├── embeddings.py # Embedding generation
│ └── rag.py # RAG system implementation
├── main.py # Main entry point
├── requirements.txt # Project dependencies
└── README.md # This file
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.