fixes memgraph async attirbute error (#3209)

This commit is contained in:
Parshva Daftari
2025-08-01 13:19:08 -07:00
committed by GitHub
parent 89b67e0834
commit 7d1d0ca806
2 changed files with 32 additions and 12 deletions
+22
View File
@@ -106,3 +106,25 @@ class VectorStoreFactory:
def reset(cls, instance):
instance.reset()
return instance
class GraphStoreFactory:
"""
Factory for creating MemoryGraph instances for different graph store providers.
Usage: GraphStoreFactory.create(provider_name, config)
"""
provider_to_class = {
"memgraph": "mem0.memory.memgraph_memory.MemoryGraph",
"neptune": "mem0.graphs.neptune.main.MemoryGraph",
"default": "mem0.memory.graph_memory.MemoryGraph",
}
@classmethod
def create(cls, provider_name, config):
class_type = cls.provider_to_class.get(provider_name, cls.provider_to_class["default"])
try:
GraphClass = load_class(class_type)
except (ImportError, AttributeError) as e:
raise ImportError(f"Could not import MemoryGraph for provider '{provider_name}': {e}")
return GraphClass(config)