chromadb 3.4.2 → 3.5.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.
- package/dist/chromadb.d.ts +40 -6
- package/dist/chromadb.legacy-esm.js +49 -16
- package/dist/chromadb.mjs +49 -16
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +49 -16
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +40 -6
- package/dist/cjs/cli.cjs +3 -0
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cli.mjs +3 -0
- package/dist/cli.mjs.map +1 -1
- package/package.json +22 -22
- package/src/api/sdk.gen.ts +39 -1
- package/src/api/types.gen.ts +132 -6
- package/src/chroma-client.ts +32 -0
- package/src/cli.ts +4 -0
- package/src/collection.ts +2 -0
- package/src/schema.ts +39 -39
- package/src/types.ts +3 -0
package/src/schema.ts
CHANGED
|
@@ -251,72 +251,72 @@ export class SparseVectorIndexConfig {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
export class FtsIndexType {
|
|
254
|
-
constructor(public enabled: boolean, public config: FtsIndexConfig) {
|
|
254
|
+
constructor(public enabled: boolean, public config: FtsIndexConfig) {}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
export class StringInvertedIndexType {
|
|
258
258
|
constructor(
|
|
259
259
|
public enabled: boolean,
|
|
260
260
|
public config: StringInvertedIndexConfig,
|
|
261
|
-
) {
|
|
261
|
+
) {}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
export class VectorIndexType {
|
|
265
|
-
constructor(public enabled: boolean, public config: VectorIndexConfig) {
|
|
265
|
+
constructor(public enabled: boolean, public config: VectorIndexConfig) {}
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
export class SparseVectorIndexType {
|
|
269
269
|
constructor(
|
|
270
270
|
public enabled: boolean,
|
|
271
271
|
public config: SparseVectorIndexConfig,
|
|
272
|
-
) {
|
|
272
|
+
) {}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
export class IntInvertedIndexType {
|
|
276
|
-
constructor(public enabled: boolean, public config: IntInvertedIndexConfig) {
|
|
276
|
+
constructor(public enabled: boolean, public config: IntInvertedIndexConfig) {}
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
export class FloatInvertedIndexType {
|
|
280
280
|
constructor(
|
|
281
281
|
public enabled: boolean,
|
|
282
282
|
public config: FloatInvertedIndexConfig,
|
|
283
|
-
) {
|
|
283
|
+
) {}
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
export class BoolInvertedIndexType {
|
|
287
287
|
constructor(
|
|
288
288
|
public enabled: boolean,
|
|
289
289
|
public config: BoolInvertedIndexConfig,
|
|
290
|
-
) {
|
|
290
|
+
) {}
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
export class StringValueType {
|
|
294
294
|
constructor(
|
|
295
295
|
public ftsIndex: FtsIndexType | null = null,
|
|
296
296
|
public stringInvertedIndex: StringInvertedIndexType | null = null,
|
|
297
|
-
) {
|
|
297
|
+
) {}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
export class FloatListValueType {
|
|
301
|
-
constructor(public vectorIndex: VectorIndexType | null = null) {
|
|
301
|
+
constructor(public vectorIndex: VectorIndexType | null = null) {}
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
export class SparseVectorValueType {
|
|
305
|
-
constructor(public sparseVectorIndex: SparseVectorIndexType | null = null) {
|
|
305
|
+
constructor(public sparseVectorIndex: SparseVectorIndexType | null = null) {}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
export class IntValueType {
|
|
309
|
-
constructor(public intInvertedIndex: IntInvertedIndexType | null = null) {
|
|
309
|
+
constructor(public intInvertedIndex: IntInvertedIndexType | null = null) {}
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
export class FloatValueType {
|
|
313
313
|
constructor(
|
|
314
314
|
public floatInvertedIndex: FloatInvertedIndexType | null = null,
|
|
315
|
-
) {
|
|
315
|
+
) {}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
export class BoolValueType {
|
|
319
|
-
constructor(public boolInvertedIndex: BoolInvertedIndexType | null = null) {
|
|
319
|
+
constructor(public boolInvertedIndex: BoolInvertedIndexType | null = null) {}
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
export class ValueTypes {
|
|
@@ -351,11 +351,11 @@ const cloneObject = <T>(value: T): T => {
|
|
|
351
351
|
return Array.isArray(value)
|
|
352
352
|
? (value.map((item) => cloneObject(item)) as T)
|
|
353
353
|
: (Object.fromEntries(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
354
|
+
Object.entries(value as Record<string, unknown>).map(([k, v]) => [
|
|
355
|
+
k,
|
|
356
|
+
cloneObject(v),
|
|
357
|
+
]),
|
|
358
|
+
) as T);
|
|
359
359
|
};
|
|
360
360
|
|
|
361
361
|
const resolveEmbeddingFunctionName = (
|
|
@@ -520,7 +520,11 @@ export class Schema {
|
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
// Only allow #document with FtsIndexConfig
|
|
523
|
-
if (
|
|
523
|
+
if (
|
|
524
|
+
keyProvided &&
|
|
525
|
+
key === DOCUMENT_KEY &&
|
|
526
|
+
!(config instanceof FtsIndexConfig)
|
|
527
|
+
) {
|
|
524
528
|
throw new Error(
|
|
525
529
|
`Cannot create index on special key '${key}' with this config. Only FtsIndexConfig is allowed for #document.`,
|
|
526
530
|
);
|
|
@@ -545,7 +549,10 @@ export class Schema {
|
|
|
545
549
|
}
|
|
546
550
|
|
|
547
551
|
// FTS index is only allowed on #document key
|
|
548
|
-
if (
|
|
552
|
+
if (
|
|
553
|
+
config instanceof FtsIndexConfig &&
|
|
554
|
+
(!keyProvided || key !== DOCUMENT_KEY)
|
|
555
|
+
) {
|
|
549
556
|
throw new Error(
|
|
550
557
|
"FTS index can only be enabled on #document key. Use createIndex(new FtsIndexConfig(), '#document')",
|
|
551
558
|
);
|
|
@@ -586,13 +593,15 @@ export class Schema {
|
|
|
586
593
|
|
|
587
594
|
// Disallow using special internal key #embedding
|
|
588
595
|
if (keyProvided && key && key === EMBEDDING_KEY) {
|
|
589
|
-
throw new Error(
|
|
590
|
-
"Cannot modify #embedding. Currently not supported",
|
|
591
|
-
);
|
|
596
|
+
throw new Error("Cannot modify #embedding. Currently not supported");
|
|
592
597
|
}
|
|
593
598
|
|
|
594
599
|
// Only allow #document with FtsIndexConfig (to disable FTS)
|
|
595
|
-
if (
|
|
600
|
+
if (
|
|
601
|
+
keyProvided &&
|
|
602
|
+
key === DOCUMENT_KEY &&
|
|
603
|
+
!(config instanceof FtsIndexConfig)
|
|
604
|
+
) {
|
|
596
605
|
throw new Error(
|
|
597
606
|
`Cannot delete index on special key '${key}' with this config. Only FtsIndexConfig is allowed for #document.`,
|
|
598
607
|
);
|
|
@@ -619,7 +628,10 @@ export class Schema {
|
|
|
619
628
|
}
|
|
620
629
|
|
|
621
630
|
// FTS deletion is only allowed on #document key
|
|
622
|
-
if (
|
|
631
|
+
if (
|
|
632
|
+
config instanceof FtsIndexConfig &&
|
|
633
|
+
(!keyProvided || key !== DOCUMENT_KEY)
|
|
634
|
+
) {
|
|
623
635
|
throw new Error("Deleting FTS index is only supported on #document key.");
|
|
624
636
|
}
|
|
625
637
|
|
|
@@ -769,7 +781,6 @@ export class Schema {
|
|
|
769
781
|
enabled: boolean,
|
|
770
782
|
): void {
|
|
771
783
|
if (config instanceof SparseVectorIndexConfig && enabled) {
|
|
772
|
-
this.validateSingleSparseVectorIndex(key);
|
|
773
784
|
this.validateSparseVectorConfig(config);
|
|
774
785
|
}
|
|
775
786
|
|
|
@@ -865,18 +876,6 @@ export class Schema {
|
|
|
865
876
|
);
|
|
866
877
|
}
|
|
867
878
|
|
|
868
|
-
private validateSingleSparseVectorIndex(targetKey: string): void {
|
|
869
|
-
for (const [existingKey, valueTypes] of Object.entries(this.keys)) {
|
|
870
|
-
if (existingKey === targetKey) continue;
|
|
871
|
-
const sparseIndex = valueTypes.sparseVector?.sparseVectorIndex;
|
|
872
|
-
if (sparseIndex?.enabled) {
|
|
873
|
-
throw new Error(
|
|
874
|
-
`Cannot enable sparse vector index on key '${targetKey}'. A sparse vector index is already enabled on key '${existingKey}'. Only one sparse vector index is allowed per collection.`,
|
|
875
|
-
);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
|
|
880
879
|
private validateSparseVectorConfig(config: SparseVectorIndexConfig): void {
|
|
881
880
|
// Validate that if source_key is provided then embedding_function is also provided
|
|
882
881
|
// since there is no default embedding function
|
|
@@ -1087,7 +1086,8 @@ export class Schema {
|
|
|
1087
1086
|
!embeddingFunction.supportedSpaces().includes(resolvedSpace)
|
|
1088
1087
|
) {
|
|
1089
1088
|
console.warn(
|
|
1090
|
-
`Space '${resolvedSpace}' is not supported by embedding function '${
|
|
1089
|
+
`Space '${resolvedSpace}' is not supported by embedding function '${
|
|
1090
|
+
resolveEmbeddingFunctionName(embeddingFunction) ?? "unknown"
|
|
1091
1091
|
}'. Supported spaces: ${embeddingFunction
|
|
1092
1092
|
.supportedSpaces()
|
|
1093
1093
|
.join(", ")}`,
|
package/src/types.ts
CHANGED
|
@@ -18,10 +18,13 @@ export type UserIdentity = GetUserIdentityResponse;
|
|
|
18
18
|
* All committed writes will be visible. This is the default.
|
|
19
19
|
* - INDEX_ONLY: Read only from the compacted index, skipping the WAL.
|
|
20
20
|
* Recent writes that haven't been compacted may not be visible, but queries are faster.
|
|
21
|
+
* - INDEX_AND_BOUNDED_WAL: Read from the index and up to a server-configured number of
|
|
22
|
+
* WAL entries for bounded query latency.
|
|
21
23
|
*/
|
|
22
24
|
export const ReadLevel = {
|
|
23
25
|
INDEX_AND_WAL: "index_and_wal",
|
|
24
26
|
INDEX_ONLY: "index_only",
|
|
27
|
+
INDEX_AND_BOUNDED_WAL: "index_and_bounded_wal",
|
|
25
28
|
} as const;
|
|
26
29
|
|
|
27
30
|
export type ReadLevel = (typeof ReadLevel)[keyof typeof ReadLevel];
|