diff --git a/.env.template b/.env.template index cfcb62bb4..4cc11d96e 100644 --- a/.env.template +++ b/.env.template @@ -27,9 +27,9 @@ EMBEDDING_API_VERSION="" EMBEDDING_DIMENSIONS=3072 EMBEDDING_MAX_TOKENS=8191 -# "neo4j", "networkx" or "kuzu" +# "neo4j", "networkx", "kuzu" or "memgraph" GRAPH_DATABASE_PROVIDER="networkx" -# Only needed if using neo4j +# Only needed if using neo4j or memgraph GRAPH_DATABASE_URL= GRAPH_DATABASE_USERNAME= GRAPH_DATABASE_PASSWORD= diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 000000000..523695a95 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,12 @@ +## 💫 Contributors + +Thanks to our amazing contributors! 💖 + + + + + +## 🏆 Top Contributors + +| Rank | Contributor | Contributions | +|------|------------|---------------| diff --git a/cognee/infrastructure/databases/graph/memgraph/memgraph_adapter.py b/cognee/infrastructure/databases/graph/memgraph/memgraph_adapter.py index 5ef438077..f74143971 100644 --- a/cognee/infrastructure/databases/graph/memgraph/memgraph_adapter.py +++ b/cognee/infrastructure/databases/graph/memgraph/memgraph_adapter.py @@ -358,13 +358,32 @@ class MemgraphAdapter(GraphDBInterface): return [result["successor"] for result in results] - async def get_neighbours(self, node_id: str) -> List[Dict[str, Any]]: + async def get_neighbors(self, node_id: str) -> List[Dict[str, Any]]: predecessors, successors = await asyncio.gather( self.get_predecessors(node_id), self.get_successors(node_id) ) return predecessors + successors + async def get_node(self, node_id: str) -> Optional[Dict[str, Any]]: + """Get a single node by ID.""" + query = """ + MATCH (node {id: $node_id}) + RETURN node + """ + results = await self.query(query, {"node_id": node_id}) + return results[0]["node"] if results else None + + async def get_nodes(self, node_ids: List[str]) -> List[Dict[str, Any]]: + """Get multiple nodes by their IDs.""" + query = """ + UNWIND $node_ids AS id + MATCH (node {id: id}) + RETURN node + """ + results = await self.query(query, {"node_ids": node_ids}) + return [result["node"] for result in results] + async def get_connections(self, node_id: UUID) -> list: predecessors_query = """ MATCH (node)<-[relation]-(neighbour)