chromadb 1.7.1 → 1.7.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/README.md +1 -1
- package/dist/chromadb.d.ts +5 -10
- package/dist/chromadb.legacy-esm.js +66 -29
- package/dist/chromadb.mjs +66 -29
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +66 -29
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +5 -10
- package/package.json +6 -2
- package/src/embeddings/CohereEmbeddingFunction.ts +109 -48
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ const collection = await chroma.createCollection({ name: "test-from-js" });
|
|
|
24
24
|
for (let i = 0; i < 20; i++) {
|
|
25
25
|
await collection.add({
|
|
26
26
|
ids: ["test-id-" + i.toString()],
|
|
27
|
-
embeddings
|
|
27
|
+
embeddings: [1, 2, 3, 4, 5],
|
|
28
28
|
documents: ["test"],
|
|
29
29
|
});
|
|
30
30
|
}
|
package/dist/chromadb.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as openai from 'openai';
|
|
2
|
-
import * as cohere_ai from 'cohere-ai';
|
|
3
2
|
import * as _google_generative_ai from '@google/generative-ai';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -1242,19 +1241,15 @@ declare class OpenAIEmbeddingFunction implements IEmbeddingFunction {
|
|
|
1242
1241
|
}
|
|
1243
1242
|
|
|
1244
1243
|
declare class CohereEmbeddingFunction implements IEmbeddingFunction {
|
|
1245
|
-
private api_key;
|
|
1246
|
-
private model;
|
|
1247
1244
|
private cohereAiApi?;
|
|
1248
|
-
|
|
1245
|
+
private model;
|
|
1246
|
+
private apiKey;
|
|
1247
|
+
constructor({ cohere_api_key, model, }: {
|
|
1249
1248
|
cohere_api_key: string;
|
|
1250
1249
|
model?: string;
|
|
1251
1250
|
});
|
|
1252
|
-
private
|
|
1253
|
-
generate(texts: string[]): Promise<
|
|
1254
|
-
/** @ignore */
|
|
1255
|
-
static import(): Promise<{
|
|
1256
|
-
cohere: typeof cohere_ai;
|
|
1257
|
-
}>;
|
|
1251
|
+
private initCohereClient;
|
|
1252
|
+
generate(texts: string[]): Promise<number[][]>;
|
|
1258
1253
|
}
|
|
1259
1254
|
|
|
1260
1255
|
declare class GoogleGenerativeAiEmbeddingFunction implements IEmbeddingFunction {
|
|
@@ -2949,46 +2949,83 @@ var OpenAIEmbeddingFunction = class _OpenAIEmbeddingFunction {
|
|
|
2949
2949
|
};
|
|
2950
2950
|
|
|
2951
2951
|
// src/embeddings/CohereEmbeddingFunction.ts
|
|
2952
|
-
var
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
this.api_key = cohere_api_key;
|
|
2956
|
-
this.model = model || "large";
|
|
2952
|
+
var CohereAISDK56 = class {
|
|
2953
|
+
constructor(configuration) {
|
|
2954
|
+
this.apiKey = configuration.apiKey;
|
|
2957
2955
|
}
|
|
2958
2956
|
async loadClient() {
|
|
2959
|
-
if (this.
|
|
2957
|
+
if (this.cohereClient)
|
|
2960
2958
|
return;
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
CohereAiApi.init(this.api_key);
|
|
2965
|
-
} catch (_a) {
|
|
2966
|
-
if (_a.code === "MODULE_NOT_FOUND") {
|
|
2967
|
-
throw new Error("Please install the cohere-ai package to use the CohereEmbeddingFunction, `npm install -S cohere-ai`");
|
|
2968
|
-
}
|
|
2969
|
-
throw _a;
|
|
2970
|
-
}
|
|
2971
|
-
this.cohereAiApi = CohereAiApi;
|
|
2959
|
+
const { default: cohere } = await import("cohere-ai");
|
|
2960
|
+
cohere.init(this.apiKey);
|
|
2961
|
+
this.cohereClient = cohere;
|
|
2972
2962
|
}
|
|
2973
|
-
async
|
|
2963
|
+
async createEmbedding(params) {
|
|
2974
2964
|
await this.loadClient();
|
|
2975
|
-
|
|
2976
|
-
texts,
|
|
2977
|
-
model:
|
|
2965
|
+
return await this.cohereClient.embed({
|
|
2966
|
+
texts: params.input,
|
|
2967
|
+
model: params.model
|
|
2968
|
+
}).then((response) => {
|
|
2969
|
+
return response.body.embeddings;
|
|
2978
2970
|
});
|
|
2979
|
-
return response.body.embeddings;
|
|
2980
2971
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
2972
|
+
};
|
|
2973
|
+
var CohereAISDK7 = class {
|
|
2974
|
+
constructor(configuration) {
|
|
2975
|
+
this.apiKey = configuration.apiKey;
|
|
2976
|
+
}
|
|
2977
|
+
async loadClient() {
|
|
2978
|
+
if (this.cohereClient)
|
|
2979
|
+
return;
|
|
2980
|
+
const cohere = await import("cohere-ai").then((cohere2) => {
|
|
2981
|
+
return cohere2;
|
|
2982
|
+
});
|
|
2983
|
+
this.cohereClient = new cohere.CohereClient({
|
|
2984
|
+
token: this.apiKey
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
async createEmbedding(params) {
|
|
2988
|
+
await this.loadClient();
|
|
2989
|
+
return await this.cohereClient.embed({ texts: params.input, model: params.model }).then((response) => {
|
|
2990
|
+
return response.embeddings;
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
};
|
|
2994
|
+
var CohereEmbeddingFunction = class {
|
|
2995
|
+
constructor({
|
|
2996
|
+
cohere_api_key,
|
|
2997
|
+
model
|
|
2998
|
+
}) {
|
|
2999
|
+
this.model = model || "large";
|
|
3000
|
+
this.apiKey = cohere_api_key;
|
|
3001
|
+
}
|
|
3002
|
+
async initCohereClient() {
|
|
3003
|
+
if (this.cohereAiApi)
|
|
3004
|
+
return;
|
|
2983
3005
|
try {
|
|
2984
|
-
|
|
2985
|
-
|
|
3006
|
+
this.cohereAiApi = await import("cohere-ai").then((cohere) => {
|
|
3007
|
+
if (cohere.CohereClient) {
|
|
3008
|
+
return new CohereAISDK7({ apiKey: this.apiKey });
|
|
3009
|
+
} else {
|
|
3010
|
+
return new CohereAISDK56({ apiKey: this.apiKey });
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
2986
3013
|
} catch (e) {
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
3014
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
3015
|
+
throw new Error(
|
|
3016
|
+
"Please install the cohere-ai package to use the CohereEmbeddingFunction, `npm install -S cohere-ai`"
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
throw e;
|
|
2990
3020
|
}
|
|
2991
3021
|
}
|
|
3022
|
+
async generate(texts) {
|
|
3023
|
+
await this.initCohereClient();
|
|
3024
|
+
return await this.cohereAiApi.createEmbedding({
|
|
3025
|
+
model: this.model,
|
|
3026
|
+
input: texts
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
2992
3029
|
};
|
|
2993
3030
|
|
|
2994
3031
|
// src/embeddings/GoogleGeminiEmbeddingFunction.ts
|
package/dist/chromadb.mjs
CHANGED
|
@@ -2949,46 +2949,83 @@ var OpenAIEmbeddingFunction = class _OpenAIEmbeddingFunction {
|
|
|
2949
2949
|
};
|
|
2950
2950
|
|
|
2951
2951
|
// src/embeddings/CohereEmbeddingFunction.ts
|
|
2952
|
-
var
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
this.api_key = cohere_api_key;
|
|
2956
|
-
this.model = model || "large";
|
|
2952
|
+
var CohereAISDK56 = class {
|
|
2953
|
+
constructor(configuration) {
|
|
2954
|
+
this.apiKey = configuration.apiKey;
|
|
2957
2955
|
}
|
|
2958
2956
|
async loadClient() {
|
|
2959
|
-
if (this.
|
|
2957
|
+
if (this.cohereClient)
|
|
2960
2958
|
return;
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
CohereAiApi.init(this.api_key);
|
|
2965
|
-
} catch (_a) {
|
|
2966
|
-
if (_a.code === "MODULE_NOT_FOUND") {
|
|
2967
|
-
throw new Error("Please install the cohere-ai package to use the CohereEmbeddingFunction, `npm install -S cohere-ai`");
|
|
2968
|
-
}
|
|
2969
|
-
throw _a;
|
|
2970
|
-
}
|
|
2971
|
-
this.cohereAiApi = CohereAiApi;
|
|
2959
|
+
const { default: cohere } = await import("cohere-ai");
|
|
2960
|
+
cohere.init(this.apiKey);
|
|
2961
|
+
this.cohereClient = cohere;
|
|
2972
2962
|
}
|
|
2973
|
-
async
|
|
2963
|
+
async createEmbedding(params) {
|
|
2974
2964
|
await this.loadClient();
|
|
2975
|
-
|
|
2976
|
-
texts,
|
|
2977
|
-
model:
|
|
2965
|
+
return await this.cohereClient.embed({
|
|
2966
|
+
texts: params.input,
|
|
2967
|
+
model: params.model
|
|
2968
|
+
}).then((response) => {
|
|
2969
|
+
return response.body.embeddings;
|
|
2978
2970
|
});
|
|
2979
|
-
return response.body.embeddings;
|
|
2980
2971
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
2972
|
+
};
|
|
2973
|
+
var CohereAISDK7 = class {
|
|
2974
|
+
constructor(configuration) {
|
|
2975
|
+
this.apiKey = configuration.apiKey;
|
|
2976
|
+
}
|
|
2977
|
+
async loadClient() {
|
|
2978
|
+
if (this.cohereClient)
|
|
2979
|
+
return;
|
|
2980
|
+
const cohere = await import("cohere-ai").then((cohere2) => {
|
|
2981
|
+
return cohere2;
|
|
2982
|
+
});
|
|
2983
|
+
this.cohereClient = new cohere.CohereClient({
|
|
2984
|
+
token: this.apiKey
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
async createEmbedding(params) {
|
|
2988
|
+
await this.loadClient();
|
|
2989
|
+
return await this.cohereClient.embed({ texts: params.input, model: params.model }).then((response) => {
|
|
2990
|
+
return response.embeddings;
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
};
|
|
2994
|
+
var CohereEmbeddingFunction = class {
|
|
2995
|
+
constructor({
|
|
2996
|
+
cohere_api_key,
|
|
2997
|
+
model
|
|
2998
|
+
}) {
|
|
2999
|
+
this.model = model || "large";
|
|
3000
|
+
this.apiKey = cohere_api_key;
|
|
3001
|
+
}
|
|
3002
|
+
async initCohereClient() {
|
|
3003
|
+
if (this.cohereAiApi)
|
|
3004
|
+
return;
|
|
2983
3005
|
try {
|
|
2984
|
-
|
|
2985
|
-
|
|
3006
|
+
this.cohereAiApi = await import("cohere-ai").then((cohere) => {
|
|
3007
|
+
if (cohere.CohereClient) {
|
|
3008
|
+
return new CohereAISDK7({ apiKey: this.apiKey });
|
|
3009
|
+
} else {
|
|
3010
|
+
return new CohereAISDK56({ apiKey: this.apiKey });
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
2986
3013
|
} catch (e) {
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
3014
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
3015
|
+
throw new Error(
|
|
3016
|
+
"Please install the cohere-ai package to use the CohereEmbeddingFunction, `npm install -S cohere-ai`"
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
throw e;
|
|
2990
3020
|
}
|
|
2991
3021
|
}
|
|
3022
|
+
async generate(texts) {
|
|
3023
|
+
await this.initCohereClient();
|
|
3024
|
+
return await this.cohereAiApi.createEmbedding({
|
|
3025
|
+
model: this.model,
|
|
3026
|
+
input: texts
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
2992
3029
|
};
|
|
2993
3030
|
|
|
2994
3031
|
// src/embeddings/GoogleGeminiEmbeddingFunction.ts
|