This project is a web-based email spam classifier built with Django. It utilizes OpenAI's GPT API to classify emails as either "spam" or "not spam" based on the email's contents and metadata, such as the sender's address.
- Python 3.10+
- OpenAI API Key
- Gmail API Access (enabled via GCP)
-
Clone the repository:
git clone https://github.com/knakamura13/LLM-Gmail-Spam-Filter cd LLM-Gmail-Spam-Filter
-
Create a Conda environment:
conda env create -n "llm-spam-filter" -f environment.yml
-
Set up environment variables for the OpenAI API. Create a
.env
file in the root directory and add:OPENAI_API_KEY="<your_openai_api_key_here>" GOOGLE_API_TOKEN_PATH=token.json
-
Run database migrations:
python manage.py migrate
-
Start the Django development server:
python manage.py runserver
Navigate to http://localhost:8000/emails/classify/
to view the email classification page.
├── django_gpt_email_spam_filter/
│ ├── settings.py
│ └── urls.py
├── email_classifier/
│ ├── views.py
│ ├── tasks.py
│ └── urls.py
├── templates/
│ └── email_classifier/
│ └── email_classification.html
├── README.md
├── requirements.txt
├── manage.py
├── get_google_token.py
├── credentials.json # Used by `get_google_token.py` to generate `token.json`
├── token.json
└── .env # Create this file
- Django: Web framework.
- OpenAI API: For email classification using GPT models.
- Google Auth API: For email retrieval and filtering.