chromadb 3.1.3 → 3.1.5
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 -1
- package/dist/chromadb.legacy-esm.js +20 -22
- package/dist/chromadb.mjs +20 -22
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +20 -22
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +2 -1
- package/package.json +6 -6
- package/src/embedding-function.ts +3 -3
- package/src/schema.ts +42 -23
package/dist/chromadb.d.ts
CHANGED
|
@@ -688,7 +688,7 @@ declare const registerSparseEmbeddingFunction: (name: string, fn: SparseEmbeddin
|
|
|
688
688
|
* @param efConfig - Configuration for the embedding function
|
|
689
689
|
* @returns EmbeddingFunction instance or undefined if it cannot be constructed
|
|
690
690
|
*/
|
|
691
|
-
declare const getEmbeddingFunction: (collectionName: string, efConfig?: EmbeddingFunctionConfiguration
|
|
691
|
+
declare const getEmbeddingFunction: (collectionName: string, efConfig?: EmbeddingFunctionConfiguration) => Promise<EmbeddingFunction | undefined>;
|
|
692
692
|
/**
|
|
693
693
|
* Retrieves and instantiates a sparse embedding function from configuration.
|
|
694
694
|
* @param collectionName - Name of the collection (for error messages)
|
|
@@ -1009,6 +1009,7 @@ declare class Schema {
|
|
|
1009
1009
|
private enableAllIndexesForKey;
|
|
1010
1010
|
private disableAllIndexesForKey;
|
|
1011
1011
|
private validateSingleSparseVectorIndex;
|
|
1012
|
+
private validateSparseVectorConfig;
|
|
1012
1013
|
private initializeDefaults;
|
|
1013
1014
|
private initializeKeys;
|
|
1014
1015
|
private serializeValueTypes;
|
|
@@ -1286,7 +1286,8 @@ var knownEmbeddingFunctions = /* @__PURE__ */ new Map();
|
|
|
1286
1286
|
var pythonEmbeddingFunctions = {
|
|
1287
1287
|
onnx_mini_lm_l6_v2: "default-embed",
|
|
1288
1288
|
default: "default-embed",
|
|
1289
|
-
together_ai: "together-ai"
|
|
1289
|
+
together_ai: "together-ai",
|
|
1290
|
+
sentence_transformer: "sentence-transformer"
|
|
1290
1291
|
};
|
|
1291
1292
|
var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
|
|
1292
1293
|
"amazon_bedrock",
|
|
@@ -1297,7 +1298,6 @@ var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
|
|
|
1297
1298
|
"instructor",
|
|
1298
1299
|
"open_clip",
|
|
1299
1300
|
"roboflow",
|
|
1300
|
-
"sentence_transformer",
|
|
1301
1301
|
"text2vec"
|
|
1302
1302
|
]);
|
|
1303
1303
|
var knownSparseEmbeddingFunctions = /* @__PURE__ */ new Map();
|
|
@@ -1325,7 +1325,7 @@ var registerSparseEmbeddingFunction = (name, fn) => {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
knownSparseEmbeddingFunctions.set(name, fn);
|
|
1327
1327
|
};
|
|
1328
|
-
var getEmbeddingFunction = async (collectionName, efConfig
|
|
1328
|
+
var getEmbeddingFunction = async (collectionName, efConfig) => {
|
|
1329
1329
|
if (!efConfig) {
|
|
1330
1330
|
console.warn(
|
|
1331
1331
|
`No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
@@ -1354,15 +1354,7 @@ var getEmbeddingFunction = async (collectionName, efConfig, debug) => {
|
|
|
1354
1354
|
return void 0;
|
|
1355
1355
|
}
|
|
1356
1356
|
const packageName = pythonEmbeddingFunctions[efConfig.name] || efConfig.name;
|
|
1357
|
-
if (debug) {
|
|
1358
|
-
console.log("DEBUFFING");
|
|
1359
|
-
console.log(packageName);
|
|
1360
|
-
}
|
|
1361
1357
|
if (packageName === "default-embed") {
|
|
1362
|
-
console.log("INSIDE HIT");
|
|
1363
|
-
if (debug) {
|
|
1364
|
-
console.log("FROM DEBUG");
|
|
1365
|
-
}
|
|
1366
1358
|
await getDefaultEFConfig();
|
|
1367
1359
|
}
|
|
1368
1360
|
let embeddingFunction = knownEmbeddingFunctions.get(packageName);
|
|
@@ -2762,8 +2754,9 @@ var Schema = class _Schema {
|
|
|
2762
2754
|
);
|
|
2763
2755
|
}
|
|
2764
2756
|
if (!configProvided && keyProvided && key) {
|
|
2765
|
-
|
|
2766
|
-
|
|
2757
|
+
throw new Error(
|
|
2758
|
+
`Cannot enable all index types for key '${key}'. Please specify a specific index configuration.`
|
|
2759
|
+
);
|
|
2767
2760
|
}
|
|
2768
2761
|
if (configProvided && !keyProvided) {
|
|
2769
2762
|
this.setIndexInDefaults(config, true);
|
|
@@ -2797,8 +2790,9 @@ var Schema = class _Schema {
|
|
|
2797
2790
|
);
|
|
2798
2791
|
}
|
|
2799
2792
|
if (keyProvided && !configProvided && key) {
|
|
2800
|
-
|
|
2801
|
-
|
|
2793
|
+
throw new Error(
|
|
2794
|
+
`Cannot disable all index types for key '${key}'. Please specify a specific index configuration.`
|
|
2795
|
+
);
|
|
2802
2796
|
}
|
|
2803
2797
|
if (keyProvided && configProvided && key) {
|
|
2804
2798
|
this.setIndexForKey(key, config, false);
|
|
@@ -2915,6 +2909,7 @@ var Schema = class _Schema {
|
|
|
2915
2909
|
setIndexForKey(key, config, enabled) {
|
|
2916
2910
|
if (config instanceof SparseVectorIndexConfig && enabled) {
|
|
2917
2911
|
this.validateSingleSparseVectorIndex(key);
|
|
2912
|
+
this.validateSparseVectorConfig(config);
|
|
2918
2913
|
}
|
|
2919
2914
|
const current = this.keys[key] = ensureValueTypes(this.keys[key]);
|
|
2920
2915
|
if (config instanceof StringInvertedIndexConfig) {
|
|
@@ -2961,7 +2956,7 @@ var Schema = class _Schema {
|
|
|
2961
2956
|
new VectorIndexType(true, new VectorIndexConfig())
|
|
2962
2957
|
);
|
|
2963
2958
|
current.sparseVector = new SparseVectorValueType(
|
|
2964
|
-
new SparseVectorIndexType(
|
|
2959
|
+
new SparseVectorIndexType(false, new SparseVectorIndexConfig())
|
|
2965
2960
|
);
|
|
2966
2961
|
current.intValue = new IntValueType(
|
|
2967
2962
|
new IntInvertedIndexType(true, new IntInvertedIndexConfig())
|
|
@@ -3011,6 +3006,13 @@ var Schema = class _Schema {
|
|
|
3011
3006
|
}
|
|
3012
3007
|
}
|
|
3013
3008
|
}
|
|
3009
|
+
validateSparseVectorConfig(config) {
|
|
3010
|
+
if (config.sourceKey !== null && config.sourceKey !== void 0 && !config.embeddingFunction) {
|
|
3011
|
+
throw new Error(
|
|
3012
|
+
`If sourceKey is provided then embeddingFunction must also be provided since there is no default embedding function. Config: ${JSON.stringify(config)}`
|
|
3013
|
+
);
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3014
3016
|
initializeDefaults() {
|
|
3015
3017
|
this.defaults.string = new StringValueType(
|
|
3016
3018
|
new FtsIndexType(false, new FtsIndexConfig()),
|
|
@@ -3311,11 +3313,9 @@ var Schema = class _Schema {
|
|
|
3311
3313
|
hnsw: json.hnsw ? cloneObject(json.hnsw) : null,
|
|
3312
3314
|
spann: json.spann ? cloneObject(json.spann) : null
|
|
3313
3315
|
});
|
|
3314
|
-
console.log("SCHEMA THING 1");
|
|
3315
3316
|
config.embeddingFunction = await getEmbeddingFunction(
|
|
3316
3317
|
"schema deserialization",
|
|
3317
|
-
json.embedding_function
|
|
3318
|
-
true
|
|
3318
|
+
json.embedding_function
|
|
3319
3319
|
);
|
|
3320
3320
|
if (!config.space && config.embeddingFunction?.defaultSpace) {
|
|
3321
3321
|
config.space = config.embeddingFunction.defaultSpace();
|
|
@@ -4022,9 +4022,7 @@ var chromaFetch = async (input, init) => {
|
|
|
4022
4022
|
case 429:
|
|
4023
4023
|
throw new ChromaRateLimitError("Rate limit exceeded");
|
|
4024
4024
|
}
|
|
4025
|
-
throw new
|
|
4026
|
-
`Unable to connect to the chromadb server (status: ${response.status}). Please try again later.`
|
|
4027
|
-
);
|
|
4025
|
+
throw new ChromaServerError(`${response.status}: ${response.statusText}`);
|
|
4028
4026
|
};
|
|
4029
4027
|
|
|
4030
4028
|
// src/admin-client.ts
|
package/dist/chromadb.mjs
CHANGED
|
@@ -1286,7 +1286,8 @@ var knownEmbeddingFunctions = /* @__PURE__ */ new Map();
|
|
|
1286
1286
|
var pythonEmbeddingFunctions = {
|
|
1287
1287
|
onnx_mini_lm_l6_v2: "default-embed",
|
|
1288
1288
|
default: "default-embed",
|
|
1289
|
-
together_ai: "together-ai"
|
|
1289
|
+
together_ai: "together-ai",
|
|
1290
|
+
sentence_transformer: "sentence-transformer"
|
|
1290
1291
|
};
|
|
1291
1292
|
var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
|
|
1292
1293
|
"amazon_bedrock",
|
|
@@ -1297,7 +1298,6 @@ var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
|
|
|
1297
1298
|
"instructor",
|
|
1298
1299
|
"open_clip",
|
|
1299
1300
|
"roboflow",
|
|
1300
|
-
"sentence_transformer",
|
|
1301
1301
|
"text2vec"
|
|
1302
1302
|
]);
|
|
1303
1303
|
var knownSparseEmbeddingFunctions = /* @__PURE__ */ new Map();
|
|
@@ -1325,7 +1325,7 @@ var registerSparseEmbeddingFunction = (name, fn) => {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
knownSparseEmbeddingFunctions.set(name, fn);
|
|
1327
1327
|
};
|
|
1328
|
-
var getEmbeddingFunction = async (collectionName, efConfig
|
|
1328
|
+
var getEmbeddingFunction = async (collectionName, efConfig) => {
|
|
1329
1329
|
if (!efConfig) {
|
|
1330
1330
|
console.warn(
|
|
1331
1331
|
`No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
@@ -1354,15 +1354,7 @@ var getEmbeddingFunction = async (collectionName, efConfig, debug) => {
|
|
|
1354
1354
|
return void 0;
|
|
1355
1355
|
}
|
|
1356
1356
|
const packageName = pythonEmbeddingFunctions[efConfig.name] || efConfig.name;
|
|
1357
|
-
if (debug) {
|
|
1358
|
-
console.log("DEBUFFING");
|
|
1359
|
-
console.log(packageName);
|
|
1360
|
-
}
|
|
1361
1357
|
if (packageName === "default-embed") {
|
|
1362
|
-
console.log("INSIDE HIT");
|
|
1363
|
-
if (debug) {
|
|
1364
|
-
console.log("FROM DEBUG");
|
|
1365
|
-
}
|
|
1366
1358
|
await getDefaultEFConfig();
|
|
1367
1359
|
}
|
|
1368
1360
|
let embeddingFunction = knownEmbeddingFunctions.get(packageName);
|
|
@@ -2762,8 +2754,9 @@ var Schema = class _Schema {
|
|
|
2762
2754
|
);
|
|
2763
2755
|
}
|
|
2764
2756
|
if (!configProvided && keyProvided && key) {
|
|
2765
|
-
|
|
2766
|
-
|
|
2757
|
+
throw new Error(
|
|
2758
|
+
`Cannot enable all index types for key '${key}'. Please specify a specific index configuration.`
|
|
2759
|
+
);
|
|
2767
2760
|
}
|
|
2768
2761
|
if (configProvided && !keyProvided) {
|
|
2769
2762
|
this.setIndexInDefaults(config, true);
|
|
@@ -2797,8 +2790,9 @@ var Schema = class _Schema {
|
|
|
2797
2790
|
);
|
|
2798
2791
|
}
|
|
2799
2792
|
if (keyProvided && !configProvided && key) {
|
|
2800
|
-
|
|
2801
|
-
|
|
2793
|
+
throw new Error(
|
|
2794
|
+
`Cannot disable all index types for key '${key}'. Please specify a specific index configuration.`
|
|
2795
|
+
);
|
|
2802
2796
|
}
|
|
2803
2797
|
if (keyProvided && configProvided && key) {
|
|
2804
2798
|
this.setIndexForKey(key, config, false);
|
|
@@ -2915,6 +2909,7 @@ var Schema = class _Schema {
|
|
|
2915
2909
|
setIndexForKey(key, config, enabled) {
|
|
2916
2910
|
if (config instanceof SparseVectorIndexConfig && enabled) {
|
|
2917
2911
|
this.validateSingleSparseVectorIndex(key);
|
|
2912
|
+
this.validateSparseVectorConfig(config);
|
|
2918
2913
|
}
|
|
2919
2914
|
const current = this.keys[key] = ensureValueTypes(this.keys[key]);
|
|
2920
2915
|
if (config instanceof StringInvertedIndexConfig) {
|
|
@@ -2961,7 +2956,7 @@ var Schema = class _Schema {
|
|
|
2961
2956
|
new VectorIndexType(true, new VectorIndexConfig())
|
|
2962
2957
|
);
|
|
2963
2958
|
current.sparseVector = new SparseVectorValueType(
|
|
2964
|
-
new SparseVectorIndexType(
|
|
2959
|
+
new SparseVectorIndexType(false, new SparseVectorIndexConfig())
|
|
2965
2960
|
);
|
|
2966
2961
|
current.intValue = new IntValueType(
|
|
2967
2962
|
new IntInvertedIndexType(true, new IntInvertedIndexConfig())
|
|
@@ -3011,6 +3006,13 @@ var Schema = class _Schema {
|
|
|
3011
3006
|
}
|
|
3012
3007
|
}
|
|
3013
3008
|
}
|
|
3009
|
+
validateSparseVectorConfig(config) {
|
|
3010
|
+
if (config.sourceKey !== null && config.sourceKey !== void 0 && !config.embeddingFunction) {
|
|
3011
|
+
throw new Error(
|
|
3012
|
+
`If sourceKey is provided then embeddingFunction must also be provided since there is no default embedding function. Config: ${JSON.stringify(config)}`
|
|
3013
|
+
);
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3014
3016
|
initializeDefaults() {
|
|
3015
3017
|
this.defaults.string = new StringValueType(
|
|
3016
3018
|
new FtsIndexType(false, new FtsIndexConfig()),
|
|
@@ -3311,11 +3313,9 @@ var Schema = class _Schema {
|
|
|
3311
3313
|
hnsw: json.hnsw ? cloneObject(json.hnsw) : null,
|
|
3312
3314
|
spann: json.spann ? cloneObject(json.spann) : null
|
|
3313
3315
|
});
|
|
3314
|
-
console.log("SCHEMA THING 1");
|
|
3315
3316
|
config.embeddingFunction = await getEmbeddingFunction(
|
|
3316
3317
|
"schema deserialization",
|
|
3317
|
-
json.embedding_function
|
|
3318
|
-
true
|
|
3318
|
+
json.embedding_function
|
|
3319
3319
|
);
|
|
3320
3320
|
if (!config.space && config.embeddingFunction?.defaultSpace) {
|
|
3321
3321
|
config.space = config.embeddingFunction.defaultSpace();
|
|
@@ -4022,9 +4022,7 @@ var chromaFetch = async (input, init) => {
|
|
|
4022
4022
|
case 429:
|
|
4023
4023
|
throw new ChromaRateLimitError("Rate limit exceeded");
|
|
4024
4024
|
}
|
|
4025
|
-
throw new
|
|
4026
|
-
`Unable to connect to the chromadb server (status: ${response.status}). Please try again later.`
|
|
4027
|
-
);
|
|
4025
|
+
throw new ChromaServerError(`${response.status}: ${response.statusText}`);
|
|
4028
4026
|
};
|
|
4029
4027
|
|
|
4030
4028
|
// src/admin-client.ts
|