From e64284467f9bd7ee201d82e4b1933f9980096fbb Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Tue, 3 Dec 2024 17:41:19 +0100 Subject: [PATCH] chore: adding a deprecation warning on the `SentenceWindowRetriever` (#8597) * linting * improving message * fixing header * adding deprecation in the release notes --- .../components/retrievers/sentence_window_retriever.py | 8 ++++++++ .../sentence-window-deprecation-b7db8efc56f33940.yaml | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 releasenotes/notes/sentence-window-deprecation-b7db8efc56f33940.yaml diff --git a/haystack/components/retrievers/sentence_window_retriever.py b/haystack/components/retrievers/sentence_window_retriever.py index fbc389ed3e..979a462ea4 100644 --- a/haystack/components/retrievers/sentence_window_retriever.py +++ b/haystack/components/retrievers/sentence_window_retriever.py @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 +import warnings from typing import Any, Dict, List, Optional from haystack import Document, component, default_from_dict, default_to_dict @@ -92,6 +93,13 @@ def __init__(self, document_store: DocumentStore, window_size: int = 3): self.window_size = window_size self.document_store = document_store + warnings.warn( + "The output of `context_documents` will change in the next release. Instead of a " + "List[List[Document]], the output will be a List[Document], where the documents are ordered by " + "`split_idx_start`.", + DeprecationWarning, + ) + @staticmethod def merge_documents_text(documents: List[Document]) -> str: """ diff --git a/releasenotes/notes/sentence-window-deprecation-b7db8efc56f33940.yaml b/releasenotes/notes/sentence-window-deprecation-b7db8efc56f33940.yaml new file mode 100644 index 0000000000..d1a80b5438 --- /dev/null +++ b/releasenotes/notes/sentence-window-deprecation-b7db8efc56f33940.yaml @@ -0,0 +1,3 @@ +deprecations: + | + "The output of `context_documents` will change in the next release. Instead of a List[List[Document]], the output will be a List[Document], where the documents are ordered by `split_idx_start`.",