diff --git a/docs/open-source/graph_memory/overview.mdx b/docs/open-source/graph_memory/overview.mdx index a6593861..fe933db8 100644 --- a/docs/open-source/graph_memory/overview.mdx +++ b/docs/open-source/graph_memory/overview.mdx @@ -7,6 +7,16 @@ Mem0 now supports **Graph Memory**. With Graph Memory, users can now create and utilize complex relationships between pieces of information, allowing for more nuanced and context-aware responses. This integration enables users to leverage the strengths of both vector-based and graph-based approaches, resulting in more accurate and comprehensive information retrieval and generation. +## Installation + +To use Mem0 with Graph Memory support, install it using pip: + +```bash +pip install mem0ai[graph] +``` + +This command installs Mem0 along with the necessary dependencies for graph functionality. + Try Graph Memory on Google Colab. Open In Colab diff --git a/mem0/memory/graph_memory.py b/mem0/memory/graph_memory.py index f25d7552..09ad55cf 100644 --- a/mem0/memory/graph_memory.py +++ b/mem0/memory/graph_memory.py @@ -1,7 +1,14 @@ import logging -from langchain_community.graphs import Neo4jGraph -from rank_bm25 import BM25Okapi +try: + from langchain_community.graphs import Neo4jGraph +except ImportError: + raise ImportError("langchain_community is not installed. Please install it using pip install langchain-community") + +try: + from rank_bm25 import BM25Okapi +except ImportError: + raise ImportError("rank_bm25 is not installed. Please install it using pip install rank-bm25") from mem0.graphs.tools import ( ADD_MEMORY_STRUCT_TOOL_GRAPH,