Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsbatista committed Mar 1, 2024
1 parent 84f3754 commit a3c530c
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
class QdrantEmbeddingRetriever:
"""
A component for retrieving documents from an QdrantDocumentStore.
Usage example:
```python
from haystack_integrations.components.retrievers.qdrant import QdrantEmbeddingRetriever
from haystack_integrations.document_stores.qdrant import QdrantDocumentStore
document_store = QdrantDocumentStore(
":memory:",
recreate_index=True,
return_embedding=True,
wait_result_from_api=True,
)
retriever = QdrantEmbeddingRetriever(document_store=document_store)
# using a fake vector to keep the example simple
retriever.run(query_embedding=[0.1]*768)
```
"""

def __init__(
Expand Down Expand Up @@ -35,15 +52,17 @@ def __init__(
raise ValueError(msg)

self._document_store = document_store

self._filters = filters
self._top_k = top_k
self._scale_score = scale_score
self._return_embedding = return_embedding

def to_dict(self) -> Dict[str, Any]:
"""
Serialize this component to a dictionary.
Serializes the component to a dictionary.
:returns:
Dictionary with serialized data.
"""
d = default_to_dict(
self,
Expand All @@ -60,7 +79,12 @@ def to_dict(self) -> Dict[str, Any]:
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "QdrantEmbeddingRetriever":
"""
Deserialize this component from a dictionary.
Deserializes the component from a dictionary.
:param data:
Dictionary to deserialize from.
:returns:
Deserialized component.
"""
document_store = QdrantDocumentStore.from_dict(data["init_parameters"]["document_store"])
data["init_parameters"]["document_store"] = document_store
Expand All @@ -83,7 +107,8 @@ def run(
:param top_k: The maximum number of documents to return.
:param scale_score: Whether to scale the scores of the retrieved documents or not.
:param return_embedding: Whether to return the embedding of the retrieved Documents.
:return: The retrieved documents.
:returns:
The retrieved documents.
"""
docs = self._document_store.query_by_embedding(
Expand Down

0 comments on commit a3c530c

Please sign in to comment.