qdrant-haystack 3.6.0__tar.gz → 3.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/PKG-INFO +1 -1
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/document_stores/qdrant/document_store.py +19 -25
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/.gitignore +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/LICENSE.txt +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/README.md +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/examples/embedding_retrieval.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/pydoc/config.yml +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/pyproject.toml +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/components/retrievers/qdrant/__init__.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/components/retrievers/qdrant/retriever.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/document_stores/qdrant/__init__.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/document_stores/qdrant/converters.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/document_stores/qdrant/filters.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/src/haystack_integrations/document_stores/qdrant/migrate_to_sparse.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/__init__.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/conftest.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/test_converters.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/test_dict_converters.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/test_document_store.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/test_filters.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/test_legacy_filters.py +0 -0
- {qdrant_haystack-3.6.0 → qdrant_haystack-3.7.0}/tests/test_retriever.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: qdrant-haystack
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.0
|
|
4
4
|
Summary: An integration of Qdrant ANN vector database backend with Haystack
|
|
5
5
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
|
|
6
6
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/qdrant/README.md
|
|
@@ -5,7 +5,6 @@ from typing import Any, ClassVar, Dict, Generator, List, Optional, Set, Union
|
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import qdrant_client
|
|
8
|
-
from grpc import RpcError
|
|
9
8
|
from haystack import default_from_dict, default_to_dict
|
|
10
9
|
from haystack.dataclasses import Document
|
|
11
10
|
from haystack.dataclasses.sparse_embedding import SparseEmbedding
|
|
@@ -471,7 +470,7 @@ class QdrantDocumentStore:
|
|
|
471
470
|
|
|
472
471
|
return results
|
|
473
472
|
|
|
474
|
-
def
|
|
473
|
+
def get_distance(self, similarity: str) -> rest.Distance:
|
|
475
474
|
try:
|
|
476
475
|
return self.SIMILARITY[similarity]
|
|
477
476
|
except KeyError as ke:
|
|
@@ -505,31 +504,17 @@ class QdrantDocumentStore:
|
|
|
505
504
|
on_disk: bool = False,
|
|
506
505
|
payload_fields_to_index: Optional[List[dict]] = None,
|
|
507
506
|
):
|
|
508
|
-
distance = self.
|
|
507
|
+
distance = self.get_distance(similarity)
|
|
509
508
|
|
|
510
|
-
if recreate_collection:
|
|
509
|
+
if recreate_collection or not self.client.collection_exists(collection_name):
|
|
511
510
|
# There is no need to verify the current configuration of that
|
|
512
|
-
# collection. It might be just recreated again.
|
|
513
|
-
self.
|
|
511
|
+
# collection. It might be just recreated again or does not exist yet.
|
|
512
|
+
self.recreate_collection(collection_name, distance, embedding_dim, on_disk, use_sparse_embeddings)
|
|
514
513
|
# Create Payload index if payload_fields_to_index is provided
|
|
515
514
|
self._create_payload_index(collection_name, payload_fields_to_index)
|
|
516
515
|
return
|
|
517
516
|
|
|
518
|
-
|
|
519
|
-
# Check if the collection already exists and validate its
|
|
520
|
-
# current configuration with the parameters.
|
|
521
|
-
collection_info = self.client.get_collection(collection_name)
|
|
522
|
-
except (UnexpectedResponse, RpcError, ValueError):
|
|
523
|
-
# That indicates the collection does not exist, so it can be
|
|
524
|
-
# safely created with any configuration.
|
|
525
|
-
#
|
|
526
|
-
# Qdrant local raises ValueError if the collection is not found, but
|
|
527
|
-
# with the remote server UnexpectedResponse / RpcError is raised.
|
|
528
|
-
# Until that's unified, we need to catch both.
|
|
529
|
-
self._recreate_collection(collection_name, distance, embedding_dim, on_disk, use_sparse_embeddings)
|
|
530
|
-
# Create Payload index if payload_fields_to_index is provided
|
|
531
|
-
self._create_payload_index(collection_name, payload_fields_to_index)
|
|
532
|
-
return
|
|
517
|
+
collection_info = self.client.get_collection(collection_name)
|
|
533
518
|
|
|
534
519
|
has_named_vectors = (
|
|
535
520
|
isinstance(collection_info.config.params.vectors, dict)
|
|
@@ -580,14 +565,20 @@ class QdrantDocumentStore:
|
|
|
580
565
|
)
|
|
581
566
|
raise ValueError(msg)
|
|
582
567
|
|
|
583
|
-
def
|
|
568
|
+
def recreate_collection(
|
|
584
569
|
self,
|
|
585
570
|
collection_name: str,
|
|
586
571
|
distance,
|
|
587
572
|
embedding_dim: int,
|
|
588
|
-
on_disk: bool,
|
|
589
|
-
use_sparse_embeddings: bool,
|
|
573
|
+
on_disk: Optional[bool] = None,
|
|
574
|
+
use_sparse_embeddings: Optional[bool] = None,
|
|
590
575
|
):
|
|
576
|
+
if on_disk is None:
|
|
577
|
+
on_disk = self.on_disk
|
|
578
|
+
|
|
579
|
+
if use_sparse_embeddings is None:
|
|
580
|
+
use_sparse_embeddings = self.use_sparse_embeddings
|
|
581
|
+
|
|
591
582
|
# dense vectors configuration
|
|
592
583
|
vectors_config = rest.VectorParams(size=embedding_dim, on_disk=on_disk, distance=distance)
|
|
593
584
|
|
|
@@ -603,7 +594,10 @@ class QdrantDocumentStore:
|
|
|
603
594
|
),
|
|
604
595
|
}
|
|
605
596
|
|
|
606
|
-
self.client.
|
|
597
|
+
if self.client.collection_exists(collection_name):
|
|
598
|
+
self.client.delete_collection(collection_name)
|
|
599
|
+
|
|
600
|
+
self.client.create_collection(
|
|
607
601
|
collection_name=collection_name,
|
|
608
602
|
vectors_config=vectors_config,
|
|
609
603
|
sparse_vectors_config=sparse_vectors_config if use_sparse_embeddings else None,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|