1- from __future__ import annotations
1+ # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
24
3- from typing import Any
5+ from typing import Any , Optional , Union
46
57from haystack import component , default_from_dict , default_to_dict
68from haystack .dataclasses import Document
@@ -61,9 +63,9 @@ def __init__(
6163 self ,
6264 * ,
6365 document_store : ValkeyDocumentStore ,
64- filters : dict [str , Any ] | None = None ,
66+ filters : Optional [ dict [str , Any ]] = None ,
6567 top_k : int = 10 ,
66- filter_policy : str | FilterPolicy = FilterPolicy .REPLACE ,
68+ filter_policy : Union [ str , FilterPolicy ] = FilterPolicy .REPLACE ,
6769 ):
6870 """
6971 :param document_store: The Valkey Document Store.
@@ -99,7 +101,7 @@ def to_dict(self) -> dict[str, Any]:
99101 )
100102
101103 @classmethod
102- def from_dict (cls , data : dict [str , Any ]) -> ValkeyEmbeddingRetriever :
104+ def from_dict (cls , data : dict [str , Any ]) -> " ValkeyEmbeddingRetriever" :
103105 """
104106 Deserializes the component from a dictionary.
105107 :param data:
@@ -120,8 +122,8 @@ def from_dict(cls, data: dict[str, Any]) -> ValkeyEmbeddingRetriever:
120122 def run (
121123 self ,
122124 query_embedding : list [float ],
123- filters : dict [str , Any ] | None = None ,
124- top_k : int | None = None ,
125+ filters : Optional [ dict [str , Any ]] = None ,
126+ top_k : Optional [ int ] = None ,
125127 ) -> dict [str , list [Document ]]:
126128 """
127129 Retrieve documents from the `ValkeyDocumentStore`, based on their dense embeddings.
0 commit comments