A simple chatbot application built using Flask, focusing on information of depression and also generating jokes and motivational quotes.
- flask
- waitress
- random
- json
- pytorch
- nltk
- numpy
- bootstrap
- jQuery
- templates/index.html => Frontend code to show the simple user interface using HTML, jQuery and Bootstrap
- app.py => The main web app built using Flask
- chat_terminal.py => A test code to check if the chatbot is functioning on the command line before integrating it with the frontend
- evaluation.py => To evaluate which class does the input (pattern) belongs to and then randomly generates a response from that class
- model.py => Simple Feed Forward Neural Network implemented in Pytorch
- nltk.utils.py => Helper functions to pre-process the text
- train.py => Defining the training loop to train the model
OS used: Windows 10
- Clone the repository, open the command line and make the repository the current working directory
D:\simple-chatbot>
- Make a new python file, named it config.py, this file will store the config key needed for Flask application
D:\simple-chatbot>vim config.py
- open another terminal and activate python
D:\simple-chatbot>python
- Type the following command to generate the key
>>> import os
>>> os.urandom(15).hex()
- After obtaining the key, copy the key value and paste it in the config.py as shown below and then save the file, make sure config.py file is in the same directory as the other .py files
SECRET_KEY = 'YOUR KEY HERE'
- To test the bot on the command line interface, type this in the anaconda prompt:
D:\simple-chatbot>python chat_terminal.py
And then you can start the conversation with the bot
- To run the app, type this in the anaconda prompt:
D:\simple-chatbot>python app.py
The app will then be on localhost port 8080.
- Go to your brower and type:
localhost:8080/
And you will see the chatbot web app.
To deploy this chat app into an Amazon EC2 instance.