qdrant-haystack 3.6.0__py3-none-any.whl → 3.8.0__py3-none-any.whl
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.
Potentially problematic release.
This version of qdrant-haystack might be problematic. Click here for more details.
- haystack_integrations/document_stores/qdrant/document_store.py +22 -25
- {qdrant_haystack-3.6.0.dist-info → qdrant_haystack-3.8.0.dist-info}/METADATA +1 -1
- {qdrant_haystack-3.6.0.dist-info → qdrant_haystack-3.8.0.dist-info}/RECORD +5 -5
- {qdrant_haystack-3.6.0.dist-info → qdrant_haystack-3.8.0.dist-info}/WHEEL +0 -0
- {qdrant_haystack-3.6.0.dist-info → qdrant_haystack-3.8.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -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
|
|
@@ -69,6 +68,7 @@ class QdrantDocumentStore:
|
|
|
69
68
|
timeout: Optional[int] = None,
|
|
70
69
|
host: Optional[str] = None,
|
|
71
70
|
path: Optional[str] = None,
|
|
71
|
+
force_disable_check_same_thread: bool = False,
|
|
72
72
|
index: str = "Document",
|
|
73
73
|
embedding_dim: int = 768,
|
|
74
74
|
on_disk: bool = False,
|
|
@@ -110,6 +110,7 @@ class QdrantDocumentStore:
|
|
|
110
110
|
self.timeout = timeout
|
|
111
111
|
self.host = host
|
|
112
112
|
self.path = path
|
|
113
|
+
self.force_disable_check_same_thread = force_disable_check_same_thread
|
|
113
114
|
self.metadata = metadata or {}
|
|
114
115
|
self.api_key = api_key
|
|
115
116
|
|
|
@@ -156,6 +157,7 @@ class QdrantDocumentStore:
|
|
|
156
157
|
host=self.host,
|
|
157
158
|
path=self.path,
|
|
158
159
|
metadata=self.metadata,
|
|
160
|
+
force_disable_check_same_thread=self.force_disable_check_same_thread,
|
|
159
161
|
)
|
|
160
162
|
# Make sure the collection is properly set up
|
|
161
163
|
self._set_up_collection(
|
|
@@ -471,7 +473,7 @@ class QdrantDocumentStore:
|
|
|
471
473
|
|
|
472
474
|
return results
|
|
473
475
|
|
|
474
|
-
def
|
|
476
|
+
def get_distance(self, similarity: str) -> rest.Distance:
|
|
475
477
|
try:
|
|
476
478
|
return self.SIMILARITY[similarity]
|
|
477
479
|
except KeyError as ke:
|
|
@@ -505,31 +507,17 @@ class QdrantDocumentStore:
|
|
|
505
507
|
on_disk: bool = False,
|
|
506
508
|
payload_fields_to_index: Optional[List[dict]] = None,
|
|
507
509
|
):
|
|
508
|
-
distance = self.
|
|
510
|
+
distance = self.get_distance(similarity)
|
|
509
511
|
|
|
510
|
-
if recreate_collection:
|
|
512
|
+
if recreate_collection or not self.client.collection_exists(collection_name):
|
|
511
513
|
# There is no need to verify the current configuration of that
|
|
512
|
-
# collection. It might be just recreated again.
|
|
513
|
-
self.
|
|
514
|
+
# collection. It might be just recreated again or does not exist yet.
|
|
515
|
+
self.recreate_collection(collection_name, distance, embedding_dim, on_disk, use_sparse_embeddings)
|
|
514
516
|
# Create Payload index if payload_fields_to_index is provided
|
|
515
517
|
self._create_payload_index(collection_name, payload_fields_to_index)
|
|
516
518
|
return
|
|
517
519
|
|
|
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
|
|
520
|
+
collection_info = self.client.get_collection(collection_name)
|
|
533
521
|
|
|
534
522
|
has_named_vectors = (
|
|
535
523
|
isinstance(collection_info.config.params.vectors, dict)
|
|
@@ -580,14 +568,20 @@ class QdrantDocumentStore:
|
|
|
580
568
|
)
|
|
581
569
|
raise ValueError(msg)
|
|
582
570
|
|
|
583
|
-
def
|
|
571
|
+
def recreate_collection(
|
|
584
572
|
self,
|
|
585
573
|
collection_name: str,
|
|
586
574
|
distance,
|
|
587
575
|
embedding_dim: int,
|
|
588
|
-
on_disk: bool,
|
|
589
|
-
use_sparse_embeddings: bool,
|
|
576
|
+
on_disk: Optional[bool] = None,
|
|
577
|
+
use_sparse_embeddings: Optional[bool] = None,
|
|
590
578
|
):
|
|
579
|
+
if on_disk is None:
|
|
580
|
+
on_disk = self.on_disk
|
|
581
|
+
|
|
582
|
+
if use_sparse_embeddings is None:
|
|
583
|
+
use_sparse_embeddings = self.use_sparse_embeddings
|
|
584
|
+
|
|
591
585
|
# dense vectors configuration
|
|
592
586
|
vectors_config = rest.VectorParams(size=embedding_dim, on_disk=on_disk, distance=distance)
|
|
593
587
|
|
|
@@ -603,7 +597,10 @@ class QdrantDocumentStore:
|
|
|
603
597
|
),
|
|
604
598
|
}
|
|
605
599
|
|
|
606
|
-
self.client.
|
|
600
|
+
if self.client.collection_exists(collection_name):
|
|
601
|
+
self.client.delete_collection(collection_name)
|
|
602
|
+
|
|
603
|
+
self.client.create_collection(
|
|
607
604
|
collection_name=collection_name,
|
|
608
605
|
vectors_config=vectors_config,
|
|
609
606
|
sparse_vectors_config=sparse_vectors_config if use_sparse_embeddings else None,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: qdrant-haystack
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.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
|
|
@@ -2,10 +2,10 @@ haystack_integrations/components/retrievers/qdrant/__init__.py,sha256=IRjcM4f8b5
|
|
|
2
2
|
haystack_integrations/components/retrievers/qdrant/retriever.py,sha256=r416_a7_6l7ehfPLdFtyHncsPrHj3mFCyROeJJF9rwM,13463
|
|
3
3
|
haystack_integrations/document_stores/qdrant/__init__.py,sha256=kUGc5uewqArhmVR-JqB_NmJ4kNkTIQIvYDNSoO2ELn0,302
|
|
4
4
|
haystack_integrations/document_stores/qdrant/converters.py,sha256=oSO2YlsWEQbcw9CPlWfSg_HoTZlnkAhZw_6VlYWzKKs,2525
|
|
5
|
-
haystack_integrations/document_stores/qdrant/document_store.py,sha256=
|
|
5
|
+
haystack_integrations/document_stores/qdrant/document_store.py,sha256=B8oR4621IrnXKKvYycP7CLUmo8T5xK48Lmk3bDErzIs,26567
|
|
6
6
|
haystack_integrations/document_stores/qdrant/filters.py,sha256=0w70Wa3Za1fNdbJ5O95sZDIpXfblJG_sBBUv0JTQ0-o,8337
|
|
7
7
|
haystack_integrations/document_stores/qdrant/migrate_to_sparse.py,sha256=i6wBC_9_JVzYZtqKm3dhHKTxhwNdcAdpgki8GABDp1c,4909
|
|
8
|
-
qdrant_haystack-3.
|
|
9
|
-
qdrant_haystack-3.
|
|
10
|
-
qdrant_haystack-3.
|
|
11
|
-
qdrant_haystack-3.
|
|
8
|
+
qdrant_haystack-3.8.0.dist-info/METADATA,sha256=FsZssukO3zv1nkdEhOHiz-sLBrk41Ta9u64mWuZC_Ec,1862
|
|
9
|
+
qdrant_haystack-3.8.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
10
|
+
qdrant_haystack-3.8.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
|
|
11
|
+
qdrant_haystack-3.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|