feat: Tweak CacheChecker output type (#6719)

* specify cache checker output type

* (de)serialization

* tests

* add default value for type

* reno

* mypy

* feedback

* reduce diff

* reduce diff

* reno
This commit is contained in:
ZanSara 2024-01-11 12:33:26 +01:00 committed by GitHub
parent 79d67b0338
commit 60780ce897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -57,7 +57,7 @@ class CacheChecker:
data["init_parameters"]["document_store"] = docstore
return default_from_dict(cls, data)
@component.output_types(hits=List[Document], misses=List[Any])
@component.output_types(hits=List[Document], misses=List)
def run(self, items: List[Any]):
"""
Checks if any document associated with the specified field is already present in the store. If matching documents

View File

@ -0,0 +1,3 @@
---
enhancements:
- Modify the output type of `CacheChecker` from `List[Any]` to `List` to make it possible to connect it in a Pipeline.

View File

@ -6,7 +6,7 @@ from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.caching.cache_checker import CacheChecker
class TestUrlCacheChecker:
class TestCacheChecker:
def test_to_dict(self):
mocked_docstore_class = document_store_class("MockedDocumentStore")
component = CacheChecker(document_store=mocked_docstore_class(), cache_field="url")