mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-10 05:21:47 +08:00
fix retrieval resource positon missed (#9155)
Co-authored-by: Bowen Liang <liangbowen@gf.com.cn>
This commit is contained in:
parent
a34891851b
commit
cabdb4ef17
@ -1,3 +1,5 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
@ -7,4 +9,4 @@ class DocumentContext(BaseModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
content: str
|
content: str
|
||||||
score: float
|
score: Optional[float] = None
|
||||||
|
@ -231,6 +231,9 @@ class DatasetRetrieval:
|
|||||||
source["content"] = segment.content
|
source["content"] = segment.content
|
||||||
retrieval_resource_list.append(source)
|
retrieval_resource_list.append(source)
|
||||||
if hit_callback and retrieval_resource_list:
|
if hit_callback and retrieval_resource_list:
|
||||||
|
retrieval_resource_list = sorted(retrieval_resource_list, key=lambda x: x.get("score"), reverse=True)
|
||||||
|
for position, item in enumerate(retrieval_resource_list, start=1):
|
||||||
|
item["position"] = position
|
||||||
hit_callback.return_retriever_resource_info(retrieval_resource_list)
|
hit_callback.return_retriever_resource_info(retrieval_resource_list)
|
||||||
if document_context_list:
|
if document_context_list:
|
||||||
document_context_list = sorted(document_context_list, key=lambda x: x.score, reverse=True)
|
document_context_list = sorted(document_context_list, key=lambda x: x.score, reverse=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user