Open madgrizzle opened 5 months ago
Yes this makes sense! We originally designed the CoreMemory
class to be extendible to allow for different memory structures. It would be great to get a PR for extending the core memory class to include support for multiple users.
In the future, I think we should move away from explicitly specifying a user
and persona
for the agent's core memory, and move towards a more general K/V store for the in-context memory. So an agent would be created like:
agent = client.create_agent(
....
memory={"bob": ..., "alice": ..., "organization": ...}
)
Then we could have the memory editing function look more like:
def core_memory_replace(self: Agent, key: str, new_value: str, orig_value: str) -> Optional[str]:
Is your feature request related to a problem? Please describe. I'm working on incorporating MemGPT into my robot to be it's interface to the user(s) and I'm making some changes for my applicaiton and would like to submit them as a PR in some manner that doesn't break how it works today.. I'm open to any direction on how to make it work and be incorporated into MemGPT main branch.
I initially will use MemGPT just as a chat-bot on my robot but eventually will expand its capabilities. But the initial problem is that most chat-bots expect only one user to converse with it. My MemGPT will have a single agent that will interact with multiple people and it's important that the agent can keep track of who's talking to it and store information about those users correctly. For example, a memory "Name: John" by itself is going to be problematic when someone else talks to the robot and says their name is Sparkles.. In that case, the robot will do a core_memory_replace and change it to "Name: Sparkles". What I propose is to incorporate a method of allow MemGPT to keep track of different users. This might be able to be handled just by prompt engineering, but I didn't have any real success until I incorporated an additional parameter to core_memory_append and core_memory_append named 'subsection'.
Describe the solution you'd like I modified the base functions as follows:
In the prompt, I've added the following:
To properly manage it, I have converted the self.human portion of CoreMemory object to a json (dictionary for each subsection and a list for each new memory stored). This eliminates the potential for core_memory_replace to update the wrong subsection if two users had the same information. For example, if in both the John and Sparkles subsection there is "Enjoys drinking wine" and John tells the robot that he prefers beer, then a core_memory_replace (I think) would replace both John's and Sparkle's entry because its using a simple python replace function of a string.
I added a few additional details to format the the human memory into a string for inclusion in the prompt and have been playing around with using embedding for core_memory_replace searches.
Describe alternatives you've considered I had originally tried to use prompt engineering only, but it didn't work well, but I'm very new to all this so maybe it could be done. I don't know, but the results of what I've done are pretty good.
I know some of this could be handled by adding two new functions but then I don't think I can readily take advantage of the models that are fine-tuned using the MemGPT dataset since they will want to call core_memory_append and not something like multiuser_core_memory_append. I'm open to any suggestions on how to make this work because I really would like it incorporated into the main code (make my life easier instead of sitting out here on a fork).
Additional context This is the /memory dump after simulating a conversation with Floyd (my robot) with John and Sparkles taking turns talking to him. He does a fairly good job of tracking who's talking if you let him know you switched users. The first line under === Human === is the raw json and below that is the formatted text that's used in the prompt.