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/cjs/chromadb.cjs
CHANGED
|
@@ -146,7 +146,8 @@ if (typeof globalThis.Deno !== "undefined") {
|
|
|
146
146
|
// src/types.ts
|
|
147
147
|
var ReadLevel = {
|
|
148
148
|
INDEX_AND_WAL: "index_and_wal",
|
|
149
|
-
INDEX_ONLY: "index_only"
|
|
149
|
+
INDEX_ONLY: "index_only",
|
|
150
|
+
INDEX_AND_BOUNDED_WAL: "index_and_bounded_wal"
|
|
150
151
|
};
|
|
151
152
|
var baseRecordSetFields = [
|
|
152
153
|
"ids",
|
|
@@ -556,6 +557,22 @@ var CollectionService = class {
|
|
|
556
557
|
}
|
|
557
558
|
});
|
|
558
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Get collection by ID
|
|
562
|
+
* Returns a collection by its UUID within a specific tenant and database.
|
|
563
|
+
*/
|
|
564
|
+
static getCollectionById(options) {
|
|
565
|
+
return (options.client ?? client).get({
|
|
566
|
+
security: [
|
|
567
|
+
{
|
|
568
|
+
name: "x-chroma-token",
|
|
569
|
+
type: "apiKey"
|
|
570
|
+
}
|
|
571
|
+
],
|
|
572
|
+
url: "/api/v2/tenants/{tenant}/databases/{database}/collections/by-id/{collection_id}",
|
|
573
|
+
...options
|
|
574
|
+
});
|
|
575
|
+
}
|
|
559
576
|
/**
|
|
560
577
|
* Delete collection
|
|
561
578
|
* Deletes a collection in a database.
|
|
@@ -3421,9 +3438,7 @@ var Schema = class _Schema {
|
|
|
3421
3438
|
);
|
|
3422
3439
|
}
|
|
3423
3440
|
if (keyProvided && key && key === EMBEDDING_KEY) {
|
|
3424
|
-
throw new Error(
|
|
3425
|
-
"Cannot modify #embedding. Currently not supported"
|
|
3426
|
-
);
|
|
3441
|
+
throw new Error("Cannot modify #embedding. Currently not supported");
|
|
3427
3442
|
}
|
|
3428
3443
|
if (keyProvided && key === DOCUMENT_KEY && !(config instanceof FtsIndexConfig)) {
|
|
3429
3444
|
throw new Error(
|
|
@@ -3561,7 +3576,6 @@ var Schema = class _Schema {
|
|
|
3561
3576
|
}
|
|
3562
3577
|
setIndexForKey(key, config, enabled) {
|
|
3563
3578
|
if (config instanceof SparseVectorIndexConfig && enabled) {
|
|
3564
|
-
this.validateSingleSparseVectorIndex(key);
|
|
3565
3579
|
this.validateSparseVectorConfig(config);
|
|
3566
3580
|
}
|
|
3567
3581
|
const current = this.keys[key] = ensureValueTypes(this.keys[key]);
|
|
@@ -3648,17 +3662,6 @@ var Schema = class _Schema {
|
|
|
3648
3662
|
new BoolInvertedIndexType(false, new BoolInvertedIndexConfig())
|
|
3649
3663
|
);
|
|
3650
3664
|
}
|
|
3651
|
-
validateSingleSparseVectorIndex(targetKey) {
|
|
3652
|
-
for (const [existingKey, valueTypes] of Object.entries(this.keys)) {
|
|
3653
|
-
if (existingKey === targetKey) continue;
|
|
3654
|
-
const sparseIndex = valueTypes.sparseVector?.sparseVectorIndex;
|
|
3655
|
-
if (sparseIndex?.enabled) {
|
|
3656
|
-
throw new Error(
|
|
3657
|
-
`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.`
|
|
3658
|
-
);
|
|
3659
|
-
}
|
|
3660
|
-
}
|
|
3661
|
-
}
|
|
3662
3665
|
validateSparseVectorConfig(config) {
|
|
3663
3666
|
if (config.sourceKey !== null && config.sourceKey !== void 0 && !config.embeddingFunction) {
|
|
3664
3667
|
throw new Error(
|
|
@@ -5229,6 +5232,36 @@ var ChromaClient = class {
|
|
|
5229
5232
|
schema
|
|
5230
5233
|
});
|
|
5231
5234
|
}
|
|
5235
|
+
/**
|
|
5236
|
+
* Retrieves an existing collection by its ID.
|
|
5237
|
+
* @param id - The UUID of the collection to retrieve
|
|
5238
|
+
* @returns Promise resolving to the Collection instance
|
|
5239
|
+
* @throws Error if the collection does not exist
|
|
5240
|
+
*/
|
|
5241
|
+
async getCollectionById(id) {
|
|
5242
|
+
const { data } = await CollectionService.getCollectionById({
|
|
5243
|
+
client: this.apiClient,
|
|
5244
|
+
path: { ...await this._path(), collection_id: id }
|
|
5245
|
+
});
|
|
5246
|
+
const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
|
|
5247
|
+
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
5248
|
+
const resolvedEmbeddingFunction = await getEmbeddingFunction({
|
|
5249
|
+
efConfig: data.configuration_json.embedding_function ?? void 0,
|
|
5250
|
+
client: this
|
|
5251
|
+
}) ?? schemaEmbeddingFunction;
|
|
5252
|
+
return new CollectionImpl({
|
|
5253
|
+
chromaClient: this,
|
|
5254
|
+
apiClient: this.apiClient,
|
|
5255
|
+
name: data.name,
|
|
5256
|
+
tenant: data.tenant,
|
|
5257
|
+
database: data.database,
|
|
5258
|
+
configuration: data.configuration_json,
|
|
5259
|
+
metadata: deserializeMetadata(data.metadata ?? void 0) ?? void 0,
|
|
5260
|
+
embeddingFunction: resolvedEmbeddingFunction,
|
|
5261
|
+
id: data.id,
|
|
5262
|
+
schema
|
|
5263
|
+
});
|
|
5264
|
+
}
|
|
5232
5265
|
/**
|
|
5233
5266
|
* Retrieves multiple collections by name.
|
|
5234
5267
|
* @param items - Array of collection names or objects with name and optional embedding function (should match the ones used to create the collections)
|