Repository navigation
Expand file tree
/
Copy pathmodels.py
More file actions
4416 lines (3459 loc) · 186 KB
/
Copy pathmodels.py
File metadata and controls
4416 lines (3459 loc) · 186 KB
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 AcornSearchParams(BaseModel, extra="forbid"):
"""
ACORN-related search parameters
"""
enable: Optional[bool] = Field(
default=False,
description="If true, then ACORN may be used for the HNSW search based on filters selectivity. Improves search recall for searches with multiple low-selectivity payload filters, at cost of performance.",
)
max_selectivity: Optional[float] = Field(
default=None,
description="Maximum selectivity of filters to enable ACORN. If estimated filters selectivity is higher than this value, ACORN will not be used. Selectivity is estimated as: `estimated number of points satisfying the filters / total number of points`. 0.0 for never, 1.0 for always. Default is 0.4.",
)
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="")
runtime_features: Optional["FeatureFlags"] = Field(default=None, description="")
low_memory_mode: Optional["LowMemoryMode"] = Field(default=None, description="")
hnsw_global_config: Optional["HnswGlobalConfig"] = 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="")
audit: Optional["AuditTelemetry"] = Field(default=None, description="")
startup: Union[datetime, date] = Field(..., description="")
class AppFeaturesTelemetry(BaseModel):
debug: bool = Field(..., description="")
service_debug_feature: bool = Field(..., description="")
recovery_mode: bool = Field(..., description="")
gpu: bool = Field(..., description="")
rocksdb: bool = Field(..., description="")
staging: bool = Field(..., description="")
class AuditTelemetry(BaseModel):
dir: str = Field(..., description="")
rotation: str = Field(..., description="")
max_log_files: int = Field(..., description="")
trust_forwarded_headers: bool = Field(..., description="")
log_api: bool = Field(..., description="")
dir_size_bytes: Optional[int] = Field(default=None, 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="Deprecated: use `memory` instead.")
memory: Optional["Memory"] = Field(
default=None,
description="Memory placement of quantized vectors. Overrides the deprecated `always_ram` flag if both are set. Default: follow the memory placement of the original vector storage.",
)
encoding: Optional["BinaryQuantizationEncoding"] = Field(default=None, description="")
query_encoding: Optional["BinaryQuantizationQueryEncoding"] = Field(
default=None,
description="Asymmetric quantization configuration allows a query to have different quantization than stored vectors. It can increase the accuracy of search at the cost of performance.",
)
class BinaryQuantizationEncoding(str, Enum):
ONE_BIT = "one_bit"
TWO_BITS = "two_bits"
ONE_AND_HALF_BITS = "one_and_half_bits"
class BinaryQuantizationQueryEncoding(str, Enum):
DEFAULT = "default"
BINARY = "binary"
SCALAR4BITS = "scalar4bits"
SCALAR8BITS = "scalar8bits"
class Bm25Config(BaseModel, extra="forbid"):
"""
Configuration of the local bm25 models.
"""
k: Optional[float] = Field(
default=1.2,
description="Controls term frequency saturation. Higher values mean term frequency has more impact. Default is 1.2",
)
b: Optional[float] = Field(
default=0.75,
description="Controls document length normalization. Ranges from 0 (no normalization) to 1 (full normalization). Higher values mean longer documents have less impact. Default is 0.75.",
)
avg_len: Optional[float] = Field(
default=256, description="Expected average document length in the collection. Default is 256."
)
tokenizer: Optional["TokenizerType"] = Field(default=None, description="Configuration of the local bm25 models.")
language: Optional[str] = Field(
default=None,
description="Defines which language to use for text preprocessing. This parameter is used to construct default stopwords filter and stemmer. To disable language-specific processing, set `stemmer` to `{'type': 'none'}` and configure an empty stopword set. The legacy `'language': 'none'` hack is deprecated and may be rejected in a future release. If not specified, English is assumed.",
)
lowercase: Optional[bool] = Field(
default=None, description="Lowercase the text before tokenization. Default is `true`."
)
ascii_folding: Optional[bool] = Field(
default=None,
description="If true, normalize tokens by folding accented characters to ASCII (e.g., 'ação' -> 'acao'). Default is `false`.",
)
stopwords: Optional["StopwordsInterface"] = Field(
default=None,
description="Configuration of the stopwords filter. Supports list of pre-defined languages and custom stopwords. Default: initialized for specified `language` or English if not specified.",
)
stemmer: Optional["StemmingAlgorithm"] = Field(
default=None,
description="Configuration of the stemmer. Processes tokens to their root form. Default: initialized Snowball stemmer for specified `language` or English if not specified.",
)
min_token_len: Optional[int] = Field(
default=None,
description="Minimum token length to keep. If token is shorter than this, it will be discarded. Default is `None`, which means no minimum length.",
)
max_token_len: Optional[int] = Field(
default=None,
description="Maximum token length to keep. If token is longer than this, it will be discarded. Default is `None`, which means no maximum length.",
)
class BoolIndexParams(BaseModel, extra="forbid"):
type: "BoolIndexType" = Field(..., description="")
on_disk: Optional[bool] = Field(
default=None, description="Deprecated: use `memory` instead. If true, store the index on disk. Default: false."
)
memory: Optional["Memory"] = Field(
default=None,
description="Memory placement of the index. Overrides the deprecated `on_disk` flag if both are set. Default: `pinned` (`cold` if `on_disk` is set to true).",
)
enable_hnsw: Optional[bool] = Field(
default=None,
description="Enable HNSW graph building for this payload field. If true, builds additional HNSW links (Need payload_m > 0). Default: true.",
)
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="")
peer_metadata: Optional[Dict[str, "PeerMetadata"]] = Field(default=None, description="")
metadata: Optional[Dict[str, Any]] = Field(default=None, description="")
resharding_enabled: Optional[bool] = 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"
)
metadata: Optional["Payload"] = Field(
default=None,
description="Arbitrary JSON metadata for the collection This can be used to store application-specific information such as creation time, migration data, inference model info, etc.",
)
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="")
metadata: Optional["Payload"] = Field(default=None, description="Arbitrary JSON metadata for the collection")
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"
)
warnings: Optional[List["CollectionWarning"]] = Field(
default=None, description="Warnings related to the collection"
)
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")
update_queue: Optional["UpdateQueueInfo"] = Field(default=None, description="Update queue info")
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.",
)
read_fan_out_delay_ms: Optional[int] = Field(
default=None,
description="Define number of milliseconds to wait before attempting to read from another replica. This setting can help to reduce latency spikes in case of occasional slow replicas. Default is 0, which means delayed fan out request is disabled.",
)
on_disk_payload: Optional[bool] = Field(
default=True,
description="Deprecated: use `payload.memory` instead. 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",
)
payload: Optional["PayloadStorageParams"] = Field(default=None, description="Configuration of the payload storage")
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)",
)
read_fan_out_delay_ms: Optional[int] = Field(
default=None, description="Delay in milliseconds before sending read requests to remote nodes"
)
on_disk_payload: Optional[bool] = Field(
default=None,
description="Deprecated: use `payload.memory` instead. 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.",
)
payload: Optional["PayloadStorageParams"] = Field(
default=None, description="Update params of the payload storage. If none - it is left unchanged."
)
class CollectionSnapshotTelemetry(BaseModel):
id: str = Field(..., description="")
running_snapshots: Optional[int] = Field(default=None, description="")
running_snapshot_recovery: Optional[int] = Field(default=None, description="")
total_snapshot_creations: Optional[int] = Field(default=None, description="")
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: Optional[int] = Field(default=None, description="")
config: Optional["CollectionConfigTelemetry"] = Field(default=None, description="")
shards: Optional[List["ReplicaSetTelemetry"]] = Field(default=None, description="")
transfers: Optional[List["ShardTransferInfo"]] = Field(default=None, description="")
resharding: Optional[List["ReshardingInfo"]] = Field(default=None, description="")
shard_clean_tasks: Optional[Dict[str, "ShardCleanStatusTelemetry"]] = Field(default=None, description="")
class CollectionWarning(BaseModel):
message: str = Field(..., description="Warning message")
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="")
max_collections: Optional[int] = Field(default=None, description="")
collections: Optional[List["CollectionTelemetryEnum"]] = Field(default=None, description="")
snapshots: Optional[List["CollectionSnapshotTelemetry"]] = 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 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="Deprecated: use `payload.memory` instead. 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",
)
payload: Optional["PayloadStorageParams"] = Field(default=None, description="Configuration of the payload storage")
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.",
)
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.")
metadata: Optional["Payload"] = Field(
default=None,
description="Arbitrary JSON metadata for the collection This can be used to store application-specific information such as creation time, migration data, inference model info, etc.",
)
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",
)
initial_state: Optional["ReplicaState"] = Field(
default=None,
description="Initial state of the shards for this key If not specified, will be `Initializing` first and then `Active` Warning: do not change this unless you know what you are doing",
)
class CreateShardingKeyOperation(BaseModel, extra="forbid"):
create_sharding_key: "CreateShardingKey" = Field(..., description="")
class Datatype(str, Enum):
FLOAT32 = "float32"
UINT8 = "uint8"
FLOAT16 = "float16"
TURBO4 = "turbo4"
class DatetimeExpression(BaseModel, extra="forbid"):
datetime: str = Field(..., description="")
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="Deprecated: use `memory` instead. If true, store the index on disk. Default: false."
)
memory: Optional["Memory"] = Field(
default=None,
description="Memory placement of the index. Overrides the deprecated `on_disk` flag if both are set. Default: `pinned` (`cold` if `on_disk` is set to true).",
)
enable_hnsw: Optional[bool] = Field(
default=None,
description="Enable HNSW graph building for this payload field. If true, builds additional HNSW links (Need payload_m > 0). Default: true.",
)
class DatetimeIndexType(str, Enum):
DATETIME = "datetime"
class DatetimeKeyExpression(BaseModel, extra="forbid"):
datetime_key: str = Field(..., description="")
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 DecayParamsExpression(BaseModel, extra="forbid"):
x: "Expression" = Field(..., description="")
target: Optional["Expression"] = Field(
default=None, description="The target value to start decaying from. Defaults to 0."
)
scale: Optional[float] = Field(
default=None,
description="The scale factor of the decay, in terms of `x`. Defaults to 1.0. Must be a non-zero positive number.",
)
midpoint: Optional[float] = Field(
default=None,
description="The midpoint of the decay. Should be between 0 and 1.Defaults to 0.5. Output will be this value when `|x - target| == scale`.",
)
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 DenseVectorConfig(BaseModel, extra="forbid"):
"""
Configuration for creating a new dense named vector. Only includes properties that define the vector space and cannot be changed after creation. Storage type, index type, and quantization are inferred.
"""
size: int = Field(..., description="Dimensionality of the vectors")
distance: "Distance" = Field(
...,
description="Configuration for creating a new dense named vector. Only includes properties that define the vector space and cannot be changed after creation. Storage type, index type, and quantization are inferred.",
)
multivector_config: Optional["MultiVectorConfig"] = Field(
default=None, description="Configuration for multi-vector points (e.g., ColBERT)"
)
datatype: Optional["VectorStorageDatatype"] = Field(
default=None, description="Element storage type (Float32, Float16, Uint8, Turbo4)"
)
class DenseVectorNameConfig(BaseModel, extra="forbid"):
"""
Wrapper for dense vector creation config.
"""
dense: "DenseVectorConfig" = Field(..., description="Wrapper for dense vector creation config.")
class Direction(str, Enum):
ASC = "asc"
DESC = "desc"
class Disabled(str, Enum):
DISABLED = "Disabled"
class DisabledStemmerParams(BaseModel, extra="forbid"):
type: "NoStemmer" = Field(..., description="")
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 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 DistributedClusterTelemetry(BaseModel):
enabled: bool = Field(..., description="")
number_of_peers: Optional[int] = Field(default=None, description="")
peers: Dict[str, "DistributedPeerInfo"] = Field(..., description="")
class DistributedCollectionTelemetry(BaseModel):
id: str = Field(..., description="Collection name")
shards: Optional[List["DistributedShardTelemetry"]] = Field(default=None, description="Shards topology")
reshardings: Optional[List["ReshardingInfo"]] = Field(default=None, description="Ongoing resharding operations")
shard_transfers: Optional[List["ShardTransferInfo"]] = Field(default=None, description="Ongoing shard transfers")
class DistributedPeerDetails(BaseModel):
version: str = Field(..., description="Qdrant version")
role: Optional["StateRole"] = Field(default=None, description="Consensus role for the peer")
is_voter: bool = Field(..., description="Whether it can participate in leader elections")
term: int = Field(..., description="Election term")
commit: int = Field(..., description="Latest accepted commit")
num_pending_operations: int = Field(..., description="Number of operations pending for being applied")
consensus_thread_status: "ConsensusThreadStatus" = Field(..., description="")
class DistributedPeerInfo(BaseModel):
uri: str = Field(..., description="URI of the peer")
responsive: bool = Field(..., description="Whether this peer responded for this request")
details: Optional["DistributedPeerDetails"] = Field(
default=None, description="If responsive, these details should be available"
)
class DistributedReplicaTelemetry(BaseModel):
peer_id: int = Field(..., description="Peer ID hosting this replica")
state: "ReplicaState" = Field(..., description="")
status: Optional["ShardStatus"] = Field(default=None, description="Shard status")
total_optimized_points: Optional[int] = Field(default=None, description="Total optimized points")
vectors_size_bytes: Optional[int] = Field(default=None, description="Estimated vectors size in bytes")
payloads_size_bytes: Optional[int] = Field(default=None, description="Estimated payloads size in bytes")
num_points: Optional[int] = Field(default=None, description="Approximate number of points")
num_vectors: Optional[int] = Field(default=None, description="Approximate number of vectors")
num_vectors_by_name: Optional[Dict[str, int]] = Field(
default=None, description="Approximate number of vectors by name"
)
shard_cleaning_status: Optional["ShardCleanStatusTelemetry"] = Field(
default=None,
description="Shard cleaning task status. After a resharding, a cleanup task is performed to remove outdated points from this shard.",
)
partial_snapshot: Optional["PartialSnapshotTelemetry"] = Field(
default=None, description="Partial snapshot telemetry"
)
class DistributedShardTelemetry(BaseModel):
id: int = Field(..., description="Shard ID")
key: Optional["ShardKey"] = Field(default=None, description="Optional shard key")
replicas: List["DistributedReplicaTelemetry"] = Field(..., description="Replica information")
class DistributedTelemetryData(BaseModel):
collections: Dict[str, "DistributedCollectionTelemetry"] = Field(..., description="")
cluster: Optional["DistributedClusterTelemetry"] = Field(default=None, description="")
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["DocumentOptions"] = Field(
default=None,
description="Additional options for the model, will be passed to the inference service as-is. See model cards for available options.",
)
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 ExpDecayExpression(BaseModel, extra="forbid"):
exp_decay: "DecayParamsExpression" = Field(..., description="")
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 FeatureFlags(BaseModel):
all: Optional[bool] = Field(
default=False,
description="Magic feature flag that enables all features. Note that this will only be applied to all flags when passed into [`init_feature_flags`].",
)
incremental_hnsw_building: Optional[bool] = Field(
default=True, description="Use incremental HNSW building. Enabled by default in Qdrant 1.14.1."
)
appendable_quantization: Optional[bool] = Field(
default=True,
description="Use appendable quantization in appendable plain segments. Enabled by default in Qdrant 1.16.0.",
)
single_file_mmap_vector_storage: Optional[bool] = Field(
default=True,
description="Use single-file mmap in-ram vector storage (InRamMmap) Enabled by default in Qdrant 1.18.3+",
)
async_payload_storage: Optional[bool] = Field(
default=True,
description="Allow the io_uring-based payload storage implementation. When disabled, io_uring payload storage is *never* used. When enabled, payload storage backend is decided based on `storage.performance.io_uring` option and payload storage type.",
)
write_segment_manifest: Optional[bool] = Field(
default=False,
description="Write a segment manifest (`segments_manifest.json`, next to the `segments/` directory) listing the shard's segments and their state, so out-of-process readers can discover segments without scanning the filesystem.",
)
append_only_mutations: Optional[bool] = Field(
default=False,
description="Build new segments in append-only mode: in-place point mutations become clone-and-tombstone appends instead. Intended for testing the append-only storage path.",
)
compact_bitmask: Optional[bool] = Field(
default=False,
description="Persist write-once bitmasks in the compact `StoredBitmask` format instead of raw dense bitslices. Only gates writing: both formats are always readable.",
)
serverless_compatible: Optional[bool] = Field(
default=False,
description="Serverless-compatible deployment mode. Automatically enables [`Self::write_segment_manifest`], [`Self::append_only_mutations`] and [`Self::compact_bitmask`]. Note that this will only be applied when passed into [`init_feature_flags`].",
)
class FeedbackItem(BaseModel, extra="forbid"):
example: "VectorInput" = Field(..., description="")
score: float = 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(