Skip to content

Commit

Permalink
Update API to v1.13 (#874)
Browse files Browse the repository at this point in the history
* update openapi and grpc + conversions

* add strict mode to conversions + coverage

* add strict mode to collection creation

* add local mode for has_vectors condition

* regen async with python 3.10

* tests for has-vector

* fix filters in tests

* fix conversion

* fix test

* Has vector tests (#878)

* new: add has vector fixture

* tests: add has vector multivector test

* fix: add missing strict mode config usage and conversion (#877)

* fix: add missing strict mode config usage and conversion

* fix: pass strict mode config in update collection

* fix: add strict mode config to recreate collection

---------

Co-authored-by: George <[email protected]>
  • Loading branch information
generall and joein authored Jan 6, 2025
1 parent 67b7eb8 commit 3f56da7
Show file tree
Hide file tree
Showing 22 changed files with 1,016 additions and 417 deletions.
2 changes: 1 addition & 1 deletion qdrant_client/_pydantic_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def model_fields_set(model: BaseModel) -> set:
return model.__fields_set__


def model_json_schema(model: BaseModel, *args: Any, **kwargs: Any) -> dict[str, Any]:
def model_json_schema(model: Type[BaseModel], *args: Any, **kwargs: Any) -> dict[str, Any]:
if PYDANTIC_V2:
return model.model_json_schema(*args, **kwargs)
else:
Expand Down
9 changes: 9 additions & 0 deletions qdrant_client/async_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,7 @@ async def update_collection(
quantization_config: Optional[types.QuantizationConfigDiff] = None,
timeout: Optional[int] = None,
sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None,
strict_mode_config: Optional[types.StrictModeConfig] = None,
**kwargs: Any,
) -> bool:
"""Update parameters of the collection
Expand All @@ -2115,6 +2116,7 @@ async def update_collection(
Wait for operation commit timeout in seconds.
If timeout is reached - request will return with service error.
sparse_vectors_config: Override for sparse vector-specific configuration
strict_mode_config: Override for strict mode configuration
Returns:
Operation result
"""
Expand All @@ -2134,6 +2136,7 @@ async def update_collection(
quantization_config=quantization_config,
timeout=timeout,
sparse_vectors_config=sparse_vectors_config,
strict_mode_config=strict_mode_config,
**kwargs,
)

Expand Down Expand Up @@ -2172,6 +2175,7 @@ async def create_collection(
quantization_config: Optional[types.QuantizationConfig] = None,
init_from: Optional[types.InitFrom] = None,
timeout: Optional[int] = None,
strict_mode_config: Optional[types.StrictModeConfig] = None,
**kwargs: Any,
) -> bool:
"""Create empty collection with given parameters
Expand Down Expand Up @@ -2217,6 +2221,7 @@ async def create_collection(
timeout:
Wait for operation commit timeout in seconds.
If timeout is reached - request will return with service error.
strict_mode_config: Configure limitations for the collection, such as max size, rate limits, etc.
Returns:
Operation result
Expand All @@ -2237,6 +2242,7 @@ async def create_collection(
init_from=init_from,
timeout=timeout,
sparse_vectors_config=sparse_vectors_config,
strict_mode_config=strict_mode_config,
**kwargs,
)

Expand All @@ -2256,6 +2262,7 @@ async def recreate_collection(
quantization_config: Optional[types.QuantizationConfig] = None,
init_from: Optional[types.InitFrom] = None,
timeout: Optional[int] = None,
strict_mode_config: Optional[types.StrictModeConfig] = None,
**kwargs: Any,
) -> bool:
"""Delete and create empty collection with given parameters
Expand Down Expand Up @@ -2301,6 +2308,7 @@ async def recreate_collection(
timeout:
Wait for operation commit timeout in seconds.
If timeout is reached - request will return with service error.
strict_mode_config: Configure limitations for the collection, such as max size, rate limits, etc.
Returns:
Operation result
Expand All @@ -2326,6 +2334,7 @@ async def recreate_collection(
init_from=init_from,
timeout=timeout,
sparse_vectors_config=sparse_vectors_config,
strict_mode_config=strict_mode_config,
**kwargs,
)

Expand Down
12 changes: 12 additions & 0 deletions qdrant_client/async_qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,7 @@ async def update_collection(
quantization_config: Optional[types.QuantizationConfigDiff] = None,
timeout: Optional[int] = None,
sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None,
strict_mode_config: Optional[types.StrictModeConfig] = None,
**kwargs: Any,
) -> bool:
if self._prefer_grpc:
Expand All @@ -2352,6 +2353,8 @@ async def update_collection(
sparse_vectors_config = RestToGrpc.convert_sparse_vector_config(
sparse_vectors_config
)
if isinstance(strict_mode_config, models.StrictModeConfig):
strict_mode_config = RestToGrpc.convert_strict_mode_config(strict_mode_config)
return (
await self.grpc_collections.Update(
grpc.UpdateCollection(
Expand All @@ -2362,6 +2365,7 @@ async def update_collection(
hnsw_config=hnsw_config,
quantization_config=quantization_config,
sparse_vectors_config=sparse_vectors_config,
strict_mode_config=strict_mode_config,
timeout=timeout,
),
timeout=timeout if timeout is not None else self._timeout,
Expand All @@ -2387,6 +2391,7 @@ async def update_collection(
hnsw_config=hnsw_config,
quantization_config=quantization_config,
sparse_vectors=sparse_vectors_config,
strict_mode_config=strict_mode_config,
),
timeout=timeout,
)
Expand Down Expand Up @@ -2426,6 +2431,7 @@ async def create_collection(
timeout: Optional[int] = None,
sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None,
sharding_method: Optional[types.ShardingMethod] = None,
strict_mode_config: Optional[types.StrictModeConfig] = None,
**kwargs: Any,
) -> bool:
if init_from is not None:
Expand All @@ -2449,6 +2455,8 @@ async def create_collection(
)
if isinstance(sharding_method, models.ShardingMethod):
sharding_method = RestToGrpc.convert_sharding_method(sharding_method)
if isinstance(strict_mode_config, models.StrictModeConfig):
strict_mode_config = RestToGrpc.convert_strict_mode_config(strict_mode_config)
create_collection = grpc.CreateCollection(
collection_name=collection_name,
hnsw_config=hnsw_config,
Expand All @@ -2464,6 +2472,7 @@ async def create_collection(
quantization_config=quantization_config,
sparse_vectors_config=sparse_vectors_config,
sharding_method=sharding_method,
strict_mode_config=strict_mode_config,
)
return (
await self.grpc_collections.Create(create_collection, timeout=self._timeout)
Expand Down Expand Up @@ -2491,6 +2500,7 @@ async def create_collection(
init_from=init_from,
sparse_vectors=sparse_vectors_config,
sharding_method=sharding_method,
strict_mode_config=strict_mode_config,
)
result: Optional[bool] = (
await self.http.collections_api.create_collection(
Expand Down Expand Up @@ -2518,6 +2528,7 @@ async def recreate_collection(
timeout: Optional[int] = None,
sparse_vectors_config: Optional[Mapping[str, types.SparseVectorParams]] = None,
sharding_method: Optional[types.ShardingMethod] = None,
strict_mode_config: Optional[types.StrictModeConfig] = None,
**kwargs: Any,
) -> bool:
await self.delete_collection(collection_name, timeout=timeout)
Expand All @@ -2536,6 +2547,7 @@ async def recreate_collection(
timeout=timeout,
sparse_vectors_config=sparse_vectors_config,
sharding_method=sharding_method,
strict_mode_config=strict_mode_config,
)

@property
Expand Down
1 change: 1 addition & 0 deletions qdrant_client/conversions/common_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def get_args_subscribed(tp): # type: ignore
Document: TypeAlias = rest.Document
Image: TypeAlias = rest.Image
InferenceObject: TypeAlias = rest.InferenceObject
StrictModeConfig: TypeAlias = rest.StrictModeConfig

SearchRequest = Union[rest.SearchRequest, grpc.SearchPoints]
RecommendRequest = Union[rest.RecommendRequest, grpc.RecommendPoints]
Expand Down
Loading

0 comments on commit 3f56da7

Please sign in to comment.