A Flask app to use OpenAI api as a chatbot. The project is built on Python for backend and logic, on HTML5 and CSS for the frontend. Since the Api has price/call, it's required that the user uses his own key.
- Python 3
- Virtual environment for Python3
Linux/Mac:Windows:python3 -m pip install virtualenv
python -m pip install virtualenv
To start using this project, you need to follow these steps:
- Download source code from here or from the green button above file tree
- Create the virtual environment
python -m venv venv
- Enter into virtual environment
LinuxWindowssource venv/bin/activate
. venv/Scripts/activate
- Install requirements:
pip install -r requirements.txt
The first time you need to set up env variables.
Rename .env.example
to .env
and set:
- OPENAI_API_KEY -> secret api key from OpenAI
- PASSWORD -> the login password for Flask UI
To start as development server:
- Enable virtual environment, if not already in (as Installation #3)
- Run
flask run
To deploy the app you can use a package manager as PM2, these are the step with it:
- Enable virtual environment, if not already in (as Installation #3)
- Run
pm2 run --name "put a name of your choice here" app.py --interpreter python3 pm2 save
- The app will be available on
127.0.0.1:5002
orlocalhost:5002
(you can change port inapp.py
inserve
command)
This web app is made on Flask.
You can modify HTML files in templates/
folder and CSS in static/
;
you can also add other static files (such as JS and images) in static/
and then link in HTML as {{ url_for('static', filename='*****.***') }}
.
All the logic is in app.py
, including Flask routes.
This project is made by Lorenzo Corallo (developer) and Luis Dodaj (creator, developer) for a school assignment.