Update Memgraph integration (#850)
<!-- .github/pull_request_template.md --> ## Description Update Memgraph integration with the missing abstract methods `get_neighbors`, `get_node`, `get_nodes` ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --------- Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
This commit is contained in:
parent
b1b4ae3d5f
commit
822cc55b02
3 changed files with 34 additions and 3 deletions
|
|
@ -27,9 +27,9 @@ EMBEDDING_API_VERSION=""
|
||||||
EMBEDDING_DIMENSIONS=3072
|
EMBEDDING_DIMENSIONS=3072
|
||||||
EMBEDDING_MAX_TOKENS=8191
|
EMBEDDING_MAX_TOKENS=8191
|
||||||
|
|
||||||
# "neo4j", "networkx" or "kuzu"
|
# "neo4j", "networkx", "kuzu" or "memgraph"
|
||||||
GRAPH_DATABASE_PROVIDER="networkx"
|
GRAPH_DATABASE_PROVIDER="networkx"
|
||||||
# Only needed if using neo4j
|
# Only needed if using neo4j or memgraph
|
||||||
GRAPH_DATABASE_URL=
|
GRAPH_DATABASE_URL=
|
||||||
GRAPH_DATABASE_USERNAME=
|
GRAPH_DATABASE_USERNAME=
|
||||||
GRAPH_DATABASE_PASSWORD=
|
GRAPH_DATABASE_PASSWORD=
|
||||||
|
|
|
||||||
12
CONTRIBUTORS.md
Normal file
12
CONTRIBUTORS.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
## 💫 Contributors
|
||||||
|
|
||||||
|
Thanks to our amazing contributors! 💖
|
||||||
|
|
||||||
|
<a href="https://github.com/topoteretes/cognee/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=topoteretes/cognee" />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
## 🏆 Top Contributors
|
||||||
|
|
||||||
|
| Rank | Contributor | Contributions |
|
||||||
|
|------|------------|---------------|
|
||||||
|
|
@ -358,13 +358,32 @@ class MemgraphAdapter(GraphDBInterface):
|
||||||
|
|
||||||
return [result["successor"] for result in results]
|
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(
|
predecessors, successors = await asyncio.gather(
|
||||||
self.get_predecessors(node_id), self.get_successors(node_id)
|
self.get_predecessors(node_id), self.get_successors(node_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
return predecessors + successors
|
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:
|
async def get_connections(self, node_id: UUID) -> list:
|
||||||
predecessors_query = """
|
predecessors_query = """
|
||||||
MATCH (node)<-[relation]-(neighbour)
|
MATCH (node)<-[relation]-(neighbour)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue