cpacker / memgpt Goto Github PK
View Code? Open in Web Editor NEWBuilding persistent LLM agents with long-term memory ๐๐ฆ
Home Page: https://memgpt.readme.io
License: Apache License 2.0
Building persistent LLM agents with long-term memory ๐๐ฆ
Home Page: https://memgpt.readme.io
License: Apache License 2.0
Can I use OpenAI api proxy? If yes then how?
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
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.
Have the MemGPT tuning the gpt4? or just using functions as something like instructions on GPT4
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?
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())
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
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?
I'd suggest the following updates to the documentation:
Add your OpenAI API key to your environment:
"Use MemGPT to talk to your Database:"
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:
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
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:
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!
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
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.
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:
/load
to loading most recent agent/load
argIt will be helpful to load CSV files.
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!
Line 7 in 134df8f
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.
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.
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
I've also been talking to people in non-engineering areas such as:
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.
Add implicit version of MemGPT with two separate threads (dialogue thread + memory management thread)
title
Have you integrated this with other llm api provider like amazon bedrock or watsonx? If you have can refr me some documentation.
Enable workflow where MemGPT + user can co-edit a document together.
Add write_to_text_file
function and read_to_text_file
function.
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 ?
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.
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.
Add example READMEs into main README.
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'>
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_chunk4)]
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.
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
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.
Hi there, is it possible to add support for chat-gpt free version?
Meaning model 3.5
s/your/you/
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
Very interesting implementation... where is the data saved when conversing with the chatbot? how is memory handled in this implementation?
I saw in the README.md file that it mentions using the GPT-4 API, but I don't have access to the official OpenAI GPT-4 API. I'm wondering if I can use a third-party service that offers OpenAI GPT-4 API, like this website: https://docs.aiproxy.io/guide/quick-start. If it's possible, how should I set it up?
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 !!!!
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
Continuation on #1
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
:
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 monologuegpt-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)Remaining problems with gpt-3.5-turbo
:
gpt-4
send_message
and putting messages in inner thoughtsTry 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
:
$ 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?
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
--refresh-embeddings
flag- [ ] questionary-style CLI UI for (1) loading+saving (2) viewing bot memory
TODO: add examples for backing archival/recall memory with real databases:
PersistenceManager
subclasshttps://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.
Archival
and Recall
memory storesThese need to support the insert and query operations that MemGPT will attempt to use in agent.py
Archival
and Recall
are backed by the same databaseclass 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
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
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.