修复知识库查询时的空结果处理,增强动态TopK选择函数的输入检查

This commit is contained in:
墨梓柒
2025-08-03 11:03:27 +08:00
parent 1f53ecff10
commit 0b298bf6c8
2 changed files with 10 additions and 1 deletions

View File

@@ -5,6 +5,10 @@ def dyn_select_top_k(
score: List[Tuple[Any, float]], jmp_factor: float, var_factor: float
) -> List[Tuple[Any, float, float]]:
"""动态TopK选择"""
# 检查输入列表是否为空
if not score:
return []
# 按照分数排序(降序)
sorted_score = sorted(score, key=lambda x: x[1], reverse=True)