A local AI-powered email automation system that learns from your email style and creates draft responses for every unread email in your (Gmail) inbox.
demo.mp4
- Save time replying to emails -- JUST Open the draft and Send
- Keep all data and model to yourself -- No cloud, no tracking
- Something everyone can use everyday -- Set up in less than 10 minutes and forget about it
- Automatically extracts your email communication patterns from Gmail
- Fine-tunes LLaMA models on your email style using LoRA
- Creates AI-generated draft responses for unread emails
- Supports both Apple Silicon (MLX) and CUDA GPUs
- Python 3.10+
- Gmail Account with API access
- For Mac: MLX compatible device (M1/M2/M3/M4/...)
- For others: CUDA compatible GPU
- Clone the repository:
git clone https://github.com/zycyc/LAMBDA.git
cd LAMBDA
- Install dependencies:
For Mac (Apple Silicon) and Linux:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
For Windows:
python -m venv .venv
Set-ExecutionPolicy Unrestricted -Scope Process
.venv\Scripts\activate
pip install -r requirements.txt
Note: If you encounter any issues with PyTorch installation:
- For Windows, you can manually install PyTorch with CUDA using:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
- For Linux, you can manually install PyTorch using:
pip3 install torch torchvision torchaudio
-
Enable Gmail API and Setup Credentials (only takes about 5 minutes):
-
Go to Google Cloud Console
-
Create a new project:
- Click on the project dropdown at the top of the page
- Click "New Project"
- Enter a project name (e.g., "LAMBDA Email Assistant")
- Click "Create"
- Wait for the project to be created and click "SELECT PROJECT"
-
Enable Gmail API:
- Click on the hamburger menu (☰) in the top-left corner
- Navigate to "APIs & Services" > "Library"
- Search for "Gmail API"
- Click on "Gmail API" in the results
- Click "Enable"
-
Configure OAuth consent screen:
- Go to "APIs & Services" > "OAuth consent screen"
- Select "External" user type (unless you're in an organization)
- Click "Create"
- Fill in the required fields:
- App name: "LAMBDA Email Assistant"
- User support email: your email
- Developer contact information: your email
- Click "Save and Continue"
- On "Scopes" page
- Click "ADD OR REMOVE SCOPES"
- Search for "Gmail API" and select "Read, compose, and send emails from your Gmail account"
- Click "UPDATE" and then "SAVE AND CONTINUE"
- On "Test users" page, click "ADD USER" and enter your email, then click "SAVE AND CONTINUE"
- Click "Back to Dashboard"
-
Create OAuth 2.0 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" at the top
- Select "OAuth client ID"
- Choose "Desktop app" as the application type
- Name it "LAMBDA Desktop Client"
- Click "Create"
-
Download credentials:
- In the popup that appears, click "Download" (or download from the credentials page)
- Rename the downloaded file to
credentials.json
- Move the file to your LAMBDA project root directory
Note: When you first run the application, it will open a browser window asking you to authorize the application. This is normal and only needs to be done once.
-
Run the LAMBDA interface:
python lambda.py
or run the bot in background once you're satisfied with everything:
nohup python lambda_bot.py &> lambda_bot.log &
The interactive menu will guide you through the following options:
- Create/Update training dataset
- Train model
- Run email bot
- Run complete workflow (all steps)
- Exit
On first run, you'll be prompted to enter your name if not already configured. This name will be used by the AI to personalize responses.
The bot will:
- Check for unread emails every 5 minutes (adjustable in config.py)
- Generate responses using your fine-tuned model
- Create draft responses in Gmail
- Skip threads that already have drafts
LAMBDA/
├── README.md
├── requirements.txt
├── blacklist.txt # Sender blacklist to ignore
├── config.py # Configuration settings
├── lambda.py # Main interface script
├── create_dataset.py # Gmail data extraction
├── train_model.py # Model fine-tuning
├── lambda_bot.py # Email bot implementation
└── gmail_utils.py # Gmail API utilities
Edit config.py
to customize:
- Model selection
- Training hyperparameters
- Email settings
- Response templates
LAMBDA provides multiple ways to filter which emails get processed:
By default, LAMBDA skips emails with the following Gmail labels:
- CATEGORY_SOCIAL (social media notifications)
- CATEGORY_UPDATES (automatic updates)
- CATEGORY_FORUMS (forum posts)
- CATEGORY_PROMOTIONS (marketing emails)
You can manually specify which senders to ignore by adding their email addresses to blacklist.txt
:
- Open
blacklist.txt
in any text editor - Add one email address per line
- You can use partial matches - they will match anywhere in the sender's email
- Lines starting with # are treated as comments
Example blacklist.txt:
no-reply@
newsletter@
notifications@
marketing@
This would skip any emails from addresses containing these strings (e.g., no-reply@company.com, marketing@example.com)
- Can I run this on X computer with a Y GPU?
- Non-M-chip Macs are not supported. Otherwise, as long as it comes with a M-Chip or a CUDA-compatible GPU, it should work.
- Do I have enough GPU power to run this? Can I run smaller/quicker models?
- It reallydepends. In general, I'd recommend asking any LLMs for a proper setup of hyperparameters that you'd want to put in
config.py
. For Mac users, mlx docs offers useful instructions (including how to convert the default LoRA model to QLoRA format).
- It reallydepends. In general, I'd recommend asking any LLMs for a proper setup of hyperparameters that you'd want to put in
- Will this work with my Outlook email?
- No, this is a Gmail-only tool for now. I got some example scripts for Outlook, but they are not fully tested & integrated yet. The key difficulty is that there're many Gmail-specific APIs that have already been built into the current version.
- Anything else?
- Feel free to file an issue on Github!
- CUDA QLoRA support
- Windows support (now only tested on Mac)
- Filter out spam ads emails by using replied rate (or is there some API for this?)
- A configurable list of senders to ignore (e.g., no-reply@example.com)
- Shortcuts support for voice-input-based rewriting (whisper)
- RAG support for personal knowledge base
- Outlook Exchange support
- Labeling emails for priorities / categories
- ...
MIT License - see LICENSE file for details