check rerank document is not empty (#1740)
Co-authored-by: jyong <jyong@dify.ai>
This commit is contained in:
parent
994fceece3
commit
d5695b3170
2 changed files with 7 additions and 2 deletions
|
|
@ -24,7 +24,10 @@ class CohereReranking(BaseReranking):
|
||||||
|
|
||||||
super().__init__(model_provider, client, name)
|
super().__init__(model_provider, client, name)
|
||||||
|
|
||||||
def rerank(self, query: str, documents: List[Document], score_threshold: Optional[float], top_k: Optional[int]) -> Optional[List[Document]]:
|
def rerank(self, query: str, documents: List[Document], score_threshold: Optional[float], top_k: Optional[int]) -> \
|
||||||
|
Optional[List[Document]]:
|
||||||
|
if not documents:
|
||||||
|
return []
|
||||||
docs = []
|
docs = []
|
||||||
doc_id = []
|
doc_id = []
|
||||||
unique_documents = []
|
unique_documents = []
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ class XinferenceReranking(BaseReranking):
|
||||||
super().__init__(model_provider, client, name)
|
super().__init__(model_provider, client, name)
|
||||||
|
|
||||||
def rerank(self, query: str, documents: List[Document], score_threshold: Optional[float], top_k: Optional[int]) -> Optional[List[Document]]:
|
def rerank(self, query: str, documents: List[Document], score_threshold: Optional[float], top_k: Optional[int]) -> Optional[List[Document]]:
|
||||||
|
if not documents:
|
||||||
|
return []
|
||||||
docs = []
|
docs = []
|
||||||
doc_id = []
|
doc_id = []
|
||||||
unique_documents = []
|
unique_documents = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue