This is a ChatGPT-like chatbot that uses the ChatGPT API. It was created for my YouTube channel. You can find the playlist of videos here.
- Clone the repository
- Add your OpenAI API key to
settings.php
(seesettings.sample.php
) - Start a server
$ php -S localhost:8080
- Go to http://localhost:8080
$ sudo docker build -t chatwtf .
$ sudo docker run -p 8080:80 chatwtf
Note: If you get caught SIGWINCH, shutting down gracefully
, add the -d
flag to run it in the background.
The chatbot uses PHP sessions to store the conversations by default. You can also use an SQL database. There is a SQLite dump and a MySQL dump in the db
folder. You can install the SQLite version by running the install_sqlite.php
script.
Database config has to be put into settings.php
(see settings.sample.php
). You need to also change storage_type
to sql
in the settings in order to use a database.
You will need an API key from OpenAI to use the code. The API key must be added to the settings.sample.php
file, which you will need to rename to settings.php
.
You can change the system message in the settings to make the chatbot do what you want.
If you like this code or use it in some useful way, consider buying me a coffee: https://www.buymeacoffee.com/unconv