chromadb 1.7.2 → 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 +230 -488
- package/dist/chromadb.legacy-esm.js +154 -879
- package/dist/chromadb.mjs +154 -879
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +157 -885
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +230 -488
- package/package.json +2 -6
- package/src/ChromaClient.ts +41 -67
- package/src/Collection.ts +58 -17
- package/src/embeddings/DefaultEmbeddingFunction.ts +99 -0
- package/src/embeddings/TransformersEmbeddingFunction.ts +99 -0
- package/src/generated/api.ts +45 -563
- package/src/generated/configuration.ts +5 -5
- package/src/generated/index.ts +2 -2
- package/src/generated/models.ts +35 -79
- package/src/generated/runtime.ts +5 -5
- package/src/index.ts +3 -36
- package/src/types.ts +0 -75
- package/src/utils.ts +3 -17
- package/src/AdminClient.ts +0 -272
- package/src/CloudClient.ts +0 -46
- package/src/embeddings/GoogleGeminiEmbeddingFunction.ts +0 -69
- package/src/embeddings/HuggingFaceEmbeddingServerFunction.ts +0 -31
- package/src/embeddings/JinaEmbeddingFunction.ts +0 -46
package/dist/cjs/chromadb.cjs
CHANGED
|
@@ -47,16 +47,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
47
47
|
// src/index.ts
|
|
48
48
|
var src_exports = {};
|
|
49
49
|
__export(src_exports, {
|
|
50
|
-
AdminClient: () => AdminClient,
|
|
51
50
|
ChromaClient: () => ChromaClient,
|
|
52
|
-
CloudClient: () => CloudClient,
|
|
53
51
|
CohereEmbeddingFunction: () => CohereEmbeddingFunction,
|
|
54
52
|
Collection: () => Collection,
|
|
55
|
-
|
|
56
|
-
HuggingFaceEmbeddingServerFunction: () => HuggingFaceEmbeddingServerFunction,
|
|
53
|
+
DefaultEmbeddingFunction: () => DefaultEmbeddingFunction,
|
|
57
54
|
IncludeEnum: () => IncludeEnum,
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
OpenAIEmbeddingFunction: () => OpenAIEmbeddingFunction,
|
|
56
|
+
TransformersEmbeddingFunction: () => TransformersEmbeddingFunction
|
|
60
57
|
});
|
|
61
58
|
module.exports = __toCommonJS(src_exports);
|
|
62
59
|
|
|
@@ -222,47 +219,13 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
222
219
|
options: localVarRequestOptions
|
|
223
220
|
};
|
|
224
221
|
},
|
|
225
|
-
/**
|
|
226
|
-
* @summary Count Collections
|
|
227
|
-
* @param {string} [tenant]
|
|
228
|
-
* @param {string} [database]
|
|
229
|
-
* @param {RequestInit} [options] Override http request option.
|
|
230
|
-
* @throws {RequiredError}
|
|
231
|
-
*/
|
|
232
|
-
countCollections(tenant, database, options = {}) {
|
|
233
|
-
let localVarPath = `/api/v1/count_collections`;
|
|
234
|
-
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
235
|
-
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
236
|
-
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
237
|
-
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
238
|
-
if (localVarPathQueryStart !== -1) {
|
|
239
|
-
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
240
|
-
}
|
|
241
|
-
if (tenant !== void 0) {
|
|
242
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
243
|
-
}
|
|
244
|
-
if (database !== void 0) {
|
|
245
|
-
localVarQueryParameter.append("database", String(database));
|
|
246
|
-
}
|
|
247
|
-
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
248
|
-
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
249
|
-
if (localVarQueryParameterString) {
|
|
250
|
-
localVarPath += "?" + localVarQueryParameterString;
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
url: localVarPath,
|
|
254
|
-
options: localVarRequestOptions
|
|
255
|
-
};
|
|
256
|
-
},
|
|
257
222
|
/**
|
|
258
223
|
* @summary Create Collection
|
|
259
|
-
* @param {string} [tenant]
|
|
260
|
-
* @param {string} [database]
|
|
261
224
|
* @param {Api.CreateCollection} request
|
|
262
225
|
* @param {RequestInit} [options] Override http request option.
|
|
263
226
|
* @throws {RequiredError}
|
|
264
227
|
*/
|
|
265
|
-
createCollection(
|
|
228
|
+
createCollection(request, options = {}) {
|
|
266
229
|
if (request === null || request === void 0) {
|
|
267
230
|
throw new RequiredError("request", "Required parameter request was null or undefined when calling createCollection.");
|
|
268
231
|
}
|
|
@@ -274,80 +237,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
274
237
|
if (localVarPathQueryStart !== -1) {
|
|
275
238
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
276
239
|
}
|
|
277
|
-
if (tenant !== void 0) {
|
|
278
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
279
|
-
}
|
|
280
|
-
if (database !== void 0) {
|
|
281
|
-
localVarQueryParameter.append("database", String(database));
|
|
282
|
-
}
|
|
283
|
-
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
284
|
-
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
285
|
-
if (request !== void 0) {
|
|
286
|
-
localVarRequestOptions.body = JSON.stringify(request || {});
|
|
287
|
-
}
|
|
288
|
-
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
289
|
-
if (localVarQueryParameterString) {
|
|
290
|
-
localVarPath += "?" + localVarQueryParameterString;
|
|
291
|
-
}
|
|
292
|
-
return {
|
|
293
|
-
url: localVarPath,
|
|
294
|
-
options: localVarRequestOptions
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
/**
|
|
298
|
-
* @summary Create Database
|
|
299
|
-
* @param {string} [tenant]
|
|
300
|
-
* @param {Api.CreateDatabase} request
|
|
301
|
-
* @param {RequestInit} [options] Override http request option.
|
|
302
|
-
* @throws {RequiredError}
|
|
303
|
-
*/
|
|
304
|
-
createDatabase(tenant, request, options = {}) {
|
|
305
|
-
if (request === null || request === void 0) {
|
|
306
|
-
throw new RequiredError("request", "Required parameter request was null or undefined when calling createDatabase.");
|
|
307
|
-
}
|
|
308
|
-
let localVarPath = `/api/v1/databases`;
|
|
309
|
-
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
310
|
-
const localVarRequestOptions = Object.assign({ method: "POST" }, options);
|
|
311
|
-
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
312
|
-
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
313
|
-
if (localVarPathQueryStart !== -1) {
|
|
314
|
-
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
315
|
-
}
|
|
316
|
-
if (tenant !== void 0) {
|
|
317
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
318
|
-
}
|
|
319
|
-
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
320
|
-
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
321
|
-
if (request !== void 0) {
|
|
322
|
-
localVarRequestOptions.body = JSON.stringify(request || {});
|
|
323
|
-
}
|
|
324
|
-
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
325
|
-
if (localVarQueryParameterString) {
|
|
326
|
-
localVarPath += "?" + localVarQueryParameterString;
|
|
327
|
-
}
|
|
328
|
-
return {
|
|
329
|
-
url: localVarPath,
|
|
330
|
-
options: localVarRequestOptions
|
|
331
|
-
};
|
|
332
|
-
},
|
|
333
|
-
/**
|
|
334
|
-
* @summary Create Tenant
|
|
335
|
-
* @param {Api.CreateTenant} request
|
|
336
|
-
* @param {RequestInit} [options] Override http request option.
|
|
337
|
-
* @throws {RequiredError}
|
|
338
|
-
*/
|
|
339
|
-
createTenant(request, options = {}) {
|
|
340
|
-
if (request === null || request === void 0) {
|
|
341
|
-
throw new RequiredError("request", "Required parameter request was null or undefined when calling createTenant.");
|
|
342
|
-
}
|
|
343
|
-
let localVarPath = `/api/v1/tenants`;
|
|
344
|
-
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
345
|
-
const localVarRequestOptions = Object.assign({ method: "POST" }, options);
|
|
346
|
-
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
347
|
-
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
348
|
-
if (localVarPathQueryStart !== -1) {
|
|
349
|
-
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
350
|
-
}
|
|
351
240
|
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
352
241
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
353
242
|
if (request !== void 0) {
|
|
@@ -365,12 +254,10 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
365
254
|
/**
|
|
366
255
|
* @summary Delete Collection
|
|
367
256
|
* @param {string} collectionName
|
|
368
|
-
* @param {string} [tenant]
|
|
369
|
-
* @param {string} [database]
|
|
370
257
|
* @param {RequestInit} [options] Override http request option.
|
|
371
258
|
* @throws {RequiredError}
|
|
372
259
|
*/
|
|
373
|
-
deleteCollection(collectionName,
|
|
260
|
+
deleteCollection(collectionName, options = {}) {
|
|
374
261
|
if (collectionName === null || collectionName === void 0) {
|
|
375
262
|
throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling deleteCollection.");
|
|
376
263
|
}
|
|
@@ -382,12 +269,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
382
269
|
if (localVarPathQueryStart !== -1) {
|
|
383
270
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
384
271
|
}
|
|
385
|
-
if (tenant !== void 0) {
|
|
386
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
387
|
-
}
|
|
388
|
-
if (database !== void 0) {
|
|
389
|
-
localVarQueryParameter.append("database", String(database));
|
|
390
|
-
}
|
|
391
272
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
392
273
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
393
274
|
if (localVarQueryParameterString) {
|
|
@@ -401,12 +282,10 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
401
282
|
/**
|
|
402
283
|
* @summary Get Collection
|
|
403
284
|
* @param {string} collectionName
|
|
404
|
-
* @param {string} [tenant]
|
|
405
|
-
* @param {string} [database]
|
|
406
285
|
* @param {RequestInit} [options] Override http request option.
|
|
407
286
|
* @throws {RequiredError}
|
|
408
287
|
*/
|
|
409
|
-
getCollection(collectionName,
|
|
288
|
+
getCollection(collectionName, options = {}) {
|
|
410
289
|
if (collectionName === null || collectionName === void 0) {
|
|
411
290
|
throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling getCollection.");
|
|
412
291
|
}
|
|
@@ -418,44 +297,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
418
297
|
if (localVarPathQueryStart !== -1) {
|
|
419
298
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
420
299
|
}
|
|
421
|
-
if (tenant !== void 0) {
|
|
422
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
423
|
-
}
|
|
424
|
-
if (database !== void 0) {
|
|
425
|
-
localVarQueryParameter.append("database", String(database));
|
|
426
|
-
}
|
|
427
|
-
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
428
|
-
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
429
|
-
if (localVarQueryParameterString) {
|
|
430
|
-
localVarPath += "?" + localVarQueryParameterString;
|
|
431
|
-
}
|
|
432
|
-
return {
|
|
433
|
-
url: localVarPath,
|
|
434
|
-
options: localVarRequestOptions
|
|
435
|
-
};
|
|
436
|
-
},
|
|
437
|
-
/**
|
|
438
|
-
* @summary Get Database
|
|
439
|
-
* @param {string} database
|
|
440
|
-
* @param {string} [tenant]
|
|
441
|
-
* @param {RequestInit} [options] Override http request option.
|
|
442
|
-
* @throws {RequiredError}
|
|
443
|
-
*/
|
|
444
|
-
getDatabase(database, tenant, options = {}) {
|
|
445
|
-
if (database === null || database === void 0) {
|
|
446
|
-
throw new RequiredError("database", "Required parameter database was null or undefined when calling getDatabase.");
|
|
447
|
-
}
|
|
448
|
-
let localVarPath = `/api/v1/databases/{database}`.replace("{database}", encodeURIComponent(String(database)));
|
|
449
|
-
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
450
|
-
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
451
|
-
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
452
|
-
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
453
|
-
if (localVarPathQueryStart !== -1) {
|
|
454
|
-
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
455
|
-
}
|
|
456
|
-
if (tenant !== void 0) {
|
|
457
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
458
|
-
}
|
|
459
300
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
460
301
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
461
302
|
if (localVarQueryParameterString) {
|
|
@@ -502,34 +343,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
502
343
|
options: localVarRequestOptions
|
|
503
344
|
};
|
|
504
345
|
},
|
|
505
|
-
/**
|
|
506
|
-
* @summary Get Tenant
|
|
507
|
-
* @param {string} tenant
|
|
508
|
-
* @param {RequestInit} [options] Override http request option.
|
|
509
|
-
* @throws {RequiredError}
|
|
510
|
-
*/
|
|
511
|
-
getTenant(tenant, options = {}) {
|
|
512
|
-
if (tenant === null || tenant === void 0) {
|
|
513
|
-
throw new RequiredError("tenant", "Required parameter tenant was null or undefined when calling getTenant.");
|
|
514
|
-
}
|
|
515
|
-
let localVarPath = `/api/v1/tenants/{tenant}`.replace("{tenant}", encodeURIComponent(String(tenant)));
|
|
516
|
-
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
517
|
-
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
518
|
-
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
519
|
-
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
520
|
-
if (localVarPathQueryStart !== -1) {
|
|
521
|
-
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
522
|
-
}
|
|
523
|
-
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
524
|
-
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
525
|
-
if (localVarQueryParameterString) {
|
|
526
|
-
localVarPath += "?" + localVarQueryParameterString;
|
|
527
|
-
}
|
|
528
|
-
return {
|
|
529
|
-
url: localVarPath,
|
|
530
|
-
options: localVarRequestOptions
|
|
531
|
-
};
|
|
532
|
-
},
|
|
533
346
|
/**
|
|
534
347
|
* @summary Heartbeat
|
|
535
348
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -556,14 +369,10 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
556
369
|
},
|
|
557
370
|
/**
|
|
558
371
|
* @summary List Collections
|
|
559
|
-
* @param {string} [tenant]
|
|
560
|
-
* @param {string} [database]
|
|
561
|
-
* @param {number} [limit]
|
|
562
|
-
* @param {number} [offset]
|
|
563
372
|
* @param {RequestInit} [options] Override http request option.
|
|
564
373
|
* @throws {RequiredError}
|
|
565
374
|
*/
|
|
566
|
-
listCollections(
|
|
375
|
+
listCollections(options = {}) {
|
|
567
376
|
let localVarPath = `/api/v1/collections`;
|
|
568
377
|
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
569
378
|
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
@@ -572,42 +381,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
572
381
|
if (localVarPathQueryStart !== -1) {
|
|
573
382
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
574
383
|
}
|
|
575
|
-
if (tenant !== void 0) {
|
|
576
|
-
localVarQueryParameter.append("tenant", String(tenant));
|
|
577
|
-
}
|
|
578
|
-
if (database !== void 0) {
|
|
579
|
-
localVarQueryParameter.append("database", String(database));
|
|
580
|
-
}
|
|
581
|
-
if (limit !== void 0) {
|
|
582
|
-
localVarQueryParameter.append("limit", String(limit));
|
|
583
|
-
}
|
|
584
|
-
if (offset !== void 0) {
|
|
585
|
-
localVarQueryParameter.append("offset", String(offset));
|
|
586
|
-
}
|
|
587
|
-
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
588
|
-
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
589
|
-
if (localVarQueryParameterString) {
|
|
590
|
-
localVarPath += "?" + localVarQueryParameterString;
|
|
591
|
-
}
|
|
592
|
-
return {
|
|
593
|
-
url: localVarPath,
|
|
594
|
-
options: localVarRequestOptions
|
|
595
|
-
};
|
|
596
|
-
},
|
|
597
|
-
/**
|
|
598
|
-
* @summary Pre Flight Checks
|
|
599
|
-
* @param {RequestInit} [options] Override http request option.
|
|
600
|
-
* @throws {RequiredError}
|
|
601
|
-
*/
|
|
602
|
-
preFlightChecks(options = {}) {
|
|
603
|
-
let localVarPath = `/api/v1/pre-flight-checks`;
|
|
604
|
-
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
605
|
-
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
606
|
-
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
607
|
-
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
608
|
-
if (localVarPathQueryStart !== -1) {
|
|
609
|
-
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
610
|
-
}
|
|
611
384
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
612
385
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
613
386
|
if (localVarQueryParameterString) {
|
|
@@ -917,102 +690,14 @@ var ApiApiFp = function(configuration) {
|
|
|
917
690
|
});
|
|
918
691
|
};
|
|
919
692
|
},
|
|
920
|
-
/**
|
|
921
|
-
* @summary Count Collections
|
|
922
|
-
* @param {string} [tenant]
|
|
923
|
-
* @param {string} [database]
|
|
924
|
-
* @param {RequestInit} [options] Override http request option.
|
|
925
|
-
* @throws {RequiredError}
|
|
926
|
-
*/
|
|
927
|
-
countCollections(tenant, database, options) {
|
|
928
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).countCollections(tenant, database, options);
|
|
929
|
-
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
930
|
-
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
931
|
-
const contentType = response.headers.get("Content-Type");
|
|
932
|
-
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
933
|
-
if (response.status === 200) {
|
|
934
|
-
if (mimeType === "application/json") {
|
|
935
|
-
return response.json();
|
|
936
|
-
}
|
|
937
|
-
throw response;
|
|
938
|
-
}
|
|
939
|
-
if (response.status === 422) {
|
|
940
|
-
if (mimeType === "application/json") {
|
|
941
|
-
throw response;
|
|
942
|
-
}
|
|
943
|
-
throw response;
|
|
944
|
-
}
|
|
945
|
-
throw response;
|
|
946
|
-
});
|
|
947
|
-
};
|
|
948
|
-
},
|
|
949
693
|
/**
|
|
950
694
|
* @summary Create Collection
|
|
951
|
-
* @param {string} [tenant]
|
|
952
|
-
* @param {string} [database]
|
|
953
695
|
* @param {Api.CreateCollection} request
|
|
954
696
|
* @param {RequestInit} [options] Override http request option.
|
|
955
697
|
* @throws {RequiredError}
|
|
956
698
|
*/
|
|
957
|
-
createCollection(
|
|
958
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(
|
|
959
|
-
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
960
|
-
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
961
|
-
const contentType = response.headers.get("Content-Type");
|
|
962
|
-
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
963
|
-
if (response.status === 200) {
|
|
964
|
-
if (mimeType === "application/json") {
|
|
965
|
-
return response.json();
|
|
966
|
-
}
|
|
967
|
-
throw response;
|
|
968
|
-
}
|
|
969
|
-
if (response.status === 422) {
|
|
970
|
-
if (mimeType === "application/json") {
|
|
971
|
-
throw response;
|
|
972
|
-
}
|
|
973
|
-
throw response;
|
|
974
|
-
}
|
|
975
|
-
throw response;
|
|
976
|
-
});
|
|
977
|
-
};
|
|
978
|
-
},
|
|
979
|
-
/**
|
|
980
|
-
* @summary Create Database
|
|
981
|
-
* @param {string} [tenant]
|
|
982
|
-
* @param {Api.CreateDatabase} request
|
|
983
|
-
* @param {RequestInit} [options] Override http request option.
|
|
984
|
-
* @throws {RequiredError}
|
|
985
|
-
*/
|
|
986
|
-
createDatabase(tenant, request, options) {
|
|
987
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createDatabase(tenant, request, options);
|
|
988
|
-
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
989
|
-
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
990
|
-
const contentType = response.headers.get("Content-Type");
|
|
991
|
-
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
992
|
-
if (response.status === 200) {
|
|
993
|
-
if (mimeType === "application/json") {
|
|
994
|
-
return response.json();
|
|
995
|
-
}
|
|
996
|
-
throw response;
|
|
997
|
-
}
|
|
998
|
-
if (response.status === 422) {
|
|
999
|
-
if (mimeType === "application/json") {
|
|
1000
|
-
throw response;
|
|
1001
|
-
}
|
|
1002
|
-
throw response;
|
|
1003
|
-
}
|
|
1004
|
-
throw response;
|
|
1005
|
-
});
|
|
1006
|
-
};
|
|
1007
|
-
},
|
|
1008
|
-
/**
|
|
1009
|
-
* @summary Create Tenant
|
|
1010
|
-
* @param {Api.CreateTenant} request
|
|
1011
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1012
|
-
* @throws {RequiredError}
|
|
1013
|
-
*/
|
|
1014
|
-
createTenant(request, options) {
|
|
1015
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createTenant(request, options);
|
|
699
|
+
createCollection(request, options) {
|
|
700
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(request, options);
|
|
1016
701
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1017
702
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1018
703
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1036,13 +721,11 @@ var ApiApiFp = function(configuration) {
|
|
|
1036
721
|
/**
|
|
1037
722
|
* @summary Delete Collection
|
|
1038
723
|
* @param {string} collectionName
|
|
1039
|
-
* @param {string} [tenant]
|
|
1040
|
-
* @param {string} [database]
|
|
1041
724
|
* @param {RequestInit} [options] Override http request option.
|
|
1042
725
|
* @throws {RequiredError}
|
|
1043
726
|
*/
|
|
1044
|
-
deleteCollection(collectionName,
|
|
1045
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName,
|
|
727
|
+
deleteCollection(collectionName, options) {
|
|
728
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, options);
|
|
1046
729
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1047
730
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1048
731
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1066,42 +749,11 @@ var ApiApiFp = function(configuration) {
|
|
|
1066
749
|
/**
|
|
1067
750
|
* @summary Get Collection
|
|
1068
751
|
* @param {string} collectionName
|
|
1069
|
-
* @param {string} [tenant]
|
|
1070
|
-
* @param {string} [database]
|
|
1071
752
|
* @param {RequestInit} [options] Override http request option.
|
|
1072
753
|
* @throws {RequiredError}
|
|
1073
754
|
*/
|
|
1074
|
-
getCollection(collectionName,
|
|
1075
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName,
|
|
1076
|
-
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1077
|
-
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1078
|
-
const contentType = response.headers.get("Content-Type");
|
|
1079
|
-
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
1080
|
-
if (response.status === 200) {
|
|
1081
|
-
if (mimeType === "application/json") {
|
|
1082
|
-
return response.json();
|
|
1083
|
-
}
|
|
1084
|
-
throw response;
|
|
1085
|
-
}
|
|
1086
|
-
if (response.status === 422) {
|
|
1087
|
-
if (mimeType === "application/json") {
|
|
1088
|
-
throw response;
|
|
1089
|
-
}
|
|
1090
|
-
throw response;
|
|
1091
|
-
}
|
|
1092
|
-
throw response;
|
|
1093
|
-
});
|
|
1094
|
-
};
|
|
1095
|
-
},
|
|
1096
|
-
/**
|
|
1097
|
-
* @summary Get Database
|
|
1098
|
-
* @param {string} database
|
|
1099
|
-
* @param {string} [tenant]
|
|
1100
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1101
|
-
* @throws {RequiredError}
|
|
1102
|
-
*/
|
|
1103
|
-
getDatabase(database, tenant, options) {
|
|
1104
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getDatabase(database, tenant, options);
|
|
755
|
+
getCollection(collectionName, options) {
|
|
756
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName, options);
|
|
1105
757
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1106
758
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1107
759
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1151,34 +803,6 @@ var ApiApiFp = function(configuration) {
|
|
|
1151
803
|
});
|
|
1152
804
|
};
|
|
1153
805
|
},
|
|
1154
|
-
/**
|
|
1155
|
-
* @summary Get Tenant
|
|
1156
|
-
* @param {string} tenant
|
|
1157
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1158
|
-
* @throws {RequiredError}
|
|
1159
|
-
*/
|
|
1160
|
-
getTenant(tenant, options) {
|
|
1161
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getTenant(tenant, options);
|
|
1162
|
-
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1163
|
-
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1164
|
-
const contentType = response.headers.get("Content-Type");
|
|
1165
|
-
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
1166
|
-
if (response.status === 200) {
|
|
1167
|
-
if (mimeType === "application/json") {
|
|
1168
|
-
return response.json();
|
|
1169
|
-
}
|
|
1170
|
-
throw response;
|
|
1171
|
-
}
|
|
1172
|
-
if (response.status === 422) {
|
|
1173
|
-
if (mimeType === "application/json") {
|
|
1174
|
-
throw response;
|
|
1175
|
-
}
|
|
1176
|
-
throw response;
|
|
1177
|
-
}
|
|
1178
|
-
throw response;
|
|
1179
|
-
});
|
|
1180
|
-
};
|
|
1181
|
-
},
|
|
1182
806
|
/**
|
|
1183
807
|
* @summary Heartbeat
|
|
1184
808
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -1202,42 +826,11 @@ var ApiApiFp = function(configuration) {
|
|
|
1202
826
|
},
|
|
1203
827
|
/**
|
|
1204
828
|
* @summary List Collections
|
|
1205
|
-
* @param {string} [tenant]
|
|
1206
|
-
* @param {string} [database]
|
|
1207
|
-
* @param {number} [limit]
|
|
1208
|
-
* @param {number} [offset]
|
|
1209
829
|
* @param {RequestInit} [options] Override http request option.
|
|
1210
830
|
* @throws {RequiredError}
|
|
1211
831
|
*/
|
|
1212
|
-
listCollections(
|
|
1213
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(
|
|
1214
|
-
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1215
|
-
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1216
|
-
const contentType = response.headers.get("Content-Type");
|
|
1217
|
-
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
1218
|
-
if (response.status === 200) {
|
|
1219
|
-
if (mimeType === "application/json") {
|
|
1220
|
-
return response.json();
|
|
1221
|
-
}
|
|
1222
|
-
throw response;
|
|
1223
|
-
}
|
|
1224
|
-
if (response.status === 422) {
|
|
1225
|
-
if (mimeType === "application/json") {
|
|
1226
|
-
throw response;
|
|
1227
|
-
}
|
|
1228
|
-
throw response;
|
|
1229
|
-
}
|
|
1230
|
-
throw response;
|
|
1231
|
-
});
|
|
1232
|
-
};
|
|
1233
|
-
},
|
|
1234
|
-
/**
|
|
1235
|
-
* @summary Pre Flight Checks
|
|
1236
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1237
|
-
* @throws {RequiredError}
|
|
1238
|
-
*/
|
|
1239
|
-
preFlightChecks(options) {
|
|
1240
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).preFlightChecks(options);
|
|
832
|
+
listCollections(options) {
|
|
833
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(options);
|
|
1241
834
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1242
835
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1243
836
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1444,77 +1037,32 @@ var ApiApi = class extends BaseAPI {
|
|
|
1444
1037
|
count(collectionId, options) {
|
|
1445
1038
|
return ApiApiFp(this.configuration).count(collectionId, options)(this.fetch, this.basePath);
|
|
1446
1039
|
}
|
|
1447
|
-
/**
|
|
1448
|
-
* @summary Count Collections
|
|
1449
|
-
* @param {string} [tenant]
|
|
1450
|
-
* @param {string} [database]
|
|
1451
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1452
|
-
* @throws {RequiredError}
|
|
1453
|
-
*/
|
|
1454
|
-
countCollections(tenant, database, options) {
|
|
1455
|
-
return ApiApiFp(this.configuration).countCollections(tenant, database, options)(this.fetch, this.basePath);
|
|
1456
|
-
}
|
|
1457
1040
|
/**
|
|
1458
1041
|
* @summary Create Collection
|
|
1459
|
-
* @param {string} [tenant]
|
|
1460
|
-
* @param {string} [database]
|
|
1461
1042
|
* @param {Api.CreateCollection} request
|
|
1462
1043
|
* @param {RequestInit} [options] Override http request option.
|
|
1463
1044
|
* @throws {RequiredError}
|
|
1464
1045
|
*/
|
|
1465
|
-
createCollection(
|
|
1466
|
-
return ApiApiFp(this.configuration).createCollection(
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* @summary Create Database
|
|
1470
|
-
* @param {string} [tenant]
|
|
1471
|
-
* @param {Api.CreateDatabase} request
|
|
1472
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1473
|
-
* @throws {RequiredError}
|
|
1474
|
-
*/
|
|
1475
|
-
createDatabase(tenant, request, options) {
|
|
1476
|
-
return ApiApiFp(this.configuration).createDatabase(tenant, request, options)(this.fetch, this.basePath);
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* @summary Create Tenant
|
|
1480
|
-
* @param {Api.CreateTenant} request
|
|
1481
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1482
|
-
* @throws {RequiredError}
|
|
1483
|
-
*/
|
|
1484
|
-
createTenant(request, options) {
|
|
1485
|
-
return ApiApiFp(this.configuration).createTenant(request, options)(this.fetch, this.basePath);
|
|
1046
|
+
createCollection(request, options) {
|
|
1047
|
+
return ApiApiFp(this.configuration).createCollection(request, options)(this.fetch, this.basePath);
|
|
1486
1048
|
}
|
|
1487
1049
|
/**
|
|
1488
1050
|
* @summary Delete Collection
|
|
1489
1051
|
* @param {string} collectionName
|
|
1490
|
-
* @param {string} [tenant]
|
|
1491
|
-
* @param {string} [database]
|
|
1492
1052
|
* @param {RequestInit} [options] Override http request option.
|
|
1493
1053
|
* @throws {RequiredError}
|
|
1494
1054
|
*/
|
|
1495
|
-
deleteCollection(collectionName,
|
|
1496
|
-
return ApiApiFp(this.configuration).deleteCollection(collectionName,
|
|
1055
|
+
deleteCollection(collectionName, options) {
|
|
1056
|
+
return ApiApiFp(this.configuration).deleteCollection(collectionName, options)(this.fetch, this.basePath);
|
|
1497
1057
|
}
|
|
1498
1058
|
/**
|
|
1499
1059
|
* @summary Get Collection
|
|
1500
1060
|
* @param {string} collectionName
|
|
1501
|
-
* @param {string} [tenant]
|
|
1502
|
-
* @param {string} [database]
|
|
1503
1061
|
* @param {RequestInit} [options] Override http request option.
|
|
1504
1062
|
* @throws {RequiredError}
|
|
1505
1063
|
*/
|
|
1506
|
-
getCollection(collectionName,
|
|
1507
|
-
return ApiApiFp(this.configuration).getCollection(collectionName,
|
|
1508
|
-
}
|
|
1509
|
-
/**
|
|
1510
|
-
* @summary Get Database
|
|
1511
|
-
* @param {string} database
|
|
1512
|
-
* @param {string} [tenant]
|
|
1513
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1514
|
-
* @throws {RequiredError}
|
|
1515
|
-
*/
|
|
1516
|
-
getDatabase(database, tenant, options) {
|
|
1517
|
-
return ApiApiFp(this.configuration).getDatabase(database, tenant, options)(this.fetch, this.basePath);
|
|
1064
|
+
getCollection(collectionName, options) {
|
|
1065
|
+
return ApiApiFp(this.configuration).getCollection(collectionName, options)(this.fetch, this.basePath);
|
|
1518
1066
|
}
|
|
1519
1067
|
/**
|
|
1520
1068
|
* @summary Get Nearest Neighbors
|
|
@@ -1526,15 +1074,6 @@ var ApiApi = class extends BaseAPI {
|
|
|
1526
1074
|
getNearestNeighbors(collectionId, request, options) {
|
|
1527
1075
|
return ApiApiFp(this.configuration).getNearestNeighbors(collectionId, request, options)(this.fetch, this.basePath);
|
|
1528
1076
|
}
|
|
1529
|
-
/**
|
|
1530
|
-
* @summary Get Tenant
|
|
1531
|
-
* @param {string} tenant
|
|
1532
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1533
|
-
* @throws {RequiredError}
|
|
1534
|
-
*/
|
|
1535
|
-
getTenant(tenant, options) {
|
|
1536
|
-
return ApiApiFp(this.configuration).getTenant(tenant, options)(this.fetch, this.basePath);
|
|
1537
|
-
}
|
|
1538
1077
|
/**
|
|
1539
1078
|
* @summary Heartbeat
|
|
1540
1079
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -1545,23 +1084,11 @@ var ApiApi = class extends BaseAPI {
|
|
|
1545
1084
|
}
|
|
1546
1085
|
/**
|
|
1547
1086
|
* @summary List Collections
|
|
1548
|
-
* @param {string} [tenant]
|
|
1549
|
-
* @param {string} [database]
|
|
1550
|
-
* @param {number} [limit]
|
|
1551
|
-
* @param {number} [offset]
|
|
1552
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1553
|
-
* @throws {RequiredError}
|
|
1554
|
-
*/
|
|
1555
|
-
listCollections(tenant, database, limit, offset, options) {
|
|
1556
|
-
return ApiApiFp(this.configuration).listCollections(tenant, database, limit, offset, options)(this.fetch, this.basePath);
|
|
1557
|
-
}
|
|
1558
|
-
/**
|
|
1559
|
-
* @summary Pre Flight Checks
|
|
1560
1087
|
* @param {RequestInit} [options] Override http request option.
|
|
1561
1088
|
* @throws {RequiredError}
|
|
1562
1089
|
*/
|
|
1563
|
-
|
|
1564
|
-
return ApiApiFp(this.configuration).
|
|
1090
|
+
listCollections(options) {
|
|
1091
|
+
return ApiApiFp(this.configuration).listCollections(options)(this.fetch, this.basePath);
|
|
1565
1092
|
}
|
|
1566
1093
|
/**
|
|
1567
1094
|
* @summary Reset
|
|
@@ -1627,8 +1154,8 @@ var Api;
|
|
|
1627
1154
|
let Include;
|
|
1628
1155
|
((Include2) => {
|
|
1629
1156
|
let EnumValueEnum;
|
|
1630
|
-
((
|
|
1631
|
-
|
|
1157
|
+
((EnumValueEnum5) => {
|
|
1158
|
+
EnumValueEnum5["Documents"] = "documents";
|
|
1632
1159
|
})(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
|
|
1633
1160
|
let EnumValueEnum2;
|
|
1634
1161
|
((EnumValueEnum22) => {
|
|
@@ -1642,14 +1169,6 @@ var Api;
|
|
|
1642
1169
|
((EnumValueEnum42) => {
|
|
1643
1170
|
EnumValueEnum42["Distances"] = "distances";
|
|
1644
1171
|
})(EnumValueEnum4 = Include2.EnumValueEnum4 || (Include2.EnumValueEnum4 = {}));
|
|
1645
|
-
let EnumValueEnum5;
|
|
1646
|
-
((EnumValueEnum52) => {
|
|
1647
|
-
EnumValueEnum52["Uris"] = "uris";
|
|
1648
|
-
})(EnumValueEnum5 = Include2.EnumValueEnum5 || (Include2.EnumValueEnum5 = {}));
|
|
1649
|
-
let EnumValueEnum6;
|
|
1650
|
-
((EnumValueEnum62) => {
|
|
1651
|
-
EnumValueEnum62["Data"] = "data";
|
|
1652
|
-
})(EnumValueEnum6 = Include2.EnumValueEnum6 || (Include2.EnumValueEnum6 = {}));
|
|
1653
1172
|
})(Include = GetEmbedding2.Include || (GetEmbedding2.Include = {}));
|
|
1654
1173
|
})(GetEmbedding = Api2.GetEmbedding || (Api2.GetEmbedding = {}));
|
|
1655
1174
|
let QueryEmbedding;
|
|
@@ -1657,8 +1176,8 @@ var Api;
|
|
|
1657
1176
|
let Include;
|
|
1658
1177
|
((Include2) => {
|
|
1659
1178
|
let EnumValueEnum;
|
|
1660
|
-
((
|
|
1661
|
-
|
|
1179
|
+
((EnumValueEnum5) => {
|
|
1180
|
+
EnumValueEnum5["Documents"] = "documents";
|
|
1662
1181
|
})(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
|
|
1663
1182
|
let EnumValueEnum2;
|
|
1664
1183
|
((EnumValueEnum22) => {
|
|
@@ -1672,14 +1191,6 @@ var Api;
|
|
|
1672
1191
|
((EnumValueEnum42) => {
|
|
1673
1192
|
EnumValueEnum42["Distances"] = "distances";
|
|
1674
1193
|
})(EnumValueEnum4 = Include2.EnumValueEnum4 || (Include2.EnumValueEnum4 = {}));
|
|
1675
|
-
let EnumValueEnum5;
|
|
1676
|
-
((EnumValueEnum52) => {
|
|
1677
|
-
EnumValueEnum52["Uris"] = "uris";
|
|
1678
|
-
})(EnumValueEnum5 = Include2.EnumValueEnum5 || (Include2.EnumValueEnum5 = {}));
|
|
1679
|
-
let EnumValueEnum6;
|
|
1680
|
-
((EnumValueEnum62) => {
|
|
1681
|
-
EnumValueEnum62["Data"] = "data";
|
|
1682
|
-
})(EnumValueEnum6 = Include2.EnumValueEnum6 || (Include2.EnumValueEnum6 = {}));
|
|
1683
1194
|
})(Include = QueryEmbedding2.Include || (QueryEmbedding2.Include = {}));
|
|
1684
1195
|
})(QueryEmbedding = Api2.QueryEmbedding || (Api2.QueryEmbedding = {}));
|
|
1685
1196
|
})(Api || (Api = {}));
|
|
@@ -1730,6 +1241,7 @@ async function handleError(error) {
|
|
|
1730
1241
|
}
|
|
1731
1242
|
} catch (e) {
|
|
1732
1243
|
return {
|
|
1244
|
+
//@ts-ignore
|
|
1733
1245
|
error: e && typeof e === "object" && "message" in e ? e.message : "unknown error"
|
|
1734
1246
|
};
|
|
1735
1247
|
}
|
|
@@ -1746,18 +1258,6 @@ async function handleSuccess(response) {
|
|
|
1746
1258
|
return repack(response);
|
|
1747
1259
|
}
|
|
1748
1260
|
}
|
|
1749
|
-
async function validateTenantDatabase(adminClient, tenant, database) {
|
|
1750
|
-
try {
|
|
1751
|
-
await adminClient.getTenant({ name: tenant });
|
|
1752
|
-
} catch (error) {
|
|
1753
|
-
throw new Error(`Error: ${error}, Could not connect to tenant ${tenant}. Are you sure it exists?`);
|
|
1754
|
-
}
|
|
1755
|
-
try {
|
|
1756
|
-
await adminClient.getDatabase({ name: database, tenantName: tenant });
|
|
1757
|
-
} catch (error) {
|
|
1758
|
-
throw new Error(`Error: ${error}, Could not connect to database ${database} for tenant ${tenant}. Are you sure it exists?`);
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
1261
|
|
|
1762
1262
|
// src/Collection.ts
|
|
1763
1263
|
var Collection = class {
|
|
@@ -2408,206 +1908,79 @@ var IsomorphicFetchClientAuthProtocolAdapter = class {
|
|
|
2408
1908
|
}
|
|
2409
1909
|
};
|
|
2410
1910
|
|
|
2411
|
-
// src/
|
|
2412
|
-
var
|
|
2413
|
-
var
|
|
2414
|
-
var AdminClient = class {
|
|
1911
|
+
// src/embeddings/DefaultEmbeddingFunction.ts
|
|
1912
|
+
var TransformersApi;
|
|
1913
|
+
var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
|
|
2415
1914
|
/**
|
|
2416
|
-
*
|
|
2417
|
-
* @param
|
|
2418
|
-
* @param
|
|
2419
|
-
* @
|
|
2420
|
-
*
|
|
2421
|
-
* @
|
|
2422
|
-
* ```typescript
|
|
2423
|
-
* const client = new AdminClient({
|
|
2424
|
-
* path: "http://localhost:8000"
|
|
2425
|
-
* });
|
|
2426
|
-
* ```
|
|
1915
|
+
* DefaultEmbeddingFunction constructor.
|
|
1916
|
+
* @param options The configuration options.
|
|
1917
|
+
* @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`.
|
|
1918
|
+
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
1919
|
+
* @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
|
|
1920
|
+
* @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
2427
1921
|
*/
|
|
2428
1922
|
constructor({
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
database = DEFAULT_DATABASE
|
|
1923
|
+
model = "Xenova/all-MiniLM-L6-v2",
|
|
1924
|
+
revision = "main",
|
|
1925
|
+
quantized = false,
|
|
1926
|
+
progress_callback = null
|
|
2434
1927
|
} = {}) {
|
|
2435
|
-
this.
|
|
2436
|
-
this.
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
this.tenant = tenant;
|
|
2440
|
-
this.database = database;
|
|
2441
|
-
const apiConfig = new Configuration({
|
|
2442
|
-
basePath: path
|
|
2443
|
-
});
|
|
2444
|
-
if (auth !== void 0) {
|
|
2445
|
-
this.apiAdapter = new IsomorphicFetchClientAuthProtocolAdapter(new ApiApi(apiConfig), auth);
|
|
2446
|
-
this.api = this.apiAdapter.getApi();
|
|
2447
|
-
} else {
|
|
2448
|
-
this.api = new ApiApi(apiConfig);
|
|
2449
|
-
}
|
|
2450
|
-
this.api.options = fetchOptions != null ? fetchOptions : {};
|
|
2451
|
-
}
|
|
2452
|
-
/**
|
|
2453
|
-
* Sets the tenant and database for the client.
|
|
2454
|
-
*
|
|
2455
|
-
* @param {Object} params - The parameters for setting tenant and database.
|
|
2456
|
-
* @param {string} params.tenant - The name of the tenant.
|
|
2457
|
-
* @param {string} params.database - The name of the database.
|
|
2458
|
-
*
|
|
2459
|
-
* @returns {Promise<void>} A promise that returns nothing
|
|
2460
|
-
* @throws {Error} Any issues
|
|
2461
|
-
*
|
|
2462
|
-
* @example
|
|
2463
|
-
* ```typescript
|
|
2464
|
-
* await adminClient.setTenant({
|
|
2465
|
-
* tenant: "my_tenant",
|
|
2466
|
-
* database: "my_database",
|
|
2467
|
-
* });
|
|
2468
|
-
* ```
|
|
2469
|
-
*/
|
|
2470
|
-
async setTenant({
|
|
2471
|
-
tenant = DEFAULT_TENANT,
|
|
2472
|
-
database = DEFAULT_DATABASE
|
|
2473
|
-
}) {
|
|
2474
|
-
await validateTenantDatabase(this, tenant, database);
|
|
2475
|
-
this.tenant = tenant;
|
|
2476
|
-
this.database = database;
|
|
2477
|
-
}
|
|
2478
|
-
/**
|
|
2479
|
-
* Sets the database for the client.
|
|
2480
|
-
*
|
|
2481
|
-
* @param {Object} params - The parameters for setting the database.
|
|
2482
|
-
* @param {string} params.database - The name of the database.
|
|
2483
|
-
*
|
|
2484
|
-
* @returns {Promise<void>} A promise that returns nothing
|
|
2485
|
-
* @throws {Error} Any issues
|
|
2486
|
-
*
|
|
2487
|
-
* @example
|
|
2488
|
-
* ```typescript
|
|
2489
|
-
* await adminClient.setDatabase({
|
|
2490
|
-
* database: "my_database",
|
|
2491
|
-
* });
|
|
2492
|
-
* ```
|
|
2493
|
-
*/
|
|
2494
|
-
async setDatabase({
|
|
2495
|
-
database = DEFAULT_DATABASE
|
|
2496
|
-
}) {
|
|
2497
|
-
await validateTenantDatabase(this, this.tenant, database);
|
|
2498
|
-
this.database = database;
|
|
1928
|
+
this.model = model;
|
|
1929
|
+
this.revision = revision;
|
|
1930
|
+
this.quantized = quantized;
|
|
1931
|
+
this.progress_callback = progress_callback;
|
|
2499
1932
|
}
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
}
|
|
2523
|
-
return { name };
|
|
2524
|
-
}
|
|
2525
|
-
/**
|
|
2526
|
-
* Gets a tenant with the specified properties.
|
|
2527
|
-
*
|
|
2528
|
-
* @param {Object} params - The parameters for getting a tenant.
|
|
2529
|
-
* @param {string} params.name - The name of the tenant.
|
|
2530
|
-
*
|
|
2531
|
-
* @returns {Promise<Tenant>} A promise that resolves to the tenant.
|
|
2532
|
-
* @throws {Error} If there is an issue getting the tenant.
|
|
2533
|
-
*
|
|
2534
|
-
* @example
|
|
2535
|
-
* ```typescript
|
|
2536
|
-
* await adminClient.getTenant({
|
|
2537
|
-
* name: "my_tenant",
|
|
2538
|
-
* });
|
|
2539
|
-
* ```
|
|
2540
|
-
*/
|
|
2541
|
-
async getTenant({
|
|
2542
|
-
name
|
|
2543
|
-
}) {
|
|
2544
|
-
const getTenant = await this.api.getTenant(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2545
|
-
if (getTenant.error) {
|
|
2546
|
-
throw new Error(getTenant.error);
|
|
2547
|
-
}
|
|
2548
|
-
return { name: getTenant.name };
|
|
1933
|
+
async generate(texts) {
|
|
1934
|
+
await this.loadClient();
|
|
1935
|
+
this.pipelinePromise = new Promise(async (resolve, reject) => {
|
|
1936
|
+
try {
|
|
1937
|
+
const pipeline = this.transformersApi;
|
|
1938
|
+
const quantized = this.quantized;
|
|
1939
|
+
const revision = this.revision;
|
|
1940
|
+
const progress_callback = this.progress_callback;
|
|
1941
|
+
resolve(
|
|
1942
|
+
await pipeline("feature-extraction", this.model, {
|
|
1943
|
+
quantized,
|
|
1944
|
+
revision,
|
|
1945
|
+
progress_callback
|
|
1946
|
+
})
|
|
1947
|
+
);
|
|
1948
|
+
} catch (e) {
|
|
1949
|
+
reject(e);
|
|
1950
|
+
}
|
|
1951
|
+
});
|
|
1952
|
+
let pipe = await this.pipelinePromise;
|
|
1953
|
+
let output = await pipe(texts, { pooling: "mean", normalize: true });
|
|
1954
|
+
return output.tolist();
|
|
2549
1955
|
}
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
* ```typescript
|
|
2562
|
-
* await adminClient.createDatabase({
|
|
2563
|
-
* name: "my_database",
|
|
2564
|
-
* tenantName: "my_tenant",
|
|
2565
|
-
* });
|
|
2566
|
-
* ```
|
|
2567
|
-
*/
|
|
2568
|
-
async createDatabase({
|
|
2569
|
-
name,
|
|
2570
|
-
tenantName
|
|
2571
|
-
}) {
|
|
2572
|
-
const newDatabase = await this.api.createDatabase(tenantName, { name }, this.api.options).then(handleSuccess).catch(handleError);
|
|
2573
|
-
if (newDatabase && newDatabase.error) {
|
|
2574
|
-
throw new Error(newDatabase.error);
|
|
1956
|
+
async loadClient() {
|
|
1957
|
+
if (this.transformersApi)
|
|
1958
|
+
return;
|
|
1959
|
+
try {
|
|
1960
|
+
let { pipeline } = await _DefaultEmbeddingFunction.import();
|
|
1961
|
+
TransformersApi = pipeline;
|
|
1962
|
+
} catch (_a) {
|
|
1963
|
+
if (_a.code === "MODULE_NOT_FOUND") {
|
|
1964
|
+
throw new Error("Please install the chromadb-default-embed package to use the DefaultEmbeddingFunction, `npm install -S chromadb-default-embed`");
|
|
1965
|
+
}
|
|
1966
|
+
throw _a;
|
|
2575
1967
|
}
|
|
2576
|
-
|
|
1968
|
+
this.transformersApi = TransformersApi;
|
|
2577
1969
|
}
|
|
2578
|
-
/**
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
*
|
|
2588
|
-
* @example
|
|
2589
|
-
* ```typescript
|
|
2590
|
-
* await adminClient.getDatabase({
|
|
2591
|
-
* name: "my_database",
|
|
2592
|
-
* tenantName: "my_tenant",
|
|
2593
|
-
* });
|
|
2594
|
-
* ```
|
|
2595
|
-
*/
|
|
2596
|
-
async getDatabase({
|
|
2597
|
-
name,
|
|
2598
|
-
tenantName
|
|
2599
|
-
}) {
|
|
2600
|
-
const getDatabase = await this.api.getDatabase(name, tenantName, this.api.options).then(handleSuccess).catch(handleError);
|
|
2601
|
-
if (getDatabase.error) {
|
|
2602
|
-
throw new Error(getDatabase.error);
|
|
1970
|
+
/** @ignore */
|
|
1971
|
+
static async import() {
|
|
1972
|
+
try {
|
|
1973
|
+
const { pipeline } = await import("chromadb-default-embed");
|
|
1974
|
+
return { pipeline };
|
|
1975
|
+
} catch (e) {
|
|
1976
|
+
throw new Error(
|
|
1977
|
+
"Please install chromadb-default-embed as a dependency with, e.g. `yarn add chromadb-default-embed`"
|
|
1978
|
+
);
|
|
2603
1979
|
}
|
|
2604
|
-
return { name: getDatabase.name };
|
|
2605
1980
|
}
|
|
2606
1981
|
};
|
|
2607
1982
|
|
|
2608
1983
|
// src/ChromaClient.ts
|
|
2609
|
-
var DEFAULT_TENANT2 = "default_tenant";
|
|
2610
|
-
var DEFAULT_DATABASE2 = "default_database";
|
|
2611
1984
|
var ChromaClient = class {
|
|
2612
1985
|
/**
|
|
2613
1986
|
* Creates a new ChromaClient instance.
|
|
@@ -2625,16 +1998,10 @@ var ChromaClient = class {
|
|
|
2625
1998
|
constructor({
|
|
2626
1999
|
path,
|
|
2627
2000
|
fetchOptions,
|
|
2628
|
-
auth
|
|
2629
|
-
tenant = DEFAULT_TENANT2,
|
|
2630
|
-
database = DEFAULT_DATABASE2
|
|
2001
|
+
auth
|
|
2631
2002
|
} = {}) {
|
|
2632
|
-
this.tenant = DEFAULT_TENANT2;
|
|
2633
|
-
this.database = DEFAULT_DATABASE2;
|
|
2634
2003
|
if (path === void 0)
|
|
2635
2004
|
path = "http://localhost:8000";
|
|
2636
|
-
this.tenant = tenant;
|
|
2637
|
-
this.database = database;
|
|
2638
2005
|
const apiConfig = new Configuration({
|
|
2639
2006
|
basePath: path
|
|
2640
2007
|
});
|
|
@@ -2644,13 +2011,6 @@ var ChromaClient = class {
|
|
|
2644
2011
|
} else {
|
|
2645
2012
|
this.api = new ApiApi(apiConfig);
|
|
2646
2013
|
}
|
|
2647
|
-
this._adminClient = new AdminClient({
|
|
2648
|
-
path,
|
|
2649
|
-
fetchOptions,
|
|
2650
|
-
auth,
|
|
2651
|
-
tenant,
|
|
2652
|
-
database
|
|
2653
|
-
});
|
|
2654
2014
|
this.api.options = fetchOptions != null ? fetchOptions : {};
|
|
2655
2015
|
}
|
|
2656
2016
|
/**
|
|
@@ -2720,7 +2080,10 @@ var ChromaClient = class {
|
|
|
2720
2080
|
metadata,
|
|
2721
2081
|
embeddingFunction
|
|
2722
2082
|
}) {
|
|
2723
|
-
|
|
2083
|
+
if (embeddingFunction === void 0) {
|
|
2084
|
+
embeddingFunction = new DefaultEmbeddingFunction();
|
|
2085
|
+
}
|
|
2086
|
+
const newCollection = await this.api.createCollection({
|
|
2724
2087
|
name,
|
|
2725
2088
|
metadata
|
|
2726
2089
|
}, this.api.options).then(handleSuccess).catch(handleError);
|
|
@@ -2755,7 +2118,10 @@ var ChromaClient = class {
|
|
|
2755
2118
|
metadata,
|
|
2756
2119
|
embeddingFunction
|
|
2757
2120
|
}) {
|
|
2758
|
-
|
|
2121
|
+
if (embeddingFunction === void 0) {
|
|
2122
|
+
embeddingFunction = new DefaultEmbeddingFunction();
|
|
2123
|
+
}
|
|
2124
|
+
const newCollection = await this.api.createCollection({
|
|
2759
2125
|
name,
|
|
2760
2126
|
metadata,
|
|
2761
2127
|
"get_or_create": true
|
|
@@ -2775,44 +2141,15 @@ var ChromaClient = class {
|
|
|
2775
2141
|
* Lists all collections.
|
|
2776
2142
|
*
|
|
2777
2143
|
* @returns {Promise<CollectionType[]>} A promise that resolves to a list of collection names.
|
|
2778
|
-
* @param {PositiveInteger} [params.limit] - Optional limit on the number of items to get.
|
|
2779
|
-
* @param {PositiveInteger} [params.offset] - Optional offset on the items to get.
|
|
2780
2144
|
* @throws {Error} If there is an issue listing the collections.
|
|
2781
2145
|
*
|
|
2782
2146
|
* @example
|
|
2783
2147
|
* ```typescript
|
|
2784
|
-
* const collections = await client.listCollections(
|
|
2785
|
-
* limit: 10,
|
|
2786
|
-
* offset: 0,
|
|
2787
|
-
* });
|
|
2148
|
+
* const collections = await client.listCollections();
|
|
2788
2149
|
* ```
|
|
2789
2150
|
*/
|
|
2790
|
-
async listCollections({
|
|
2791
|
-
|
|
2792
|
-
offset
|
|
2793
|
-
} = {}) {
|
|
2794
|
-
const response = await this.api.listCollections(
|
|
2795
|
-
this.tenant,
|
|
2796
|
-
this.database,
|
|
2797
|
-
limit,
|
|
2798
|
-
offset,
|
|
2799
|
-
this.api.options
|
|
2800
|
-
);
|
|
2801
|
-
return handleSuccess(response);
|
|
2802
|
-
}
|
|
2803
|
-
/**
|
|
2804
|
-
* Counts all collections.
|
|
2805
|
-
*
|
|
2806
|
-
* @returns {Promise<number>} A promise that resolves to the number of collections.
|
|
2807
|
-
* @throws {Error} If there is an issue counting the collections.
|
|
2808
|
-
*
|
|
2809
|
-
* @example
|
|
2810
|
-
* ```typescript
|
|
2811
|
-
* const collections = await client.countCollections();
|
|
2812
|
-
* ```
|
|
2813
|
-
*/
|
|
2814
|
-
async countCollections() {
|
|
2815
|
-
const response = await this.api.countCollections(this.tenant, this.database, this.api.options);
|
|
2151
|
+
async listCollections() {
|
|
2152
|
+
const response = await this.api.listCollections(this.api.options);
|
|
2816
2153
|
return handleSuccess(response);
|
|
2817
2154
|
}
|
|
2818
2155
|
/**
|
|
@@ -2834,7 +2171,7 @@ var ChromaClient = class {
|
|
|
2834
2171
|
name,
|
|
2835
2172
|
embeddingFunction
|
|
2836
2173
|
}) {
|
|
2837
|
-
const response = await this.api.getCollection(name, this.
|
|
2174
|
+
const response = await this.api.getCollection(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2838
2175
|
if (response.error) {
|
|
2839
2176
|
throw new Error(response.error);
|
|
2840
2177
|
}
|
|
@@ -2863,33 +2200,7 @@ var ChromaClient = class {
|
|
|
2863
2200
|
async deleteCollection({
|
|
2864
2201
|
name
|
|
2865
2202
|
}) {
|
|
2866
|
-
return await this.api.deleteCollection(name, this.
|
|
2867
|
-
}
|
|
2868
|
-
};
|
|
2869
|
-
|
|
2870
|
-
// src/CloudClient.ts
|
|
2871
|
-
var CloudClient = class extends ChromaClient {
|
|
2872
|
-
constructor({ apiKey, database, cloudHost, cloudPort }) {
|
|
2873
|
-
if (!apiKey) {
|
|
2874
|
-
apiKey = process.env.CHROMA_API_KEY;
|
|
2875
|
-
}
|
|
2876
|
-
if (!apiKey) {
|
|
2877
|
-
throw new Error("No API key provided");
|
|
2878
|
-
}
|
|
2879
|
-
cloudHost = cloudHost || "https://api.trychroma.com";
|
|
2880
|
-
cloudPort = cloudPort || "8000";
|
|
2881
|
-
const path = `${cloudHost}:${cloudPort}`;
|
|
2882
|
-
const auth = {
|
|
2883
|
-
provider: "token",
|
|
2884
|
-
credentials: apiKey,
|
|
2885
|
-
providerOptions: { headerType: "X_CHROMA_TOKEN" }
|
|
2886
|
-
};
|
|
2887
|
-
return new ChromaClient({
|
|
2888
|
-
path,
|
|
2889
|
-
auth,
|
|
2890
|
-
database
|
|
2891
|
-
});
|
|
2892
|
-
super();
|
|
2203
|
+
return await this.api.deleteCollection(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2893
2204
|
}
|
|
2894
2205
|
};
|
|
2895
2206
|
|
|
@@ -3033,50 +2344,73 @@ var CohereEmbeddingFunction = class _CohereEmbeddingFunction {
|
|
|
3033
2344
|
}
|
|
3034
2345
|
};
|
|
3035
2346
|
|
|
3036
|
-
// src/embeddings/
|
|
3037
|
-
var
|
|
3038
|
-
var
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
2347
|
+
// src/embeddings/TransformersEmbeddingFunction.ts
|
|
2348
|
+
var TransformersApi2;
|
|
2349
|
+
var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
2350
|
+
/**
|
|
2351
|
+
* TransformersEmbeddingFunction constructor.
|
|
2352
|
+
* @param options The configuration options.
|
|
2353
|
+
* @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`.
|
|
2354
|
+
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
2355
|
+
* @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
|
|
2356
|
+
* @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
2357
|
+
*/
|
|
2358
|
+
constructor({
|
|
2359
|
+
model = "Xenova/all-MiniLM-L6-v2",
|
|
2360
|
+
revision = "main",
|
|
2361
|
+
quantized = false,
|
|
2362
|
+
progress_callback = null
|
|
2363
|
+
} = {}) {
|
|
2364
|
+
this.model = model;
|
|
2365
|
+
this.revision = revision;
|
|
2366
|
+
this.quantized = quantized;
|
|
2367
|
+
this.progress_callback = progress_callback;
|
|
2368
|
+
}
|
|
2369
|
+
async generate(texts) {
|
|
2370
|
+
await this.loadClient();
|
|
2371
|
+
this.pipelinePromise = new Promise(async (resolve, reject) => {
|
|
2372
|
+
try {
|
|
2373
|
+
const pipeline = this.transformersApi;
|
|
2374
|
+
const quantized = this.quantized;
|
|
2375
|
+
const revision = this.revision;
|
|
2376
|
+
const progress_callback = this.progress_callback;
|
|
2377
|
+
resolve(
|
|
2378
|
+
await pipeline("feature-extraction", this.model, {
|
|
2379
|
+
quantized,
|
|
2380
|
+
revision,
|
|
2381
|
+
progress_callback
|
|
2382
|
+
})
|
|
2383
|
+
);
|
|
2384
|
+
} catch (e) {
|
|
2385
|
+
reject(e);
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
let pipe = await this.pipelinePromise;
|
|
2389
|
+
let output = await pipe(texts, { pooling: "mean", normalize: true });
|
|
2390
|
+
return output.tolist();
|
|
3043
2391
|
}
|
|
3044
2392
|
async loadClient() {
|
|
3045
|
-
if (this.
|
|
2393
|
+
if (this.transformersApi)
|
|
3046
2394
|
return;
|
|
3047
2395
|
try {
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
googleGenAiApi = new googleGenAiApi(this.api_key);
|
|
2396
|
+
let { pipeline } = await _TransformersEmbeddingFunction.import();
|
|
2397
|
+
TransformersApi2 = pipeline;
|
|
3051
2398
|
} catch (_a) {
|
|
3052
2399
|
if (_a.code === "MODULE_NOT_FOUND") {
|
|
3053
|
-
throw new Error("Please install the @
|
|
2400
|
+
throw new Error("Please install the @xenova/transformers package to use the TransformersEmbeddingFunction, `npm install -S @xenova/transformers`");
|
|
3054
2401
|
}
|
|
3055
2402
|
throw _a;
|
|
3056
2403
|
}
|
|
3057
|
-
this.
|
|
3058
|
-
}
|
|
3059
|
-
async generate(texts) {
|
|
3060
|
-
await this.loadClient();
|
|
3061
|
-
const model = this.googleGenAiApi.getGenerativeModel({ model: this.model });
|
|
3062
|
-
const response = await model.batchEmbedContents({
|
|
3063
|
-
requests: texts.map((t) => ({
|
|
3064
|
-
content: { parts: [{ text: t }] },
|
|
3065
|
-
taskType: this.taskType
|
|
3066
|
-
}))
|
|
3067
|
-
});
|
|
3068
|
-
const embeddings = response.embeddings.map((e) => e.values);
|
|
3069
|
-
return embeddings;
|
|
2404
|
+
this.transformersApi = TransformersApi2;
|
|
3070
2405
|
}
|
|
3071
2406
|
/** @ignore */
|
|
3072
2407
|
static async import() {
|
|
3073
2408
|
try {
|
|
3074
|
-
const {
|
|
3075
|
-
|
|
3076
|
-
return { googleGenAi };
|
|
2409
|
+
const { pipeline } = await import("@xenova/transformers");
|
|
2410
|
+
return { pipeline };
|
|
3077
2411
|
} catch (e) {
|
|
3078
2412
|
throw new Error(
|
|
3079
|
-
"Please install @
|
|
2413
|
+
"Please install @xenova/transformers as a dependency with, e.g. `yarn add @xenova/transformers`"
|
|
3080
2414
|
);
|
|
3081
2415
|
}
|
|
3082
2416
|
}
|
|
@@ -3090,76 +2424,14 @@ var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
|
3090
2424
|
IncludeEnum2["Distances"] = "distances";
|
|
3091
2425
|
return IncludeEnum2;
|
|
3092
2426
|
})(IncludeEnum || {});
|
|
3093
|
-
|
|
3094
|
-
// src/embeddings/HuggingFaceEmbeddingServerFunction.ts
|
|
3095
|
-
var HuggingFaceEmbeddingServerFunction = class {
|
|
3096
|
-
constructor({ url }) {
|
|
3097
|
-
this.url = url;
|
|
3098
|
-
}
|
|
3099
|
-
async generate(texts) {
|
|
3100
|
-
const response = await fetch(this.url, {
|
|
3101
|
-
method: "POST",
|
|
3102
|
-
headers: {
|
|
3103
|
-
"Content-Type": "application/json"
|
|
3104
|
-
},
|
|
3105
|
-
body: JSON.stringify({ "inputs": texts })
|
|
3106
|
-
});
|
|
3107
|
-
if (!response.ok) {
|
|
3108
|
-
throw new Error(`Failed to generate embeddings: ${response.statusText}`);
|
|
3109
|
-
}
|
|
3110
|
-
const data = await response.json();
|
|
3111
|
-
return data;
|
|
3112
|
-
}
|
|
3113
|
-
};
|
|
3114
|
-
|
|
3115
|
-
// src/embeddings/JinaEmbeddingFunction.ts
|
|
3116
|
-
var JinaEmbeddingFunction = class {
|
|
3117
|
-
constructor({ jinaai_api_key, model_name }) {
|
|
3118
|
-
this.model_name = model_name || "jina-embeddings-v2-base-en";
|
|
3119
|
-
this.api_url = "https://api.jina.ai/v1/embeddings";
|
|
3120
|
-
this.headers = {
|
|
3121
|
-
Authorization: `Bearer ${jinaai_api_key}`,
|
|
3122
|
-
"Accept-Encoding": "identity",
|
|
3123
|
-
"Content-Type": "application/json"
|
|
3124
|
-
};
|
|
3125
|
-
}
|
|
3126
|
-
async generate(texts) {
|
|
3127
|
-
try {
|
|
3128
|
-
const response = await fetch(this.api_url, {
|
|
3129
|
-
method: "POST",
|
|
3130
|
-
headers: this.headers,
|
|
3131
|
-
body: JSON.stringify({
|
|
3132
|
-
input: texts,
|
|
3133
|
-
model: this.model_name
|
|
3134
|
-
})
|
|
3135
|
-
});
|
|
3136
|
-
const data = await response.json();
|
|
3137
|
-
if (!data || !data.data) {
|
|
3138
|
-
throw new Error(data.detail);
|
|
3139
|
-
}
|
|
3140
|
-
const embeddings = data.data;
|
|
3141
|
-
const sortedEmbeddings = embeddings.sort((a, b) => a.index - b.index);
|
|
3142
|
-
return sortedEmbeddings.map((result) => result.embedding);
|
|
3143
|
-
} catch (error) {
|
|
3144
|
-
if (error instanceof Error) {
|
|
3145
|
-
throw new Error(`Error calling Jina AI API: ${error.message}`);
|
|
3146
|
-
} else {
|
|
3147
|
-
throw new Error(`Error calling Jina AI API: ${error}`);
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
};
|
|
3152
2427
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3153
2428
|
0 && (module.exports = {
|
|
3154
|
-
AdminClient,
|
|
3155
2429
|
ChromaClient,
|
|
3156
|
-
CloudClient,
|
|
3157
2430
|
CohereEmbeddingFunction,
|
|
3158
2431
|
Collection,
|
|
3159
|
-
|
|
3160
|
-
HuggingFaceEmbeddingServerFunction,
|
|
2432
|
+
DefaultEmbeddingFunction,
|
|
3161
2433
|
IncludeEnum,
|
|
3162
|
-
|
|
3163
|
-
|
|
2434
|
+
OpenAIEmbeddingFunction,
|
|
2435
|
+
TransformersEmbeddingFunction
|
|
3164
2436
|
});
|
|
3165
2437
|
//# sourceMappingURL=chromadb.cjs.map
|