chromadb 1.7.3-beta1 → 1.7.3-beta2
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 +31 -1
- package/dist/chromadb.legacy-esm.js +82 -9
- package/dist/chromadb.mjs +82 -9
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +83 -9
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +31 -1
- package/package.json +1 -1
package/dist/chromadb.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as openai from 'openai';
|
|
2
2
|
import * as cohere_ai from 'cohere-ai';
|
|
3
3
|
import * as _xenova_transformers from '@xenova/transformers';
|
|
4
|
+
import * as chromadb_default_embed from 'chromadb-default-embed';
|
|
4
5
|
|
|
5
6
|
interface IEmbeddingFunction {
|
|
6
7
|
generate(texts: string[]): Promise<number[][]>;
|
|
@@ -1006,4 +1007,33 @@ declare class TransformersEmbeddingFunction implements IEmbeddingFunction {
|
|
|
1006
1007
|
}>;
|
|
1007
1008
|
}
|
|
1008
1009
|
|
|
1009
|
-
|
|
1010
|
+
declare class DefaultEmbeddingFunction implements IEmbeddingFunction {
|
|
1011
|
+
private pipelinePromise?;
|
|
1012
|
+
private transformersApi;
|
|
1013
|
+
private model;
|
|
1014
|
+
private revision;
|
|
1015
|
+
private quantized;
|
|
1016
|
+
private progress_callback;
|
|
1017
|
+
/**
|
|
1018
|
+
* DefaultEmbeddingFunction constructor.
|
|
1019
|
+
* @param options The configuration options.
|
|
1020
|
+
* @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
|
|
1021
|
+
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
1022
|
+
* @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
|
|
1023
|
+
* @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
1024
|
+
*/
|
|
1025
|
+
constructor({ model, revision, quantized, progress_callback, }?: {
|
|
1026
|
+
model?: string;
|
|
1027
|
+
revision?: string;
|
|
1028
|
+
quantized?: boolean;
|
|
1029
|
+
progress_callback?: Function | null;
|
|
1030
|
+
});
|
|
1031
|
+
generate(texts: string[]): Promise<number[][]>;
|
|
1032
|
+
private loadClient;
|
|
1033
|
+
/** @ignore */
|
|
1034
|
+
static import(): Promise<{
|
|
1035
|
+
pipeline: typeof chromadb_default_embed;
|
|
1036
|
+
}>;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
export { ChromaClient, CohereEmbeddingFunction, Collection, DefaultEmbeddingFunction, type IEmbeddingFunction, IncludeEnum, OpenAIEmbeddingFunction, TransformersEmbeddingFunction };
|
|
@@ -1869,11 +1869,11 @@ var IsomorphicFetchClientAuthProtocolAdapter = class {
|
|
|
1869
1869
|
}
|
|
1870
1870
|
};
|
|
1871
1871
|
|
|
1872
|
-
// src/embeddings/
|
|
1872
|
+
// src/embeddings/DefaultEmbeddingFunction.ts
|
|
1873
1873
|
var TransformersApi;
|
|
1874
|
-
var
|
|
1874
|
+
var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
|
|
1875
1875
|
/**
|
|
1876
|
-
*
|
|
1876
|
+
* DefaultEmbeddingFunction constructor.
|
|
1877
1877
|
* @param options The configuration options.
|
|
1878
1878
|
* @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
|
|
1879
1879
|
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
@@ -1918,11 +1918,11 @@ var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
|
1918
1918
|
if (this.transformersApi)
|
|
1919
1919
|
return;
|
|
1920
1920
|
try {
|
|
1921
|
-
let { pipeline } = await
|
|
1921
|
+
let { pipeline } = await _DefaultEmbeddingFunction.import();
|
|
1922
1922
|
TransformersApi = pipeline;
|
|
1923
1923
|
} catch (_a) {
|
|
1924
1924
|
if (_a.code === "MODULE_NOT_FOUND") {
|
|
1925
|
-
throw new Error("Please install the
|
|
1925
|
+
throw new Error("Please install the chromadb-default-embed package to use the DefaultEmbeddingFunction, `npm install -S chromadb-default-embed`");
|
|
1926
1926
|
}
|
|
1927
1927
|
throw _a;
|
|
1928
1928
|
}
|
|
@@ -1931,11 +1931,11 @@ var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
|
1931
1931
|
/** @ignore */
|
|
1932
1932
|
static async import() {
|
|
1933
1933
|
try {
|
|
1934
|
-
const { pipeline } = await import("
|
|
1934
|
+
const { pipeline } = await import("chromadb-default-embed");
|
|
1935
1935
|
return { pipeline };
|
|
1936
1936
|
} catch (e) {
|
|
1937
1937
|
throw new Error(
|
|
1938
|
-
"Please install
|
|
1938
|
+
"Please install chromadb-default-embed as a dependency with, e.g. `yarn add chromadb-default-embed`"
|
|
1939
1939
|
);
|
|
1940
1940
|
}
|
|
1941
1941
|
}
|
|
@@ -2042,7 +2042,7 @@ var ChromaClient = class {
|
|
|
2042
2042
|
embeddingFunction
|
|
2043
2043
|
}) {
|
|
2044
2044
|
if (embeddingFunction === void 0) {
|
|
2045
|
-
embeddingFunction = new
|
|
2045
|
+
embeddingFunction = new DefaultEmbeddingFunction();
|
|
2046
2046
|
}
|
|
2047
2047
|
const newCollection = await this.api.createCollection({
|
|
2048
2048
|
name,
|
|
@@ -2080,7 +2080,7 @@ var ChromaClient = class {
|
|
|
2080
2080
|
embeddingFunction
|
|
2081
2081
|
}) {
|
|
2082
2082
|
if (embeddingFunction === void 0) {
|
|
2083
|
-
embeddingFunction = new
|
|
2083
|
+
embeddingFunction = new DefaultEmbeddingFunction();
|
|
2084
2084
|
}
|
|
2085
2085
|
const newCollection = await this.api.createCollection({
|
|
2086
2086
|
name,
|
|
@@ -2305,6 +2305,78 @@ var CohereEmbeddingFunction = class _CohereEmbeddingFunction {
|
|
|
2305
2305
|
}
|
|
2306
2306
|
};
|
|
2307
2307
|
|
|
2308
|
+
// src/embeddings/TransformersEmbeddingFunction.ts
|
|
2309
|
+
var TransformersApi2;
|
|
2310
|
+
var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
2311
|
+
/**
|
|
2312
|
+
* TransformersEmbeddingFunction constructor.
|
|
2313
|
+
* @param options The configuration options.
|
|
2314
|
+
* @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
|
|
2315
|
+
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
2316
|
+
* @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
|
|
2317
|
+
* @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
2318
|
+
*/
|
|
2319
|
+
constructor({
|
|
2320
|
+
model = "Xenova/all-MiniLM-L6-v2",
|
|
2321
|
+
revision = "main",
|
|
2322
|
+
quantized = false,
|
|
2323
|
+
progress_callback = null
|
|
2324
|
+
} = {}) {
|
|
2325
|
+
this.model = model;
|
|
2326
|
+
this.revision = revision;
|
|
2327
|
+
this.quantized = quantized;
|
|
2328
|
+
this.progress_callback = progress_callback;
|
|
2329
|
+
}
|
|
2330
|
+
async generate(texts) {
|
|
2331
|
+
await this.loadClient();
|
|
2332
|
+
this.pipelinePromise = new Promise(async (resolve, reject) => {
|
|
2333
|
+
try {
|
|
2334
|
+
const pipeline = this.transformersApi;
|
|
2335
|
+
const quantized = this.quantized;
|
|
2336
|
+
const revision = this.revision;
|
|
2337
|
+
const progress_callback = this.progress_callback;
|
|
2338
|
+
resolve(
|
|
2339
|
+
await pipeline("feature-extraction", this.model, {
|
|
2340
|
+
quantized,
|
|
2341
|
+
revision,
|
|
2342
|
+
progress_callback
|
|
2343
|
+
})
|
|
2344
|
+
);
|
|
2345
|
+
} catch (e) {
|
|
2346
|
+
reject(e);
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
let pipe = await this.pipelinePromise;
|
|
2350
|
+
let output = await pipe(texts, { pooling: "mean", normalize: true });
|
|
2351
|
+
return output.tolist();
|
|
2352
|
+
}
|
|
2353
|
+
async loadClient() {
|
|
2354
|
+
if (this.transformersApi)
|
|
2355
|
+
return;
|
|
2356
|
+
try {
|
|
2357
|
+
let { pipeline } = await _TransformersEmbeddingFunction.import();
|
|
2358
|
+
TransformersApi2 = pipeline;
|
|
2359
|
+
} catch (_a) {
|
|
2360
|
+
if (_a.code === "MODULE_NOT_FOUND") {
|
|
2361
|
+
throw new Error("Please install the @xenova/transformers package to use the TransformersEmbeddingFunction, `npm install -S @xenova/transformers`");
|
|
2362
|
+
}
|
|
2363
|
+
throw _a;
|
|
2364
|
+
}
|
|
2365
|
+
this.transformersApi = TransformersApi2;
|
|
2366
|
+
}
|
|
2367
|
+
/** @ignore */
|
|
2368
|
+
static async import() {
|
|
2369
|
+
try {
|
|
2370
|
+
const { pipeline } = await import("@xenova/transformers");
|
|
2371
|
+
return { pipeline };
|
|
2372
|
+
} catch (e) {
|
|
2373
|
+
throw new Error(
|
|
2374
|
+
"Please install @xenova/transformers as a dependency with, e.g. `yarn add @xenova/transformers`"
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2308
2380
|
// src/types.ts
|
|
2309
2381
|
var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
2310
2382
|
IncludeEnum2["Documents"] = "documents";
|
|
@@ -2317,6 +2389,7 @@ export {
|
|
|
2317
2389
|
ChromaClient,
|
|
2318
2390
|
CohereEmbeddingFunction,
|
|
2319
2391
|
Collection,
|
|
2392
|
+
DefaultEmbeddingFunction,
|
|
2320
2393
|
IncludeEnum,
|
|
2321
2394
|
OpenAIEmbeddingFunction,
|
|
2322
2395
|
TransformersEmbeddingFunction
|
package/dist/chromadb.mjs
CHANGED
|
@@ -1869,11 +1869,11 @@ var IsomorphicFetchClientAuthProtocolAdapter = class {
|
|
|
1869
1869
|
}
|
|
1870
1870
|
};
|
|
1871
1871
|
|
|
1872
|
-
// src/embeddings/
|
|
1872
|
+
// src/embeddings/DefaultEmbeddingFunction.ts
|
|
1873
1873
|
var TransformersApi;
|
|
1874
|
-
var
|
|
1874
|
+
var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
|
|
1875
1875
|
/**
|
|
1876
|
-
*
|
|
1876
|
+
* DefaultEmbeddingFunction constructor.
|
|
1877
1877
|
* @param options The configuration options.
|
|
1878
1878
|
* @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
|
|
1879
1879
|
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
@@ -1918,11 +1918,11 @@ var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
|
1918
1918
|
if (this.transformersApi)
|
|
1919
1919
|
return;
|
|
1920
1920
|
try {
|
|
1921
|
-
let { pipeline } = await
|
|
1921
|
+
let { pipeline } = await _DefaultEmbeddingFunction.import();
|
|
1922
1922
|
TransformersApi = pipeline;
|
|
1923
1923
|
} catch (_a) {
|
|
1924
1924
|
if (_a.code === "MODULE_NOT_FOUND") {
|
|
1925
|
-
throw new Error("Please install the
|
|
1925
|
+
throw new Error("Please install the chromadb-default-embed package to use the DefaultEmbeddingFunction, `npm install -S chromadb-default-embed`");
|
|
1926
1926
|
}
|
|
1927
1927
|
throw _a;
|
|
1928
1928
|
}
|
|
@@ -1931,11 +1931,11 @@ var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
|
1931
1931
|
/** @ignore */
|
|
1932
1932
|
static async import() {
|
|
1933
1933
|
try {
|
|
1934
|
-
const { pipeline } = await import("
|
|
1934
|
+
const { pipeline } = await import("chromadb-default-embed");
|
|
1935
1935
|
return { pipeline };
|
|
1936
1936
|
} catch (e) {
|
|
1937
1937
|
throw new Error(
|
|
1938
|
-
"Please install
|
|
1938
|
+
"Please install chromadb-default-embed as a dependency with, e.g. `yarn add chromadb-default-embed`"
|
|
1939
1939
|
);
|
|
1940
1940
|
}
|
|
1941
1941
|
}
|
|
@@ -2042,7 +2042,7 @@ var ChromaClient = class {
|
|
|
2042
2042
|
embeddingFunction
|
|
2043
2043
|
}) {
|
|
2044
2044
|
if (embeddingFunction === void 0) {
|
|
2045
|
-
embeddingFunction = new
|
|
2045
|
+
embeddingFunction = new DefaultEmbeddingFunction();
|
|
2046
2046
|
}
|
|
2047
2047
|
const newCollection = await this.api.createCollection({
|
|
2048
2048
|
name,
|
|
@@ -2080,7 +2080,7 @@ var ChromaClient = class {
|
|
|
2080
2080
|
embeddingFunction
|
|
2081
2081
|
}) {
|
|
2082
2082
|
if (embeddingFunction === void 0) {
|
|
2083
|
-
embeddingFunction = new
|
|
2083
|
+
embeddingFunction = new DefaultEmbeddingFunction();
|
|
2084
2084
|
}
|
|
2085
2085
|
const newCollection = await this.api.createCollection({
|
|
2086
2086
|
name,
|
|
@@ -2305,6 +2305,78 @@ var CohereEmbeddingFunction = class _CohereEmbeddingFunction {
|
|
|
2305
2305
|
}
|
|
2306
2306
|
};
|
|
2307
2307
|
|
|
2308
|
+
// src/embeddings/TransformersEmbeddingFunction.ts
|
|
2309
|
+
var TransformersApi2;
|
|
2310
|
+
var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
2311
|
+
/**
|
|
2312
|
+
* TransformersEmbeddingFunction constructor.
|
|
2313
|
+
* @param options The configuration options.
|
|
2314
|
+
* @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
|
|
2315
|
+
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
2316
|
+
* @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
|
|
2317
|
+
* @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
2318
|
+
*/
|
|
2319
|
+
constructor({
|
|
2320
|
+
model = "Xenova/all-MiniLM-L6-v2",
|
|
2321
|
+
revision = "main",
|
|
2322
|
+
quantized = false,
|
|
2323
|
+
progress_callback = null
|
|
2324
|
+
} = {}) {
|
|
2325
|
+
this.model = model;
|
|
2326
|
+
this.revision = revision;
|
|
2327
|
+
this.quantized = quantized;
|
|
2328
|
+
this.progress_callback = progress_callback;
|
|
2329
|
+
}
|
|
2330
|
+
async generate(texts) {
|
|
2331
|
+
await this.loadClient();
|
|
2332
|
+
this.pipelinePromise = new Promise(async (resolve, reject) => {
|
|
2333
|
+
try {
|
|
2334
|
+
const pipeline = this.transformersApi;
|
|
2335
|
+
const quantized = this.quantized;
|
|
2336
|
+
const revision = this.revision;
|
|
2337
|
+
const progress_callback = this.progress_callback;
|
|
2338
|
+
resolve(
|
|
2339
|
+
await pipeline("feature-extraction", this.model, {
|
|
2340
|
+
quantized,
|
|
2341
|
+
revision,
|
|
2342
|
+
progress_callback
|
|
2343
|
+
})
|
|
2344
|
+
);
|
|
2345
|
+
} catch (e) {
|
|
2346
|
+
reject(e);
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
let pipe = await this.pipelinePromise;
|
|
2350
|
+
let output = await pipe(texts, { pooling: "mean", normalize: true });
|
|
2351
|
+
return output.tolist();
|
|
2352
|
+
}
|
|
2353
|
+
async loadClient() {
|
|
2354
|
+
if (this.transformersApi)
|
|
2355
|
+
return;
|
|
2356
|
+
try {
|
|
2357
|
+
let { pipeline } = await _TransformersEmbeddingFunction.import();
|
|
2358
|
+
TransformersApi2 = pipeline;
|
|
2359
|
+
} catch (_a) {
|
|
2360
|
+
if (_a.code === "MODULE_NOT_FOUND") {
|
|
2361
|
+
throw new Error("Please install the @xenova/transformers package to use the TransformersEmbeddingFunction, `npm install -S @xenova/transformers`");
|
|
2362
|
+
}
|
|
2363
|
+
throw _a;
|
|
2364
|
+
}
|
|
2365
|
+
this.transformersApi = TransformersApi2;
|
|
2366
|
+
}
|
|
2367
|
+
/** @ignore */
|
|
2368
|
+
static async import() {
|
|
2369
|
+
try {
|
|
2370
|
+
const { pipeline } = await import("@xenova/transformers");
|
|
2371
|
+
return { pipeline };
|
|
2372
|
+
} catch (e) {
|
|
2373
|
+
throw new Error(
|
|
2374
|
+
"Please install @xenova/transformers as a dependency with, e.g. `yarn add @xenova/transformers`"
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2308
2380
|
// src/types.ts
|
|
2309
2381
|
var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
2310
2382
|
IncludeEnum2["Documents"] = "documents";
|
|
@@ -2317,6 +2389,7 @@ export {
|
|
|
2317
2389
|
ChromaClient,
|
|
2318
2390
|
CohereEmbeddingFunction,
|
|
2319
2391
|
Collection,
|
|
2392
|
+
DefaultEmbeddingFunction,
|
|
2320
2393
|
IncludeEnum,
|
|
2321
2394
|
OpenAIEmbeddingFunction,
|
|
2322
2395
|
TransformersEmbeddingFunction
|