qdrant-haystack 3.6.0__py3-none-any.whl → 3.7.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.

@@ -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 _get_distance(self, similarity: str) -> rest.Distance:
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._get_distance(similarity)
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._recreate_collection(collection_name, distance, embedding_dim, on_disk, use_sparse_embeddings)
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
- try:
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 _recreate_collection(
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.recreate_collection(
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qdrant-haystack
3
- Version: 3.6.0
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
@@ -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=ouPp-oM1M4VvkYtpZ2pl5kGVQ5Ei4kc--Jwd7cYRlzk,26827
5
+ haystack_integrations/document_stores/qdrant/document_store.py,sha256=JOOBaE4nGWAp8MZmjsBgYIYUZzZCLrRUGa8KNwiVEd0,26347
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.6.0.dist-info/METADATA,sha256=8pAGEH2tOoSqU-YXe0hoCfgUUOMEdcV1KSEcj4YMOsM,1862
9
- qdrant_haystack-3.6.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
10
- qdrant_haystack-3.6.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
11
- qdrant_haystack-3.6.0.dist-info/RECORD,,
8
+ qdrant_haystack-3.7.0.dist-info/METADATA,sha256=Q2rwJIK4Cw96sSyHuOJY1w8az1kVk4jUMIBLbqSKJGI,1862
9
+ qdrant_haystack-3.7.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
10
+ qdrant_haystack-3.7.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
11
+ qdrant_haystack-3.7.0.dist-info/RECORD,,