yangdx
commited on
Commit
·
8e16c5c
1
Parent(s):
547e11b
Add null check for edge data
Browse files- lightrag/operate.py +12 -1
lightrag/operate.py
CHANGED
|
@@ -400,6 +400,16 @@ async def _merge_edges_then_upsert(
|
|
| 400 |
|
| 401 |
for need_insert_id in [src_id, tgt_id]:
|
| 402 |
if not (await knowledge_graph_inst.has_node(need_insert_id)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
await knowledge_graph_inst.upsert_node(
|
| 404 |
need_insert_id,
|
| 405 |
node_data={
|
|
@@ -738,7 +748,8 @@ async def extract_entities(
|
|
| 738 |
pipeline_status_lock,
|
| 739 |
llm_response_cache,
|
| 740 |
)
|
| 741 |
-
|
|
|
|
| 742 |
|
| 743 |
# Update vector databases with all collected data
|
| 744 |
if entity_vdb is not None and entities_data:
|
|
|
|
| 400 |
|
| 401 |
for need_insert_id in [src_id, tgt_id]:
|
| 402 |
if not (await knowledge_graph_inst.has_node(need_insert_id)):
|
| 403 |
+
# # Discard this edge if the node does not exist
|
| 404 |
+
# if need_insert_id == src_id:
|
| 405 |
+
# logger.warning(
|
| 406 |
+
# f"Discard edge: {src_id} - {tgt_id} | Source node missing"
|
| 407 |
+
# )
|
| 408 |
+
# else:
|
| 409 |
+
# logger.warning(
|
| 410 |
+
# f"Discard edge: {src_id} - {tgt_id} | Target node missing"
|
| 411 |
+
# )
|
| 412 |
+
# return None
|
| 413 |
await knowledge_graph_inst.upsert_node(
|
| 414 |
need_insert_id,
|
| 415 |
node_data={
|
|
|
|
| 748 |
pipeline_status_lock,
|
| 749 |
llm_response_cache,
|
| 750 |
)
|
| 751 |
+
if edge_data is not None:
|
| 752 |
+
relationships_data.append(edge_data)
|
| 753 |
|
| 754 |
# Update vector databases with all collected data
|
| 755 |
if entity_vdb is not None and entities_data:
|