https://github.com/patrickloeber/chatbot-deployment
Deployment of PyTorch chatbot with Flask
https://github.com/patrickloeber/chatbot-deployment
Last synced: 6 days ago
JSON representation
Deployment of PyTorch chatbot with Flask
- Host: GitHub
- URL: https://github.com/patrickloeber/chatbot-deployment
- Owner: patrickloeber
- License: mit
- Created: 2021-08-28T12:49:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-20T11:12:29.000Z (over 1 year ago)
- Last Synced: 2025-02-08T06:10:04.310Z (13 days ago)
- Language: CSS
- Size: 5.86 KB
- Stars: 379
- Watchers: 6
- Forks: 474
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - patrickloeber/chatbot-deployment - Deployment of PyTorch chatbot with Flask (CSS)
README
# Chatbot Deployment with Flask and JavaScript
In this tutorial we deploy the chatbot I created in [this](https://github.com/python-engineer/pytorch-chatbot) tutorial with Flask and JavaScript.
This gives 2 deployment options:
- Deploy within Flask app with jinja2 template
- Serve only the Flask prediction API. The used html and javascript files can be included in any Frontend application (with only a slight modification) and can run completely separate from the Flask App then.## Initial Setup:
This repo currently contains the starter files.Clone repo and create a virtual environment
```
$ git clone https://github.com/python-engineer/chatbot-deployment.git
$ cd chatbot-deployment
$ python3 -m venv venv
$ . venv/bin/activate
```
Install dependencies
```
$ (venv) pip install Flask torch torchvision nltk
```
Install nltk package
```
$ (venv) python
>>> import nltk
>>> nltk.download('punkt')
```
Modify `intents.json` with different intents and responses for your ChatbotRun
```
$ (venv) python train.py
```
This will dump data.pth file. And then run
the following command to test it in the console.
```
$ (venv) python chat.py
```Now for deployment follow my tutorial to implement `app.py` and `app.js`.
## Watch the Tutorial
[](https://youtu.be/a37BL0stIuM)
[https://youtu.be/a37BL0stIuM](https://youtu.be/a37BL0stIuM)## Note
In the video we implement the first approach using jinja2 templates within our Flask app. Only slight modifications are needed to run the frontend separately. I put the final frontend code for a standalone frontend application in the [standalone-frontend](/standalone-frontend) folder.## Credits:
This repo was used for the frontend code:
https://github.com/hitchcliff/front-end-chatjs