Replies: 3 comments
-
|
Graph memory is a natural evolution for Mem0. Here's an architecture that could work: Graph Memory Extension Designfrom typing import List, Dict, Optional
from dataclasses import dataclass
@dataclass
class MemoryNode:
id: str
content: str
embedding: List[float]
metadata: Dict
node_type: str # "fact", "event", "entity", "preference"
@dataclass
class MemoryEdge:
source_id: str
target_id: str
relation_type: str # "causes", "related_to", "contradicts", "updates"
weight: float
timestamp: str
class GraphMemoryStore:
def __init__(self, vector_store, graph_db):
self.vectors = vector_store # Existing Mem0 store
self.graph = graph_db # Neo4j/NetworkX
def add_memory(self, content: str, user_id: str):
# 1. Create node with embedding (existing Mem0 flow)
node = self.vectors.add(content, user_id=user_id)
# 2. Extract entities and relationships
entities = self.extract_entities(content)
# 3. Link to existing memories
similar = self.vectors.search(content, limit=5)
for mem in similar:
relation = self.infer_relation(content, mem.content)
if relation:
self.graph.add_edge(MemoryEdge(
source_id=node.id,
target_id=mem.id,
relation_type=relation,
weight=mem.score
))
return node
def search_with_context(self, query: str, depth: int = 2):
# Vector search for initial matches
matches = self.vectors.search(query)
# Expand via graph traversal
expanded = set()
for match in matches:
neighbors = self.graph.get_neighbors(match.id, depth=depth)
expanded.update(neighbors)
# Rank by combined vector + graph score
return self.rank_results(matches, expanded)Key Benefits
Integration Points# Could extend existing Mem0 Memory class
from mem0 import Memory
class GraphMemory(Memory):
def __init__(self, config):
super().__init__(config)
self.graph = GraphStore(config.graph_config)More on state-based memory: https://github.com/KeepALifeUS/autonomous-agents |
Beta Was this translation helpful? Give feedback.
-
|
We built an open-source OpenClaw plugin that talks to a self-hosted Mem0 REST server (not the cloud platform). Currently uses the standard vector memory endpoints — would love to add graph-memory support once that's exposed via the REST API. The plugin is a thin HTTP client, so adding graph-memory queries would be straightforward if Mem0 exposes them at |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys,
thanks a bunch for providing the openclaw extension!
I wonder whether we can expect graph-memory support for the opensource mode soon?
Currently
enableGraphis only available for the platform-mode.Beta Was this translation helpful? Give feedback.
All reactions