This project implements an AI-powered email assistant that monitors a Gmail inbox, processes new emails, and generates draft responses using a Retrieval-Augmented Generation (RAG) approach.
- Monitors Gmail inbox for new emails
- Processes emails using a multi-agent system:
- Query Generation Agent
- Knowledge Base Search Agent
- Response Generation Agent
- Final Review Agent
- Generates draft responses based on email content and knowledge base
- Applies an "AI_Drafted" label to processed emails
- Python 3.7+
- Gmail account
- Google Cloud Platform project with Gmail API enabled
-
Clone the repository:
git clone https://github.com/your-username/email-rag-assistant.git cd email-rag-assistant
-
Create a virtual environment and activate it:
python -m venv email_rag_env source email_rag_env/bin/activate # On Windows, use `email_rag_env\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
For a full reproducible environment, you can use:
pip install -r requirements-full.txt
-
Set up Gmail API:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API for your project
- Create OAuth 2.0 credentials (Desktop app)
- Download the client configuration and save it as
client_secret.json
in the project root
-
Create a
.env
file in the project root and add the following:OPENAI_API_KEY=your_openai_api_key USE_LOCAL_LLM=false EMAIL_HISTORY_DAYS=30
-
Run the main script:
python -m src.main
-
On first run, you'll be prompted to authorize the application. Follow the URL provided in the console to grant access to your Gmail account.
-
The script will start monitoring your inbox for new emails and process them automatically.
- To modify the knowledge base, update the documents in the
knowledge_base
directory. - Adjust the email processing pipeline in
src/email_processing_pipeline.py
. - Modify the Gmail monitoring settings in
src/email_integration.py
.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.