chromadb 3.3.2 → 3.3.3
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 +2 -2
- package/dist/chromadb.legacy-esm.js +11 -67
- package/dist/chromadb.mjs +11 -67
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +11 -67
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +2 -2
- package/package.json +1 -1
- package/src/chroma-client.ts +0 -5
- package/src/collection-configuration.ts +0 -1
- package/src/collection.ts +7 -6
- package/src/embedding-function.ts +11 -68
- package/src/schema.ts +0 -2
package/dist/cjs/chromadb.d.cts
CHANGED
|
@@ -757,7 +757,6 @@ declare const registerSparseEmbeddingFunction: (name: string, fn: SparseEmbeddin
|
|
|
757
757
|
* @returns EmbeddingFunction instance or undefined if it cannot be constructed
|
|
758
758
|
*/
|
|
759
759
|
declare const getEmbeddingFunction: (args: {
|
|
760
|
-
collectionName: string;
|
|
761
760
|
client: ChromaClient;
|
|
762
761
|
efConfig?: EmbeddingFunctionConfiguration;
|
|
763
762
|
}) => Promise<EmbeddingFunction | undefined>;
|
|
@@ -765,7 +764,7 @@ declare const getEmbeddingFunction: (args: {
|
|
|
765
764
|
* Retrieves and instantiates a sparse embedding function from configuration.
|
|
766
765
|
* @returns SparseEmbeddingFunction instance or undefined if it cannot be constructed
|
|
767
766
|
*/
|
|
768
|
-
declare const getSparseEmbeddingFunction: (
|
|
767
|
+
declare const getSparseEmbeddingFunction: (client: ChromaClient, efConfig?: EmbeddingFunctionConfiguration) => Promise<SparseEmbeddingFunction | undefined>;
|
|
769
768
|
/**
|
|
770
769
|
* Serializes an embedding function to configuration format.
|
|
771
770
|
* @param embeddingFunction - User provided embedding function
|
|
@@ -1722,6 +1721,7 @@ interface Collection {
|
|
|
1722
1721
|
/**
|
|
1723
1722
|
* Performs hybrid search on the collection using expression builders.
|
|
1724
1723
|
* @param searches - Single search payload or array of payloads
|
|
1724
|
+
* @param options
|
|
1725
1725
|
* @returns Promise resolving to column-major search results
|
|
1726
1726
|
*/
|
|
1727
1727
|
search(searches: SearchLike | SearchLike[], options?: {
|
package/package.json
CHANGED
package/src/chroma-client.ts
CHANGED
|
@@ -259,7 +259,6 @@ export class ChromaClient {
|
|
|
259
259
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
260
260
|
const resolvedEmbeddingFunction =
|
|
261
261
|
(await getEmbeddingFunction({
|
|
262
|
-
collectionName: collection.name,
|
|
263
262
|
client: this,
|
|
264
263
|
efConfig:
|
|
265
264
|
collection.configuration_json.embedding_function ?? undefined,
|
|
@@ -346,7 +345,6 @@ export class ChromaClient {
|
|
|
346
345
|
const resolvedEmbeddingFunction =
|
|
347
346
|
embeddingFunction ??
|
|
348
347
|
(await getEmbeddingFunction({
|
|
349
|
-
collectionName: data.name,
|
|
350
348
|
client: this,
|
|
351
349
|
efConfig: data.configuration_json.embedding_function ?? undefined,
|
|
352
350
|
})) ??
|
|
@@ -391,7 +389,6 @@ export class ChromaClient {
|
|
|
391
389
|
const resolvedEmbeddingFunction =
|
|
392
390
|
embeddingFunction ??
|
|
393
391
|
(await getEmbeddingFunction({
|
|
394
|
-
collectionName: data.name,
|
|
395
392
|
client: this,
|
|
396
393
|
efConfig: data.configuration_json.embedding_function ?? undefined,
|
|
397
394
|
})) ??
|
|
@@ -426,7 +423,6 @@ export class ChromaClient {
|
|
|
426
423
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
427
424
|
const resolvedEmbeddingFunction =
|
|
428
425
|
(await getEmbeddingFunction({
|
|
429
|
-
collectionName: data.name,
|
|
430
426
|
efConfig: data.configuration_json.embedding_function ?? undefined,
|
|
431
427
|
client: this,
|
|
432
428
|
})) ?? schemaEmbeddingFunction;
|
|
@@ -523,7 +519,6 @@ export class ChromaClient {
|
|
|
523
519
|
const resolvedEmbeddingFunction =
|
|
524
520
|
embeddingFunction ??
|
|
525
521
|
(await getEmbeddingFunction({
|
|
526
|
-
collectionName: name,
|
|
527
522
|
efConfig: data.configuration_json.embedding_function ?? undefined,
|
|
528
523
|
client: this,
|
|
529
524
|
})) ??
|
|
@@ -207,7 +207,6 @@ export const processUpdateCollectionConfig = async ({
|
|
|
207
207
|
const embeddingFunction =
|
|
208
208
|
currentEmbeddingFunction ||
|
|
209
209
|
(await getEmbeddingFunction({
|
|
210
|
-
collectionName: collectionName,
|
|
211
210
|
client,
|
|
212
211
|
efConfig: currentConfiguration.embeddingFunction ?? undefined,
|
|
213
212
|
}));
|
package/src/collection.ts
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
processUpdateCollectionConfig,
|
|
46
46
|
UpdateCollectionConfiguration,
|
|
47
47
|
} from "./collection-configuration";
|
|
48
|
-
import { SearchLike, SearchResult, toSearch } from "./execution
|
|
48
|
+
import { SearchLike, SearchResult, toSearch } from "./execution";
|
|
49
49
|
import { isPlainObject } from "./execution/expression/common";
|
|
50
50
|
import { Schema, EMBEDDING_KEY, DOCUMENT_KEY } from "./schema";
|
|
51
51
|
import type { SparseVectorIndexConfig } from "./schema";
|
|
@@ -216,6 +216,7 @@ export interface Collection {
|
|
|
216
216
|
/**
|
|
217
217
|
* Performs hybrid search on the collection using expression builders.
|
|
218
218
|
* @param searches - Single search payload or array of payloads
|
|
219
|
+
* @param options
|
|
219
220
|
* @returns Promise resolving to column-major search results
|
|
220
221
|
*/
|
|
221
222
|
search(
|
|
@@ -366,7 +367,9 @@ export class CollectionImpl implements Collection {
|
|
|
366
367
|
|
|
367
368
|
if (!embeddingFunction) {
|
|
368
369
|
throw new ChromaValueError(
|
|
369
|
-
|
|
370
|
+
`No embedding function found for collection '${this._name}'. ` +
|
|
371
|
+
"You can either provide embeddings directly, or ensure the appropriate " +
|
|
372
|
+
"embedding function package (e.g. @chroma-core/default-embed) is installed.",
|
|
370
373
|
);
|
|
371
374
|
}
|
|
372
375
|
|
|
@@ -459,10 +462,8 @@ export class CollectionImpl implements Collection {
|
|
|
459
462
|
// Get document at this position
|
|
460
463
|
if (index < documentsList.length) {
|
|
461
464
|
const doc = documentsList[index];
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
positions.push(index);
|
|
465
|
-
}
|
|
465
|
+
inputs.push(doc);
|
|
466
|
+
positions.push(index);
|
|
466
467
|
}
|
|
467
468
|
});
|
|
468
469
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EmbeddingFunctionConfiguration, SparseVector } from "./api";
|
|
2
2
|
import { ChromaValueError } from "./errors";
|
|
3
|
-
import { DefaultEmbeddingFunction } from "@chroma-core/default-embed";
|
|
4
3
|
import { ChromaClient } from "./chroma-client";
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -140,7 +139,8 @@ const pythonEmbeddingFunctions: Record<string, string> = {
|
|
|
140
139
|
default: "default-embed",
|
|
141
140
|
together_ai: "together-ai",
|
|
142
141
|
sentence_transformer: "sentence-transformer",
|
|
143
|
-
|
|
142
|
+
google_gemini: "google-gemini",
|
|
143
|
+
google_genai: "google-gemini", // Backward compatibility alias
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
const unsupportedEmbeddingFunctions: Set<string> = new Set([
|
|
@@ -225,41 +225,16 @@ export const registerSparseEmbeddingFunction = (
|
|
|
225
225
|
* @returns EmbeddingFunction instance or undefined if it cannot be constructed
|
|
226
226
|
*/
|
|
227
227
|
export const getEmbeddingFunction = async (args: {
|
|
228
|
-
collectionName: string;
|
|
229
228
|
client: ChromaClient;
|
|
230
229
|
efConfig?: EmbeddingFunctionConfiguration;
|
|
231
230
|
}) => {
|
|
232
|
-
const {
|
|
231
|
+
const { client, efConfig } = args;
|
|
233
232
|
|
|
234
|
-
if (
|
|
235
|
-
console.warn(
|
|
236
|
-
`No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`,
|
|
237
|
-
);
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (efConfig.type === "legacy") {
|
|
242
|
-
console.warn(
|
|
243
|
-
`No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`,
|
|
244
|
-
);
|
|
245
|
-
return undefined;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (efConfig.type === "unknown") {
|
|
249
|
-
console.warn(
|
|
250
|
-
`Unknown embedding function configuration for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`,
|
|
251
|
-
);
|
|
252
|
-
return undefined;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (efConfig.type !== "known") {
|
|
233
|
+
if (efConfig?.type !== "known") {
|
|
256
234
|
return undefined;
|
|
257
235
|
}
|
|
258
236
|
|
|
259
237
|
if (unsupportedEmbeddingFunctions.has(efConfig.name)) {
|
|
260
|
-
console.warn(
|
|
261
|
-
`Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly.`,
|
|
262
|
-
);
|
|
263
238
|
return undefined;
|
|
264
239
|
}
|
|
265
240
|
|
|
@@ -276,33 +251,23 @@ export const getEmbeddingFunction = async (args: {
|
|
|
276
251
|
await import(fullPackageName);
|
|
277
252
|
embeddingFunction = knownEmbeddingFunctions.get(packageName);
|
|
278
253
|
} catch (error) {
|
|
279
|
-
// Dynamic loading failed
|
|
254
|
+
// Dynamic loading failed
|
|
280
255
|
}
|
|
281
256
|
|
|
282
257
|
if (!embeddingFunction) {
|
|
283
|
-
console.warn(
|
|
284
|
-
`Collection ${collectionName} was created with the ${packageName} embedding function. However, the @chroma-core/${packageName} package is not installed. 'add' and 'query' will fail unless you provide them embeddings directly, or install the @chroma-core/${packageName} package.`,
|
|
285
|
-
);
|
|
286
258
|
return undefined;
|
|
287
259
|
}
|
|
288
260
|
}
|
|
289
261
|
|
|
290
|
-
|
|
291
|
-
|
|
262
|
+
const constructorConfig: Record<string, any> =
|
|
263
|
+
(efConfig.config as Record<string, any>) ?? {};
|
|
292
264
|
|
|
293
265
|
try {
|
|
294
266
|
if (embeddingFunction.buildFromConfig) {
|
|
295
267
|
return embeddingFunction.buildFromConfig(constructorConfig, client);
|
|
296
268
|
}
|
|
297
|
-
|
|
298
|
-
console.warn(
|
|
299
|
-
`Embedding function ${packageName} does not define a 'buildFromConfig' function. 'add' and 'query' will fail unless you provide them embeddings directly.`,
|
|
300
|
-
);
|
|
301
269
|
return undefined;
|
|
302
270
|
} catch (e) {
|
|
303
|
-
console.warn(
|
|
304
|
-
`Embedding function ${packageName} failed to build with config: ${constructorConfig}. 'add' and 'query' will fail unless you provide them embeddings directly. Error: ${e}`,
|
|
305
|
-
);
|
|
306
271
|
return undefined;
|
|
307
272
|
}
|
|
308
273
|
};
|
|
@@ -312,26 +277,14 @@ export const getEmbeddingFunction = async (args: {
|
|
|
312
277
|
* @returns SparseEmbeddingFunction instance or undefined if it cannot be constructed
|
|
313
278
|
*/
|
|
314
279
|
export const getSparseEmbeddingFunction = async (
|
|
315
|
-
collectionName: string,
|
|
316
280
|
client: ChromaClient,
|
|
317
281
|
efConfig?: EmbeddingFunctionConfiguration,
|
|
318
282
|
) => {
|
|
319
|
-
if (
|
|
320
|
-
return undefined;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (efConfig.type === "legacy") {
|
|
324
|
-
return undefined;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (efConfig.type !== "known") {
|
|
283
|
+
if (efConfig?.type !== "known") {
|
|
328
284
|
return undefined;
|
|
329
285
|
}
|
|
330
286
|
|
|
331
287
|
if (unsupportedSparseEmbeddingFunctions.has(efConfig.name)) {
|
|
332
|
-
console.warn(
|
|
333
|
-
"Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly.",
|
|
334
|
-
);
|
|
335
288
|
return undefined;
|
|
336
289
|
}
|
|
337
290
|
|
|
@@ -345,33 +298,23 @@ export const getSparseEmbeddingFunction = async (
|
|
|
345
298
|
await import(fullPackageName);
|
|
346
299
|
sparseEmbeddingFunction = knownSparseEmbeddingFunctions.get(packageName);
|
|
347
300
|
} catch (error) {
|
|
348
|
-
// Dynamic loading failed
|
|
301
|
+
// Dynamic loading failed
|
|
349
302
|
}
|
|
350
303
|
|
|
351
304
|
if (!sparseEmbeddingFunction) {
|
|
352
|
-
console.warn(
|
|
353
|
-
`Collection ${collectionName} was created with the ${packageName} sparse embedding function. However, the @chroma-core/${packageName} package is not installed.`,
|
|
354
|
-
);
|
|
355
305
|
return undefined;
|
|
356
306
|
}
|
|
357
307
|
}
|
|
358
308
|
|
|
359
|
-
|
|
360
|
-
|
|
309
|
+
const constructorConfig: Record<string, any> =
|
|
310
|
+
(efConfig.config as Record<string, any>) ?? {};
|
|
361
311
|
|
|
362
312
|
try {
|
|
363
313
|
if (sparseEmbeddingFunction.buildFromConfig) {
|
|
364
314
|
return sparseEmbeddingFunction.buildFromConfig(constructorConfig, client);
|
|
365
315
|
}
|
|
366
|
-
|
|
367
|
-
console.warn(
|
|
368
|
-
`Sparse embedding function ${packageName} does not define a 'buildFromConfig' function.`,
|
|
369
|
-
);
|
|
370
316
|
return undefined;
|
|
371
317
|
} catch (e) {
|
|
372
|
-
console.warn(
|
|
373
|
-
`Sparse embedding function ${packageName} failed to build with config: ${constructorConfig}. Error: ${e}`,
|
|
374
|
-
);
|
|
375
318
|
return undefined;
|
|
376
319
|
}
|
|
377
320
|
};
|
package/src/schema.ts
CHANGED
|
@@ -1285,7 +1285,6 @@ export class Schema {
|
|
|
1285
1285
|
});
|
|
1286
1286
|
|
|
1287
1287
|
config.embeddingFunction = await getEmbeddingFunction({
|
|
1288
|
-
collectionName: "schema deserialization",
|
|
1289
1288
|
client,
|
|
1290
1289
|
efConfig: json.embedding_function as EmbeddingFunctionConfiguration,
|
|
1291
1290
|
});
|
|
@@ -1307,7 +1306,6 @@ export class Schema {
|
|
|
1307
1306
|
|
|
1308
1307
|
const embeddingFunction =
|
|
1309
1308
|
(await getSparseEmbeddingFunction(
|
|
1310
|
-
"schema deserialization",
|
|
1311
1309
|
client,
|
|
1312
1310
|
json.embedding_function as EmbeddingFunctionConfiguration,
|
|
1313
1311
|
)) ??
|