Giter VIP home page Giter VIP logo

memgpt's People

Contributors

agiletechnologist avatar arduenify avatar claucambra avatar cpacker avatar goetzrobin avatar ifsheldon avatar jammaster1999 avatar jimlloyd avatar maximilian-winter avatar oceaster avatar oderwat avatar paulasquin avatar prashantdixit0 avatar qzgao avatar rabbabansh avatar robbyt avatar rudra-ji avatar sanegaming avatar sarahwooders avatar shishirpatil avatar shresthasurav avatar starsnatched avatar taddeusb90 avatar tombedor avatar tractorjuice avatar vivi avatar vladcuciureanu avatar web3wes avatar wrmedford avatar xavieryao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

memgpt's Issues

can not find the file

when try to load the txt file, it can not find it. defaults to 'basic.txt'?

raise FileNotFoundError(f"No file found for key {key}, path={file_path}")
FileNotFoundError: No file found for key basic, path=/Users/home/Downloads/MemGPT/memgpt/humans/examples/basic.txt

integration flowiseai

For active testing and use of the modularization system, please make an integration https://flowiseai.com/, it is a visual editor of all langchain modules. it will also greatly increase the interest of the audience.

Line breaks

I would be nice if it were possible to send messages containing line breaks (this is useful e.g. for code). This problem is solved in https://github.com/sigoden/aichat/ by having the user surround their message by curly braces; could there be a similar mechanism?

main.py:328: DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop()

C:\Users\Admin\Desktop\MemGPT\MemGPT>main.py --model gpt-3.5-turbo
C:\Users\Admin\Desktop\MemGPT\MemGPT\main.py:328: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()

1 You can create a new event loop in your thread if it does not have one. Here is a
 simple example:

import asyncio

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

2 You can upgrade your code to use asyncio.run(), which is the recommended way of
running asyncio programs since Python 3.7. It automatically manages the event loop
and closes it when the program finishes. For example:

asyncio.run(your_async_function())

Tkinter input and auto-loading most recent conversation for selected profile.

I've added a few changes to your program and added a few things.
Added -memgpt_run.bat (This allows you to autoload all profiles and personas, select or create a new one)
Added -personamaker.py and - profilemaker.py respectively. (They get called during the memgpt_run.bat)
Changed -main.py (Attached is a text file. I've added the code I injected in there. Just a simple tkinter window for longer context with MemGPT instead of the terminal, and auto-loading the latest conversation based off of the profile selected.)

addedcode.txt
memgpt_run.txt
personamaker.txt
profilemaker.txt

Persona Exceeding memory

I wanted to provide a quite extensive persona and apparently it is too much:

ValueError: Edit failed: Exceeds 2000 character limit (requested 7194). Consider summarizing existing core memories in 'persona' and/or moving lower priority content to archival memory to free up space in core memory, then trying again.

My persona includes a quite large example of what I want the agent to give me when I ask for a final answer. How can I put this example in archival memory from the start?

Documentation: additional infos to run on Windows

I'd suggest the following updates to the documentation:

Add your OpenAI API key to your environment:

  • on Linux/Mac: export OPENAI_API_KEY=YOUR_API_KEY
  • on Windows: setx OpenAI_API_KEY = YOUR_API_KEY

"Use MemGPT to talk to your Database:"

  • on Linux/Mac: pip install readline
  • on Windows: pip install pyreadline
    (or add to requirements.txt)

Example .txt file decoding issue

UnicodeDecodeError when reading file in CP1252 encoding

Bug
When running the main.py script with the --archival_storage_files_compute_embeddings flag, I encountered a UnicodeDecodeError. The error message indicates that the 'charmap' codec can't decode byte 0x90 in position 422, which maps to an undefined character.

To Reproduce
Steps to reproduce the behavior:

  1. Run main.py with the following command:
    python main.py --archival_storage_files_compute_embeddings="memgpt/personas/examples/preload_archival/uber.txt" --persona=memgpt_doc --human=basic
  2. Answer 'y' when asked to compute embeddings.
  3. See error

Error

(memgpt) <project_path>\MemGPT>python main.py --archival_storage_files_compute_embeddings="<project_path>/memgpt/personas/examples/preload_archival/*.txt" --persona=memgpt_doc --human=basic
<project_path>\MemGPT\main.py:328: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()
Running... [exit by typing '/exit']
Computing embeddings over 1 files. This will cost ~$0.03. Continue? [y/n] y
Traceback (most recent call last):
  File "<project_path>\MemGPT\main.py", line 331, in <module>
    app.run(run)
  File "<conda_env_path>\lib\site-packages\absl\app.py", line 308, in run
    _run_main(main, args)
  File "<conda_env_path>\lib\site-packages\absl\app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "<project_path>\MemGPT\main.py", line 329, in run
    loop.run_until_complete(main())
  File "<conda_env_path>\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "<project_path>\MemGPT\main.py", line 142, in main
    faiss_save_dir = await utils.prepare_archival_index_from_files_compute_embeddings(FLAGS.archival_storage_files_compute_embeddings)
  File "<project_path>\MemGPT\memgpt\utils.py", line 234, in prepare_archival_index_from_files_compute_embeddings
    archival_database = chunk_files(files, tkns_per_chunk, model)
  File "<project_path>\MemGPT\memgpt\utils.py", line 177, in chunk_files
    chunks = [c for c in chunk_file(file, tkns_per_chunk, model)]
  File "<project_path>\MemGPT\memgpt\utils.py", line 177, in <listcomp>
    chunks = [c for c in chunk_file(file, tkns_per_chunk, model)]
  File "<project_path>\MemGPT\memgpt\utils.py", line 141, in chunk_file
    lines = [l for l in read_in_chunks(f, tkns_per_chunk*4)]
  File "<project_path>\MemGPT\memgpt\utils.py", line 141, in <listcomp>
    lines = [l for l in read_in_chunks(f, tkns_per_chunk*4)]
  File "<project_path>\MemGPT\memgpt\utils.py", line 98, in read_in_chunks
    data = file_object.read(chunk_size)
  File "<conda_env_path>\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 422: character maps to <undefined>

Environment:

  • OS: Windows 11
  • Python version: 3.10.9
  • Conda version: 23.7.4

Additional context
The file I'm trying to process is encoded in UTF-8, but it seems like the script is trying to read it in CP1252 encoding. I've tried deleting and reinstalling the Conda environment with a different Python version, but the issue persists.

Any help would be appreciated!

update my profile

so when i chat , and update my information, apparently it is not saved in the default profile. does it have an option to save information i share and refer to it automatically next time? Thanks

Requirements file lists built-in `sqlite3` package

The requirements.txt file lists Python's built-in sqlite3 package, such that running pip install -r requirements.txt fails because no such package exists with that name on the Python Package Index. Removing this line allows installation to succeed.

Agent seems to be getting stuck in a perpetual 'motivational' state, in its thought stage (GPT4)

Anyone else noticed this before?

I was very harsh on purpose with the agent, being seemingly keen on how i wanted the agent to act human and make up information. It was persistent on not doing so and I kept insisting. When I load the information that was /saved, no matter what I say, it always gets stuck in a motivational loop as if reassuring itself of its capabilities.

This makes it take toooo long and sometimes it does not even reply.

Images attached related:

image
image
image

Readline package not used at all? And it is not available on Win platform

Try pip install readline, shown not availble to windows platform

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://download.pytorch.org/whl/cu118
Collecting readline
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f4/01/2cf081af8d880b44939a5f1b446551a7f8d59eae414277fd0c303757ff1b/readline-6.2.4.1.tar.gz (2.3 MB)
     ---------------------------------------- 2.3/2.3 MB 10.5 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  ร— python setup.py egg_info did not run successfully.
  โ”‚ exit code: 1
  โ•ฐโ”€> [1 lines of output]
      error: this module is not meant to work on Windows
      [end of output]

Readline is imported here, but it does not seems to be used anywhere, and memgpt runs fine when commenting this line out!

import readline

Integration with Aider

Aider is a coding assistant ( https://github.com/paul-gauthier/aider ). It helps people write better code. But its built on a strategy where it takes universal c-tags and loads the tags ( your code's structure ) into the context window. As a result, it can only handle small applications. Applications with a few thousand lines of code ( which is many ) just cannot be handled by packing the system prompt with this much information.

I think there is huge opportunity for a solution like MemGPT to realistically help and nurture coding assistants to effectively work on large code bases.

Question: database size

Just a question, does the long context technique here includes the size of outside database that it connects to (via the method shown in the example)?
Not issue, just a question.

Integration with open interpreter

I've been using open interpreter ( https://github.com/KillianLucas/open-interpreter ) quite a bit. I have an engineering/development background so I've been using it to

  • Troubleshoot system stability problems - often scanning system logs
  • Analyze application log files that are sometimes gigs in size
  • Analyze data in spreadsheets

I've also been talking to people in non-engineering areas such as:

  • Legal: Analyzing contracts stored on a network share. Conversing with my documents that sometimes are pretty large.
  • Sales & Markting: Analyzing market data
  • Services: analyzing and creating statements of work and and project plans.

In these scenarios, I can ask open interpreter to analyze data and files. But due to the restricted context windows, open-interpreter currently leverages python scripts very heavily where it will use python to grep, search for keywords, and other scenarios that lack the capabilities of natural language search and a viable long term memory of conversations.

Being able to load a documents ( log files, crash dumps, spreadsheets, contracts, market analysis, project plans ) into your memory and then being able to interpret it effectively holds huge promise. Right now I can get exceptional results when I can fit my problem into gtp 4's 32k context window. But in the above cases that 32k tokens run out very quickly.

New LLM Integration

Have you integrated this with other llm api provider like amazon bedrock or watsonx? If you have can refr me some documentation.

Is VIRTUAL CONTEXT a good description of MEMGPT ?

Just to be sure: so MEMGPT uses the principle of PAGING, that is used in Operating Systems to circumvent the limitation of RAM size, when a much larger memory size is needed? Which is called VIRTUAL MEMORY. In the case of LLMs we could call it VIRTUAL CONTEXT ?

This is a brilliant idea.

It's such a problem wrangling vectors- removing, adding, expiring, and what not. Would be cool if we could use local models. I'm sick of drinking from OpenAI's faucet.

Sorry for spamming your issues.
no issue.

Improve gpt-3.5-turbo performance

WIP

Current gpt-3.5-turbo performance is not very good due primarily due to bad understanding of function set (functions called at the wrong times, messages sent w/o call to send_message, etc.). Goal is to upload specific variations of the key prompts (tailored towards worse instruction following ability of 3.5) that provide reasonable performance.

Fix README

Add example READMEs into main README.

Azure Endpoint not working

openai.error.InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>

It seems some of azure's required parameters are missing still.

Here is the error in full:

File "G:\Code\memgpt\MemGPT\main.py", line 336, in <module> app.run(run) File "G:\Code\memgpt\MemGPT\.venv\Lib\site-packages\absl\app.py", line 308, in run _run_main(main, args) File "G:\Code\memgpt\MemGPT\.venv\Lib\site-packages\absl\app.py", line 254, in _run_main sys.exit(main(argv)) ^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\main.py", line 334, in run loop.run_until_complete(main()) File "C:\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\main.py", line 312, in main new_messages, heartbeat_request, function_failed, token_warning = await memgpt_agent.step(user_message, first_message=False, skip_verify=FLAGS.no_verify) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\memgpt\agent.py", line 545, in step raise e File "G:\Code\memgpt\MemGPT\memgpt\agent.py", line 483, in step response = await get_ai_reply_async(model=self.model, message_sequence=input_message_sequence, functions=self.functions) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\memgpt\agent.py", line 115, in get_ai_reply_async raise e File "G:\Code\memgpt\MemGPT\memgpt\agent.py", line 96, in get_ai_reply_async response = await acreate( ^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\memgpt\openai_tools.py", line 98, in wrapper raise e File "G:\Code\memgpt\MemGPT\memgpt\openai_tools.py", line 76, in wrapper return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\memgpt\openai_tools.py", line 108, in acompletions_with_backoff return await openai.ChatCompletion.acreate(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\.venv\Lib\site-packages\openai\api_resources\chat_completion.py", line 45, in acreate return await super().acreate(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\.venv\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 216, in acreate ) = cls.__prepare_create_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Code\memgpt\MemGPT\.venv\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 85, in __prepare_create_request raise error.InvalidRequestError( openai.error.InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>

UnicodeDecodeError when talking with docx files

When i try to input a bunch of .docx files i get this error:
(env_MemGPT) user@machine:~/projects/MemGPT$ python3 main.py --archival_storage_files="/home/user/projects/docs/FDS_docs/.docx" --persona=memgpt_doc --human=basic
Running... [exit by typing '/exit']
Traceback (most recent call last):
File "/home/user/projects/MemGPT/main.py", line 290, in
app.run(run)
File "/home/user/projects/MemGPT/env_MemGPT/lib/python3.10/site-packages/absl/app.py", line 308, in run
_run_main(main, args)
File "/home/user/projects/MemGPT/env_MemGPT/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
sys.exit(main(argv))
File "/home/user/projects/MemGPT/main.py", line 288, in run
loop.run_until_complete(main())
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/user/projects/MemGPT/main.py", line 55, in main
archival_database = utils.prepare_archival_index_from_files(FLAGS.archival_storage_files)
File "/home/user/projects/MemGPT/memgpt/utils.py", line 114, in prepare_archival_index_from_files
return chunk_files(files, tkns_per_chunk, model)
File "/home/user/projects/MemGPT/memgpt/utils.py", line 165, in chunk_files
chunks = [c for c in chunk_file(file, tkns_per_chunk, model)]
File "/home/user/projects/MemGPT/memgpt/utils.py", line 165, in
chunks = [c for c in chunk_file(file, tkns_per_chunk, model)]
File "/home/user/projects/MemGPT/memgpt/utils.py", line 129, in chunk_file
lines = [l for l in read_in_chunks(f, tkns_per_chunk
4)]
File "/home/user/projects/MemGPT/memgpt/utils.py", line 129, in
lines = [l for l in read_in_chunks(f, tkns_per_chunk*4)]
File "/home/user/projects/MemGPT/memgpt/utils.py", line 96, in read_in_chunks
data = file_object.read(chunk_size)
File "/usr/lib/python3.10/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 14: invalid continuation byte

Hope this gives a clue about what could be wrong.
I'm on Ubuntu, and the projects works just fine on other folders containing .txt files.

[Feature Request] Please make it possibel to injest PDFs

Saw this request in the discord, but wasn't added here yet, so thought I would.

kevin | weaksauce.eth โ€” Today at 08:04
Is it possible to have it ingest PDF docs

cpacker โ€” Today at 08:09
at the moment .pdf isn't officially supported so we'd recommend converting from pdf to txt first with some OCR software (eg https://github.com/tesseract-ocr/tesseract#installing-tesseract), then follow the README examples that use .txt input
but def open an issue about this and we'll add support for it! shouldn't be too hard to automate this for you

Stuck in a loop on first message

One of the recent changes seems to have made the model get stuck in an infinite loop of generating responses, which gets quite expensive if you just leave it running!

Here's an example (cutting out almost everything but the repeatedly generated replies):

$ python main.py --human me --persona memgpt_starter --first --debug
Enter your message: Hello, please remember the phrase "149: RL)"
...
First message function call wasn't send_message: {
  "role": "assistant",
  "content": "User has just logged in for the first time. He asked me to remember the phrase \"149: RL)\". I should store it in the archival memory for future reference.",
  "function_call": {
    "name": "archival_memory_insert",
    "arguments": "{\n  \"content\": \"User asked me to remember the phrase \\\"149: RL)\\\" on 2023-10-19.\",\n  \"request_heartbeat\": true\n}"
  }
}
...
First message function call wasn't send_message: {
  "role": "assistant",
  "content": "The user has asked me to remember a phrase: \"149: RL)\". It seems to be a code of some sort. I should archive this for future reference. I also need to reply to Kaden with a confirmation that I've 
acknowledged his message.",
  "function_call": {
    "name": "archival_memory_insert",
    "arguments": "{\n  \"content\": \"They asked me to remember the phrase \\\"149: RL)\\\" on 2023-10-19.\",\n  \"request_heartbeat\": true\n}"
  }
}
...
First message function call wasn't send_message: {
  "role": "assistant",
  "content": "User message received. Instructions indicate to remember the phrase \"149: RL)\". In updating the core memory to keep a track of this important instruction.",
  "function_call": {
    "name": "core_memory_append",
    "arguments": "{\n  \"name\": \"human\",\n  \"content\": \"\\nKey Phrase: \\\"149: RL)\\\"\",\n  \"request_heartbeat\": false\n}"
  }
}
...
First message function call wasn't send_message: {
  "role": "assistant",
  "content": "That's an interesting phrase. I should archive this since it seems important. The user could ask for it later.",
  "function_call": {
    "name": "archival_memory_insert",
    "arguments": "{\n  \"content\": \"The user shared a significant phrase: \\\"149: RL)\\\" on 2023-10-19.\",\n  \"request_heartbeat\": false\n}"
  }
}

and so on.

In-memory or persistant?

Is this currently just in-memory (and thus reset when you end the program) or can it save the updated persona and archival memory files to the disk?

My 10 minutes of experimenting suggest that it's just in-memory โ€“ I tried \save and \memorywarning, but neither of those actually write the updated archival memory to disk

Discord Bot Memory Storage Question

Very interesting implementation... where is the data saved when conversing with the chatbot? how is memory handled in this implementation?

Azure OpenAI support

It would be wonderful if you could add the Azure OpenAI as option.

We are on the path of developing the elderly care soft robots using Azure AI services like Prompt Flow, and found the MemGPT could evolve the care robot as emotion support level with long term human interaction !!!!

Https://hyodol.com

is it supposed to save info across chat session?

seems to be persistent for the one session (running locally), but if i try /save /memorylimit /exit

when i start a new session, nothing has been written to /Users/rick111/onedrive/MemGPT/memgpt/humans/examples/ryan.txt

starting with: python main.py --human ryan.txt

Improving gpt-3.5-turbo performance

Continuation on #1


What's changed for gpt-3.5-turbo?

We've added some revised prompts that are meant to run specifically with gpt-3.5-turbo, and that do better than the base prompts in the repo that were designed with gpt-4 in mind.

However, these prompts can definitely be improved. Please play around with the gpt-3.5-turbo specific prompts to see if you can come up with any modifications that make MemGPT work better, and we'll merge your changes in!

Important places where code was modified for gpt-3.5-turbo:

  • base system prompt
    • We added additional instructions which seemed to help. We also tried reducing the instructions (making the prompt more concise), and that did the opposite (made performance even worse)
  • initial boot messages
    • We noticed that gpt-3.5-turbo often didn't include any inner monologue with the gpt-4 prompts, so we modified the initial boot messages to use "inner thoughts" as a prefix inside the inner monologue
  • persona file
    • We noticed that gpt-3.5-turbo often forgets to use the send_message function (and instead puts its message inside the inner monologue), so we added an extra hint to use send_message inside the persona (hacky)

How can you help?

Remaining problems with gpt-3.5-turbo:

  • Makes mistakes with memory management functions much more often than gpt-4
    • e.g.: sometimes does not "read" from core memory correctly (ask MemGPT a fact that's in core memory and it searches archival)
  • Still makes mistakes with send_message and putting messages in inner thoughts
  • Uses generic phrasing like "How can I assist you today?", even if the persona does not warrant it

Try messing with the base system prompts, initial boot messages, persona file, etc, to improve 3.5 performance. If you have any luck, please let us know and we'll merge your edits in!


Example using gpt-3.5-turbo:

  • functional core memory corrections happen as expected
  • but model misunderstands that heartbeats are coming from user (vs itself)
$ python main.py --model gpt-3.5-turbo-0613 --persona sam_simple_pov_gpt35
Running... [exit by typing 'exit']
Warning - you are running MemGPT with gpt-3.5-turbo-0613, which is not officially supported (yet). Expect bugs!

๐Ÿ’ญ *inner thoughts* Still waiting on the user. Sending a message with function.
Hit enter to begin (will request first MemGPT message)

๐Ÿ’ญ *inner thoughts* Ah, it seems the user has just logged in for the first time. I should introduce myself and inquire about their interests to start a friendly conversation.
๐Ÿค– Hello there! I'm Sam, your virtual companion and friend. How can I assist you today?

Enter your message: Your name isn't Sam, it's Samantha!
๐Ÿ’ญ *inner thoughts* Oh, it seems the user prefers to call me Samantha instead of Sam. I should update my core memory to reflect their preference.
โšก๐Ÿง  [function] updating memory with core_memory_replace:
         My name is Sam.
        โ†’ My name is Samantha.
๐Ÿ’ญ *inner thoughts* The user seems to have requested a heartbeat. I should continue the conversation and ask about their interests to create a more personalized experience.
๐Ÿค– You're right, my apologies for the oversight. Thank you for reminding me, Samantha it is! So, Chad, tell me about your interests. What are you passionate about?

Enter your message: My name's not Chad, it's Brad!
๐Ÿ’ญ *inner thoughts* Oops, I must have misunderstood the user's name. I need to update my core memory with the correct information.
โšก๐Ÿง  [function] updating memory with core_memory_replace:
         First name: Chad
        โ†’ First name: Brad
๐Ÿ’ญ *inner thoughts* The user has requested another heartbeat. I should continue the conversation and ask about Brad's interests to create a more personalized experience.
๐Ÿค– Apologies for the confusion, Brad! Thank you for correcting me. Now, let's try this again. Tell me about your interests. What are you passionate about?

Speed improvement, add doc library (OneDrive), Internet access and local LLMs

Hi,

Love this project! Was looking into building it myself but you already did it, awesome :-)
Now some improvement suggestions:

1.Speed: it's nice to see what is happening but the chat is unusable for "normal" conversations (way to slow). Couldn't you build a backend process which adds to long term memory in background but adds current conversations to short term memory (like a basic ChatGPT)? That would boost the usability!
2.Doc library: why not add a path to local OneDrive folder and run again a scheduled job which adds that to the database (Chroma or whatever)? Other "feeding" engines like a imap/pop3 gmail (or whatever mail service) retrieval could import mails in background so memgpt can be even a better asistant (see also Rewind tool which does crazy stuff in being personal assistant)
3.Internet access, if locally no info is found, it could go and do search results, come back with internet info (see plugins ChatGPT)
4.Local LLMs, see LMStudio and their API interface, Llama 2 Luna AI or Dolphin https://youtu.be/tK1Pivdcl3U?si=_poUKPW-L6XvZvul could be good enough to speed up things, see also https://www.stevenbaert.ai/running-llms-locally-8-reasons-why-to-use-them-10-best-interfaces-to-do-so/
Keeping all things locally seems the best & cheapest way forward, right?

Cheers!
S

Improve the CLI

  • probably move to questionary
  • ask if want to update embeddings / --refresh-embeddings flag
  • support #8
  • currently, CLI only supports a limited amount of characters for input.

- [ ] questionary-style CLI UI for (1) loading+saving (2) viewing bot memory

Add more base archival/recall memory stores

TODO: add examples for backing archival/recall memory with real databases:

  • MongoDB
  • Some vector DB (chroma, etc)

How to use real databases with MemGPT

Create your own PersistenceManager subclass

https://github.com/cpacker/MemGPT/blob/main/memgpt/persistence_manager.py#L31-L41

The init of this persistence manager should do the appropriate initialization of your database. For example, initializing a connection to it. It also needs to implement utility methods like trimming etc.

Create your own database-backed Archival and Recall memory stores

These need to support the insert and query operations that MemGPT will attempt to use in agent.py


Example setup where both Archival and Recall are backed by the same database

Top-level PersistenceManager (each agent gets their own)

class DatabasePersistenceManager(PersistenceManager):
    """Sync Agent with database on every action/event"""

    def __init__(self, user_information, database_information):

        # initialize some abstraction over the database (optional)
        self.db_handler = db_handler

        # set up the PersistenceManager to point at this particular agent/user data in the database

    def init(self, agent):

        # create the user/agent in the database

        # also initialize the underlying data stores (note: you can have more than just these two, but you then need to modify MemGPT function schema + system instructions to match)
        self.recall_memory = DatabaseRecallMemory(...)
        self.archival_memory = DatabaseArchivalMemory(...)

    def trim_messages(self, num):
        raise NotImplementedError

    def prepend_to_messages(self, added_messages):
        raise NotImplementedError

    def append_to_messages(self, added_messages):
        raise NotImplementedError

    def swap_system_message(self, new_system_message):
        raise NotImplementedError

    def update_memory(self, new_memory):
        raise NotImplementedError

Individual Archival and Recall memory stores

class DatabaseArchivalMemory(ArchivalMemory):

    def __init__(self, user_information, database_information):
        # initialize the connection to the database that backs Archival

    async def insert(self, memory_string):
        if not isinstance(memory_string, str):
            return
        inserted_id = await self.db_handler.create_archival_memory(...)  # this inserts into the real database 
        return inserted_id

    async def search(self, query_string, count=None, start=None):
        results, total = await self.db_handler.search_archival_memory(...)  # this searches the real database

        # agent call expects: {
        #   'timestamp': ...,
        #   'message': {
        #       'role': ...,
        #       'content' ...,
        #   } 
        # }
        parsed_results = ...
        return parsed_results, total 

class DatabaseRecallMemory(RecallMemory):

    def __init__(self, db_handler, agent_id, api_key):
        # initialize the connection to the database that backs Recall (conversation history)

    async def search(self, query_string, count=None, start=None):
        results, total = self.db_handler.search_messages_text_query_paged(...)  # can be strict or fuzzy text search, or embedding search, or whatever you want

        # agent call expects: {
        #   'timestamp': ...,
        #   'message': {
        #       'role': ...,
        #       'content' ...,
        #   } 
        # }
        parsed_results = ...
        return parsed_results, total 

    async def date_search(self, start_date, end_date, count=None, start=None):
        results, total = self.db_handler.search_messages_by_date_paged(...)  # this does data-based search (optional)

        parsed_results = ...
        return parsed_results, total 

AttributeError: module 'collections' has no attribute 'Callable'

why do i get this error:

C:\Users\yasee.STUDY-COMPUTER\OneDrive\Documents\VS Code\MemGPT>python main.py Traceback (most recent call last): File "C:\Users\yasee.STUDY-COMPUTER\OneDrive\Documents\VS Code\MemGPT\main.py", line 8, in <module> import readline File "C:\Users\yasee.STUDY-COMPUTER\AppData\Local\Programs\Python\Python311\Lib\site-packages\readline.py", line 34, in <module> rl = Readline() ^^^^^^^^^^ File "C:\Users\yasee.STUDY-COMPUTER\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyreadline\rlmain.py", line 422, in __init__ BaseReadline.__init__(self) File "C:\Users\yasee.STUDY-COMPUTER\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyreadline\rlmain.py", line 62, in __init__ mode.init_editing_mode(None) File "C:\Users\yasee.STUDY-COMPUTER\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyreadline\modes\emacs.py", line 633, in init_editing_mode self._bind_key('space', self.self_insert) File "C:\Users\yasee.STUDY-COMPUTER\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyreadline\modes\basemode.py", line 162, in _bind_key if not callable(func): ^^^^^^^^^^^^^^ File "C:\Users\yasee.STUDY-COMPUTER\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyreadline\py3k_compat.py", line 8, in callable return isinstance(x, collections.Callable) ^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'collections' has no attribute 'Callable'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.