From d10d2f20310a892616064249db38e5d8fb160845 Mon Sep 17 00:00:00 2001 From: Michael Barlow <25936840+Michael-JB@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:16:35 +0100 Subject: [PATCH] fix: allow negative min score in SearchQuery Update the `SearchQuery` model in `document_index.py` to allow a `min_score` between -1 and 1. --- CHANGELOG.md | 2 +- .../connectors/document_index/document_index.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e34ffeef..5d11a94d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ - Add method `DocumentIndexClient.chunks()` for retrieving all text chunks of a document. ### Fixes -... +- The Document Index `SearchQuery` now correctly allows searches with a negative `min_score`. ### Deprecations ... diff --git a/src/intelligence_layer/connectors/document_index/document_index.py b/src/intelligence_layer/connectors/document_index/document_index.py index 6c160d17..0afbd1c3 100644 --- a/src/intelligence_layer/connectors/document_index/document_index.py +++ b/src/intelligence_layer/connectors/document_index/document_index.py @@ -293,16 +293,15 @@ class SearchQuery(BaseModel): query: Actual text to be searched with. max_results: Max number of search results to be retrieved by the query. Must be larger than 0. - min_score: Filter out results with a similarity score below this value. - Must be between 0 and 1. - For searches on hybrid indexes, the Document Index applies the min_score - to the semantic results before fusion of result sets. As fusion re-scores results, + min_score: Filter out results with a similarity score below this value. Must be between + -1 and 1. For searches on hybrid indexes, the Document Index applies the min_score to + the semantic results before fusion of result sets. As fusion re-scores results, returned scores may exceed this value. """ query: str max_results: int = Field(ge=0, default=1) - min_score: float = Field(ge=0.0, le=1.0, default=0.0) + min_score: float = Field(ge=-1.0, le=1.0, default=0.0) filters: Optional[list[Filters]] = None