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/dist/chromadb.d.ts
CHANGED
|
@@ -55,8 +55,21 @@ type FloatListValueType$1 = {
|
|
|
55
55
|
type FloatValueType$1 = {
|
|
56
56
|
float_inverted_index?: null | FloatInvertedIndexType$1;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Full-text search index algorithm.
|
|
60
|
+
*
|
|
61
|
+
* Controls which index format and query pipeline are used for
|
|
62
|
+
* document substring search within a collection.
|
|
63
|
+
*/
|
|
64
|
+
type FtsAlgorithm = 'trigram' | 'token_bitmap';
|
|
58
65
|
type FtsIndexConfig$1 = {
|
|
59
|
-
|
|
66
|
+
/**
|
|
67
|
+
* FTS index algorithm.
|
|
68
|
+
* Omitted from JSON when set to the default (Trigram) so that old
|
|
69
|
+
* servers/clients that do not know about this field can still
|
|
70
|
+
* deserialize the schema.
|
|
71
|
+
*/
|
|
72
|
+
algorithm?: FtsAlgorithm;
|
|
60
73
|
};
|
|
61
74
|
type FtsIndexType$1 = {
|
|
62
75
|
config: FtsIndexConfig$1;
|
|
@@ -209,10 +222,6 @@ type Schema$1 = {
|
|
|
209
222
|
keys: {
|
|
210
223
|
[key: string]: ValueTypes$1;
|
|
211
224
|
};
|
|
212
|
-
/**
|
|
213
|
-
* ID of the attached function that created this output collection (if applicable)
|
|
214
|
-
*/
|
|
215
|
-
source_attached_function_id?: string | null;
|
|
216
225
|
};
|
|
217
226
|
type SearchPayload = {
|
|
218
227
|
filter?: {
|
|
@@ -284,6 +293,13 @@ type SpannIndexConfig = {
|
|
|
284
293
|
write_rng_epsilon?: number | null;
|
|
285
294
|
write_rng_factor?: number | null;
|
|
286
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* Sparse vector index algorithm.
|
|
298
|
+
*
|
|
299
|
+
* Controls which posting list format and query engine are used for
|
|
300
|
+
* sparse vector search within a collection.
|
|
301
|
+
*/
|
|
302
|
+
type SparseIndexAlgorithm = 'wand' | 'max_score';
|
|
287
303
|
/**
|
|
288
304
|
* Represents a sparse vector using parallel arrays for indices and values.
|
|
289
305
|
*
|
|
@@ -307,6 +323,13 @@ type SparseVector = {
|
|
|
307
323
|
values: Array<number>;
|
|
308
324
|
};
|
|
309
325
|
type SparseVectorIndexConfig$1 = {
|
|
326
|
+
/**
|
|
327
|
+
* Sparse index algorithm (cloud-only, tenant-gated).
|
|
328
|
+
* Omitted from JSON when set to the default (Wand) so that old
|
|
329
|
+
* servers/clients that do not know about this field can still
|
|
330
|
+
* deserialize the schema.
|
|
331
|
+
*/
|
|
332
|
+
algorithm?: SparseIndexAlgorithm;
|
|
310
333
|
/**
|
|
311
334
|
* Whether this embedding is BM25
|
|
312
335
|
*/
|
|
@@ -396,10 +419,13 @@ type UserIdentity = GetUserIdentityResponse;
|
|
|
396
419
|
* All committed writes will be visible. This is the default.
|
|
397
420
|
* - INDEX_ONLY: Read only from the compacted index, skipping the WAL.
|
|
398
421
|
* Recent writes that haven't been compacted may not be visible, but queries are faster.
|
|
422
|
+
* - INDEX_AND_BOUNDED_WAL: Read from the index and up to a server-configured number of
|
|
423
|
+
* WAL entries for bounded query latency.
|
|
399
424
|
*/
|
|
400
425
|
declare const ReadLevel: {
|
|
401
426
|
readonly INDEX_AND_WAL: "index_and_wal";
|
|
402
427
|
readonly INDEX_ONLY: "index_only";
|
|
428
|
+
readonly INDEX_AND_BOUNDED_WAL: "index_and_bounded_wal";
|
|
403
429
|
};
|
|
404
430
|
type ReadLevel = (typeof ReadLevel)[keyof typeof ReadLevel];
|
|
405
431
|
|
|
@@ -1290,7 +1316,6 @@ declare class Schema {
|
|
|
1290
1316
|
private setIndexForKey;
|
|
1291
1317
|
private enableAllIndexesForKey;
|
|
1292
1318
|
private disableAllIndexesForKey;
|
|
1293
|
-
private validateSingleSparseVectorIndex;
|
|
1294
1319
|
private validateSparseVectorConfig;
|
|
1295
1320
|
private initializeDefaults;
|
|
1296
1321
|
private initializeKeys;
|
|
@@ -1492,6 +1517,13 @@ declare class ChromaClient {
|
|
|
1492
1517
|
* @throws Error if the collection does not exist
|
|
1493
1518
|
*/
|
|
1494
1519
|
getCollectionByCrn(crn: string): Promise<Collection>;
|
|
1520
|
+
/**
|
|
1521
|
+
* Retrieves an existing collection by its ID.
|
|
1522
|
+
* @param id - The UUID of the collection to retrieve
|
|
1523
|
+
* @returns Promise resolving to the Collection instance
|
|
1524
|
+
* @throws Error if the collection does not exist
|
|
1525
|
+
*/
|
|
1526
|
+
getCollectionById(id: string): Promise<Collection>;
|
|
1495
1527
|
/**
|
|
1496
1528
|
* Retrieves multiple collections by name.
|
|
1497
1529
|
* @param items - Array of collection names or objects with name and optional embedding function (should match the ones used to create the collections)
|
|
@@ -1594,6 +1626,7 @@ interface Collection {
|
|
|
1594
1626
|
* Controls whether to read from the write-ahead log.
|
|
1595
1627
|
* - ReadLevel.INDEX_AND_WAL: Read from both index and WAL (default)
|
|
1596
1628
|
* - ReadLevel.INDEX_ONLY: Read only from index, faster but recent writes may not be visible
|
|
1629
|
+
* - ReadLevel.INDEX_AND_BOUNDED_WAL: Read up to a server-configured number of WAL entries
|
|
1597
1630
|
*/
|
|
1598
1631
|
readLevel?: ReadLevel;
|
|
1599
1632
|
}): Promise<number>;
|
|
@@ -1747,6 +1780,7 @@ interface Collection {
|
|
|
1747
1780
|
* Controls whether to read from the write-ahead log.
|
|
1748
1781
|
* - ReadLevel.INDEX_AND_WAL: Read from both index and WAL (default)
|
|
1749
1782
|
* - ReadLevel.INDEX_ONLY: Read only from index, faster but recent writes may not be visible
|
|
1783
|
+
* - ReadLevel.INDEX_AND_BOUNDED_WAL: Read up to a server-configured number of WAL entries
|
|
1750
1784
|
*/
|
|
1751
1785
|
readLevel?: ReadLevel;
|
|
1752
1786
|
}): Promise<SearchResult>;
|
|
@@ -26,7 +26,8 @@ if (typeof globalThis.Deno !== "undefined") {
|
|
|
26
26
|
// src/types.ts
|
|
27
27
|
var ReadLevel = {
|
|
28
28
|
INDEX_AND_WAL: "index_and_wal",
|
|
29
|
-
INDEX_ONLY: "index_only"
|
|
29
|
+
INDEX_ONLY: "index_only",
|
|
30
|
+
INDEX_AND_BOUNDED_WAL: "index_and_bounded_wal"
|
|
30
31
|
};
|
|
31
32
|
var baseRecordSetFields = [
|
|
32
33
|
"ids",
|
|
@@ -436,6 +437,22 @@ var CollectionService = class {
|
|
|
436
437
|
}
|
|
437
438
|
});
|
|
438
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Get collection by ID
|
|
442
|
+
* Returns a collection by its UUID within a specific tenant and database.
|
|
443
|
+
*/
|
|
444
|
+
static getCollectionById(options) {
|
|
445
|
+
return (options.client ?? client).get({
|
|
446
|
+
security: [
|
|
447
|
+
{
|
|
448
|
+
name: "x-chroma-token",
|
|
449
|
+
type: "apiKey"
|
|
450
|
+
}
|
|
451
|
+
],
|
|
452
|
+
url: "/api/v2/tenants/{tenant}/databases/{database}/collections/by-id/{collection_id}",
|
|
453
|
+
...options
|
|
454
|
+
});
|
|
455
|
+
}
|
|
439
456
|
/**
|
|
440
457
|
* Delete collection
|
|
441
458
|
* Deletes a collection in a database.
|
|
@@ -3301,9 +3318,7 @@ var Schema = class _Schema {
|
|
|
3301
3318
|
);
|
|
3302
3319
|
}
|
|
3303
3320
|
if (keyProvided && key && key === EMBEDDING_KEY) {
|
|
3304
|
-
throw new Error(
|
|
3305
|
-
"Cannot modify #embedding. Currently not supported"
|
|
3306
|
-
);
|
|
3321
|
+
throw new Error("Cannot modify #embedding. Currently not supported");
|
|
3307
3322
|
}
|
|
3308
3323
|
if (keyProvided && key === DOCUMENT_KEY && !(config instanceof FtsIndexConfig)) {
|
|
3309
3324
|
throw new Error(
|
|
@@ -3441,7 +3456,6 @@ var Schema = class _Schema {
|
|
|
3441
3456
|
}
|
|
3442
3457
|
setIndexForKey(key, config, enabled) {
|
|
3443
3458
|
if (config instanceof SparseVectorIndexConfig && enabled) {
|
|
3444
|
-
this.validateSingleSparseVectorIndex(key);
|
|
3445
3459
|
this.validateSparseVectorConfig(config);
|
|
3446
3460
|
}
|
|
3447
3461
|
const current = this.keys[key] = ensureValueTypes(this.keys[key]);
|
|
@@ -3528,17 +3542,6 @@ var Schema = class _Schema {
|
|
|
3528
3542
|
new BoolInvertedIndexType(false, new BoolInvertedIndexConfig())
|
|
3529
3543
|
);
|
|
3530
3544
|
}
|
|
3531
|
-
validateSingleSparseVectorIndex(targetKey) {
|
|
3532
|
-
for (const [existingKey, valueTypes] of Object.entries(this.keys)) {
|
|
3533
|
-
if (existingKey === targetKey) continue;
|
|
3534
|
-
const sparseIndex = valueTypes.sparseVector?.sparseVectorIndex;
|
|
3535
|
-
if (sparseIndex?.enabled) {
|
|
3536
|
-
throw new Error(
|
|
3537
|
-
`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.`
|
|
3538
|
-
);
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
}
|
|
3542
3545
|
validateSparseVectorConfig(config) {
|
|
3543
3546
|
if (config.sourceKey !== null && config.sourceKey !== void 0 && !config.embeddingFunction) {
|
|
3544
3547
|
throw new Error(
|
|
@@ -5109,6 +5112,36 @@ var ChromaClient = class {
|
|
|
5109
5112
|
schema
|
|
5110
5113
|
});
|
|
5111
5114
|
}
|
|
5115
|
+
/**
|
|
5116
|
+
* Retrieves an existing collection by its ID.
|
|
5117
|
+
* @param id - The UUID of the collection to retrieve
|
|
5118
|
+
* @returns Promise resolving to the Collection instance
|
|
5119
|
+
* @throws Error if the collection does not exist
|
|
5120
|
+
*/
|
|
5121
|
+
async getCollectionById(id) {
|
|
5122
|
+
const { data } = await CollectionService.getCollectionById({
|
|
5123
|
+
client: this.apiClient,
|
|
5124
|
+
path: { ...await this._path(), collection_id: id }
|
|
5125
|
+
});
|
|
5126
|
+
const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
|
|
5127
|
+
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
5128
|
+
const resolvedEmbeddingFunction = await getEmbeddingFunction({
|
|
5129
|
+
efConfig: data.configuration_json.embedding_function ?? void 0,
|
|
5130
|
+
client: this
|
|
5131
|
+
}) ?? schemaEmbeddingFunction;
|
|
5132
|
+
return new CollectionImpl({
|
|
5133
|
+
chromaClient: this,
|
|
5134
|
+
apiClient: this.apiClient,
|
|
5135
|
+
name: data.name,
|
|
5136
|
+
tenant: data.tenant,
|
|
5137
|
+
database: data.database,
|
|
5138
|
+
configuration: data.configuration_json,
|
|
5139
|
+
metadata: deserializeMetadata(data.metadata ?? void 0) ?? void 0,
|
|
5140
|
+
embeddingFunction: resolvedEmbeddingFunction,
|
|
5141
|
+
id: data.id,
|
|
5142
|
+
schema
|
|
5143
|
+
});
|
|
5144
|
+
}
|
|
5112
5145
|
/**
|
|
5113
5146
|
* Retrieves multiple collections by name.
|
|
5114
5147
|
* @param items - Array of collection names or objects with name and optional embedding function (should match the ones used to create the collections)
|
package/dist/chromadb.mjs
CHANGED
|
@@ -26,7 +26,8 @@ if (typeof globalThis.Deno !== "undefined") {
|
|
|
26
26
|
// src/types.ts
|
|
27
27
|
var ReadLevel = {
|
|
28
28
|
INDEX_AND_WAL: "index_and_wal",
|
|
29
|
-
INDEX_ONLY: "index_only"
|
|
29
|
+
INDEX_ONLY: "index_only",
|
|
30
|
+
INDEX_AND_BOUNDED_WAL: "index_and_bounded_wal"
|
|
30
31
|
};
|
|
31
32
|
var baseRecordSetFields = [
|
|
32
33
|
"ids",
|
|
@@ -436,6 +437,22 @@ var CollectionService = class {
|
|
|
436
437
|
}
|
|
437
438
|
});
|
|
438
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Get collection by ID
|
|
442
|
+
* Returns a collection by its UUID within a specific tenant and database.
|
|
443
|
+
*/
|
|
444
|
+
static getCollectionById(options) {
|
|
445
|
+
return (options.client ?? client).get({
|
|
446
|
+
security: [
|
|
447
|
+
{
|
|
448
|
+
name: "x-chroma-token",
|
|
449
|
+
type: "apiKey"
|
|
450
|
+
}
|
|
451
|
+
],
|
|
452
|
+
url: "/api/v2/tenants/{tenant}/databases/{database}/collections/by-id/{collection_id}",
|
|
453
|
+
...options
|
|
454
|
+
});
|
|
455
|
+
}
|
|
439
456
|
/**
|
|
440
457
|
* Delete collection
|
|
441
458
|
* Deletes a collection in a database.
|
|
@@ -3301,9 +3318,7 @@ var Schema = class _Schema {
|
|
|
3301
3318
|
);
|
|
3302
3319
|
}
|
|
3303
3320
|
if (keyProvided && key && key === EMBEDDING_KEY) {
|
|
3304
|
-
throw new Error(
|
|
3305
|
-
"Cannot modify #embedding. Currently not supported"
|
|
3306
|
-
);
|
|
3321
|
+
throw new Error("Cannot modify #embedding. Currently not supported");
|
|
3307
3322
|
}
|
|
3308
3323
|
if (keyProvided && key === DOCUMENT_KEY && !(config instanceof FtsIndexConfig)) {
|
|
3309
3324
|
throw new Error(
|
|
@@ -3441,7 +3456,6 @@ var Schema = class _Schema {
|
|
|
3441
3456
|
}
|
|
3442
3457
|
setIndexForKey(key, config, enabled) {
|
|
3443
3458
|
if (config instanceof SparseVectorIndexConfig && enabled) {
|
|
3444
|
-
this.validateSingleSparseVectorIndex(key);
|
|
3445
3459
|
this.validateSparseVectorConfig(config);
|
|
3446
3460
|
}
|
|
3447
3461
|
const current = this.keys[key] = ensureValueTypes(this.keys[key]);
|
|
@@ -3528,17 +3542,6 @@ var Schema = class _Schema {
|
|
|
3528
3542
|
new BoolInvertedIndexType(false, new BoolInvertedIndexConfig())
|
|
3529
3543
|
);
|
|
3530
3544
|
}
|
|
3531
|
-
validateSingleSparseVectorIndex(targetKey) {
|
|
3532
|
-
for (const [existingKey, valueTypes] of Object.entries(this.keys)) {
|
|
3533
|
-
if (existingKey === targetKey) continue;
|
|
3534
|
-
const sparseIndex = valueTypes.sparseVector?.sparseVectorIndex;
|
|
3535
|
-
if (sparseIndex?.enabled) {
|
|
3536
|
-
throw new Error(
|
|
3537
|
-
`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.`
|
|
3538
|
-
);
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
}
|
|
3542
3545
|
validateSparseVectorConfig(config) {
|
|
3543
3546
|
if (config.sourceKey !== null && config.sourceKey !== void 0 && !config.embeddingFunction) {
|
|
3544
3547
|
throw new Error(
|
|
@@ -5109,6 +5112,36 @@ var ChromaClient = class {
|
|
|
5109
5112
|
schema
|
|
5110
5113
|
});
|
|
5111
5114
|
}
|
|
5115
|
+
/**
|
|
5116
|
+
* Retrieves an existing collection by its ID.
|
|
5117
|
+
* @param id - The UUID of the collection to retrieve
|
|
5118
|
+
* @returns Promise resolving to the Collection instance
|
|
5119
|
+
* @throws Error if the collection does not exist
|
|
5120
|
+
*/
|
|
5121
|
+
async getCollectionById(id) {
|
|
5122
|
+
const { data } = await CollectionService.getCollectionById({
|
|
5123
|
+
client: this.apiClient,
|
|
5124
|
+
path: { ...await this._path(), collection_id: id }
|
|
5125
|
+
});
|
|
5126
|
+
const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
|
|
5127
|
+
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
5128
|
+
const resolvedEmbeddingFunction = await getEmbeddingFunction({
|
|
5129
|
+
efConfig: data.configuration_json.embedding_function ?? void 0,
|
|
5130
|
+
client: this
|
|
5131
|
+
}) ?? schemaEmbeddingFunction;
|
|
5132
|
+
return new CollectionImpl({
|
|
5133
|
+
chromaClient: this,
|
|
5134
|
+
apiClient: this.apiClient,
|
|
5135
|
+
name: data.name,
|
|
5136
|
+
tenant: data.tenant,
|
|
5137
|
+
database: data.database,
|
|
5138
|
+
configuration: data.configuration_json,
|
|
5139
|
+
metadata: deserializeMetadata(data.metadata ?? void 0) ?? void 0,
|
|
5140
|
+
embeddingFunction: resolvedEmbeddingFunction,
|
|
5141
|
+
id: data.id,
|
|
5142
|
+
schema
|
|
5143
|
+
});
|
|
5144
|
+
}
|
|
5112
5145
|
/**
|
|
5113
5146
|
* Retrieves multiple collections by name.
|
|
5114
5147
|
* @param items - Array of collection names or objects with name and optional embedding function (should match the ones used to create the collections)
|