Merge pull request #1315 from IcySugar000/main
Browse filesFixed null value handling and ensure exceptions are avoided
- lightrag/operate.py +3 -0
- lightrag/utils.py +1 -0
lightrag/operate.py
CHANGED
|
@@ -1370,6 +1370,7 @@ async def _find_most_related_text_unit_from_entities(
|
|
| 1370 |
text_units = [
|
| 1371 |
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
|
| 1372 |
for dp in node_datas
|
|
|
|
| 1373 |
]
|
| 1374 |
edges = await asyncio.gather(
|
| 1375 |
*[knowledge_graph_inst.get_node_edges(dp["entity_name"]) for dp in node_datas]
|
|
@@ -1664,6 +1665,7 @@ async def _find_most_related_entities_from_relationships(
|
|
| 1664 |
node_datas = [
|
| 1665 |
{**n, "entity_name": k, "rank": d}
|
| 1666 |
for k, n, d in zip(entity_names, node_datas, node_degrees)
|
|
|
|
| 1667 |
]
|
| 1668 |
|
| 1669 |
len_node_datas = len(node_datas)
|
|
@@ -1688,6 +1690,7 @@ async def _find_related_text_unit_from_relationships(
|
|
| 1688 |
text_units = [
|
| 1689 |
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
|
| 1690 |
for dp in edge_datas
|
|
|
|
| 1691 |
]
|
| 1692 |
all_text_units_lookup = {}
|
| 1693 |
|
|
|
|
| 1370 |
text_units = [
|
| 1371 |
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
|
| 1372 |
for dp in node_datas
|
| 1373 |
+
if dp["source_id"] is not None
|
| 1374 |
]
|
| 1375 |
edges = await asyncio.gather(
|
| 1376 |
*[knowledge_graph_inst.get_node_edges(dp["entity_name"]) for dp in node_datas]
|
|
|
|
| 1665 |
node_datas = [
|
| 1666 |
{**n, "entity_name": k, "rank": d}
|
| 1667 |
for k, n, d in zip(entity_names, node_datas, node_degrees)
|
| 1668 |
+
if n is not None
|
| 1669 |
]
|
| 1670 |
|
| 1671 |
len_node_datas = len(node_datas)
|
|
|
|
| 1690 |
text_units = [
|
| 1691 |
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
|
| 1692 |
for dp in edge_datas
|
| 1693 |
+
if dp["source_id"] is not None
|
| 1694 |
]
|
| 1695 |
all_text_units_lookup = {}
|
| 1696 |
|
lightrag/utils.py
CHANGED
|
@@ -334,6 +334,7 @@ def split_string_by_multi_markers(content: str, markers: list[str]) -> list[str]
|
|
| 334 |
"""Split a string by multiple markers"""
|
| 335 |
if not markers:
|
| 336 |
return [content]
|
|
|
|
| 337 |
results = re.split("|".join(re.escape(marker) for marker in markers), content)
|
| 338 |
return [r.strip() for r in results if r.strip()]
|
| 339 |
|
|
|
|
| 334 |
"""Split a string by multiple markers"""
|
| 335 |
if not markers:
|
| 336 |
return [content]
|
| 337 |
+
content = content if content is not None else ""
|
| 338 |
results = re.split("|".join(re.escape(marker) for marker in markers), content)
|
| 339 |
return [r.strip() for r in results if r.strip()]
|
| 340 |
|