-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
haystack/components/retrievers/sentence_window_retrieval.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SPDX-FileCopyrightText: 2022-present deepset GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import warnings | ||
|
||
from .sentence_window_retriever import SentenceWindowRetriever | ||
|
||
|
||
class SentenceWindowRetrieval(SentenceWindowRetriever): | ||
""" | ||
This class is deprecated. Please use `SentenceWindowRetriever` instead. | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
warnings.warn( | ||
"The class `SentenceWindowRetrieval` is deprecated and will be removed in a future release. " | ||
"Please use `SentenceWindowRetriever` instead.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
super().__init__(*args, **kwargs) |
4 changes: 4 additions & 0 deletions
4
releasenotes/notes/deprecate-sentence-window-retrieval-9d7f8a61429a514b.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
deprecations: | ||
- | | ||
`SentenceWindowRetrieval` is deprecated and will be removed in future. Use `SentenceWindowRetriever` instead. |
16 changes: 16 additions & 0 deletions
16
test/components/retrievers/test_sentence_window_retrieval.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from haystack.components.retrievers.sentence_window_retrieval import SentenceWindowRetrieval | ||
from haystack.components.retrievers.sentence_window_retriever import SentenceWindowRetriever | ||
from haystack.document_stores.in_memory import InMemoryDocumentStore | ||
from unittest.mock import patch | ||
|
||
|
||
class TestSentenceWindowRetrieval: | ||
def test_init_default(self): | ||
retriever = SentenceWindowRetrieval(InMemoryDocumentStore()) | ||
assert retriever.window_size == 3 | ||
|
||
def test_init_calls_parent(self): | ||
with patch.object(SentenceWindowRetriever, "__init__", return_value=None) as mock_init: | ||
document_store = InMemoryDocumentStore() | ||
retriever = SentenceWindowRetrieval(document_store) | ||
mock_init.assert_called_once_with(document_store) |