Skip to content

Commit adde72c

Browse files
authored
Merge pull request #1315 from IcySugar000/main
Fixed null value handling and ensure exceptions are avoided
2 parents 97ce84a + 224f63c commit adde72c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lightrag/operate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ async def _find_most_related_text_unit_from_entities(
13701370
text_units = [
13711371
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
13721372
for dp in node_datas
1373+
if dp["source_id"] is not None
13731374
]
13741375
edges = await asyncio.gather(
13751376
*[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(
16641665
node_datas = [
16651666
{**n, "entity_name": k, "rank": d}
16661667
for k, n, d in zip(entity_names, node_datas, node_degrees)
1668+
if n is not None
16671669
]
16681670

16691671
len_node_datas = len(node_datas)
@@ -1688,6 +1690,7 @@ async def _find_related_text_unit_from_relationships(
16881690
text_units = [
16891691
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
16901692
for dp in edge_datas
1693+
if dp["source_id"] is not None
16911694
]
16921695
all_text_units_lookup = {}
16931696

lightrag/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ def split_string_by_multi_markers(content: str, markers: list[str]) -> list[str]
334334
"""Split a string by multiple markers"""
335335
if not markers:
336336
return [content]
337+
content = content if content is not None else ""
337338
results = re.split("|".join(re.escape(marker) for marker in markers), content)
338339
return [r.strip() for r in results if r.strip()]
339340

0 commit comments

Comments
 (0)