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 [email protected]:johnregan3/tars.git
- Set up configuration in a
.env
file bash tars-setup.sh
(only the first time you start TARS)bash tars.sh
- Visit
http://localhost:4200
- Chat with your new best friend
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 3.0+
- To confirm, in your command shell run
python -V
or evenpython3 -V
.
- To confirm, in your command shell run
- Docker
- Your OpenAI API Key
-
Download these files. You have two options:
- Clone this repo:
git clone [email protected]:johnregan3/tars.git
- Download the zip file like a caveman.
- Clone this repo:
-
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.- To shut it down, simply run the command
deactivate
- To shut it down, simply run the command
-
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.- You can run
npm run dev
to launch a frontend preview if you want to play with the design. It will be viewable athttp://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.
- You can run
-
Run
cd ../
to go back up to the main directory. -
Run the app. You have two options:
- Run
python tars.py
to fire up the dev site. It will be athttp://127.0.0.1:5500
- Or run
bash tars.sh
to start Docker, then visithttp://localhost:4200
to enjoy the fruits of your labor.
- Run
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.
- Architecture inspired by Dave Shapiro's work
- Dave Shapiro's YT video Series:
- Icons purchased from "Interstellar Icon Pack" on IconFinder
- Spotlight Theme purchased from TailwindUI