-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathmodels.py
3459 lines (2671 loc) · 138 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from datetime import date, datetime
from enum import Enum
from typing import Any, Dict, List, Literal, Optional, Union
from uuid import UUID
from pydantic import BaseModel, Field
from pydantic.types import StrictBool, StrictFloat, StrictInt, StrictStr
Payload = Dict[str, Any]
SparseVectorsConfig = Dict[str, "SparseVectorParams"]
StrictModeMultivectorConfig = Dict[str, "StrictModeMultivector"]
StrictModeMultivectorConfigOutput = Dict[str, "StrictModeMultivectorOutput"]
StrictModeSparseConfig = Dict[str, "StrictModeSparse"]
StrictModeSparseConfigOutput = Dict[str, "StrictModeSparseOutput"]
VectorsConfigDiff = Dict[str, "VectorParamsDiff"]
class AbortReshardingOperation(BaseModel, extra="forbid"):
abort_resharding: Any = Field(..., description="")
class AbortShardTransfer(BaseModel, extra="forbid"):
shard_id: int = Field(..., description="")
to_peer_id: int = Field(..., description="")
from_peer_id: int = Field(..., description="")
class AbortTransferOperation(BaseModel, extra="forbid"):
abort_transfer: "AbortShardTransfer" = Field(..., description="")
class AbsExpression(BaseModel, extra="forbid"):
abs: "Expression" = Field(..., description="")
class AliasDescription(BaseModel):
alias_name: str = Field(..., description="")
collection_name: str = Field(..., description="")
class AppBuildTelemetry(BaseModel):
name: str = Field(..., description="")
version: str = Field(..., description="")
features: Optional["AppFeaturesTelemetry"] = Field(default=None, description="")
system: Optional["RunningEnvironmentTelemetry"] = Field(default=None, description="")
jwt_rbac: Optional[bool] = Field(default=None, description="")
hide_jwt_dashboard: Optional[bool] = Field(default=None, description="")
startup: Union[datetime, date] = Field(..., description="")
class AppFeaturesTelemetry(BaseModel):
debug: bool = Field(..., description="")
web_feature: bool = Field(..., description="")
service_debug_feature: bool = Field(..., description="")
recovery_mode: bool = Field(..., description="")
gpu: bool = Field(..., description="")
class Batch(BaseModel, extra="forbid"):
ids: List["ExtendedPointId"] = Field(..., description="")
vectors: "BatchVectorStruct" = Field(..., description="")
payloads: Optional[List["Payload"]] = Field(default=None, description="")
class BinaryQuantization(BaseModel, extra="forbid"):
binary: "BinaryQuantizationConfig" = Field(..., description="")
class BinaryQuantizationConfig(BaseModel, extra="forbid"):
always_ram: Optional[bool] = Field(default=None, description="")
class BoolIndexParams(BaseModel, extra="forbid"):
type: "BoolIndexType" = Field(..., description="")
on_disk: Optional[bool] = Field(default=None, description="If true, store the index on disk. Default: false.")
class BoolIndexType(str, Enum):
BOOL = "bool"
class ChangeAliasesOperation(BaseModel, extra="forbid"):
"""
Operation for performing changes of collection aliases. Alias changes are atomic, meaning that no collection modifications can happen between alias operations.
"""
actions: List["AliasOperations"] = Field(
...,
description="Operation for performing changes of collection aliases. Alias changes are atomic, meaning that no collection modifications can happen between alias operations.",
)
class ClearPayloadOperation(BaseModel, extra="forbid"):
clear_payload: "PointsSelector" = Field(..., description="")
class ClusterConfigTelemetry(BaseModel):
grpc_timeout_ms: int = Field(..., description="")
p2p: "P2pConfigTelemetry" = Field(..., description="")
consensus: "ConsensusConfigTelemetry" = Field(..., description="")
class ClusterStatusOneOf(BaseModel):
status: Literal[
"disabled",
] = Field(..., description="")
class ClusterStatusOneOf1(BaseModel):
"""
Description of enabled cluster
"""
status: Literal[
"enabled",
] = Field(..., description="Description of enabled cluster")
peer_id: int = Field(..., description="ID of this peer")
peers: Dict[str, "PeerInfo"] = Field(..., description="Peers composition of the cluster with main information")
raft_info: "RaftInfo" = Field(..., description="Description of enabled cluster")
consensus_thread_status: "ConsensusThreadStatus" = Field(..., description="Description of enabled cluster")
message_send_failures: Dict[str, "MessageSendErrors"] = Field(
...,
description="Consequent failures of message send operations in consensus by peer address. On the first success to send to that peer - entry is removed from this hashmap.",
)
class ClusterStatusTelemetry(BaseModel):
number_of_peers: int = Field(..., description="")
term: int = Field(..., description="")
commit: int = Field(..., description="")
pending_operations: int = Field(..., description="")
role: Optional["StateRole"] = Field(default=None, description="")
is_voter: bool = Field(..., description="")
peer_id: Optional[int] = Field(default=None, description="")
consensus_thread_status: "ConsensusThreadStatus" = Field(..., description="")
class ClusterTelemetry(BaseModel):
enabled: bool = Field(..., description="")
status: Optional["ClusterStatusTelemetry"] = Field(default=None, description="")
config: Optional["ClusterConfigTelemetry"] = Field(default=None, description="")
peers: Optional[Dict[str, "PeerInfo"]] = Field(default=None, description="")
metadata: Optional[Dict[str, Any]] = Field(default=None, description="")
class CollectionClusterInfo(BaseModel):
"""
Current clustering distribution for the collection
"""
peer_id: int = Field(..., description="ID of this peer")
shard_count: int = Field(..., description="Total number of shards")
local_shards: List["LocalShardInfo"] = Field(..., description="Local shards")
remote_shards: List["RemoteShardInfo"] = Field(..., description="Remote shards")
shard_transfers: List["ShardTransferInfo"] = Field(..., description="Shard transfers")
resharding_operations: Optional[List["ReshardingInfo"]] = Field(default=None, description="Resharding operations")
class CollectionConfig(BaseModel):
"""
Information about the collection configuration
"""
params: "CollectionParams" = Field(..., description="Information about the collection configuration")
hnsw_config: "HnswConfig" = Field(..., description="Information about the collection configuration")
optimizer_config: "OptimizersConfig" = Field(..., description="Information about the collection configuration")
wal_config: Optional["WalConfig"] = Field(
default=None, description="Information about the collection configuration"
)
quantization_config: Optional["QuantizationConfig"] = Field(
default=None, description="Information about the collection configuration"
)
strict_mode_config: Optional["StrictModeConfigOutput"] = Field(
default=None, description="Information about the collection configuration"
)
class CollectionConfigTelemetry(BaseModel):
params: "CollectionParams" = Field(..., description="")
hnsw_config: "HnswConfig" = Field(..., description="")
optimizer_config: "OptimizersConfig" = Field(..., description="")
wal_config: "WalConfig" = Field(..., description="")
quantization_config: Optional["QuantizationConfig"] = Field(default=None, description="")
strict_mode_config: Optional["StrictModeConfigOutput"] = Field(default=None, description="")
uuid: Optional[UUID] = Field(default=None, description="")
class CollectionDescription(BaseModel):
name: str = Field(..., description="")
class CollectionExistence(BaseModel):
"""
State of existence of a collection, true = exists, false = does not exist
"""
exists: bool = Field(..., description="State of existence of a collection, true = exists, false = does not exist")
class CollectionInfo(BaseModel):
"""
Current statistics and configuration of the collection
"""
status: "CollectionStatus" = Field(..., description="Current statistics and configuration of the collection")
optimizer_status: "OptimizersStatus" = Field(
..., description="Current statistics and configuration of the collection"
)
vectors_count: Optional[int] = Field(
default=None,
description="DEPRECATED: Approximate number of vectors in collection. All vectors in collection are available for querying. Calculated as `points_count x vectors_per_point`. Where `vectors_per_point` is a number of named vectors in schema.",
)
indexed_vectors_count: Optional[int] = Field(
default=None,
description="Approximate number of indexed vectors in the collection. Indexed vectors in large segments are faster to query, as it is stored in a specialized vector index.",
)
points_count: Optional[int] = Field(
default=None,
description="Approximate number of points (vectors + payloads) in collection. Each point could be accessed by unique id.",
)
segments_count: int = Field(
..., description="Number of segments in collection. Each segment has independent vector as payload indexes"
)
config: "CollectionConfig" = Field(..., description="Current statistics and configuration of the collection")
payload_schema: Dict[str, "PayloadIndexInfo"] = Field(..., description="Types of stored payload")
class CollectionParams(BaseModel):
vectors: Optional["VectorsConfig"] = Field(default=None, description="")
shard_number: Optional[int] = Field(default=1, description="Number of shards the collection has")
sharding_method: Optional["ShardingMethod"] = Field(
default=None,
description="Sharding method Default is Auto - points are distributed across all available shards Custom - points are distributed across shards according to shard key",
)
replication_factor: Optional[int] = Field(default=1, description="Number of replicas for each shard")
write_consistency_factor: Optional[int] = Field(
default=1,
description="Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact.",
)
read_fan_out_factor: Optional[int] = Field(
default=None,
description="Defines how many additional replicas should be processing read request at the same time. Default value is Auto, which means that fan-out will be determined automatically based on the busyness of the local replica. Having more than 0 might be useful to smooth latency spikes of individual nodes.",
)
on_disk_payload: Optional[bool] = Field(
default=True,
description="If true - point's payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM. Default: true",
)
sparse_vectors: Optional[Dict[str, "SparseVectorParams"]] = Field(
default=None, description="Configuration of the sparse vector storage"
)
class CollectionParamsDiff(BaseModel, extra="forbid"):
replication_factor: Optional[int] = Field(default=None, description="Number of replicas for each shard")
write_consistency_factor: Optional[int] = Field(
default=None, description="Minimal number successful responses from replicas to consider operation successful"
)
read_fan_out_factor: Optional[int] = Field(
default=None,
description="Fan-out every read request to these many additional remote nodes (and return first available response)",
)
on_disk_payload: Optional[bool] = Field(
default=None,
description="If true - point's payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM.",
)
class CollectionStatus(str, Enum):
"""
Current state of the collection. `Green` - all good. `Yellow` - optimization is running, 'Grey' - optimizations are possible but not triggered, `Red` - some operations failed and was not recovered
"""
def __str__(self) -> str:
return str(self.value)
GREEN = "green"
YELLOW = "yellow"
GREY = "grey"
RED = "red"
class CollectionTelemetry(BaseModel):
id: str = Field(..., description="")
init_time_ms: int = Field(..., description="")
config: "CollectionConfigTelemetry" = Field(..., description="")
shards: List["ReplicaSetTelemetry"] = Field(..., description="")
transfers: List["ShardTransferInfo"] = Field(..., description="")
resharding: List["ReshardingInfo"] = Field(..., description="")
shard_clean_tasks: Dict[str, "ShardCleanStatusTelemetry"] = Field(..., description="")
class CollectionsAggregatedTelemetry(BaseModel):
vectors: int = Field(..., description="")
optimizers_status: "OptimizersStatus" = Field(..., description="")
params: "CollectionParams" = Field(..., description="")
class CollectionsAliasesResponse(BaseModel):
aliases: List["AliasDescription"] = Field(..., description="")
class CollectionsResponse(BaseModel):
collections: List["CollectionDescription"] = Field(..., description="")
class CollectionsTelemetry(BaseModel):
number_of_collections: int = Field(..., description="")
collections: Optional[List["CollectionTelemetryEnum"]] = Field(default=None, description="")
class CompressionRatio(str, Enum):
X4 = "x4"
X8 = "x8"
X16 = "x16"
X32 = "x32"
X64 = "x64"
class ConsensusConfigTelemetry(BaseModel):
max_message_queue_size: int = Field(..., description="")
tick_period_ms: int = Field(..., description="")
bootstrap_timeout_sec: int = Field(..., description="")
class ConsensusThreadStatusOneOf(BaseModel):
consensus_thread_status: Literal[
"working",
] = Field(..., description="")
last_update: Union[datetime, date] = Field(..., description="")
class ConsensusThreadStatusOneOf1(BaseModel):
consensus_thread_status: Literal[
"stopped",
] = Field(..., description="")
class ConsensusThreadStatusOneOf2(BaseModel):
consensus_thread_status: Literal[
"stopped_with_err",
] = Field(..., description="")
err: str = Field(..., description="")
class ContextExamplePair(BaseModel, extra="forbid"):
positive: "RecommendExample" = Field(..., description="")
negative: "RecommendExample" = Field(..., description="")
class ContextPair(BaseModel, extra="forbid"):
positive: "VectorInput" = Field(..., description="")
negative: "VectorInput" = Field(..., description="")
class ContextQuery(BaseModel, extra="forbid"):
context: "ContextInput" = Field(..., description="")
class CountRequest(BaseModel, extra="forbid"):
"""
Count Request Counts the number of points which satisfy the given filter. If filter is not provided, the count of all points in the collection will be returned.
"""
shard_key: Optional["ShardKeySelector"] = Field(
default=None,
description="Specify in which shards to look for the points, if not specified - look in all shards",
)
filter: Optional["Filter"] = Field(default=None, description="Look only for points which satisfies this conditions")
exact: Optional[bool] = Field(
default=True,
description="If true, count exact number of points. If false, count approximate number of points faster. Approximate count might be unreliable during the indexing process. Default: true",
)
class CountResult(BaseModel):
count: int = Field(..., description="Number of points which satisfy the conditions")
class CpuEndian(str, Enum):
LITTLE = "little"
BIG = "big"
OTHER = "other"
class CreateAlias(BaseModel, extra="forbid"):
"""
Create alternative name for a collection. Collection will be available under both names for search, retrieve,
"""
collection_name: str = Field(
...,
description="Create alternative name for a collection. Collection will be available under both names for search, retrieve,",
)
alias_name: str = Field(
...,
description="Create alternative name for a collection. Collection will be available under both names for search, retrieve,",
)
class CreateAliasOperation(BaseModel, extra="forbid"):
create_alias: "CreateAlias" = Field(..., description="")
class CreateCollection(BaseModel, extra="forbid"):
"""
Operation for creating new collection and (optionally) specify index params
"""
vectors: Optional["VectorsConfig"] = Field(
default=None, description="Operation for creating new collection and (optionally) specify index params"
)
shard_number: Optional[int] = Field(
default=None,
description="For auto sharding: Number of shards in collection. - Default is 1 for standalone, otherwise equal to the number of nodes - Minimum is 1 For custom sharding: Number of shards in collection per shard group. - Default is 1, meaning that each shard key will be mapped to a single shard - Minimum is 1",
)
sharding_method: Optional["ShardingMethod"] = Field(
default=None,
description="Sharding method Default is Auto - points are distributed across all available shards Custom - points are distributed across shards according to shard key",
)
replication_factor: Optional[int] = Field(
default=None, description="Number of shards replicas. Default is 1 Minimum is 1"
)
write_consistency_factor: Optional[int] = Field(
default=None,
description="Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact.",
)
on_disk_payload: Optional[bool] = Field(
default=None,
description="If true - point's payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM. Default: true",
)
hnsw_config: Optional["HnswConfigDiff"] = Field(
default=None,
description="Custom params for HNSW index. If none - values from service configuration file are used.",
)
wal_config: Optional["WalConfigDiff"] = Field(
default=None, description="Custom params for WAL. If none - values from service configuration file are used."
)
optimizers_config: Optional["OptimizersConfigDiff"] = Field(
default=None,
description="Custom params for Optimizers. If none - values from service configuration file are used.",
)
init_from: Optional["InitFrom"] = Field(default=None, description="Specify other collection to copy data from.")
quantization_config: Optional["QuantizationConfig"] = Field(
default=None, description="Quantization parameters. If none - quantization is disabled."
)
sparse_vectors: Optional[Dict[str, "SparseVectorParams"]] = Field(
default=None, description="Sparse vector data config."
)
strict_mode_config: Optional["StrictModeConfig"] = Field(default=None, description="Strict-mode config.")
class CreateFieldIndex(BaseModel, extra="forbid"):
field_name: str = Field(..., description="")
field_schema: Optional["PayloadFieldSchema"] = Field(default=None, description="")
class CreateShardingKey(BaseModel, extra="forbid"):
shard_key: "ShardKey" = Field(..., description="")
shards_number: Optional[int] = Field(
default=None,
description="How many shards to create for this key If not specified, will use the default value from config",
)
replication_factor: Optional[int] = Field(
default=None,
description="How many replicas to create for each shard If not specified, will use the default value from config",
)
placement: Optional[List[int]] = Field(
default=None,
description="Placement of shards for this key List of peer ids, that can be used to place shards for this key If not specified, will be randomly placed among all peers",
)
class CreateShardingKeyOperation(BaseModel, extra="forbid"):
create_sharding_key: "CreateShardingKey" = Field(..., description="")
class Datatype(str, Enum):
FLOAT32 = "float32"
UINT8 = "uint8"
FLOAT16 = "float16"
class DatetimeIndexParams(BaseModel, extra="forbid"):
type: "DatetimeIndexType" = Field(..., description="")
is_principal: Optional[bool] = Field(
default=None,
description="If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests.",
)
on_disk: Optional[bool] = Field(default=None, description="If true, store the index on disk. Default: false.")
class DatetimeIndexType(str, Enum):
DATETIME = "datetime"
class DatetimeRange(BaseModel, extra="forbid"):
"""
Range filter request
"""
lt: Optional[Union[datetime, date]] = Field(default=None, description="point.key < range.lt")
gt: Optional[Union[datetime, date]] = Field(default=None, description="point.key > range.gt")
gte: Optional[Union[datetime, date]] = Field(default=None, description="point.key >= range.gte")
lte: Optional[Union[datetime, date]] = Field(default=None, description="point.key <= range.lte")
class DeleteAlias(BaseModel, extra="forbid"):
"""
Delete alias if exists
"""
alias_name: str = Field(..., description="Delete alias if exists")
class DeleteAliasOperation(BaseModel, extra="forbid"):
"""
Delete alias if exists
"""
delete_alias: "DeleteAlias" = Field(..., description="Delete alias if exists")
class DeleteOperation(BaseModel, extra="forbid"):
delete: "PointsSelector" = Field(..., description="")
class DeletePayload(BaseModel, extra="forbid"):
"""
This data structure is used in API interface and applied across multiple shards
"""
keys: List[str] = Field(..., description="List of payload keys to remove from payload")
points: Optional[List["ExtendedPointId"]] = Field(
default=None, description="Deletes values from each point in this list"
)
filter: Optional["Filter"] = Field(
default=None, description="Deletes values from points that satisfy this filter condition"
)
shard_key: Optional["ShardKeySelector"] = Field(
default=None, description="This data structure is used in API interface and applied across multiple shards"
)
class DeletePayloadOperation(BaseModel, extra="forbid"):
delete_payload: "DeletePayload" = Field(..., description="")
class DeleteVectors(BaseModel, extra="forbid"):
points: Optional[List["ExtendedPointId"]] = Field(
default=None, description="Deletes values from each point in this list"
)
filter: Optional["Filter"] = Field(
default=None, description="Deletes values from points that satisfy this filter condition"
)
vector: List[str] = Field(..., description="Vector names")
shard_key: Optional["ShardKeySelector"] = Field(default=None, description="")
class DeleteVectorsOperation(BaseModel, extra="forbid"):
delete_vectors: "DeleteVectors" = Field(..., description="")
class Direction(str, Enum):
ASC = "asc"
DESC = "desc"
class Disabled(str, Enum):
DISABLED = "Disabled"
class DiscoverInput(BaseModel, extra="forbid"):
target: "VectorInput" = Field(..., description="")
context: Union[List["ContextPair"], "ContextPair"] = Field(
..., description="Search space will be constrained by these pairs of vectors"
)
class DiscoverQuery(BaseModel, extra="forbid"):
discover: "DiscoverInput" = Field(..., description="")
class DiscoverRequest(BaseModel, extra="forbid"):
"""
Use context and a target to find the most similar points, constrained by the context.
"""
shard_key: Optional["ShardKeySelector"] = Field(
default=None,
description="Specify in which shards to look for the points, if not specified - look in all shards",
)
target: Optional["RecommendExample"] = Field(
default=None,
description="Look for vectors closest to this. When using the target (with or without context), the integer part of the score represents the rank with respect to the context, while the decimal part of the score relates to the distance to the target.",
)
context: Optional[List["ContextExamplePair"]] = Field(
default=None,
description="Pairs of { positive, negative } examples to constrain the search. When using only the context (without a target), a special search - called context search - is performed where pairs of points are used to generate a loss that guides the search towards the zone where most positive examples overlap. This means that the score minimizes the scenario of finding a point closer to a negative than to a positive part of a pair. Since the score of a context relates to loss, the maximum score a point can get is 0.0, and it becomes normal that many points can have a score of 0.0. For discovery search (when including a target), the context part of the score for each pair is calculated +1 if the point is closer to a positive than to a negative part of a pair, and -1 otherwise.",
)
filter: Optional["Filter"] = Field(default=None, description="Look only for points which satisfies this conditions")
params: Optional["SearchParams"] = Field(default=None, description="Additional search params")
limit: int = Field(..., description="Max number of result to return")
offset: Optional[int] = Field(
default=None,
description="Offset of the first result to return. May be used to paginate results. Note: large offset values may cause performance issues.",
)
with_payload: Optional["WithPayloadInterface"] = Field(
default=None, description="Select which payload to return with the response. Default is false."
)
with_vector: Optional["WithVector"] = Field(
default=None, description="Options for specifying which vectors to include into response. Default is false."
)
using: Optional["UsingVector"] = Field(
default=None,
description="Define which vector to use for recommendation, if not specified - try to use default vector",
)
lookup_from: Optional["LookupLocation"] = Field(
default=None,
description="The location used to lookup vectors. If not specified - use current collection. Note: the other collection should have the same vector size as the current collection",
)
class DiscoverRequestBatch(BaseModel, extra="forbid"):
searches: List["DiscoverRequest"] = Field(..., description="")
class Distance(str, Enum):
"""
Type of internal tags, build from payload Distance function types used to compare vectors
"""
def __str__(self) -> str:
return str(self.value)
COSINE = "Cosine"
EUCLID = "Euclid"
DOT = "Dot"
MANHATTAN = "Manhattan"
class DivExpression(BaseModel, extra="forbid"):
div: "DivParams" = Field(..., description="")
class DivParams(BaseModel, extra="forbid"):
left: "Expression" = Field(..., description="")
right: "Expression" = Field(..., description="")
by_zero_default: Optional[float] = Field(default=None, description="")
class Document(BaseModel, extra="forbid"):
"""
WARN: Work-in-progress, unimplemented Text document for embedding. Requires inference infrastructure, unimplemented.
"""
text: str = Field(..., description="Text of the document This field will be used as input for the embedding model")
model: str = Field(
..., description="Name of the model used to generate the vector List of available models depends on a provider"
)
options: Optional[Dict[str, Any]] = Field(
default=None, description="Parameters for the model Values of the parameters are model-specific"
)
class DropReplicaOperation(BaseModel, extra="forbid"):
drop_replica: "Replica" = Field(..., description="")
class DropShardingKey(BaseModel, extra="forbid"):
shard_key: "ShardKey" = Field(..., description="")
class DropShardingKeyOperation(BaseModel, extra="forbid"):
drop_sharding_key: "DropShardingKey" = Field(..., description="")
class ErrorResponse(BaseModel):
time: Optional[float] = Field(default=None, description="Time spent to process this request")
status: Optional["ErrorResponseStatus"] = Field(default=None, description="")
result: Optional[Any] = Field(default=None, description="")
class ErrorResponseStatus(BaseModel):
error: Optional[str] = Field(default=None, description="Description of the occurred error.")
class ExpExpression(BaseModel, extra="forbid"):
exp: "Expression" = Field(..., description="")
class FacetRequest(BaseModel, extra="forbid"):
shard_key: Optional["ShardKeySelector"] = Field(default=None, description="")
key: str = Field(..., description="Payload key to use for faceting.")
limit: Optional[int] = Field(default=None, description="Max number of hits to return. Default is 10.")
filter: Optional["Filter"] = Field(
default=None, description="Filter conditions - only consider points that satisfy these conditions."
)
exact: Optional[bool] = Field(
default=None,
description="Whether to do a more expensive exact count for each of the values in the facet. Default is false.",
)
class FacetResponse(BaseModel):
hits: List["FacetValueHit"] = Field(..., description="")
class FacetValueHit(BaseModel):
value: "FacetValue" = Field(..., description="")
count: int = Field(..., description="")
class FieldCondition(BaseModel, extra="forbid"):
"""
All possible payload filtering conditions
"""
key: str = Field(..., description="Payload key")
match: Optional["Match"] = Field(default=None, description="Check if point has field with a given value")
range: Optional["RangeInterface"] = Field(default=None, description="Check if points value lies in a given range")
geo_bounding_box: Optional["GeoBoundingBox"] = Field(
default=None, description="Check if points geolocation lies in a given area"
)
geo_radius: Optional["GeoRadius"] = Field(default=None, description="Check if geo point is within a given radius")
geo_polygon: Optional["GeoPolygon"] = Field(
default=None, description="Check if geo point is within a given polygon"
)
values_count: Optional["ValuesCount"] = Field(default=None, description="Check number of values of the field")
is_empty: Optional[bool] = Field(
default=None,
description="Check that the field is empty, alternative syntax for `is_empty: \"field_name\"`",
)
is_null: Optional[bool] = Field(
default=None,
description="Check that the field is null, alternative syntax for `is_null: \"field_name\"`",
)
class Filter(BaseModel, extra="forbid"):
should: Optional[Union[List["Condition"], "Condition"]] = Field(
default=None, description="At least one of those conditions should match"
)
min_should: Optional["MinShould"] = Field(
default=None, description="At least minimum amount of given conditions should match"
)
must: Optional[Union[List["Condition"], "Condition"]] = Field(default=None, description="All conditions must match")
must_not: Optional[Union[List["Condition"], "Condition"]] = Field(
default=None, description="All conditions must NOT match"
)
class FilterSelector(BaseModel, extra="forbid"):
filter: "Filter" = Field(..., description="")
shard_key: Optional["ShardKeySelector"] = Field(default=None, description="")
class FloatIndexParams(BaseModel, extra="forbid"):
type: "FloatIndexType" = Field(..., description="")
is_principal: Optional[bool] = Field(
default=None,
description="If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests.",
)
on_disk: Optional[bool] = Field(default=None, description="If true, store the index on disk. Default: false.")
class FloatIndexType(str, Enum):
FLOAT = "float"
class FormulaQuery(BaseModel, extra="forbid"):
formula: "Expression" = Field(..., description="")
defaults: Optional[Dict[str, Any]] = Field(default={}, description="")
class Fusion(str, Enum):
"""
Fusion algorithm allows to combine results of multiple prefetches. Available fusion algorithms: * `rrf` - Reciprocal Rank Fusion * `dbsf` - Distribution-Based Score Fusion
"""
def __str__(self) -> str:
return str(self.value)
RRF = "rrf"
DBSF = "dbsf"
class FusionQuery(BaseModel, extra="forbid"):
fusion: "Fusion" = Field(..., description="")
class GeoBoundingBox(BaseModel, extra="forbid"):
"""
Geo filter request Matches coordinates inside the rectangle, described by coordinates of lop-left and bottom-right edges
"""
top_left: "GeoPoint" = Field(
...,
description="Geo filter request Matches coordinates inside the rectangle, described by coordinates of lop-left and bottom-right edges",
)
bottom_right: "GeoPoint" = Field(
...,
description="Geo filter request Matches coordinates inside the rectangle, described by coordinates of lop-left and bottom-right edges",
)
class GeoDistance(BaseModel, extra="forbid"):
geo_distance: "GeoDistanceParams" = Field(..., description="")
class GeoDistanceParams(BaseModel, extra="forbid"):
origin: "GeoPoint" = Field(..., description="")
to: str = Field(..., description="Payload field with the destination geo point")
class GeoIndexParams(BaseModel, extra="forbid"):
type: "GeoIndexType" = Field(..., description="")
on_disk: Optional[bool] = Field(default=None, description="If true, store the index on disk. Default: false.")
class GeoIndexType(str, Enum):
GEO = "geo"
class GeoLineString(BaseModel, extra="forbid"):
"""
Ordered sequence of GeoPoints representing the line
"""
points: List["GeoPoint"] = Field(..., description="Ordered sequence of GeoPoints representing the line")
class GeoPoint(BaseModel, extra="forbid"):
"""
Geo point payload schema
"""
lon: float = Field(..., description="Geo point payload schema")
lat: float = Field(..., description="Geo point payload schema")
class GeoPolygon(BaseModel, extra="forbid"):
"""
Geo filter request Matches coordinates inside the polygon, defined by `exterior` and `interiors`
"""
exterior: "GeoLineString" = Field(
...,
description="Geo filter request Matches coordinates inside the polygon, defined by `exterior` and `interiors`",
)
interiors: Optional[List["GeoLineString"]] = Field(
default=None,
description="Interior lines (if present) bound holes within the surface each GeoLineString must consist of a minimum of 4 points, and the first and last points must be the same.",
)
class GeoRadius(BaseModel, extra="forbid"):
"""
Geo filter request Matches coordinates inside the circle of `radius` and center with coordinates `center`
"""
center: "GeoPoint" = Field(
...,
description="Geo filter request Matches coordinates inside the circle of `radius` and center with coordinates `center`",
)
radius: float = Field(..., description="Radius of the area in meters")
class GpuDeviceTelemetry(BaseModel):
name: str = Field(..., description="")
class GroupsResult(BaseModel):
groups: List["PointGroup"] = Field(..., description="")
class GrpcTelemetry(BaseModel):
responses: Dict[str, "OperationDurationStatistics"] = Field(..., description="")
class HardwareTelemetry(BaseModel):
collection_data: Dict[str, "HardwareUsage"] = Field(..., description="")
class HardwareUsage(BaseModel):
"""
Usage of the hardware resources, spent to process the request
"""
cpu: int = Field(..., description="Usage of the hardware resources, spent to process the request")
payload_io_read: int = Field(..., description="Usage of the hardware resources, spent to process the request")
payload_io_write: int = Field(..., description="Usage of the hardware resources, spent to process the request")
vector_io_read: int = Field(..., description="Usage of the hardware resources, spent to process the request")
vector_io_write: int = Field(..., description="Usage of the hardware resources, spent to process the request")
class HasIdCondition(BaseModel, extra="forbid"):
"""
ID-based filtering condition
"""
has_id: List["ExtendedPointId"] = Field(..., description="ID-based filtering condition")
class HasVectorCondition(BaseModel, extra="forbid"):
"""
Filter points which have specific vector assigned
"""
has_vector: str = Field(..., description="Filter points which have specific vector assigned")
class HnswConfig(BaseModel):
"""
Config of HNSW index
"""
m: int = Field(
...,
description="Number of edges per node in the index graph. Larger the value - more accurate the search, more space required.",
)
ef_construct: int = Field(
...,
description="Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build index.",
)
full_scan_threshold: int = Field(
...,
description="Minimal size (in KiloBytes) of vectors for additional payload-based indexing. If payload chunk is smaller than `full_scan_threshold_kb` additional indexing won't be used - in this case full-scan search should be preferred by query planner and additional indexing is not required. Note: 1Kb = 1 vector of size 256",
)
max_indexing_threads: Optional[int] = Field(
default=0,
description="Number of parallel threads used for background index building. If 0 - automatically select from 8 to 16. Best to keep between 8 and 16 to prevent likelihood of slow building or broken/inefficient HNSW graphs. On small CPUs, less threads are used.",
)
on_disk: Optional[bool] = Field(
default=None,
description="Store HNSW index on disk. If set to false, index will be stored in RAM. Default: false",
)
payload_m: Optional[int] = Field(
default=None,
description="Custom M param for hnsw graph built for payload index. If not set, default M will be used.",
)
class HnswConfigDiff(BaseModel, extra="forbid"):
m: Optional[int] = Field(
default=None,
description="Number of edges per node in the index graph. Larger the value - more accurate the search, more space required.",
)
ef_construct: Optional[int] = Field(
default=None,
description="Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build the index.",
)
full_scan_threshold: Optional[int] = Field(
default=None,
description="Minimal size (in kilobytes) of vectors for additional payload-based indexing. If payload chunk is smaller than `full_scan_threshold_kb` additional indexing won't be used - in this case full-scan search should be preferred by query planner and additional indexing is not required. Note: 1Kb = 1 vector of size 256",
)
max_indexing_threads: Optional[int] = Field(
default=None,
description="Number of parallel threads used for background index building. If 0 - automatically select from 8 to 16. Best to keep between 8 and 16 to prevent likelihood of building broken/inefficient HNSW graphs. On small CPUs, less threads are used.",
)
on_disk: Optional[bool] = Field(
default=None,
description="Store HNSW index on disk. If set to false, the index will be stored in RAM. Default: false",
)
payload_m: Optional[int] = Field(
default=None,
description="Custom M param for additional payload-aware HNSW links. If not set, default M will be used.",
)
class Image(BaseModel, extra="forbid"):
"""
WARN: Work-in-progress, unimplemented Image object for embedding. Requires inference infrastructure, unimplemented.
"""
image: Any = Field(..., description="Image data: base64 encoded image or an URL")
model: str = Field(
..., description="Name of the model used to generate the vector List of available models depends on a provider"
)
options: Optional[Dict[str, Any]] = Field(
default=None, description="Parameters for the model Values of the parameters are model-specific"
)
class IndexesOneOf(BaseModel):
"""
Do not use any index, scan whole vector collection during search. Guarantee 100% precision, but may be time consuming on large collections.
"""
type: Literal["plain",] = Field(
...,
description="Do not use any index, scan whole vector collection during search. Guarantee 100% precision, but may be time consuming on large collections.",
)
options: Any = Field(
...,
description="Do not use any index, scan whole vector collection during search. Guarantee 100% precision, but may be time consuming on large collections.",
)
class IndexesOneOf1(BaseModel):
"""