Skip to content

mainadennis/An-AI-Chatbot-in-Python-and-Flask

Repository files navigation

An-AI-Chatbot-in-Python-and-Flask

An AI Chatbot using Python and Flask REST API

Requirements (libraries)

  1. TensorFlow
  2. Flask

VsCode SetUp

  1. Clone the repository-> cd into the cloned repository folder
  2. 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.

  1. Activate the virtual environment
#linux
source ./venv/bin/activate  # sh, bash, or zsh

#windows
.\venv\Scripts\activate
  1. Run pip install --upgrade tensorflow to install Tensorflow
  2. Run pip install -U nltk to install nltk
  3. Run pip install -U Flask to install flask
  4. To expose your bot via Ngrok, run pip install flask-ngrok to install flask-ngrok Then you'll need to configure your ngrok credentials(login: email + password) Then uncomment this line run_with_ngrok(app) and comment the last two lines if __name__ == "__main__": app.run() Notice that ngrok is not used by default.
  5. To access your bot on localhost, go to http://127.0.0.1:5000/ If you're on Ngrok your url will be some-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

Twitter LinkedIn

Having troubles implementing?

Reach out to me [email protected] I will be happy to assist

want something improved or added?

Fork the repo @ GitHub.

Regards,

DentriceDev Solutions.

About

An AI Chatbot using Python and Flask REST API

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published