From f594c7d156ac3d2f1f2395717959198ac2059c69 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 3 Jul 2024 16:41:29 +0300 Subject: [PATCH] fix: fix sparse vector config conversion in collection params (#674) --- qdrant_client/conversions/conversion.py | 8 ++++++++ tests/conversions/fixtures.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/qdrant_client/conversions/conversion.py b/qdrant_client/conversions/conversion.py index 4050f716..d9c7639b 100644 --- a/qdrant_client/conversions/conversion.py +++ b/qdrant_client/conversions/conversion.py @@ -609,6 +609,9 @@ def convert_collection_params(cls, model: grpc.CollectionParams) -> rest.Collect if model.HasField("write_consistency_factor") else None ), + sparse_vectors=cls.convert_sparse_vector_config(model.sparse_vectors_config) + if model.HasField("sparse_vectors_config") + else None, ) @classmethod @@ -2023,6 +2026,11 @@ def convert_collection_params(cls, model: rest.CollectionParams) -> grpc.Collect write_consistency_factor=model.write_consistency_factor, replication_factor=model.replication_factor, read_fan_out_factor=model.read_fan_out_factor, + sparse_vectors_config=( + cls.convert_sparse_vector_config(model.sparse_vectors) + if model.sparse_vectors is not None + else None + ), ) @classmethod diff --git a/tests/conversions/fixtures.py b/tests/conversions/fixtures.py index dffda520..86b21c09 100644 --- a/tests/conversions/fixtures.py +++ b/tests/conversions/fixtures.py @@ -211,6 +211,9 @@ params_map=grpc.VectorParamsMap(map={"text_vector": vector_param}) ) +sparse_vector_config = grpc.SparseVectorConfig( + map={"sparse": grpc.SparseVectorParams(index=grpc.SparseIndexConfig(full_scan_threshold=1212))} +) collection_params = grpc.CollectionParams( vectors_config=single_vector_config, shard_number=10, @@ -222,6 +225,7 @@ replication_factor=2, write_consistency_factor=1, read_fan_out_factor=2, + sparse_vectors_config=sparse_vector_config, ) hnsw_config = grpc.HnswConfigDiff(