From f29da4989333fd9a505e85e8dc05a8c66b29f4ca Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Mon, 17 Feb 2025 12:02:44 +0800 Subject: [PATCH] Fix keyerror issue while rebuilding graph. (#5022) ### What problem does this PR solve? #4995 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- graphrag/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphrag/utils.py b/graphrag/utils.py index 1c715072b..1fcf9c477 100644 --- a/graphrag/utils.py +++ b/graphrag/utils.py @@ -540,7 +540,7 @@ def rebuild_graph(tenant_id, kb_id): src_ids.extend(d.get("source_id", [])) if d["knowledge_graph_kwd"] == "entity": graph.add_node(d["entity_kwd"], entity_type=d["entity_type_kwd"]) - else: + elif "from_entity_kwd" in d and "to_entity_kwd" in d: graph.add_edge( d["from_entity_kwd"], d["to_entity_kwd"],