chromadb 3.0.17 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,16 @@
1
+ type BoolInvertedIndexConfig$1 = {
2
+ [key: string]: never;
3
+ };
4
+ type BoolInvertedIndexType$1 = {
5
+ config: BoolInvertedIndexConfig$1;
6
+ enabled: boolean;
7
+ };
8
+ /**
9
+ * Boolean value type index configurations
10
+ */
11
+ type BoolValueType$1 = {
12
+ bool_inverted_index?: null | BoolInvertedIndexType$1;
13
+ };
1
14
  type ChecklistResponse = {
2
15
  max_batch_size: number;
3
16
  supports_base64_encoding: boolean;
@@ -11,26 +24,195 @@ type EmbeddingFunctionConfiguration = {
11
24
  type: 'legacy';
12
25
  } | (EmbeddingFunctionNewConfiguration & {
13
26
  type: 'known';
14
- });
27
+ }) | {
28
+ type: 'unknown';
29
+ };
15
30
  type EmbeddingFunctionNewConfiguration = {
16
31
  config: unknown;
17
32
  name: string;
18
33
  };
34
+ type FloatInvertedIndexConfig$1 = {
35
+ [key: string]: never;
36
+ };
37
+ type FloatInvertedIndexType$1 = {
38
+ config: FloatInvertedIndexConfig$1;
39
+ enabled: boolean;
40
+ };
41
+ /**
42
+ * Float list value type index configurations (for vectors)
43
+ */
44
+ type FloatListValueType$1 = {
45
+ vector_index?: null | VectorIndexType$1;
46
+ };
47
+ /**
48
+ * Float value type index configurations
49
+ */
50
+ type FloatValueType$1 = {
51
+ float_inverted_index?: null | FloatInvertedIndexType$1;
52
+ };
53
+ type FtsIndexConfig$1 = {
54
+ [key: string]: never;
55
+ };
56
+ type FtsIndexType$1 = {
57
+ config: FtsIndexConfig$1;
58
+ enabled: boolean;
59
+ };
19
60
  type GetUserIdentityResponse = {
20
61
  databases: Array<string>;
21
62
  tenant: string;
22
63
  user_id: string;
23
64
  };
65
+ type HashMap = {
66
+ [key: string]: boolean | number | string | SparseVector | null;
67
+ };
24
68
  type HnswConfiguration = {
25
69
  ef_construction?: number | null;
26
70
  ef_search?: number | null;
27
71
  max_neighbors?: number | null;
28
72
  resize_factor?: number | null;
29
- space?: null | HnswSpace;
73
+ space?: null | Space;
74
+ sync_threshold?: number | null;
75
+ };
76
+ /**
77
+ * Configuration for HNSW vector index algorithm parameters
78
+ */
79
+ type HnswIndexConfig = {
80
+ batch_size?: number | null;
81
+ ef_construction?: number | null;
82
+ ef_search?: number | null;
83
+ max_neighbors?: number | null;
84
+ num_threads?: number | null;
85
+ resize_factor?: number | null;
30
86
  sync_threshold?: number | null;
31
87
  };
32
- type HnswSpace = 'l2' | 'cosine' | 'ip';
33
88
  type Include = 'distances' | 'documents' | 'embeddings' | 'metadatas' | 'uris';
89
+ type IntInvertedIndexConfig$1 = {
90
+ [key: string]: never;
91
+ };
92
+ type IntInvertedIndexType$1 = {
93
+ config: IntInvertedIndexConfig$1;
94
+ enabled: boolean;
95
+ };
96
+ /**
97
+ * Integer value type index configurations
98
+ */
99
+ type IntValueType$1 = {
100
+ int_inverted_index?: null | IntInvertedIndexType$1;
101
+ };
102
+ /**
103
+ * Represents a field key in search queries.
104
+ *
105
+ * Used for both selecting fields to return and building filter expressions.
106
+ * Predefined keys access special fields, while custom keys access metadata.
107
+ *
108
+ * # Predefined Keys
109
+ *
110
+ * - `Key::Document` - Document text content (`#document`)
111
+ * - `Key::Embedding` - Vector embeddings (`#embedding`)
112
+ * - `Key::Metadata` - All metadata fields (`#metadata`)
113
+ * - `Key::Score` - Search scores (`#score`)
114
+ *
115
+ * # Custom Keys
116
+ *
117
+ * Use `Key::field()` or `Key::from()` to reference metadata fields:
118
+ *
119
+ * ```
120
+ * use chroma_types::operator::Key;
121
+ *
122
+ * let key = Key::field("author");
123
+ * let key = Key::from("title");
124
+ * ```
125
+ *
126
+ * # Examples
127
+ *
128
+ * ## Building filters
129
+ *
130
+ * ```
131
+ * use chroma_types::operator::Key;
132
+ *
133
+ * // Equality
134
+ * let filter = Key::field("status").eq("published");
135
+ *
136
+ * // Comparisons
137
+ * let filter = Key::field("year").gte(2020);
138
+ * let filter = Key::field("score").lt(0.9);
139
+ *
140
+ * // Set operations
141
+ * let filter = Key::field("category").is_in(vec!["tech", "science"]);
142
+ * let filter = Key::field("status").not_in(vec!["deleted", "archived"]);
143
+ *
144
+ * // Document content
145
+ * let filter = Key::Document.contains("machine learning");
146
+ * let filter = Key::Document.regex(r"\bAPI\b");
147
+ *
148
+ * // Combining filters
149
+ * let filter = Key::field("status").eq("published")
150
+ * & Key::field("year").gte(2020);
151
+ * ```
152
+ *
153
+ * ## Selecting fields
154
+ *
155
+ * ```
156
+ * use chroma_types::plan::SearchPayload;
157
+ * use chroma_types::operator::Key;
158
+ *
159
+ * let search = SearchPayload::default()
160
+ * .select([
161
+ * Key::Document,
162
+ * Key::Score,
163
+ * Key::field("title"),
164
+ * Key::field("author"),
165
+ * ]);
166
+ * ```
167
+ */
168
+ type Key$1 = 'Document' | 'Embedding' | 'Metadata' | 'Score' | {
169
+ MetadataField: string;
170
+ };
171
+ /**
172
+ * Schema representation for collection index configurations
173
+ *
174
+ * This represents the server-side schema structure used for index management
175
+ */
176
+ type Schema$1 = {
177
+ /**
178
+ * Default index configurations for each value type
179
+ */
180
+ defaults: ValueTypes$1;
181
+ /**
182
+ * Key-specific index overrides
183
+ * TODO(Sanket): Needed for backwards compatibility. Should remove after deploy.
184
+ */
185
+ keys: {
186
+ [key: string]: ValueTypes$1;
187
+ };
188
+ };
189
+ type SearchPayload = {
190
+ filter?: {
191
+ query_ids?: Array<string>;
192
+ where_clause?: {
193
+ [key: string]: unknown;
194
+ };
195
+ };
196
+ limit?: {
197
+ limit?: number;
198
+ offset?: number;
199
+ };
200
+ rank?: {
201
+ [key: string]: unknown;
202
+ };
203
+ select?: {
204
+ keys?: Array<string>;
205
+ };
206
+ };
207
+ type SearchResponse = {
208
+ documents: Array<Array<string | null> | null>;
209
+ embeddings: Array<Array<Array<number> | null> | null>;
210
+ ids: Array<Array<string>>;
211
+ metadatas: Array<Array<null | HashMap> | null>;
212
+ scores: Array<Array<number | null> | null>;
213
+ select: Array<Array<Key$1>>;
214
+ };
215
+ type Space = 'l2' | 'cosine' | 'ip';
34
216
  type SpannConfiguration = {
35
217
  ef_construction?: number | null;
36
218
  ef_search?: number | null;
@@ -38,12 +220,38 @@ type SpannConfiguration = {
38
220
  merge_threshold?: number | null;
39
221
  reassign_neighbor_count?: number | null;
40
222
  search_nprobe?: number | null;
41
- space?: null | HnswSpace;
223
+ space?: null | Space;
42
224
  split_threshold?: number | null;
43
225
  write_nprobe?: number | null;
44
226
  };
227
+ /**
228
+ * Configuration for SPANN vector index algorithm parameters
229
+ */
230
+ type SpannIndexConfig = {
231
+ ef_construction?: number | null;
232
+ ef_search?: number | null;
233
+ initial_lambda?: number | null;
234
+ max_neighbors?: number | null;
235
+ merge_threshold?: number | null;
236
+ nreplica_count?: number | null;
237
+ num_centers_to_merge_to?: number | null;
238
+ num_samples_kmeans?: number | null;
239
+ reassign_neighbor_count?: number | null;
240
+ search_nprobe?: number | null;
241
+ search_rng_epsilon?: number | null;
242
+ search_rng_factor?: number | null;
243
+ split_threshold?: number | null;
244
+ write_nprobe?: number | null;
245
+ write_rng_epsilon?: number | null;
246
+ write_rng_factor?: number | null;
247
+ };
45
248
  /**
46
249
  * Represents a sparse vector using parallel arrays for indices and values.
250
+ *
251
+ * On deserialization: accepts both old format `{"indices": [...], "values": [...]}`
252
+ * and new format `{"#type": "sparse_vector", "indices": [...], "values": [...]}`.
253
+ *
254
+ * On serialization: always includes `#type` field with value `"sparse_vector"`.
47
255
  */
48
256
  type SparseVector = {
49
257
  /**
@@ -55,6 +263,41 @@ type SparseVector = {
55
263
  */
56
264
  values: Array<number>;
57
265
  };
266
+ type SparseVectorIndexConfig$1 = {
267
+ /**
268
+ * Whether this embedding is BM25
269
+ */
270
+ bm25?: boolean | null;
271
+ embedding_function?: null | EmbeddingFunctionConfiguration;
272
+ /**
273
+ * Key to source the sparse vector from
274
+ */
275
+ source_key?: string | null;
276
+ };
277
+ type SparseVectorIndexType$1 = {
278
+ config: SparseVectorIndexConfig$1;
279
+ enabled: boolean;
280
+ };
281
+ /**
282
+ * Sparse vector value type index configurations
283
+ */
284
+ type SparseVectorValueType$1 = {
285
+ sparse_vector_index?: null | SparseVectorIndexType$1;
286
+ };
287
+ type StringInvertedIndexConfig$1 = {
288
+ [key: string]: never;
289
+ };
290
+ type StringInvertedIndexType$1 = {
291
+ config: StringInvertedIndexConfig$1;
292
+ enabled: boolean;
293
+ };
294
+ /**
295
+ * String value type index configurations
296
+ */
297
+ type StringValueType$1 = {
298
+ fts_index?: null | FtsIndexType$1;
299
+ string_inverted_index?: null | StringInvertedIndexType$1;
300
+ };
58
301
  type UpdateCollectionConfiguration$1 = {
59
302
  embedding_function?: null | EmbeddingFunctionConfiguration;
60
303
  hnsw?: null | UpdateHnswConfiguration;
@@ -72,11 +315,38 @@ type UpdateSpannConfiguration = {
72
315
  ef_search?: number | null;
73
316
  search_nprobe?: number | null;
74
317
  };
318
+ /**
319
+ * Strongly-typed value type configurations
320
+ * Contains optional configurations for each supported value type
321
+ */
322
+ type ValueTypes$1 = {
323
+ bool?: null | BoolValueType$1;
324
+ float?: null | FloatValueType$1;
325
+ float_list?: null | FloatListValueType$1;
326
+ int?: null | IntValueType$1;
327
+ sparse_vector?: null | SparseVectorValueType$1;
328
+ string?: null | StringValueType$1;
329
+ };
330
+ type VectorIndexConfig$1 = {
331
+ embedding_function?: null | EmbeddingFunctionConfiguration;
332
+ hnsw?: null | HnswIndexConfig;
333
+ /**
334
+ * Key to source the vector from
335
+ */
336
+ source_key?: string | null;
337
+ space?: null | Space;
338
+ spann?: null | SpannIndexConfig;
339
+ };
340
+ type VectorIndexType$1 = {
341
+ config: VectorIndexConfig$1;
342
+ enabled: boolean;
343
+ };
75
344
 
76
345
  /**
77
346
  * User identity information including tenant and database access.
78
347
  */
79
348
  type UserIdentity = GetUserIdentityResponse;
349
+
80
350
  /**
81
351
  * Metadata that can be associated with a collection.
82
352
  * Values must be boolean, number, or string types.
@@ -294,6 +564,14 @@ interface EmbeddingFunction {
294
564
  * @returns Promise resolving to array of embedding vectors
295
565
  */
296
566
  generate(texts: string[]): Promise<number[][]>;
567
+ /**
568
+ * Generates embeddings specifically for query texts.
569
+ * The client will fall back to using the implementation of `generate`
570
+ * if this function is not provided.
571
+ * @param texts - Array of query text strings to embed
572
+ * @returns Promise resolving to array of embedding vectors
573
+ */
574
+ generateForQueries?(texts: string[]): Promise<number[][]>;
297
575
  /** Optional name identifier for the embedding function */
298
576
  name?: string;
299
577
  /** Returns the default vector space for this embedding function */
@@ -315,6 +593,43 @@ interface EmbeddingFunction {
315
593
  */
316
594
  validateConfig?(config: Record<string, any>): void;
317
595
  }
596
+ /**
597
+ * Interface for sparse embedding functions.
598
+ * Sparse embedding functions transform text documents into sparse numerical representations
599
+ * where only non-zero values are stored, making them efficient for high-dimensional spaces.
600
+ */
601
+ interface SparseEmbeddingFunction {
602
+ /**
603
+ * Generates sparse embeddings for the given texts.
604
+ * @param texts - Array of text strings to embed
605
+ * @returns Promise resolving to array of sparse vectors
606
+ */
607
+ generate(texts: string[]): Promise<SparseVector[]>;
608
+ /**
609
+ * Generates sparse embeddings specifically for query texts.
610
+ * The client will fall back to using the implementation of `generate`
611
+ * if this function is not provided.
612
+ * @param texts - Array of query text strings to embed
613
+ * @returns Promise resolving to array of sparse vectors
614
+ */
615
+ generateForQueries?(texts: string[]): Promise<SparseVector[]>;
616
+ /** Optional name identifier for the embedding function */
617
+ name?: string;
618
+ /** Creates an instance from configuration object */
619
+ buildFromConfig?(config: Record<string, any>): SparseEmbeddingFunction;
620
+ /** Returns the current configuration as an object */
621
+ getConfig?(): Record<string, any>;
622
+ /**
623
+ * Validates that a configuration update is allowed.
624
+ * @param newConfig - New configuration to validate
625
+ */
626
+ validateConfigUpdate?(newConfig: Record<string, any>): void;
627
+ /**
628
+ * Validates that a configuration object is valid.
629
+ * @param config - Configuration to validate
630
+ */
631
+ validateConfig?(config: Record<string, any>): void;
632
+ }
318
633
  /**
319
634
  * Interface for embedding function constructor classes.
320
635
  * Used for registering and instantiating embedding functions.
@@ -327,11 +642,32 @@ interface EmbeddingFunctionClass {
327
642
  /** Static method to build instance from configuration */
328
643
  buildFromConfig(config: Record<string, any>): EmbeddingFunction;
329
644
  }
645
+ /**
646
+ * Interface for sparse embedding function constructor classes.
647
+ * Used for registering and instantiating sparse embedding functions.
648
+ */
649
+ interface SparseEmbeddingFunctionClass {
650
+ /** Constructor for creating new instances */
651
+ new (...args: any[]): SparseEmbeddingFunction;
652
+ /** Name identifier for the embedding function */
653
+ name: string;
654
+ /** Static method to build instance from configuration */
655
+ buildFromConfig(config: Record<string, any>): SparseEmbeddingFunction;
656
+ }
330
657
  /**
331
658
  * Registry of available embedding functions.
332
659
  * Maps function names to their constructor classes.
333
660
  */
334
661
  declare const knownEmbeddingFunctions: Map<string, EmbeddingFunctionClass>;
662
+ /**
663
+ * Registry of available sparse embedding functions.
664
+ * Maps function names to their constructor classes.
665
+ */
666
+ declare const knownSparseEmbeddingFunctions: Map<string, SparseEmbeddingFunctionClass>;
667
+ /**
668
+ * Union type covering both dense and sparse embedding functions.
669
+ */
670
+ type AnyEmbeddingFunction = EmbeddingFunction | SparseEmbeddingFunction;
335
671
  /**
336
672
  * Registers an embedding function in the global registry.
337
673
  * @param name - Unique name for the embedding function
@@ -339,13 +675,27 @@ declare const knownEmbeddingFunctions: Map<string, EmbeddingFunctionClass>;
339
675
  * @throws ChromaValueError if name is already registered
340
676
  */
341
677
  declare const registerEmbeddingFunction: (name: string, fn: EmbeddingFunctionClass) => void;
678
+ /**
679
+ * Registers a sparse embedding function in the global registry.
680
+ * @param name - Unique name for the sparse embedding function
681
+ * @param fn - Sparse embedding function class to register
682
+ * @throws ChromaValueError if name is already registered
683
+ */
684
+ declare const registerSparseEmbeddingFunction: (name: string, fn: SparseEmbeddingFunctionClass) => void;
342
685
  /**
343
686
  * Retrieves and instantiates an embedding function from configuration.
344
687
  * @param collectionName - Name of the collection (for error messages)
345
688
  * @param efConfig - Configuration for the embedding function
346
- * @returns Promise resolving to an EmbeddingFunction instance
689
+ * @returns EmbeddingFunction instance or undefined if it cannot be constructed
690
+ */
691
+ declare const getEmbeddingFunction: (collectionName: string, efConfig?: EmbeddingFunctionConfiguration) => EmbeddingFunction | undefined;
692
+ /**
693
+ * Retrieves and instantiates a sparse embedding function from configuration.
694
+ * @param collectionName - Name of the collection (for error messages)
695
+ * @param efConfig - Configuration for the sparse embedding function
696
+ * @returns SparseEmbeddingFunction instance or undefined if it cannot be constructed
347
697
  */
348
- declare const getEmbeddingFunction: (collectionName: string, efConfig?: EmbeddingFunctionConfiguration) => Promise<EmbeddingFunction | undefined>;
698
+ declare const getSparseEmbeddingFunction: (collectionName: string, efConfig?: EmbeddingFunctionConfiguration) => SparseEmbeddingFunction | undefined;
349
699
  /**
350
700
  * Serializes an embedding function to configuration format.
351
701
  * @param embeddingFunction - User provided embedding function
@@ -414,6 +764,159 @@ declare const processUpdateCollectionConfig: ({ collectionName, currentConfigura
414
764
  updateEmbeddingFunction?: EmbeddingFunction;
415
765
  }>;
416
766
 
767
+ declare const DOCUMENT_KEY = "#document";
768
+ declare const EMBEDDING_KEY = "#embedding";
769
+ declare class FtsIndexConfig {
770
+ readonly type = "FtsIndexConfig";
771
+ }
772
+ declare class StringInvertedIndexConfig {
773
+ readonly type = "StringInvertedIndexConfig";
774
+ }
775
+ declare class IntInvertedIndexConfig {
776
+ readonly type = "IntInvertedIndexConfig";
777
+ }
778
+ declare class FloatInvertedIndexConfig {
779
+ readonly type = "FloatInvertedIndexConfig";
780
+ }
781
+ declare class BoolInvertedIndexConfig {
782
+ readonly type = "BoolInvertedIndexConfig";
783
+ }
784
+ interface VectorIndexConfigOptions {
785
+ space?: Space | null;
786
+ embeddingFunction?: EmbeddingFunction | null;
787
+ sourceKey?: string | null;
788
+ hnsw?: HnswIndexConfig | null;
789
+ spann?: SpannIndexConfig | null;
790
+ }
791
+ declare class VectorIndexConfig {
792
+ readonly type = "VectorIndexConfig";
793
+ space: Space | null;
794
+ embeddingFunction: EmbeddingFunction | null;
795
+ sourceKey: string | null;
796
+ hnsw: HnswIndexConfig | null;
797
+ spann: SpannIndexConfig | null;
798
+ constructor(options?: VectorIndexConfigOptions);
799
+ }
800
+ interface SparseVectorIndexConfigOptions {
801
+ embeddingFunction?: SparseEmbeddingFunction | null;
802
+ sourceKey?: string | null;
803
+ bm25?: boolean | null;
804
+ }
805
+ declare class SparseVectorIndexConfig {
806
+ readonly type = "SparseVectorIndexConfig";
807
+ embeddingFunction: SparseEmbeddingFunction | null;
808
+ sourceKey: string | null;
809
+ bm25: boolean | null;
810
+ constructor(options?: SparseVectorIndexConfigOptions);
811
+ }
812
+ declare class FtsIndexType {
813
+ enabled: boolean;
814
+ config: FtsIndexConfig;
815
+ constructor(enabled: boolean, config: FtsIndexConfig);
816
+ }
817
+ declare class StringInvertedIndexType {
818
+ enabled: boolean;
819
+ config: StringInvertedIndexConfig;
820
+ constructor(enabled: boolean, config: StringInvertedIndexConfig);
821
+ }
822
+ declare class VectorIndexType {
823
+ enabled: boolean;
824
+ config: VectorIndexConfig;
825
+ constructor(enabled: boolean, config: VectorIndexConfig);
826
+ }
827
+ declare class SparseVectorIndexType {
828
+ enabled: boolean;
829
+ config: SparseVectorIndexConfig;
830
+ constructor(enabled: boolean, config: SparseVectorIndexConfig);
831
+ }
832
+ declare class IntInvertedIndexType {
833
+ enabled: boolean;
834
+ config: IntInvertedIndexConfig;
835
+ constructor(enabled: boolean, config: IntInvertedIndexConfig);
836
+ }
837
+ declare class FloatInvertedIndexType {
838
+ enabled: boolean;
839
+ config: FloatInvertedIndexConfig;
840
+ constructor(enabled: boolean, config: FloatInvertedIndexConfig);
841
+ }
842
+ declare class BoolInvertedIndexType {
843
+ enabled: boolean;
844
+ config: BoolInvertedIndexConfig;
845
+ constructor(enabled: boolean, config: BoolInvertedIndexConfig);
846
+ }
847
+ declare class StringValueType {
848
+ ftsIndex: FtsIndexType | null;
849
+ stringInvertedIndex: StringInvertedIndexType | null;
850
+ constructor(ftsIndex?: FtsIndexType | null, stringInvertedIndex?: StringInvertedIndexType | null);
851
+ }
852
+ declare class FloatListValueType {
853
+ vectorIndex: VectorIndexType | null;
854
+ constructor(vectorIndex?: VectorIndexType | null);
855
+ }
856
+ declare class SparseVectorValueType {
857
+ sparseVectorIndex: SparseVectorIndexType | null;
858
+ constructor(sparseVectorIndex?: SparseVectorIndexType | null);
859
+ }
860
+ declare class IntValueType {
861
+ intInvertedIndex: IntInvertedIndexType | null;
862
+ constructor(intInvertedIndex?: IntInvertedIndexType | null);
863
+ }
864
+ declare class FloatValueType {
865
+ floatInvertedIndex: FloatInvertedIndexType | null;
866
+ constructor(floatInvertedIndex?: FloatInvertedIndexType | null);
867
+ }
868
+ declare class BoolValueType {
869
+ boolInvertedIndex: BoolInvertedIndexType | null;
870
+ constructor(boolInvertedIndex?: BoolInvertedIndexType | null);
871
+ }
872
+ declare class ValueTypes {
873
+ string: StringValueType | null;
874
+ floatList: FloatListValueType | null;
875
+ sparseVector: SparseVectorValueType | null;
876
+ intValue: IntValueType | null;
877
+ floatValue: FloatValueType | null;
878
+ boolean: BoolValueType | null;
879
+ }
880
+ type IndexConfig = FtsIndexConfig | VectorIndexConfig | SparseVectorIndexConfig | StringInvertedIndexConfig | IntInvertedIndexConfig | FloatInvertedIndexConfig | BoolInvertedIndexConfig;
881
+ type JsonDict = Record<string, any>;
882
+ declare class Schema {
883
+ defaults: ValueTypes;
884
+ keys: Record<string, ValueTypes>;
885
+ constructor();
886
+ createIndex(config?: IndexConfig, key?: string): this;
887
+ deleteIndex(config?: IndexConfig, key?: string): this;
888
+ serializeToJSON(): Schema$1;
889
+ static deserializeFromJSON(json?: Schema$1 | JsonDict | null): Schema | undefined;
890
+ private setVectorIndexConfig;
891
+ private setFtsIndexConfig;
892
+ private setIndexInDefaults;
893
+ private setIndexForKey;
894
+ private enableAllIndexesForKey;
895
+ private disableAllIndexesForKey;
896
+ private validateSingleSparseVectorIndex;
897
+ private initializeDefaults;
898
+ private initializeKeys;
899
+ private serializeValueTypes;
900
+ private serializeStringValueType;
901
+ private serializeFloatListValueType;
902
+ private serializeSparseVectorValueType;
903
+ private serializeIntValueType;
904
+ private serializeFloatValueType;
905
+ private serializeBoolValueType;
906
+ private serializeConfig;
907
+ private serializeVectorConfig;
908
+ private serializeSparseVectorConfig;
909
+ private static deserializeValueTypes;
910
+ private static deserializeStringValueType;
911
+ private static deserializeFloatListValueType;
912
+ private static deserializeSparseVectorValueType;
913
+ private static deserializeIntValueType;
914
+ private static deserializeFloatValueType;
915
+ private static deserializeBoolValueType;
916
+ private static deserializeVectorConfig;
917
+ private static deserializeSparseVectorConfig;
918
+ }
919
+
417
920
  /**
418
921
  * Configuration options for the ChromaClient.
419
922
  */
@@ -510,11 +1013,12 @@ declare class ChromaClient {
510
1013
  * @returns Promise resolving to the created Collection instance
511
1014
  * @throws Error if a collection with the same name already exists
512
1015
  */
513
- createCollection({ name, configuration, metadata, embeddingFunction, }: {
1016
+ createCollection({ name, configuration, metadata, embeddingFunction, schema, }: {
514
1017
  name: string;
515
1018
  configuration?: CreateCollectionConfiguration;
516
1019
  metadata?: CollectionMetadata;
517
1020
  embeddingFunction?: EmbeddingFunction | null;
1021
+ schema?: Schema;
518
1022
  }): Promise<Collection>;
519
1023
  /**
520
1024
  * Retrieves an existing collection by name.
@@ -546,11 +1050,12 @@ declare class ChromaClient {
546
1050
  * @param options.embeddingFunction - Optional embedding function to use
547
1051
  * @returns Promise resolving to the Collection instance
548
1052
  */
549
- getOrCreateCollection({ name, configuration, metadata, embeddingFunction, }: {
1053
+ getOrCreateCollection({ name, configuration, metadata, embeddingFunction, schema, }: {
550
1054
  name: string;
551
1055
  configuration?: CreateCollectionConfiguration;
552
1056
  metadata?: CollectionMetadata;
553
1057
  embeddingFunction?: EmbeddingFunction | null;
1058
+ schema?: Schema;
554
1059
  }): Promise<Collection>;
555
1060
  /**
556
1061
  * Deletes a collection and all its data.
@@ -588,6 +1093,171 @@ declare class ChromaClient {
588
1093
  supportsBase64Encoding(): Promise<boolean>;
589
1094
  }
590
1095
 
1096
+ type WhereJSON = Record<string, unknown>;
1097
+ type WhereInput = WhereExpression | WhereJSON | null | undefined;
1098
+ declare abstract class WhereExpressionBase {
1099
+ abstract toJSON(): WhereJSON;
1100
+ and(other: WhereInput): WhereExpression;
1101
+ or(other: WhereInput): WhereExpression;
1102
+ }
1103
+ declare abstract class WhereExpression extends WhereExpressionBase {
1104
+ static from(input: WhereInput): WhereExpression | undefined;
1105
+ }
1106
+
1107
+ type IterableInput<T> = Iterable<T> | ArrayLike<T>;
1108
+
1109
+ declare class Key {
1110
+ readonly name: string;
1111
+ static readonly ID: Key;
1112
+ static readonly DOCUMENT: Key;
1113
+ static readonly EMBEDDING: Key;
1114
+ static readonly METADATA: Key;
1115
+ static readonly SCORE: Key;
1116
+ constructor(name: string);
1117
+ eq(value: unknown): WhereExpression;
1118
+ ne(value: unknown): WhereExpression;
1119
+ gt(value: unknown): WhereExpression;
1120
+ gte(value: unknown): WhereExpression;
1121
+ lt(value: unknown): WhereExpression;
1122
+ lte(value: unknown): WhereExpression;
1123
+ isIn(values: IterableInput<unknown>): WhereExpression;
1124
+ notIn(values: IterableInput<unknown>): WhereExpression;
1125
+ contains(value: string): WhereExpression;
1126
+ notContains(value: string): WhereExpression;
1127
+ regex(pattern: string): WhereExpression;
1128
+ notRegex(pattern: string): WhereExpression;
1129
+ }
1130
+ interface KeyFactory {
1131
+ (name: string): Key;
1132
+ ID: Key;
1133
+ DOCUMENT: Key;
1134
+ EMBEDDING: Key;
1135
+ METADATA: Key;
1136
+ SCORE: Key;
1137
+ }
1138
+ declare const K: KeyFactory;
1139
+
1140
+ interface LimitOptions {
1141
+ offset?: number;
1142
+ limit?: number | null | undefined;
1143
+ }
1144
+ type LimitInput = Limit | number | LimitOptions | null | undefined;
1145
+ declare class Limit {
1146
+ readonly offset: number;
1147
+ readonly limit?: number;
1148
+ constructor(options?: LimitOptions);
1149
+ static from(input: LimitInput, offsetOverride?: number): Limit;
1150
+ toJSON(): {
1151
+ offset: number;
1152
+ limit?: number;
1153
+ };
1154
+ }
1155
+
1156
+ type SelectKeyInput = string | Key;
1157
+ type SelectInput = Select | Iterable<SelectKeyInput> | {
1158
+ keys?: Iterable<SelectKeyInput>;
1159
+ } | null | undefined;
1160
+ declare class Select {
1161
+ private readonly keys;
1162
+ constructor(keys?: Iterable<SelectKeyInput>);
1163
+ static from(input: SelectInput): Select;
1164
+ static all(): Select;
1165
+ get values(): string[];
1166
+ toJSON(): {
1167
+ keys: string[];
1168
+ };
1169
+ }
1170
+
1171
+ type RankLiteral = Record<string, unknown>;
1172
+ type RankInput = RankExpression | RankLiteral | number | null | undefined;
1173
+ declare abstract class RankExpressionBase {
1174
+ abstract toJSON(): Record<string, unknown>;
1175
+ add(...others: RankInput[]): RankExpression;
1176
+ subtract(other: RankInput): RankExpression;
1177
+ multiply(...others: RankInput[]): RankExpression;
1178
+ divide(other: RankInput): RankExpression;
1179
+ negate(): RankExpression;
1180
+ abs(): RankExpression;
1181
+ exp(): RankExpression;
1182
+ log(): RankExpression;
1183
+ max(...others: RankInput[]): RankExpression;
1184
+ min(...others: RankInput[]): RankExpression;
1185
+ }
1186
+ declare abstract class RankExpression extends RankExpressionBase {
1187
+ static from(input: RankInput): RankExpression | undefined;
1188
+ }
1189
+ interface KnnOptions {
1190
+ query: IterableInput<number> | SparseVector | string;
1191
+ key?: string | Key;
1192
+ limit?: number;
1193
+ default?: number | null;
1194
+ returnRank?: boolean;
1195
+ }
1196
+ declare const Val: (value: number) => RankExpression;
1197
+ declare const Knn: (options: KnnOptions) => RankExpression;
1198
+ interface RrfOptions {
1199
+ ranks: RankInput[];
1200
+ k?: number;
1201
+ weights?: number[];
1202
+ normalize?: boolean;
1203
+ }
1204
+ declare const Rrf: ({ ranks, k, weights, normalize }: RrfOptions) => RankExpression;
1205
+ declare const Sum: (...inputs: RankInput[]) => RankExpression;
1206
+ declare const Sub: (left: RankInput, right: RankInput) => RankExpression;
1207
+ declare const Mul: (...inputs: RankInput[]) => RankExpression;
1208
+ declare const Div: (left: RankInput, right: RankInput) => RankExpression;
1209
+ declare const Abs: (input: RankInput) => RankExpression;
1210
+ declare const Exp: (input: RankInput) => RankExpression;
1211
+ declare const Log: (input: RankInput) => RankExpression;
1212
+ declare const Max: (...inputs: RankInput[]) => RankExpression;
1213
+ declare const Min: (...inputs: RankInput[]) => RankExpression;
1214
+
1215
+ interface SearchInit {
1216
+ where?: WhereInput;
1217
+ rank?: RankInput;
1218
+ limit?: LimitInput;
1219
+ select?: SelectInput;
1220
+ }
1221
+ declare class Search {
1222
+ private _where?;
1223
+ private _rank?;
1224
+ private _limit;
1225
+ private _select;
1226
+ constructor(init?: SearchInit);
1227
+ private clone;
1228
+ where(where?: WhereInput): Search;
1229
+ rank(rank?: RankInput): Search;
1230
+ limit(limit?: LimitInput, offset?: number): Search;
1231
+ select(keys?: SelectInput): Search;
1232
+ select(...keys: SelectKeyInput[]): Search;
1233
+ selectAll(): Search;
1234
+ get whereClause(): WhereExpression | undefined;
1235
+ get rankExpression(): RankExpression | undefined;
1236
+ get limitConfig(): Limit;
1237
+ get selectConfig(): Select;
1238
+ toPayload(): SearchPayload;
1239
+ }
1240
+ type SearchLike = Search | SearchInit;
1241
+ declare const toSearch: (input: SearchLike) => Search;
1242
+
1243
+ interface SearchResultRow {
1244
+ id: string;
1245
+ document?: string | null;
1246
+ embedding?: number[] | null;
1247
+ metadata?: Metadata | null;
1248
+ score?: number | null;
1249
+ }
1250
+ declare class SearchResult {
1251
+ readonly ids: string[][];
1252
+ readonly documents: Array<Array<string | null> | null>;
1253
+ readonly embeddings: Array<Array<Array<number> | null> | null>;
1254
+ readonly metadatas: Array<Array<Metadata | null> | null>;
1255
+ readonly scores: Array<Array<number | null> | null>;
1256
+ readonly select: SearchResponse["select"];
1257
+ constructor(response: SearchResponse);
1258
+ rows(): SearchResultRow[][];
1259
+ }
1260
+
591
1261
  /**
592
1262
  * Interface for collection operations using collection ID.
593
1263
  * Provides methods for adding, querying, updating, and deleting records.
@@ -603,6 +1273,8 @@ interface Collection {
603
1273
  configuration: CollectionConfiguration;
604
1274
  /** Optional embedding function. Must match the one used to create the collection. */
605
1275
  embeddingFunction?: EmbeddingFunction;
1276
+ /** Collection schema describing index configuration */
1277
+ schema?: Schema;
606
1278
  /** Gets the total number of records in the collection */
607
1279
  count(): Promise<number>;
608
1280
  /**
@@ -737,6 +1409,12 @@ interface Collection {
737
1409
  /** Document content-based filtering for deletion */
738
1410
  whereDocument?: WhereDocument;
739
1411
  }): Promise<void>;
1412
+ /**
1413
+ * Performs hybrid search on the collection using expression builders.
1414
+ * @param searches - Single search payload or array of payloads
1415
+ * @returns Promise resolving to column-major search results
1416
+ */
1417
+ search(searches: SearchLike | SearchLike[]): Promise<SearchResult>;
740
1418
  }
741
1419
 
742
1420
  declare function withChroma(userNextConfig?: any): any;
@@ -948,4 +1626,4 @@ declare class ChromaRateLimitError extends Error {
948
1626
  }
949
1627
  declare function createErrorByType(type: string, message: string): InvalidCollectionError | InvalidArgumentError | undefined;
950
1628
 
951
- export { AdminClient, type AdminClientArgs, AdminCloudClient, type BaseRecordSet, ChromaClient, type ChromaClientArgs, ChromaClientError, ChromaConnectionError, ChromaError, ChromaForbiddenError, ChromaNotFoundError, ChromaQuotaExceededError, ChromaRateLimitError, ChromaServerError, ChromaUnauthorizedError, ChromaUniqueError, ChromaValueError, CloudClient, type Collection, type CollectionConfiguration, type CollectionMetadata, type CreateCollectionConfiguration, type EmbeddingFunction, type EmbeddingFunctionClass, type EmbeddingFunctionSpace, GetResult, type HNSWConfiguration, IncludeEnum, InvalidArgumentError, InvalidCollectionError, type ListDatabasesArgs, type Metadata, type PreparedInsertRecordSet, type PreparedRecordSet, type QueryRecordSet, QueryResult, type QueryRowResult, type RecordSet, type UpdateCollectionConfiguration, type UpdateHNSWConfiguration, type UpdateSPANNConfiguration, type UserIdentity, type Where, type WhereDocument, baseRecordSetFields, createErrorByType, getDefaultEFConfig, getEmbeddingFunction, knownEmbeddingFunctions, processCreateCollectionConfig, processUpdateCollectionConfig, recordSetFields, registerEmbeddingFunction, serializeEmbeddingFunction, withChroma };
1629
+ export { Abs, AdminClient, type AdminClientArgs, AdminCloudClient, type AnyEmbeddingFunction, type BaseRecordSet, BoolInvertedIndexConfig, BoolInvertedIndexType, BoolValueType, ChromaClient, type ChromaClientArgs, ChromaClientError, ChromaConnectionError, ChromaError, ChromaForbiddenError, ChromaNotFoundError, ChromaQuotaExceededError, ChromaRateLimitError, ChromaServerError, ChromaUnauthorizedError, ChromaUniqueError, ChromaValueError, CloudClient, type Collection, type CollectionConfiguration, type CollectionMetadata, type CreateCollectionConfiguration, DOCUMENT_KEY, Div, EMBEDDING_KEY, type EmbeddingFunction, type EmbeddingFunctionClass, type EmbeddingFunctionSpace, Exp, FloatInvertedIndexConfig, FloatInvertedIndexType, FloatListValueType, FloatValueType, FtsIndexConfig, FtsIndexType, GetResult, type HNSWConfiguration, IncludeEnum, type IndexConfig, IntInvertedIndexConfig, IntInvertedIndexType, IntValueType, InvalidArgumentError, InvalidCollectionError, K, Key, type KeyFactory, Knn, type KnnOptions, Limit, type LimitInput, type LimitOptions, type ListDatabasesArgs, Log, Max, type Metadata, Min, Mul, type PreparedInsertRecordSet, type PreparedRecordSet, type QueryRecordSet, QueryResult, type QueryRowResult, RankExpression, type RankInput, type RankLiteral, type RecordSet, Rrf, type RrfOptions, Schema, Search, type SearchInit, type SearchLike, SearchResult, type SearchResultRow, Select, type SelectInput, type SelectKeyInput, type SparseEmbeddingFunction, type SparseEmbeddingFunctionClass, type SparseVector, SparseVectorIndexConfig, type SparseVectorIndexConfigOptions, SparseVectorIndexType, SparseVectorValueType, StringInvertedIndexConfig, StringInvertedIndexType, StringValueType, Sub, Sum, type UpdateCollectionConfiguration, type UpdateHNSWConfiguration, type UpdateSPANNConfiguration, type UserIdentity, Val, ValueTypes, VectorIndexConfig, type VectorIndexConfigOptions, VectorIndexType, type Where, type WhereDocument, WhereExpression, type WhereInput, type WhereJSON, baseRecordSetFields, createErrorByType, getDefaultEFConfig, getEmbeddingFunction, getSparseEmbeddingFunction, knownEmbeddingFunctions, knownSparseEmbeddingFunctions, processCreateCollectionConfig, processUpdateCollectionConfig, recordSetFields, registerEmbeddingFunction, registerSparseEmbeddingFunction, serializeEmbeddingFunction, toSearch, withChroma };