johnregan3 / tars

GPT-3 chatbot with long term memory, runs locally or in Docker
20 stars 3 forks source link
ai gpt-3 openai-api

TARS

Python Version: 3.10 Docker Version: 20.10 Code style: black

GPT-3 chatbot with long term memory, runs locally or in Docker.

tars-github-2

Overview

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.


Super-Quickstart


  1. git clone git@github.com:johnregan3/tars.git
  2. Set up configuration in a .env file
  3. bash tars-setup.sh (only the first time you start TARS)
  4. bash tars.sh
  5. Visit http://localhost:4200
  6. Chat with your new best friend

Installation


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

Requirements

Setup

  1. Download these files. You have two options:

    • Clone this repo: git clone git@github.com:johnregan3/tars.git
    • Download the zip file like a caveman.
  2. 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.

  1. 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.

  2. Run bash tars.sh to start.

  3. Your site will be available at http://localhost:4200

  4. 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.


Advanced Stuff


To do your own develpment or customize the app, here are some further instructions:

  1. Run python -m venv ./venv to create a virtual environment.

  2. Run source venv/bin/activate to start the Python environment.

    1. To shut it down, simply run the command deactivate
  3. Run pip install -r requirements.txt

  4. For toying with the front end Vue files, sart by changing directories: cd web

  5. Run npm install to get everything ready to go.

  6. 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 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.
  7. Run cd ../ to go back up to the main directory.

  8. Run the app. You have two options:

    • Run python tars.py to fire up the dev site. It will be at http://127.0.0.1:5500
    • Or run bash tars.sh to start Docker, then visit http://localhost:4200 to enjoy the fruits of your labor.

Changelog


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.

Credits