An-AI-Chatbot-in-Python-and-Flask
An-AI-Chatbot-in-Python-and-Flask copied to clipboard
An AI Chatbot using Python and Flask REST API
An-AI-Chatbot-in-Python-and-Flask
An AI Chatbot using Python and Flask REST API
Requirements (libraries)
- TensorFlow
- Flask
VsCode SetUp
- Clone the repository-> cd into the cloned repository folder
- Create a python virtual environment
# macOS/Linux
# You may need to run sudo apt-get install python3-venv first
python3 -m venv .venv
# Windows
# You can also use py -3 -m venv .venv
python -m venv .venv
When you create a new virtual environment, a prompt will be displayed to allow you to select it for the workspace.
- Activate the virtual environment
#linux
source ./venv/bin/activate # sh, bash, or zsh
#windows
.\venv\Scripts\activate
- Run
pip install --upgrade tensorflow
to installTensorflow
- Run
pip install -U nltk
to installnltk
- Run
pip install -U Flask
to installflask
- To expose your bot via Ngrok, run
pip install flask-ngrok
to installflask-ngrok
Then you'll need to configure your ngrok credentials(login: email + password) Then uncomment this linerun_with_ngrok(app)
and comment the last two linesif __name__ == "__main__": app.run()
Notice that ngrok is not used by default. - To access your bot on localhost, go to
http://127.0.0.1:5000/
If you're on Ngrok your url will besome-text.ngrok.io
Step-By-Step Explanation and Installation Guide
https://dentricedev.com/blog/how-to-create-an-ai-chatbot-in-python-and-flask-gvub
https://dev.to/dennismaina/how-to-create-an-ai-chatbot-in-python-and-flask-1c3m
Execution
To run this Bot, first run the train.py
file to train the model. This will generate a file named chatbot_model.h5
This is the model which will be used by the Flask REST API to easily give feedback without the need to retrain.
After running train.py
, next run the app.py
to initialize and start the bot.
To add more terms and vocabulary to the bot, modify the intents.json
file and add your personalized words and retrain the model again.
Find me on
Having troubles implementing?
Reach out to me [email protected] I will be happy to assist
want something improved or added?
Fork the repo @ GitHub.