mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

AttributeError: 'NoneType' object has no attribute 'payload'

Open sensahin opened this issue 1 year ago • 3 comments

🐛 Describe the bug

[{'id': '31619c76-dfb6-4418-aea4-99b5ab04040d', 'event': 'add', 'data': 'Working on improving tennis skills'}] [{'id': '31619c76-dfb6-4418-aea4-99b5ab04040d', 'text': 'Working on improving tennis skills', 'metadata': {'category': 'hobbies', 'user_id': 'alice', 'data': 'Working on improving tennis skills', 'created_at': 1721722520}}] [{'id': '31619c76-dfb6-4418-aea4-99b5ab04040d', 'text': 'Working on improving tennis skills', 'metadata': {'category': 'hobbies', 'user_id': 'alice', 'data': 'Working on improving tennis skills', 'created_at': 1721722520}, 'score': 0.2371265959456912}] Traceback (most recent call last): File "/Users/senolsahin/Work/newsforgpt/test3.py", line 23, in result = m.update(memory_id="m1", data="Likes to play tennis on weekends") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/senolsahin/Work/newsforgpt/env/lib/python3.12/site-packages/mem0/memory/main.py", line 317, in update self._update_memory_tool(memory_id, data) File "/Users/senolsahin/Work/newsforgpt/env/lib/python3.12/site-packages/mem0/memory/main.py", line 390, in _update_memory_tool prev_value = existing_memory.payload.get("data") ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'payload'

sensahin avatar Jul 23 '24 08:07 sensahin

Hey @sensahin, thanks for opening the issue. Can you please share the code snippet for this so that we can reproduce the issue?

deshraj avatar Jul 23 '24 08:07 deshraj

Hi @deshraj

I am just using the below sample code that is provided on the Github page:

import os
from mem0 import Memory

os.environ["OPENAI_API_KEY"] = "sk-proj-xxx"

# Initialize Mem0
m = Memory()

# Store a memory from any unstructured text
result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="alice", metadata={"category": "hobbies"})
print(result)
# Created memory: Improving her tennis skills. Looking for online suggestions.

# Retrieve memories
all_memories = m.get_all()
print(all_memories)

# Search memories
related_memories = m.search(query="What are Alice's hobbies?", user_id="alice")
print(related_memories)

# Update a memory
result = m.update(memory_id="m1", data="Likes to play tennis on weekends")
print(result)

# Get memory history
history = m.history(memory_id="m1")
print(history)

sensahin avatar Jul 23 '24 08:07 sensahin

Hi @deshraj

I am just using the below sample code that is provided on the Github page:

import os
from mem0 import Memory

os.environ["OPENAI_API_KEY"] = "sk-proj-xxx"

# Initialize Mem0
m = Memory()

# Store a memory from any unstructured text
result = m.add("I am working on improving my tennis skills. Suggest some online courses.", user_id="alice", metadata={"category": "hobbies"})
print(result)
# Created memory: Improving her tennis skills. Looking for online suggestions.

# Retrieve memories
all_memories = m.get_all()
print(all_memories)

# Search memories
related_memories = m.search(query="What are Alice's hobbies?", user_id="alice")
print(related_memories)

# Update a memory
result = m.update(memory_id="m1", data="Likes to play tennis on weekends")
print(result)

# Get memory history
history = m.history(memory_id="m1")
print(history)

It should be this issue. https://github.com/mem0ai/mem0/issues/1538

Mrxyy avatar Jul 23 '24 08:07 Mrxyy

Hi @Mrxyy and @deshraj thanks for your help. I changed the memory_id part and now it is working. thanks!

sensahin avatar Jul 23 '24 14:07 sensahin