mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
fix: segment resort in dataset retrieve by index_node_id_to_position (#721)
This commit is contained in:
parent
0d791839e6
commit
654985177f
|
@ -109,7 +109,11 @@ class DatasetRetrieverTool(BaseTool):
|
|||
).all()
|
||||
|
||||
if segments:
|
||||
for segment in segments:
|
||||
index_node_id_to_position = {id: position for position, id in enumerate(index_node_ids)}
|
||||
sorted_segments = sorted(segments,
|
||||
key=lambda segment: index_node_id_to_position.get(segment.index_node_id,
|
||||
float('inf')))
|
||||
for segment in sorted_segments:
|
||||
if segment.answer:
|
||||
document_context_list.append(f'question:{segment.content} \nanswer:{segment.answer}')
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user