From 22c319420f13add73b02f27e212b74256fe90031 Mon Sep 17 00:00:00 2001 From: Yuguo Qin Date: Mon, 17 Feb 2025 19:56:46 +0800 Subject: [PATCH] Fix neo4j outdated get_edge() return data format. --- lightrag/kg/neo4j_impl.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index 5ffbf2bc..e7a59b0c 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -278,14 +278,16 @@ class Neo4JStorage(BaseGraphStorage): result = await session.run(query) record = await result.single() - if record and "edge_properties" in record: + if record: try: result = dict(record["edge_properties"]) + logger.info(f"Result: {result}") # Ensure required keys exist with defaults required_keys = { "weight": 0.0, "source_id": None, - "target_id": None, + "description": None, + "keywords": None, } for key, default_value in required_keys.items(): if key not in result: @@ -305,20 +307,20 @@ class Neo4JStorage(BaseGraphStorage): f"and {entity_name_label_target}: {str(e)}" ) # Return default edge properties on error - return {"weight": 0.0, "source_id": None, "target_id": None} + return {"weight": 0.0, "description": None, "keywords": None, "source_id": None} logger.debug( f"{inspect.currentframe().f_code.co_name}: No edge found between {entity_name_label_source} and {entity_name_label_target}" ) # Return default edge properties when no edge found - return {"weight": 0.0, "source_id": None, "target_id": None} + return {"weight": 0.0, "description": None, "keywords": None, "source_id": None} except Exception as e: logger.error( f"Error in get_edge between {source_node_id} and {target_node_id}: {str(e)}" ) # Return default edge properties on error - return {"weight": 0.0, "source_id": None, "target_id": None} + return {"weight": 0.0, "description": None, "keywords": None, "source_id": None} async def get_node_edges(self, source_node_id: str) -> list[tuple[str, str]] | None: node_label = source_node_id.strip('"')