https://github.com/sagorbrur/emailwriter
Email Writer is a GPT-2 based email generator application
https://github.com/sagorbrur/emailwriter
flask-api gpt-2 nlp text-generation transformers webapp
Last synced: 2 months ago
JSON representation
Email Writer is a GPT-2 based email generator application
- Host: GitHub
- URL: https://github.com/sagorbrur/emailwriter
- Owner: sagorbrur
- Created: 2022-03-28T14:26:07.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-07T18:21:25.000Z (over 3 years ago)
- Last Synced: 2025-09-02T20:45:47.646Z (8 months ago)
- Topics: flask-api, gpt-2, nlp, text-generation, transformers, webapp
- Language: Jupyter Notebook
- Homepage:
- Size: 5.18 MB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Email Writer
Email writer is a [gpt-2](https://github.com/openai/gpt-2) based email generator application. It is a fine-tune version of [gpt-2-medium](https://huggingface.co/gpt2-medium) model which is trained on [this](https://www.kaggle.com/datasets/mikeschmidtavemac/emailblog) datasets. Model published in huggingface [model hub](https://huggingface.co/sagorsarker/emailgenerator)
## API request and response schema
```py
request = {
"prompt": str,
"token_count": int,
"temperature": float,
"n_gen": int,
"keywords": list
}
response = {
"status": str,
"ai_results": [
{
"generated_text": str,
"text_length": int
},
]
}
```
## Installation
### Method-1
environment setup using `environment.yml` file
```
conda env create -f environment.yml
conda activate email_writer_env
```
### Method-2
```bash
pip install -r requirements.txt
# install pytorch >= 1.11
conda install pytorch cudatoolkit=11.3 -c pytorch
```
## Run Application
This application is based one [Flask](https://flask.palletsprojects.com/en/2.1.x/) framework.
Default port for this application is 5000.
```bash
python app.py
```
## Test Application
Change input `data` in `tests/test_app.py` to test different inputs.
```bash
python -m tests.test_app
```
or
```py
import requests
data = {
"prompt": "love to visit again", # subject of the email
"token_count": 128,
"temperature": 0.6,
"n_gen": 4,
"keywords": ['experience', 'joyfull', 'sea'] # relevant keywords
}
response = requests.post('http://localhost:5000/generate', json=data)
print(response.json())
```