-
Notifications
You must be signed in to change notification settings - Fork 44.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Local Cache and Redis Memory backend #372
Implement Local Cache and Redis Memory backend #372
Conversation
… of instantiating a new one where used.
I should note that there is no reason why we have to wipe out the memory, unless the intent is to reset state. We could easily save the memory store's state on exit and load on start, or even per add() call. |
In redis this is simple so I went ahead and persisted the vec_num to redis and added an option to wipe on startup as the default behavior, optionally allowing users to keep their state. |
👍 |
This now implements a local version using numpy. |
It is also set to the default, orjson was added as a requirement. |
This now avoids import errors for both redis and pinecone. It is possible to remove them from requirements.txt. |
Hi, I see that both you and @cs0lar in #424 work on a memory backend/factory/interface. Great stuff! I'd suggest having a look into creating a strong combined implementation. I think @cs0lar's implementation is a bit neater and simpler, and has tests. You, @BillSchumacher, have the two additional providers, Redis and local. This memory interface is a good step 👍🏻 Happy to help and work together here |
@BillSchumacher LocalCache is crusing rn. no major errors. ~5 min of run time. Starting Redis smoke test. |
@BillSchumacher Redis - Pass of all the memory types, in my experience, redis doens't bork segmentation PC and LocalCache, dont do this well with teh stock entreprenur persona & goals |
🟢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I've use this as is for a few test setups without issue. Just a suggestion to default the env vars to make the presumed local case easier to setup.
Co-authored-by: Jason Kölker <jason@koelker.net>
I'm not sure that having a class for a single function makes sense, if other people like that I'm good with whatever. The tests are a start but we probably need some CI/CD to be able to really test. |
Taking a look at this. |
@Torantulino once you merge this then I'll merge my combo PR back into my qa pr to handle the merge conflict produced, and we will be back in buisness. |
Remove pinecone config requirement
Running this causes almost all of AutoGPT outputs to not be properly formatted as JSON for me. Anyone else experiencing this problem? |
I'm not sure the JSON errors are restricted to this branch, the main thing I'm seeing from a local model is just bad output from the model. relevant memory [[Document {'id': 'bob:0', 'payload': None, 'vector_score': '0.156416118145', 'data': 'Assistant Reply: Understood. My first task is "Search Files" for python scripts. \nResult: Command Error: returned: Unknown command Error: \nHuman Feedback: GENERATE NEXT COMMAND JSON '}]] Is what's coming back from relevent memory. |
I can see in the readme you mentioned instructions on how to make Redis memory persist between runs, however using your "LocalCache" version, memory is persisting for me by default. How do users configure this? |
memory = RedisMemory(cfg) | ||
|
||
if memory is None: | ||
memory = LocalCache(cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We appear to be missing a call to memory.clear() here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the LocalCache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there was a lot of people that wanted the memory to persist by default and I just made Pi's implementation work.
I guess a direction one way or the other needs to be picked.
Deleting the memory is easy enough for local, use just delete the json file.
But there's also a memory index if you wanted to start fresh but keep memory from a different session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, okay.
Perhaps default persistent memory is a good idea in the near future, however now I think it has the side effect of encouraging the AI to repeat it's errors.
Through my experimenting with this PR, if the AI is reminded of events from it's past were it didn't respond in JSON, it's more likely to do so again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be prudent to not even save those in memory.
Might be better |
Yeah, not saving the bad responses and returning the data seems to be working better for me. |
Agreed, I think that would make more sense to the Agent. |
Okay, nice, I think we're pretty close. Does anything else need to be resolved before we merge this? |
I thought it was good before but you are thorough =) |
Gotta look out for all the users! It's passing all my tests now though. I have a few more suggestions for tweaks to the memory system now, but they're better suited to their on PR. |
Will do |
Background
Redis is a free and open source alternative to pinecone.
We had a dicussion here: https://discord.com/channels/1092243196446249134/1093713674679615638
Changes
The memory backend was given an abstract base class.
PineconeMemory now inherits from this ABC.
RedisMemory was added.
Configuration options were added to the Config class.
Test Plan
I had SuperMario in Discord verify I did not break pinecone, I tested redis locally.
Change Safety
I didn't see any existing tests for memory and will attempt to add some at a later point in time.