A scrappy but functional attempt at a smarter inbox, like Gmail, but with AI-powered auto-responses.
This repository contains code written in Python and JavaScript to build an intelligent email auto-response system. The backend was built using Python (Flask) with PostgreSQL, while the frontend was built with React. The model to be utilised is a fine-tuned version of the GPT2 LLM. Although there's still a lot of work to be done, I thoroughly enjoyed this project. It was a great deep dive into building practical AI with real-world constraints.
Developers running this project should already have Python3, pip, PostgreSQL, Redis and Node installed on their local machines. All code in the backend follows the PEP 8 style guide. It is also recommended to run the project in a virtual environment. Instructions for setting up a virtual environment for your platform can be found in the Python docs.
Ensure PostgreSQL is running, then run the following commands on your terminal
psql autoresponse
psql autoresponse< autoresponse.psql
You can now check out the database tables using the following commands
psql autoresponse
\dt
The following steps are needed to set-up the backend:
- Navigate to the backend folder
- Set up your virtual environment and activate it
- Run
pip install requirements.txton your terminal (still inside the backend folder and virtual environment) - Run
export FLASKAPP=flaskr
export FLASKENV=development
flask run
The project should be running on http://127.0.0.1:5000 on your computer. If you are running Windows locally, you can look for the equivalent of the commands for windows in the Flask documentation.
Celery is a library which handles the asynchronous execution of the email polling and autoresponse features. You can start it up by running the following commands. Note: You need to navigate to the backend folder on 2 different terminals, and activate the virtual environment on both terminals.
On terminal 1, run:
celery -A app.celery worker --loglevel=info
On terminal 2, run:
celery -A app.celery beat --loglevel=info
If you did not see any errors, celery worker and beat should be working fine.
- Navigate to the frontend folder
- Run the following commands
npm install //run this only once to install the dependencies
npm start //to run the project at any time
Your project should be up and running and looking like
- Fine-tuning GPT-2 on an 8GB laptop was tricky. I had to use Kaggle's free 30 hours per week of TPUs and GPUs for training.
- Even after fine-tuning and downloading the fine-tuned model from Kaggle, I couldn’t fully integrate it with the backend due to the hardware limitation.
- Built backend from scratch with Postgres, added async email polling and auto-responses with Celery.
- Collaborated on frontend, handled deployment workflows, and iterated based on internal testing. Key skills gained: AI fine-tuning under constraints, async backend architecture, full-stack integration.
