fix: 修复返回的分段结果排序不对,不是按照命中高低顺序排序[BUG] #746 (#770)

This commit is contained in:
shaohuzhang1 2024-07-16 10:33:18 +08:00 committed by wangdan-fit2cloud
parent 8f529181bd
commit 5dfe56cefb

View File

@ -70,6 +70,7 @@ class BaseSearchDatasetNode(ISearchDatasetStepNode):
return get_none_result(question)
paragraph_list = self.list_paragraph(embedding_list, vector)
result = [self.reset_paragraph(paragraph, embedding_list) for paragraph in paragraph_list]
result = sorted(result, key=lambda p: p.get('similarity'), reverse=True)
return NodeResult({'paragraph_list': result,
'is_hit_handling_method_list': [row for row in result if row.get('is_hit_handling_method')],
'data': '\n'.join([paragraph.get('content') for paragraph in paragraph_list]),