/de0

chatbot with "long term memory" that can be interacted with via terminal

Primary LanguagePython

de0: A "Long-Term Memory" 🧠 Chatbot

de0 is the name I gave to my personal assistant, but you are able to change the name to whatever your heart desires. You can update both the chatbot's name and your name in the #Bueller?! section of de0.py.

image

This chatbot runs on the gpt-3.5-turbo model from OpenAI, but you can select a different OpenAI model as well. Other LLMs such as llama2 and bard will be explored in future releases. Stay Tuned!

It is important to note that LLMs may not always be accurate. This is an experiment!

See more commentary in my blog: link coming soon


Introduction 📜

I use chatGPT nearly every day - mostly (but not exclusively) to help with coding questions/problems. There are times I am working through a complex problem where I need to end my session and call it a night. Then, a few days later, I may be ready to resurrect my problem solving assistant.

But in order to "pick up" where I (and my chatbot) left off, I need to find the relevant session in order to properly "restart" my assistant in helping me solve my problem. Because I use this tool so much, I find it annoying to dig through previous sessions to find the right one that is relevant to a particular task at hand.

This made me think... What if my chatbot had long-term memory? I simply ask it something like "Hey. we were working on problem x a few days ago... Can you remind me where we left off?" and we are right back where we started. No digging through previous sessions.

This is the goal of de0.


Demo 🖥️

Ask de0 to help me with a programming problem on July 20th, 2023

de0capture

Cool. I know de0 will remember this list, so I moved on to other things that day.

A few days later, I asked de0 for birthday ideas for my wife, Haley

de0capture1

de0 responds with something relevant. I know it will remember this too, so I will come back to that another time.

A week later, I want to revist my speech to text programming problem

de0capture2

Nice job, de0! You remembered the relevant instructions for my programming solution, and excluded irrelevant details about the birthday gift.

I can handle the birthday gift. I know my wife better than you ;)


Execution ⌨️

You can start using de0 via your local terminal today! Just follow these instructions:

📋 Requirements

NOTE: The SpaCy large pipeline model is 560 MBs. You can also replace the _lg model with the _sm model (12 MBs) or the _md model (40 MBs), but the performance has not been tested with these sizes. Documentation on SpaCy english models can be found here: https://spacy.io/models/en

Other languages can also be tokenzied using SpaCy models. See the list of options here: https://spacy.io/usage/models

🗝️ API Keys

OpenAI 🤖

You must have an OpenAI developer account in order to run de0: link

Once you have that set up, you can get your API key here: https://platform.openai.com/account/api-keys

image

For OpenAI API key to work, set up paid account at OpenAI API > Billing

image

Pinecone 💾

Once you have your pinecone account, create an index.

image

Once you create the index, you can find the API key and the Environment on the following page. If you have not yet created an API key, click the +Create API Link. This will be important later:

image

I have named my index "de0-memory." You can name it whatever you like. Just make sure that if you make adjustments to either the name or the dimensions in this setup, you also update the #set llm, index, nlp model, and initial messages section of de0.py.

image

Note: 300 dimensions and the cosine metric are the best options for this use case. I talk about this more in my blog link coming soon

💻 Run de0

Copy the path here:

image

Open your terminal window and clone the repo:

git clone https://github.com/madecero/de0.git

Change your directory to the de0 folder:

cd de0

Install the required packages (must set the permissions as --user):

pip install -r requirements.txt --user

Install the SpaCy en_core_web_lg model (replace _lg with either _sm or _md if you want to use a smaller model - this will also need to be updated in the de0.py file under the #set llm, index, nlp model, and initial messages section)

python -m spacy download en_core_web_lg

Now, open the api_keys.txt file in your directory and update your open api key, pincecone key, and pinecone environment accordingly (from the 🗝️ API Keys section above)

image

Run de0.py:

python de0.py

image


Disclaimer ⚠️

It's highly recommended that you keep track of your API costs on the Usage page. You can also set limits on how much you spend on the Usage limits page.

I use de0 regularly, and my cost tends to be less than $2 a month. That said, as a best practice, you should monitor your API usage costs closely.

Hope you enjoy de0. Forgive my print statements on top of the program. You can remove those. I am just having fun :)