diff --git a/api/core/rag/entities/context_entities.py b/api/core/rag/entities/context_entities.py index ef0ed071d0a236..cd18ad081ff4fd 100644 --- a/api/core/rag/entities/context_entities.py +++ b/api/core/rag/entities/context_entities.py @@ -1,6 +1,7 @@ -from pydantic import BaseModel from typing import Optional +from pydantic import BaseModel + class DocumentContext(BaseModel): """ diff --git a/api/core/rag/retrieval/dataset_retrieval.py b/api/core/rag/retrieval/dataset_retrieval.py index 42075d92eb101c..ae79b44158c848 100644 --- a/api/core/rag/retrieval/dataset_retrieval.py +++ b/api/core/rag/retrieval/dataset_retrieval.py @@ -231,9 +231,7 @@ def retrieve( source["content"] = segment.content retrieval_resource_list.append(source) if hit_callback and retrieval_resource_list: - retrieval_resource_list = sorted( - retrieval_resource_list, key=lambda x: x.get("score"), reverse=True - ) + 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)