A Retrieval-Augmented Generation (RAG) based chatbot for email interactions. This project implements an intelligent email assistant that can understand and process email content using advanced language models and RAG techniques.
- Email processing and analysis
- RAG-based response generation
- Gmail API integration
- Pinecone based Vector Database
- OPENAI for embeddings and as generator
- Python 3.8 or higher
uvpackage manager (for dependency management)- Gmail API credentials
- First, install
uvif you haven't already:
pip install uv- Clone the repository:
git clone https://github.com/yourusername/RAG-Email-Chatbot.git
cd RAG-Email-Chatbot- Create and activate a virtual environment using
uv:
uv venv
.venv/Scripts/activate # On Windows
source .venv/bin/activate # On Unix/MacOS- Install dependencies using
uv:
uv pip install -r requirements.txt- Create a
.envfile in the root directory with the following variables:
OPENAI_API_KEY=<your_openai_api_key>
PINECONE_APT_KEY=<your_pinecone_key>
COHERE_API_KEY=<your_cohere_key>
- Set up Gmail API credentials:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API
- Create credentials (OAuth 2.0 Client ID)
- Download the credentials and save as
credentials.jsonin the project root
- Ensure your virtual environment is activated:
.venv/Scripts/activate # On Windows
source .venv/bin/activate # On Unix/MacOS- Run the main application with ingest to upsert emails in vector db:
python ./src/main.py --ingest- Run the main application (chatbot mode):
python ./src/main.pyRAG-Email-Chatbot/
├── src/ # Source code
│ ├── __init__.py # Package initializer
│ ├── main.py # Main application entry point
│ ├── mail.py # Email handling and Gmail API integration
│ ├── generator.py # RAG-based response generation
│ ├── vector_db.py # Vector database operations
│ └── utils.py # Utility functions and helpers
├── tests/ # Test files
├── logs/ # Application logs
├── requirements.txt # Project dependencies
└── .env # Environment variables
- Email text cleaning function
- Open source encoder
- Option to change LLM
- Add open source LLMs.
- Code cleanup
- Add testcases using tox.
- Create Docker Image.
This project is licensed under the MIT License - see the LICENSE file for details.
Sahil Kumar
