Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Basic memory retrieval doesn't work #1895

Open
Shakahs opened this issue Sep 23, 2024 · 5 comments
Open

Basic memory retrieval doesn't work #1895

Shakahs opened this issue Sep 23, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Shakahs
Copy link

Shakahs commented Sep 23, 2024

🐛 Describe the bug

from mem0 import Memory
import dotenv


dotenv.load_dotenv()


config = {
    "graph_store": {
        "provider": "neo4j",
        "config": {
            "url": "neo4j+s://xxx.xxx.neo4j.io",
            "username": "neo4j",
            "password": "xxx"
        }
    },
    "version": "v1.1"
}

m = Memory.from_config(config_dict=config)

result = m.add("I like to take short walks on weekdays.", user_id="alice", metadata={"category": "hobbies"})

all_memories = m.get_all()

KeyError Traceback (most recent call last)
Cell In[32], line 24
20 m = Memory.from_config(config_dict=config)
22 result = m.add("I like to take short walks on weekdays.", user_id="alice", metadata={"category": "hobbies"})
---> 24 all_memories = m.get_all()

File ~/dev/projects/Roga/code/AiResearch/venv/lib/python3.12/site-packages/mem0/memory/main.py:291, in Memory.get_all(self, user_id, agent_id, run_id, limit)
286 future_graph_entities = (
287 executor.submit(self.graph.get_all, filters) if self.version == "v1.1" and self.enable_graph else None
288 )
290 all_memories = future_memories.result()
--> 291 graph_entities = future_graph_entities.result() if future_graph_entities else None
293 if self.version == "v1.1":
294 if self.enable_graph:

File /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py:456, in Future.result(self, timeout)
454 raise CancelledError()
455 elif self._state == FINISHED:
--> 456 return self.__get_result()
457 else:
458 raise TimeoutError()

File /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None

File /opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/thread.py:58, in _WorkItem.run(self)
55 return
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)

File ~/dev/projects/Roga/code/AiResearch/venv/lib/python3.12/site-packages/mem0/memory/graph_memory.py:291, in MemoryGraph.get_all(self, filters)
286 # return all nodes and relationships
287 query = """
288 MATCH (n {user_id: $user_id})-[r]->(m {user_id: $user_id})
289 RETURN n.name AS source, type(r) AS relationship, m.name AS target
290 """
--> 291 results = self.graph.query(query, params={"user_id": filters["user_id"]})
293 final_results = []
294 for result in results:

KeyError: 'user_id'

@parshvadaftari
Copy link
Contributor

@Shakahs You have to pass the user_id when using the graph_store. If you're using vector_store you can retrieve the memory without using the user_id.

@Dev-Khant Dev-Khant added the bug Something isn't working label Sep 25, 2024
@Dev-Khant
Copy link
Collaborator

Hey @Shakahs Let us know if this fixes the issue.

@prateekchhikara
Copy link
Collaborator

@parshvadaftari I believe even for vector_store you need to pass an id (run_id, user_id, or agent_id). Correct me @Dev-Khant if I am wrong.

@Shakahs
Copy link
Author

Shakahs commented Sep 25, 2024 via email

@Dev-Khant
Copy link
Collaborator

@parshvadaftari I believe even for vector_store you need to pass an id (run_id, user_id, or agent_id). Correct me @Dev-Khant if I am wrong.

Prateek actually we can directly call get_all without passing any id for vector_store.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants