Skip to content
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

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

Closed
sensahin opened this issue Jul 23, 2024 · 4 comments · Fixed by #1549
Closed

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

sensahin opened this issue Jul 23, 2024 · 4 comments · Fixed by #1549

Comments

@sensahin
Copy link

🐛 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'

@deshraj
Copy link
Collaborator

deshraj commented Jul 23, 2024

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

@sensahin
Copy link
Author

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)

@Mrxyy
Copy link

Mrxyy commented Jul 23, 2024

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.
#1538

@Dev-Khant Dev-Khant mentioned this issue Jul 23, 2024
18 tasks
@sensahin
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants