mem0ai / mem0

The memory layer for Personalized AI

Home Page:https://mem0.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't make example work

femto opened this issue Β· comments

commented

πŸ› Describe the bug

Can't make example(the basic example on Readme) work,
m.add returns None memory id, causing
result = m.update(memory_id="m1", data="Likes to play tennis on weekends") fail.
tracked thru for calling,

tools = [ADD_MEMORY_TOOL, UPDATE_MEMORY_TOOL, DELETE_MEMORY_TOOL]
        response = self.llm.generate_response(messages=messages, tools=tools)
        tool_calls = response["tool_calls"]

this llm returns UPDATE_MEMORY_TOOL instead, which should be ADD_MEMORY_TOOL, so I don't have
memory_id

Thanks for opening the issue @femto. We don't return the memory_id intentionally after the m.add() call since previous related memories may be updated/deleted instead of adding a new one. Hence, it is not possible to return just a single memory_id here.

Please let us know if you have some other thoughts/feedback here. Happy to incorporate suggestions.

commented

if m.add() may sometimes updated/delete existing memory, then it's reasonably for currently returning value.
But I'm reporting a bug that after calling m.add()

result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="alice", metadata={"category": "hobbies"})
print(result)

outputs

[{'id': None, 'event': 'update', 'data': 'Working on improving tennis skills. Interested in online courses for tennis'}] 

(it invokes UPDATE_MEMORY_TOOL instead of ADD_MEMORY_TOOL)
which causes following example to fail

The m.add call llm.generate_response, and the memory_id in response["tool_calls"] is '1'. So there is an error in qdrant: {"status":{"error":"Format error in JSON body: value 1 is not a valid point ID, valid values are either an unsigned integer or a UUID at line 1 column 53"},"time":0.0}

tool_calls = [{'name': 'add_memory', 'arguments': {'data': 'Alice is working on improving her running skills.'}},
              {'name': 'add_memory',
               'arguments': {'data': 'Alice is interested in online courses related to running.'}},
              {'name': 'update_memory', 'arguments': {
                  'data': "Online courses and running skills improvement are Alice's preferred topics of interest.",
                  'memory_id': '1'}},
              {'name': 'add_memory', 'arguments': {'data': 'Alice is working on improving her running skills.'}},
              {'name': 'add_memory', 'arguments': {
                  'data': "Online courses and running skills improvement are Alice's preferred topics of interest."}}]

I think UPDATE_MEMORY_TOOL cannot handle it, if the id is the result of function_result = function_to_call(**function_args).

In Memory.add I add tmp_list and tmp_set to control the function_to_call.
tmp_list to append the not None function_result for memory_id .
tmp_set to continue the same function_args['data']