GPT-3 chatbot with long term memory, runs locally or in Docker.
This is an attempt to recreate Dave Shapiro's LongtermChatExternalSources, replacing storing data in text files with a database.
To his credit, Shapiro's project was an experiment and was never intended to scale. When I tried out his code, I wanted to play with the chatbot longer to see what it was capable of, but was shocked at how quickly the data amassed on my hard drive. This is what inspired me to try to put all of it into a database.
This app is run locally in your web browser. Once you have it up and running, start chatting with TARS. It takes a bit of interaction for it to gather enough data to give good responses, but I was able to have some interesting conversations with TARS, covering topics ranging from my personal goals, fried chicken recipes, ceiling fans in cars, and what I enjoy most about the people I love.
git clone git@github.com:johnregan3/tars.git
.env
filebash tars-setup.sh
(only the first time you start TARS)bash tars.sh
http://localhost:4200
Note: Unfortunately, I cannot devote much time to providing support for setup issues because I don't want to get fired from my day job
python -V
or even python3 -V
.Download these files. You have two options:
git clone git@github.com:johnregan3/tars.git
Inside of your tars/ directory (wherever you put it), set up your config file. Copy or rename .env.example
to .env
and update these settings:
OPENAI_API_KEY=sk-...g
OPENAI_ORGANIZATION=
USER_NAME=Cooper
TARS_NAME=TARS
DB_NAME=tars
You can leave the OpenAI Organization blank if you don't know it.
Note that "Cooper" can be replaced with your name, and you can call "TARS" whatever the heck you want: HAL, Ava, Shakira, it doesn't matter.
Open up your terminal and run bash tars-setup.sh
to fire it up and start Docker. This only has to be done the first time you run TARS.
Run bash tars.sh
to start.
Your site will be available at http://localhost:4200
Press Ctrl+C
to stop and exit.
🚨 Important Note: Your chat database lives inside of your Docker container, so if you destroy — not just stop — the container, your chat history will be wiped out.
To do your own develpment or customize the app, here are some further instructions:
Run python -m venv ./venv
to create a virtual environment.
Run source venv/bin/activate
to start the Python environment.
deactivate
Run pip install -r requirements.txt
For toying with the front end Vue files, sart by changing directories: cd web
Run npm install
to get everything ready to go.
Run npm run build
to compile any edits you make in this directory.
npm run dev
to launch a frontend preview if you want to play with the design. It will be viewable at http://localhost:5173/
. Note that this is just a preview URL for Vue development, so the database won't be connected. Python will later give you a different URL for your actual dev site with the database hooked up and whatnot.Run cd ../
to go back up to the main directory.
Run the app. You have two options:
python tars.py
to fire up the dev site. It will be at http://127.0.0.1:5500
bash tars.sh
to start Docker, then visit http://localhost:4200
to enjoy the fruits of your labor.v0.2 (March 2023) Major update. Now runs a Docker container with Python, Flask, SQLite, and Vue.
v0.1 (Early March 2023) Initial Release. Uses PHP/JS with Laravel, Vue and PostgreSQL. Requires local dev server like Laravel Valet.