chromadb 1.10.4 → 1.10.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 +12 -5
- package/dist/chromadb.legacy-esm.js +66 -30
- package/dist/chromadb.mjs +66 -30
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +67 -30
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +12 -5
- package/package.json +6 -2
- package/src/embeddings/DefaultEmbeddingFunction.ts +1 -2
- package/src/embeddings/OllamaEmbeddingFunction.ts +59 -21
- package/src/index.ts +2 -2
package/dist/chromadb.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as openai from 'openai';
|
|
|
2
2
|
import * as _xenova_transformers from '@xenova/transformers';
|
|
3
3
|
import * as chromadb_default_embed from 'chromadb-default-embed';
|
|
4
4
|
import * as _google_generative_ai from '@google/generative-ai';
|
|
5
|
+
import * as ollama from 'ollama';
|
|
5
6
|
|
|
6
7
|
interface IEmbeddingFunction {
|
|
7
8
|
generate(texts: string[]): Promise<number[][]>;
|
|
@@ -1846,13 +1847,19 @@ declare class GoogleGenerativeAiEmbeddingFunction implements IEmbeddingFunction
|
|
|
1846
1847
|
}
|
|
1847
1848
|
|
|
1848
1849
|
declare class OllamaEmbeddingFunction implements IEmbeddingFunction {
|
|
1849
|
-
private readonly url
|
|
1850
|
+
private readonly url?;
|
|
1850
1851
|
private readonly model;
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1852
|
+
private ollamaClient;
|
|
1853
|
+
constructor({ url, model, }?: {
|
|
1854
|
+
url?: string;
|
|
1855
|
+
model?: string;
|
|
1854
1856
|
});
|
|
1855
|
-
|
|
1857
|
+
private initClient;
|
|
1858
|
+
/** @ignore */
|
|
1859
|
+
static import(): Promise<{
|
|
1860
|
+
ollama: typeof ollama;
|
|
1861
|
+
}>;
|
|
1862
|
+
generate(texts: string[]): Promise<any>;
|
|
1856
1863
|
}
|
|
1857
1864
|
|
|
1858
1865
|
/**
|
|
@@ -3386,15 +3386,15 @@ var ApiApi = class extends BaseAPI {
|
|
|
3386
3386
|
// src/generated/models.ts
|
|
3387
3387
|
var Api;
|
|
3388
3388
|
((Api2) => {
|
|
3389
|
-
let
|
|
3390
|
-
((
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
})(
|
|
3389
|
+
let IncludeEnum2;
|
|
3390
|
+
((IncludeEnum3) => {
|
|
3391
|
+
IncludeEnum3["Documents"] = "documents";
|
|
3392
|
+
IncludeEnum3["Embeddings"] = "embeddings";
|
|
3393
|
+
IncludeEnum3["Metadatas"] = "metadatas";
|
|
3394
|
+
IncludeEnum3["Distances"] = "distances";
|
|
3395
|
+
IncludeEnum3["Uris"] = "uris";
|
|
3396
|
+
IncludeEnum3["Data"] = "data";
|
|
3397
|
+
})(IncludeEnum2 = Api2.IncludeEnum || (Api2.IncludeEnum = {}));
|
|
3398
3398
|
})(Api || (Api = {}));
|
|
3399
3399
|
|
|
3400
3400
|
// src/generated/configuration.ts
|
|
@@ -4381,9 +4381,8 @@ var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
|
|
|
4381
4381
|
let importResult;
|
|
4382
4382
|
if (isBrowser()) {
|
|
4383
4383
|
importResult = await import(
|
|
4384
|
-
// todo: we can't import chromadb-default-embed here yet because the `build` script was not run before publishing our fork to NPM, so the entrypoint in our forked package points to a non-existent file.
|
|
4385
4384
|
// @ts-expect-error
|
|
4386
|
-
"https://unpkg.com
|
|
4385
|
+
"https://unpkg.com/chromadb-default-embed@2.14.0"
|
|
4387
4386
|
);
|
|
4388
4387
|
} else {
|
|
4389
4388
|
importResult = await import("chromadb-default-embed");
|
|
@@ -5157,32 +5156,68 @@ var GoogleGenerativeAiEmbeddingFunction = class _GoogleGenerativeAiEmbeddingFunc
|
|
|
5157
5156
|
};
|
|
5158
5157
|
|
|
5159
5158
|
// src/embeddings/OllamaEmbeddingFunction.ts
|
|
5160
|
-
var
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5159
|
+
var DEFAULT_MODEL = "chroma/all-minilm-l6-v2-f32";
|
|
5160
|
+
var DEFAULT_LOCAL_URL = "http://localhost:11434";
|
|
5161
|
+
var OllamaEmbeddingFunction = class _OllamaEmbeddingFunction {
|
|
5162
|
+
constructor({
|
|
5163
|
+
url = DEFAULT_LOCAL_URL,
|
|
5164
|
+
model = DEFAULT_MODEL
|
|
5165
|
+
} = {
|
|
5166
|
+
url: DEFAULT_LOCAL_URL,
|
|
5167
|
+
model: DEFAULT_MODEL
|
|
5168
|
+
}) {
|
|
5169
|
+
if (url && url.endsWith("/api/embeddings")) {
|
|
5170
|
+
this.url = url.slice(0, -"/api/embeddings".length);
|
|
5171
|
+
} else {
|
|
5172
|
+
this.url = url || DEFAULT_LOCAL_URL;
|
|
5173
|
+
}
|
|
5174
|
+
this.model = model || DEFAULT_MODEL;
|
|
5164
5175
|
}
|
|
5165
|
-
async
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
body: JSON.stringify({ model: this.model, prompt: text })
|
|
5174
|
-
});
|
|
5175
|
-
if (!response.ok) {
|
|
5176
|
+
async initClient() {
|
|
5177
|
+
if (this.ollamaClient)
|
|
5178
|
+
return;
|
|
5179
|
+
try {
|
|
5180
|
+
const { ollama } = await _OllamaEmbeddingFunction.import();
|
|
5181
|
+
this.ollamaClient = new ollama.Ollama({ host: this.url });
|
|
5182
|
+
} catch (e) {
|
|
5183
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
5176
5184
|
throw new Error(
|
|
5177
|
-
|
|
5185
|
+
"Please install the ollama package to use the OllamaEmbeddingFunction, `npm install -S ollama`"
|
|
5178
5186
|
);
|
|
5179
5187
|
}
|
|
5180
|
-
|
|
5181
|
-
embeddings.push(finalResponse["embedding"]);
|
|
5188
|
+
throw e;
|
|
5182
5189
|
}
|
|
5183
|
-
|
|
5190
|
+
}
|
|
5191
|
+
/** @ignore */
|
|
5192
|
+
static async import() {
|
|
5193
|
+
try {
|
|
5194
|
+
const { ollama } = await import("ollama").then((m) => ({ ollama: m }));
|
|
5195
|
+
return { ollama };
|
|
5196
|
+
} catch (e) {
|
|
5197
|
+
throw new Error(
|
|
5198
|
+
"Please install Ollama as a dependency with, e.g. `npm install ollama`"
|
|
5199
|
+
);
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
async generate(texts) {
|
|
5203
|
+
await this.initClient();
|
|
5204
|
+
return await this.ollamaClient.embed({
|
|
5205
|
+
model: this.model,
|
|
5206
|
+
input: texts
|
|
5207
|
+
}).then((response) => {
|
|
5208
|
+
return response.embeddings;
|
|
5209
|
+
});
|
|
5184
5210
|
}
|
|
5185
5211
|
};
|
|
5212
|
+
|
|
5213
|
+
// src/types.ts
|
|
5214
|
+
var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
5215
|
+
IncludeEnum2["Documents"] = "documents";
|
|
5216
|
+
IncludeEnum2["Embeddings"] = "embeddings";
|
|
5217
|
+
IncludeEnum2["Metadatas"] = "metadatas";
|
|
5218
|
+
IncludeEnum2["Distances"] = "distances";
|
|
5219
|
+
return IncludeEnum2;
|
|
5220
|
+
})(IncludeEnum || {});
|
|
5186
5221
|
export {
|
|
5187
5222
|
AdminClient,
|
|
5188
5223
|
ChromaClient,
|
|
@@ -5201,6 +5236,7 @@ export {
|
|
|
5201
5236
|
DefaultEmbeddingFunction,
|
|
5202
5237
|
GoogleGenerativeAiEmbeddingFunction,
|
|
5203
5238
|
HuggingFaceEmbeddingServerFunction,
|
|
5239
|
+
IncludeEnum,
|
|
5204
5240
|
InvalidArgumentError,
|
|
5205
5241
|
InvalidCollectionError,
|
|
5206
5242
|
JinaEmbeddingFunction,
|
package/dist/chromadb.mjs
CHANGED
|
@@ -3386,15 +3386,15 @@ var ApiApi = class extends BaseAPI {
|
|
|
3386
3386
|
// src/generated/models.ts
|
|
3387
3387
|
var Api;
|
|
3388
3388
|
((Api2) => {
|
|
3389
|
-
let
|
|
3390
|
-
((
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
})(
|
|
3389
|
+
let IncludeEnum2;
|
|
3390
|
+
((IncludeEnum3) => {
|
|
3391
|
+
IncludeEnum3["Documents"] = "documents";
|
|
3392
|
+
IncludeEnum3["Embeddings"] = "embeddings";
|
|
3393
|
+
IncludeEnum3["Metadatas"] = "metadatas";
|
|
3394
|
+
IncludeEnum3["Distances"] = "distances";
|
|
3395
|
+
IncludeEnum3["Uris"] = "uris";
|
|
3396
|
+
IncludeEnum3["Data"] = "data";
|
|
3397
|
+
})(IncludeEnum2 = Api2.IncludeEnum || (Api2.IncludeEnum = {}));
|
|
3398
3398
|
})(Api || (Api = {}));
|
|
3399
3399
|
|
|
3400
3400
|
// src/generated/configuration.ts
|
|
@@ -4381,9 +4381,8 @@ var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
|
|
|
4381
4381
|
let importResult;
|
|
4382
4382
|
if (isBrowser()) {
|
|
4383
4383
|
importResult = await import(
|
|
4384
|
-
// todo: we can't import chromadb-default-embed here yet because the `build` script was not run before publishing our fork to NPM, so the entrypoint in our forked package points to a non-existent file.
|
|
4385
4384
|
// @ts-expect-error
|
|
4386
|
-
"https://unpkg.com
|
|
4385
|
+
"https://unpkg.com/chromadb-default-embed@2.14.0"
|
|
4387
4386
|
);
|
|
4388
4387
|
} else {
|
|
4389
4388
|
importResult = await import("chromadb-default-embed");
|
|
@@ -5157,32 +5156,68 @@ var GoogleGenerativeAiEmbeddingFunction = class _GoogleGenerativeAiEmbeddingFunc
|
|
|
5157
5156
|
};
|
|
5158
5157
|
|
|
5159
5158
|
// src/embeddings/OllamaEmbeddingFunction.ts
|
|
5160
|
-
var
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5159
|
+
var DEFAULT_MODEL = "chroma/all-minilm-l6-v2-f32";
|
|
5160
|
+
var DEFAULT_LOCAL_URL = "http://localhost:11434";
|
|
5161
|
+
var OllamaEmbeddingFunction = class _OllamaEmbeddingFunction {
|
|
5162
|
+
constructor({
|
|
5163
|
+
url = DEFAULT_LOCAL_URL,
|
|
5164
|
+
model = DEFAULT_MODEL
|
|
5165
|
+
} = {
|
|
5166
|
+
url: DEFAULT_LOCAL_URL,
|
|
5167
|
+
model: DEFAULT_MODEL
|
|
5168
|
+
}) {
|
|
5169
|
+
if (url && url.endsWith("/api/embeddings")) {
|
|
5170
|
+
this.url = url.slice(0, -"/api/embeddings".length);
|
|
5171
|
+
} else {
|
|
5172
|
+
this.url = url || DEFAULT_LOCAL_URL;
|
|
5173
|
+
}
|
|
5174
|
+
this.model = model || DEFAULT_MODEL;
|
|
5164
5175
|
}
|
|
5165
|
-
async
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
body: JSON.stringify({ model: this.model, prompt: text })
|
|
5174
|
-
});
|
|
5175
|
-
if (!response.ok) {
|
|
5176
|
+
async initClient() {
|
|
5177
|
+
if (this.ollamaClient)
|
|
5178
|
+
return;
|
|
5179
|
+
try {
|
|
5180
|
+
const { ollama } = await _OllamaEmbeddingFunction.import();
|
|
5181
|
+
this.ollamaClient = new ollama.Ollama({ host: this.url });
|
|
5182
|
+
} catch (e) {
|
|
5183
|
+
if (e.code === "MODULE_NOT_FOUND") {
|
|
5176
5184
|
throw new Error(
|
|
5177
|
-
|
|
5185
|
+
"Please install the ollama package to use the OllamaEmbeddingFunction, `npm install -S ollama`"
|
|
5178
5186
|
);
|
|
5179
5187
|
}
|
|
5180
|
-
|
|
5181
|
-
embeddings.push(finalResponse["embedding"]);
|
|
5188
|
+
throw e;
|
|
5182
5189
|
}
|
|
5183
|
-
|
|
5190
|
+
}
|
|
5191
|
+
/** @ignore */
|
|
5192
|
+
static async import() {
|
|
5193
|
+
try {
|
|
5194
|
+
const { ollama } = await import("ollama").then((m) => ({ ollama: m }));
|
|
5195
|
+
return { ollama };
|
|
5196
|
+
} catch (e) {
|
|
5197
|
+
throw new Error(
|
|
5198
|
+
"Please install Ollama as a dependency with, e.g. `npm install ollama`"
|
|
5199
|
+
);
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
async generate(texts) {
|
|
5203
|
+
await this.initClient();
|
|
5204
|
+
return await this.ollamaClient.embed({
|
|
5205
|
+
model: this.model,
|
|
5206
|
+
input: texts
|
|
5207
|
+
}).then((response) => {
|
|
5208
|
+
return response.embeddings;
|
|
5209
|
+
});
|
|
5184
5210
|
}
|
|
5185
5211
|
};
|
|
5212
|
+
|
|
5213
|
+
// src/types.ts
|
|
5214
|
+
var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
5215
|
+
IncludeEnum2["Documents"] = "documents";
|
|
5216
|
+
IncludeEnum2["Embeddings"] = "embeddings";
|
|
5217
|
+
IncludeEnum2["Metadatas"] = "metadatas";
|
|
5218
|
+
IncludeEnum2["Distances"] = "distances";
|
|
5219
|
+
return IncludeEnum2;
|
|
5220
|
+
})(IncludeEnum || {});
|
|
5186
5221
|
export {
|
|
5187
5222
|
AdminClient,
|
|
5188
5223
|
ChromaClient,
|
|
@@ -5201,6 +5236,7 @@ export {
|
|
|
5201
5236
|
DefaultEmbeddingFunction,
|
|
5202
5237
|
GoogleGenerativeAiEmbeddingFunction,
|
|
5203
5238
|
HuggingFaceEmbeddingServerFunction,
|
|
5239
|
+
IncludeEnum,
|
|
5204
5240
|
InvalidArgumentError,
|
|
5205
5241
|
InvalidCollectionError,
|
|
5206
5242
|
JinaEmbeddingFunction,
|