Merge pull request #1315 from IcySugar000/main

Fixed null value handling and ensure exceptions are avoided
This commit is contained in:
Daniel.y
2025-04-09 13:43:26 +08:00
committed by GitHub
2 changed files with 4 additions and 0 deletions

View File

@@ -1370,6 +1370,7 @@ async def _find_most_related_text_unit_from_entities(
text_units = [
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
for dp in node_datas
if dp["source_id"] is not None
]
edges = await asyncio.gather(
*[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(
node_datas = [
{**n, "entity_name": k, "rank": d}
for k, n, d in zip(entity_names, node_datas, node_degrees)
if n is not None
]
len_node_datas = len(node_datas)
@@ -1688,6 +1690,7 @@ async def _find_related_text_unit_from_relationships(
text_units = [
split_string_by_multi_markers(dp["source_id"], [GRAPH_FIELD_SEP])
for dp in edge_datas
if dp["source_id"] is not None
]
all_text_units_lookup = {}

View File

@@ -334,6 +334,7 @@ def split_string_by_multi_markers(content: str, markers: list[str]) -> list[str]
"""Split a string by multiple markers"""
if not markers:
return [content]
content = content if content is not None else ""
results = re.split("|".join(re.escape(marker) for marker in markers), content)
return [r.strip() for r in results if r.strip()]