mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-16 17:48:19 +00:00
fixing docstrings (#7225)
This commit is contained in:
parent
93acdc1d3a
commit
3fc77979d8
@ -63,7 +63,10 @@ class InMemoryDocumentStore:
|
|||||||
|
|
||||||
def to_dict(self) -> Dict[str, Any]:
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Serializes this store to a dictionary.
|
Serializes the component to a dictionary.
|
||||||
|
|
||||||
|
:returns:
|
||||||
|
Dictionary with serialized data.
|
||||||
"""
|
"""
|
||||||
return default_to_dict(
|
return default_to_dict(
|
||||||
self,
|
self,
|
||||||
@ -76,7 +79,12 @@ class InMemoryDocumentStore:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, data: Dict[str, Any]) -> "InMemoryDocumentStore":
|
def from_dict(cls, data: Dict[str, Any]) -> "InMemoryDocumentStore":
|
||||||
"""
|
"""
|
||||||
Deserializes the store from a dictionary.
|
Deserializes the component from a dictionary.
|
||||||
|
|
||||||
|
:param data:
|
||||||
|
The dictionary to deserialize from.
|
||||||
|
:returns:
|
||||||
|
The deserialized component.
|
||||||
"""
|
"""
|
||||||
return default_from_dict(cls, data)
|
return default_from_dict(cls, data)
|
||||||
|
|
||||||
@ -93,7 +101,7 @@ class InMemoryDocumentStore:
|
|||||||
For a detailed specification of the filters, refer to the DocumentStore.filter_documents() protocol documentation.
|
For a detailed specification of the filters, refer to the DocumentStore.filter_documents() protocol documentation.
|
||||||
|
|
||||||
:param filters: The filters to apply to the document list.
|
:param filters: The filters to apply to the document list.
|
||||||
:return: A list of Documents that match the given filters.
|
:returns: A list of Documents that match the given filters.
|
||||||
"""
|
"""
|
||||||
if filters:
|
if filters:
|
||||||
if "operator" not in filters and "conditions" not in filters:
|
if "operator" not in filters and "conditions" not in filters:
|
||||||
@ -132,7 +140,7 @@ class InMemoryDocumentStore:
|
|||||||
def delete_documents(self, document_ids: List[str]) -> None:
|
def delete_documents(self, document_ids: List[str]) -> None:
|
||||||
"""
|
"""
|
||||||
Deletes all documents with matching document_ids from the DocumentStore.
|
Deletes all documents with matching document_ids from the DocumentStore.
|
||||||
:param object_ids: The object_ids to delete.
|
:param document_ids: The object_ids to delete.
|
||||||
"""
|
"""
|
||||||
for doc_id in document_ids:
|
for doc_id in document_ids:
|
||||||
if doc_id not in self.storage.keys():
|
if doc_id not in self.storage.keys():
|
||||||
@ -149,7 +157,7 @@ class InMemoryDocumentStore:
|
|||||||
:param filters: A dictionary with filters to narrow down the search space.
|
:param filters: A dictionary with filters to narrow down the search space.
|
||||||
:param top_k: The number of top documents to retrieve. Default is 10.
|
:param top_k: The number of top documents to retrieve. Default is 10.
|
||||||
:param scale_score: Whether to scale the scores of the retrieved documents. Default is False.
|
:param scale_score: Whether to scale the scores of the retrieved documents. Default is False.
|
||||||
:return: A list of the top_k documents most relevant to the query.
|
:returns: A list of the top_k documents most relevant to the query.
|
||||||
"""
|
"""
|
||||||
if not query:
|
if not query:
|
||||||
raise ValueError("Query should be a non-empty string")
|
raise ValueError("Query should be a non-empty string")
|
||||||
@ -242,7 +250,7 @@ class InMemoryDocumentStore:
|
|||||||
:param top_k: The number of top documents to retrieve. Default is 10.
|
:param top_k: The number of top documents to retrieve. Default is 10.
|
||||||
:param scale_score: Whether to scale the scores of the retrieved Documents. Default is False.
|
:param scale_score: Whether to scale the scores of the retrieved Documents. Default is False.
|
||||||
:param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.
|
:param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.
|
||||||
:return: A list of the top_k documents most relevant to the query.
|
:returns: A list of the top_k documents most relevant to the query.
|
||||||
"""
|
"""
|
||||||
if len(query_embedding) == 0 or not isinstance(query_embedding[0], float):
|
if len(query_embedding) == 0 or not isinstance(query_embedding[0], float):
|
||||||
raise ValueError("query_embedding should be a non-empty list of floats.")
|
raise ValueError("query_embedding should be a non-empty list of floats.")
|
||||||
@ -287,7 +295,7 @@ class InMemoryDocumentStore:
|
|||||||
:param embedding: Embedding of the query.
|
:param embedding: Embedding of the query.
|
||||||
:param documents: A list of Documents.
|
:param documents: A list of Documents.
|
||||||
:param scale_score: Whether to scale the scores of the Documents. Default is False.
|
:param scale_score: Whether to scale the scores of the Documents. Default is False.
|
||||||
:return: A list of scores.
|
:returns: A list of scores.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query_embedding = np.array(embedding)
|
query_embedding = np.array(embedding)
|
||||||
|
|||||||
@ -105,7 +105,7 @@ class DocumentStore(Protocol):
|
|||||||
}
|
}
|
||||||
|
|
||||||
:param filters: the filters to apply to the document list.
|
:param filters: the filters to apply to the document list.
|
||||||
:return: a list of Documents that match the given filters.
|
:returns: a list of Documents that match the given filters.
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class DocumentStore(Protocol):
|
|||||||
- `DuplicatePolicy.OVERWRITE`: If a Document with the same id already exists, it is overwritten.
|
- `DuplicatePolicy.OVERWRITE`: If a Document with the same id already exists, it is overwritten.
|
||||||
- `DuplicatePolicy.FAIL`: If a Document with the same id already exists, an error is raised.
|
- `DuplicatePolicy.FAIL`: If a Document with the same id already exists, an error is raised.
|
||||||
:raises DuplicateError: If `policy` is set to `DuplicatePolicy.FAIL` and a Document with the same id already exists.
|
:raises DuplicateError: If `policy` is set to `DuplicatePolicy.FAIL` and a Document with the same id already exists.
|
||||||
:return: The number of Documents written.
|
:returns: The number of Documents written.
|
||||||
If `DuplicatePolicy.OVERWRITE` is used, this number is always equal to the number of documents in input.
|
If `DuplicatePolicy.OVERWRITE` is used, this number is always equal to the number of documents in input.
|
||||||
If `DuplicatePolicy.SKIP` is used, this number can be lower than the number of documents in the input list.
|
If `DuplicatePolicy.SKIP` is used, this number can be lower than the number of documents in the input list.
|
||||||
"""
|
"""
|
||||||
@ -129,8 +129,9 @@ class DocumentStore(Protocol):
|
|||||||
def delete_documents(self, document_ids: List[str]) -> None:
|
def delete_documents(self, document_ids: List[str]) -> None:
|
||||||
"""
|
"""
|
||||||
Deletes all documents with a matching document_ids from the DocumentStore.
|
Deletes all documents with a matching document_ids from the DocumentStore.
|
||||||
|
|
||||||
Fails with `MissingDocumentError` if no document with this id is present in the DocumentStore.
|
Fails with `MissingDocumentError` if no document with this id is present in the DocumentStore.
|
||||||
|
|
||||||
:param object_ids: the object_ids to delete
|
:param document_ids: the object_ids to delete
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user