Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Qdrant - remove unused init parameters: content_field, name_field, embedding_field, and duplicate_documents #861

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
def convert_haystack_documents_to_qdrant_points(
documents: List[Document],
*,
embedding_field: str,
use_sparse_embeddings: bool,
) -> List[rest.PointStruct]:
points = []
Expand All @@ -26,7 +25,7 @@ def convert_haystack_documents_to_qdrant_points(
if use_sparse_embeddings:
vector = {}

dense_vector = payload.pop(embedding_field, None)
dense_vector = payload.pop("embedding", None)
if dense_vector is not None:
vector[DENSE_VECTORS_NAME] = dense_vector

Expand All @@ -36,7 +35,7 @@ def convert_haystack_documents_to_qdrant_points(
vector[SPARSE_VECTORS_NAME] = sparse_vector_instance

else:
vector = payload.pop(embedding_field) or {}
vector = payload.pop("embedding") or {}
_id = convert_id(payload.get("id"))

point = rest.PointStruct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,10 @@ def __init__(
index: str = "Document",
embedding_dim: int = 768,
on_disk: bool = False,
content_field: str = "content",
name_field: str = "name",
embedding_field: str = "embedding",
use_sparse_embeddings: bool = False,
similarity: str = "cosine",
return_embedding: bool = False,
progress_bar: bool = True,
duplicate_documents: str = "overwrite",
recreate_index: bool = False,
shard_number: Optional[int] = None,
replication_factor: Optional[int] = None,
Expand Down Expand Up @@ -170,12 +166,6 @@ def __init__(
Dimension of the embeddings.
:param on_disk:
Whether to store the collection on disk.
:param content_field:
The field for the document content.
:param name_field:
The field for the document name.
:param embedding_field:
The field for the document embeddings.
:param use_sparse_embedding:
If set to `True`, enables support for sparse embeddings.
:param similarity:
Expand All @@ -184,8 +174,6 @@ def __init__(
Whether to return embeddings in the search results.
:param progress_bar:
Whether to show a progress bar or not.
:param duplicate_documents:
The parameter is not used and will be removed in future release.
:param recreate_index:
Whether to recreate the index.
:param shard_number:
Expand Down Expand Up @@ -260,14 +248,10 @@ def __init__(
self.use_sparse_embeddings = use_sparse_embeddings
self.embedding_dim = embedding_dim
self.on_disk = on_disk
self.content_field = content_field
self.name_field = name_field
self.embedding_field = embedding_field
self.similarity = similarity
self.index = index
self.return_embedding = return_embedding
self.progress_bar = progress_bar
self.duplicate_documents = duplicate_documents
self.write_batch_size = write_batch_size
self.scroll_size = scroll_size

Expand Down Expand Up @@ -380,7 +364,6 @@ def write_documents(
for document_batch in batched_documents:
batch = convert_haystack_documents_to_qdrant_points(
document_batch,
embedding_field=self.embedding_field,
use_sparse_embeddings=self.use_sparse_embeddings,
)

Expand Down Expand Up @@ -891,12 +874,7 @@ def _handle_duplicate_documents(

:param documents: A list of Haystack Document objects.
:param index: name of the index
:param duplicate_documents: Handle duplicate documents based on parameter options.
Parameter options : ( 'skip','overwrite','fail')
skip (default option): Ignore the duplicates documents.
overwrite: Update any existing documents with the same ID when adding documents.
fail: An error is raised if the document ID of the document being added already
exists.
:param duplicate_documents: The duplicate policy to use when writing documents.
julian-risch marked this conversation as resolved.
Show resolved Hide resolved
:returns: A list of Haystack Document objects.
"""

Expand Down
12 changes: 0 additions & 12 deletions integrations/qdrant/tests/test_dict_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ def test_to_dict():
"index": "test",
"embedding_dim": 768,
"on_disk": False,
"content_field": "content",
"name_field": "name",
"embedding_field": "embedding",
"force_disable_check_same_thread": False,
"use_sparse_embeddings": False,
"similarity": "cosine",
"return_embedding": False,
"progress_bar": True,
"duplicate_documents": "overwrite",
"recreate_index": False,
"shard_number": None,
"replication_factor": None,
Expand Down Expand Up @@ -62,15 +58,11 @@ def test_from_dict():
"index": "test",
"embedding_dim": 768,
"on_disk": False,
"content_field": "content",
"name_field": "name",
"embedding_field": "embedding",
"force_disable_check_same_thread": False,
"use_sparse_embeddings": True,
"similarity": "cosine",
"return_embedding": False,
"progress_bar": True,
"duplicate_documents": "overwrite",
"recreate_index": True,
"shard_number": None,
"quantization_config": None,
Expand All @@ -87,16 +79,12 @@ def test_from_dict():
assert all(
[
document_store.index == "test",
document_store.content_field == "content",
document_store.name_field == "name",
document_store.embedding_field == "embedding",
document_store.force_disable_check_same_thread is False,
document_store.use_sparse_embeddings is True,
document_store.on_disk is False,
document_store.similarity == "cosine",
document_store.return_embedding is False,
document_store.progress_bar,
document_store.duplicate_documents == "overwrite",
document_store.recreate_index is True,
document_store.shard_number is None,
document_store.replication_factor is None,
Expand Down
12 changes: 0 additions & 12 deletions integrations/qdrant/tests/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ def test_to_dict(self):
"index": "test",
"embedding_dim": 768,
"on_disk": False,
"content_field": "content",
"name_field": "name",
"force_disable_check_same_thread": False,
"embedding_field": "embedding",
"use_sparse_embeddings": False,
"similarity": "cosine",
"return_embedding": False,
"progress_bar": True,
"duplicate_documents": "overwrite",
"recreate_index": False,
"shard_number": None,
"replication_factor": None,
Expand Down Expand Up @@ -170,15 +166,11 @@ def test_to_dict(self):
"index": "test",
"embedding_dim": 768,
"on_disk": False,
"content_field": "content",
"name_field": "name",
"embedding_field": "embedding",
"force_disable_check_same_thread": False,
"use_sparse_embeddings": False,
"similarity": "cosine",
"return_embedding": False,
"progress_bar": True,
"duplicate_documents": "overwrite",
"recreate_index": False,
"shard_number": None,
"replication_factor": None,
Expand Down Expand Up @@ -280,15 +272,11 @@ def test_to_dict(self):
"index": "test",
"embedding_dim": 768,
"on_disk": False,
"content_field": "content",
"name_field": "name",
"embedding_field": "embedding",
"force_disable_check_same_thread": False,
"use_sparse_embeddings": False,
"similarity": "cosine",
"return_embedding": False,
"progress_bar": True,
"duplicate_documents": "overwrite",
"recreate_index": False,
"shard_number": None,
"replication_factor": None,
Expand Down