diff --git a/api/core/rag/datasource/retrieval_service.py b/api/core/rag/datasource/retrieval_service.py index dbd8fb7cd76073..abf2a2a5bfc1ac 100644 --- a/api/core/rag/datasource/retrieval_service.py +++ b/api/core/rag/datasource/retrieval_service.py @@ -106,7 +106,6 @@ def retrieve( exception_message = ";\n".join(exceptions) raise Exception(exception_message) - if retrieval_method == RetrievalMethod.HYBRID_SEARCH.value: data_post_processor = DataPostProcessor( str(dataset.tenant_id), reranking_mode, reranking_model, weights, False @@ -115,7 +114,7 @@ def retrieve( query=query, documents=all_documents, score_threshold=score_threshold, - top_n=DifyConfig.RETRIEVAL_TOP_N if DifyConfig.RETRIEVAL_TOP_N else top_k + top_n=DifyConfig.RETRIEVAL_TOP_N or top_k ) return all_documents @@ -187,7 +186,7 @@ def embedding_search( query=query, documents=documents, score_threshold=score_threshold, - top_n=DifyConfig.RETRIEVAL_TOP_N if DifyConfig.RETRIEVAL_TOP_N else len(documents) + top_n=DifyConfig.RETRIEVAL_TOP_N or len(documents) ) ) else: @@ -232,7 +231,7 @@ def full_text_index_search( query=query, documents=documents, score_threshold=score_threshold, - top_n=DifyConfig.RETRIEVAL_TOP_N if DifyConfig.RETRIEVAL_TOP_N else len(documents) + top_n=DifyConfig.RETRIEVAL_TOP_N or len(documents) ) ) else: