chromadb 1.7.2 → 1.7.3-beta1
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 +203 -491
- package/dist/chromadb.legacy-esm.js +101 -899
- package/dist/chromadb.mjs +101 -899
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +103 -905
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +203 -491
- 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,12 @@ 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
|
-
GoogleGenerativeAiEmbeddingFunction: () => GoogleGenerativeAiEmbeddingFunction,
|
|
56
|
-
HuggingFaceEmbeddingServerFunction: () => HuggingFaceEmbeddingServerFunction,
|
|
57
53
|
IncludeEnum: () => IncludeEnum,
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
OpenAIEmbeddingFunction: () => OpenAIEmbeddingFunction,
|
|
55
|
+
TransformersEmbeddingFunction: () => TransformersEmbeddingFunction
|
|
60
56
|
});
|
|
61
57
|
module.exports = __toCommonJS(src_exports);
|
|
62
58
|
|
|
@@ -222,47 +218,13 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
222
218
|
options: localVarRequestOptions
|
|
223
219
|
};
|
|
224
220
|
},
|
|
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
221
|
/**
|
|
258
222
|
* @summary Create Collection
|
|
259
|
-
* @param {string} [tenant]
|
|
260
|
-
* @param {string} [database]
|
|
261
223
|
* @param {Api.CreateCollection} request
|
|
262
224
|
* @param {RequestInit} [options] Override http request option.
|
|
263
225
|
* @throws {RequiredError}
|
|
264
226
|
*/
|
|
265
|
-
createCollection(
|
|
227
|
+
createCollection(request, options = {}) {
|
|
266
228
|
if (request === null || request === void 0) {
|
|
267
229
|
throw new RequiredError("request", "Required parameter request was null or undefined when calling createCollection.");
|
|
268
230
|
}
|
|
@@ -274,80 +236,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
274
236
|
if (localVarPathQueryStart !== -1) {
|
|
275
237
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
276
238
|
}
|
|
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
239
|
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
352
240
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
353
241
|
if (request !== void 0) {
|
|
@@ -365,12 +253,10 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
365
253
|
/**
|
|
366
254
|
* @summary Delete Collection
|
|
367
255
|
* @param {string} collectionName
|
|
368
|
-
* @param {string} [tenant]
|
|
369
|
-
* @param {string} [database]
|
|
370
256
|
* @param {RequestInit} [options] Override http request option.
|
|
371
257
|
* @throws {RequiredError}
|
|
372
258
|
*/
|
|
373
|
-
deleteCollection(collectionName,
|
|
259
|
+
deleteCollection(collectionName, options = {}) {
|
|
374
260
|
if (collectionName === null || collectionName === void 0) {
|
|
375
261
|
throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling deleteCollection.");
|
|
376
262
|
}
|
|
@@ -382,12 +268,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
382
268
|
if (localVarPathQueryStart !== -1) {
|
|
383
269
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
384
270
|
}
|
|
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
271
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
392
272
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
393
273
|
if (localVarQueryParameterString) {
|
|
@@ -401,12 +281,10 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
401
281
|
/**
|
|
402
282
|
* @summary Get Collection
|
|
403
283
|
* @param {string} collectionName
|
|
404
|
-
* @param {string} [tenant]
|
|
405
|
-
* @param {string} [database]
|
|
406
284
|
* @param {RequestInit} [options] Override http request option.
|
|
407
285
|
* @throws {RequiredError}
|
|
408
286
|
*/
|
|
409
|
-
getCollection(collectionName,
|
|
287
|
+
getCollection(collectionName, options = {}) {
|
|
410
288
|
if (collectionName === null || collectionName === void 0) {
|
|
411
289
|
throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling getCollection.");
|
|
412
290
|
}
|
|
@@ -418,44 +296,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
418
296
|
if (localVarPathQueryStart !== -1) {
|
|
419
297
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
420
298
|
}
|
|
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
299
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
460
300
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
461
301
|
if (localVarQueryParameterString) {
|
|
@@ -502,34 +342,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
502
342
|
options: localVarRequestOptions
|
|
503
343
|
};
|
|
504
344
|
},
|
|
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
345
|
/**
|
|
534
346
|
* @summary Heartbeat
|
|
535
347
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -556,14 +368,10 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
556
368
|
},
|
|
557
369
|
/**
|
|
558
370
|
* @summary List Collections
|
|
559
|
-
* @param {string} [tenant]
|
|
560
|
-
* @param {string} [database]
|
|
561
|
-
* @param {number} [limit]
|
|
562
|
-
* @param {number} [offset]
|
|
563
371
|
* @param {RequestInit} [options] Override http request option.
|
|
564
372
|
* @throws {RequiredError}
|
|
565
373
|
*/
|
|
566
|
-
listCollections(
|
|
374
|
+
listCollections(options = {}) {
|
|
567
375
|
let localVarPath = `/api/v1/collections`;
|
|
568
376
|
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
569
377
|
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
@@ -572,42 +380,6 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
572
380
|
if (localVarPathQueryStart !== -1) {
|
|
573
381
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
574
382
|
}
|
|
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
383
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
612
384
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
613
385
|
if (localVarQueryParameterString) {
|
|
@@ -917,102 +689,14 @@ var ApiApiFp = function(configuration) {
|
|
|
917
689
|
});
|
|
918
690
|
};
|
|
919
691
|
},
|
|
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
692
|
/**
|
|
950
693
|
* @summary Create Collection
|
|
951
|
-
* @param {string} [tenant]
|
|
952
|
-
* @param {string} [database]
|
|
953
694
|
* @param {Api.CreateCollection} request
|
|
954
695
|
* @param {RequestInit} [options] Override http request option.
|
|
955
696
|
* @throws {RequiredError}
|
|
956
697
|
*/
|
|
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);
|
|
698
|
+
createCollection(request, options) {
|
|
699
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(request, options);
|
|
1016
700
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1017
701
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1018
702
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1036,13 +720,11 @@ var ApiApiFp = function(configuration) {
|
|
|
1036
720
|
/**
|
|
1037
721
|
* @summary Delete Collection
|
|
1038
722
|
* @param {string} collectionName
|
|
1039
|
-
* @param {string} [tenant]
|
|
1040
|
-
* @param {string} [database]
|
|
1041
723
|
* @param {RequestInit} [options] Override http request option.
|
|
1042
724
|
* @throws {RequiredError}
|
|
1043
725
|
*/
|
|
1044
|
-
deleteCollection(collectionName,
|
|
1045
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName,
|
|
726
|
+
deleteCollection(collectionName, options) {
|
|
727
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, options);
|
|
1046
728
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1047
729
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1048
730
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1066,42 +748,11 @@ var ApiApiFp = function(configuration) {
|
|
|
1066
748
|
/**
|
|
1067
749
|
* @summary Get Collection
|
|
1068
750
|
* @param {string} collectionName
|
|
1069
|
-
* @param {string} [tenant]
|
|
1070
|
-
* @param {string} [database]
|
|
1071
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1072
|
-
* @throws {RequiredError}
|
|
1073
|
-
*/
|
|
1074
|
-
getCollection(collectionName, tenant, database, options) {
|
|
1075
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName, tenant, database, options);
|
|
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
751
|
* @param {RequestInit} [options] Override http request option.
|
|
1101
752
|
* @throws {RequiredError}
|
|
1102
753
|
*/
|
|
1103
|
-
|
|
1104
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).
|
|
754
|
+
getCollection(collectionName, options) {
|
|
755
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName, options);
|
|
1105
756
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1106
757
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1107
758
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1151,34 +802,6 @@ var ApiApiFp = function(configuration) {
|
|
|
1151
802
|
});
|
|
1152
803
|
};
|
|
1153
804
|
},
|
|
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
805
|
/**
|
|
1183
806
|
* @summary Heartbeat
|
|
1184
807
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -1202,42 +825,11 @@ var ApiApiFp = function(configuration) {
|
|
|
1202
825
|
},
|
|
1203
826
|
/**
|
|
1204
827
|
* @summary List Collections
|
|
1205
|
-
* @param {string} [tenant]
|
|
1206
|
-
* @param {string} [database]
|
|
1207
|
-
* @param {number} [limit]
|
|
1208
|
-
* @param {number} [offset]
|
|
1209
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1210
|
-
* @throws {RequiredError}
|
|
1211
|
-
*/
|
|
1212
|
-
listCollections(tenant, database, limit, offset, options) {
|
|
1213
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(tenant, database, limit, offset, options);
|
|
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
828
|
* @param {RequestInit} [options] Override http request option.
|
|
1237
829
|
* @throws {RequiredError}
|
|
1238
830
|
*/
|
|
1239
|
-
|
|
1240
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).
|
|
831
|
+
listCollections(options) {
|
|
832
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(options);
|
|
1241
833
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1242
834
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1243
835
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -1444,77 +1036,32 @@ var ApiApi = class extends BaseAPI {
|
|
|
1444
1036
|
count(collectionId, options) {
|
|
1445
1037
|
return ApiApiFp(this.configuration).count(collectionId, options)(this.fetch, this.basePath);
|
|
1446
1038
|
}
|
|
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
1039
|
/**
|
|
1458
1040
|
* @summary Create Collection
|
|
1459
|
-
* @param {string} [tenant]
|
|
1460
|
-
* @param {string} [database]
|
|
1461
1041
|
* @param {Api.CreateCollection} request
|
|
1462
1042
|
* @param {RequestInit} [options] Override http request option.
|
|
1463
1043
|
* @throws {RequiredError}
|
|
1464
1044
|
*/
|
|
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);
|
|
1045
|
+
createCollection(request, options) {
|
|
1046
|
+
return ApiApiFp(this.configuration).createCollection(request, options)(this.fetch, this.basePath);
|
|
1486
1047
|
}
|
|
1487
1048
|
/**
|
|
1488
1049
|
* @summary Delete Collection
|
|
1489
1050
|
* @param {string} collectionName
|
|
1490
|
-
* @param {string} [tenant]
|
|
1491
|
-
* @param {string} [database]
|
|
1492
1051
|
* @param {RequestInit} [options] Override http request option.
|
|
1493
1052
|
* @throws {RequiredError}
|
|
1494
1053
|
*/
|
|
1495
|
-
deleteCollection(collectionName,
|
|
1496
|
-
return ApiApiFp(this.configuration).deleteCollection(collectionName,
|
|
1054
|
+
deleteCollection(collectionName, options) {
|
|
1055
|
+
return ApiApiFp(this.configuration).deleteCollection(collectionName, options)(this.fetch, this.basePath);
|
|
1497
1056
|
}
|
|
1498
1057
|
/**
|
|
1499
1058
|
* @summary Get Collection
|
|
1500
1059
|
* @param {string} collectionName
|
|
1501
|
-
* @param {string} [tenant]
|
|
1502
|
-
* @param {string} [database]
|
|
1503
|
-
* @param {RequestInit} [options] Override http request option.
|
|
1504
|
-
* @throws {RequiredError}
|
|
1505
|
-
*/
|
|
1506
|
-
getCollection(collectionName, tenant, database, options) {
|
|
1507
|
-
return ApiApiFp(this.configuration).getCollection(collectionName, tenant, database, options)(this.fetch, this.basePath);
|
|
1508
|
-
}
|
|
1509
|
-
/**
|
|
1510
|
-
* @summary Get Database
|
|
1511
|
-
* @param {string} database
|
|
1512
|
-
* @param {string} [tenant]
|
|
1513
1060
|
* @param {RequestInit} [options] Override http request option.
|
|
1514
1061
|
* @throws {RequiredError}
|
|
1515
1062
|
*/
|
|
1516
|
-
|
|
1517
|
-
return ApiApiFp(this.configuration).
|
|
1063
|
+
getCollection(collectionName, options) {
|
|
1064
|
+
return ApiApiFp(this.configuration).getCollection(collectionName, options)(this.fetch, this.basePath);
|
|
1518
1065
|
}
|
|
1519
1066
|
/**
|
|
1520
1067
|
* @summary Get Nearest Neighbors
|
|
@@ -1526,15 +1073,6 @@ var ApiApi = class extends BaseAPI {
|
|
|
1526
1073
|
getNearestNeighbors(collectionId, request, options) {
|
|
1527
1074
|
return ApiApiFp(this.configuration).getNearestNeighbors(collectionId, request, options)(this.fetch, this.basePath);
|
|
1528
1075
|
}
|
|
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
1076
|
/**
|
|
1539
1077
|
* @summary Heartbeat
|
|
1540
1078
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -1545,23 +1083,11 @@ var ApiApi = class extends BaseAPI {
|
|
|
1545
1083
|
}
|
|
1546
1084
|
/**
|
|
1547
1085
|
* @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
1086
|
* @param {RequestInit} [options] Override http request option.
|
|
1561
1087
|
* @throws {RequiredError}
|
|
1562
1088
|
*/
|
|
1563
|
-
|
|
1564
|
-
return ApiApiFp(this.configuration).
|
|
1089
|
+
listCollections(options) {
|
|
1090
|
+
return ApiApiFp(this.configuration).listCollections(options)(this.fetch, this.basePath);
|
|
1565
1091
|
}
|
|
1566
1092
|
/**
|
|
1567
1093
|
* @summary Reset
|
|
@@ -1627,8 +1153,8 @@ var Api;
|
|
|
1627
1153
|
let Include;
|
|
1628
1154
|
((Include2) => {
|
|
1629
1155
|
let EnumValueEnum;
|
|
1630
|
-
((
|
|
1631
|
-
|
|
1156
|
+
((EnumValueEnum5) => {
|
|
1157
|
+
EnumValueEnum5["Documents"] = "documents";
|
|
1632
1158
|
})(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
|
|
1633
1159
|
let EnumValueEnum2;
|
|
1634
1160
|
((EnumValueEnum22) => {
|
|
@@ -1642,14 +1168,6 @@ var Api;
|
|
|
1642
1168
|
((EnumValueEnum42) => {
|
|
1643
1169
|
EnumValueEnum42["Distances"] = "distances";
|
|
1644
1170
|
})(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
1171
|
})(Include = GetEmbedding2.Include || (GetEmbedding2.Include = {}));
|
|
1654
1172
|
})(GetEmbedding = Api2.GetEmbedding || (Api2.GetEmbedding = {}));
|
|
1655
1173
|
let QueryEmbedding;
|
|
@@ -1657,8 +1175,8 @@ var Api;
|
|
|
1657
1175
|
let Include;
|
|
1658
1176
|
((Include2) => {
|
|
1659
1177
|
let EnumValueEnum;
|
|
1660
|
-
((
|
|
1661
|
-
|
|
1178
|
+
((EnumValueEnum5) => {
|
|
1179
|
+
EnumValueEnum5["Documents"] = "documents";
|
|
1662
1180
|
})(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
|
|
1663
1181
|
let EnumValueEnum2;
|
|
1664
1182
|
((EnumValueEnum22) => {
|
|
@@ -1672,14 +1190,6 @@ var Api;
|
|
|
1672
1190
|
((EnumValueEnum42) => {
|
|
1673
1191
|
EnumValueEnum42["Distances"] = "distances";
|
|
1674
1192
|
})(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
1193
|
})(Include = QueryEmbedding2.Include || (QueryEmbedding2.Include = {}));
|
|
1684
1194
|
})(QueryEmbedding = Api2.QueryEmbedding || (Api2.QueryEmbedding = {}));
|
|
1685
1195
|
})(Api || (Api = {}));
|
|
@@ -1730,6 +1240,7 @@ async function handleError(error) {
|
|
|
1730
1240
|
}
|
|
1731
1241
|
} catch (e) {
|
|
1732
1242
|
return {
|
|
1243
|
+
//@ts-ignore
|
|
1733
1244
|
error: e && typeof e === "object" && "message" in e ? e.message : "unknown error"
|
|
1734
1245
|
};
|
|
1735
1246
|
}
|
|
@@ -1746,18 +1257,6 @@ async function handleSuccess(response) {
|
|
|
1746
1257
|
return repack(response);
|
|
1747
1258
|
}
|
|
1748
1259
|
}
|
|
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
1260
|
|
|
1762
1261
|
// src/Collection.ts
|
|
1763
1262
|
var Collection = class {
|
|
@@ -2408,206 +1907,79 @@ var IsomorphicFetchClientAuthProtocolAdapter = class {
|
|
|
2408
1907
|
}
|
|
2409
1908
|
};
|
|
2410
1909
|
|
|
2411
|
-
// src/
|
|
2412
|
-
var
|
|
2413
|
-
var
|
|
2414
|
-
var AdminClient = class {
|
|
1910
|
+
// src/embeddings/TransformersEmbeddingFunction.ts
|
|
1911
|
+
var TransformersApi;
|
|
1912
|
+
var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
|
|
2415
1913
|
/**
|
|
2416
|
-
*
|
|
2417
|
-
* @param
|
|
2418
|
-
* @param
|
|
2419
|
-
* @
|
|
2420
|
-
*
|
|
2421
|
-
* @
|
|
2422
|
-
* ```typescript
|
|
2423
|
-
* const client = new AdminClient({
|
|
2424
|
-
* path: "http://localhost:8000"
|
|
2425
|
-
* });
|
|
2426
|
-
* ```
|
|
1914
|
+
* TransformersEmbeddingFunction constructor.
|
|
1915
|
+
* @param options The configuration options.
|
|
1916
|
+
* @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`.
|
|
1917
|
+
* @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
|
|
1918
|
+
* @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
|
|
1919
|
+
* @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
|
|
2427
1920
|
*/
|
|
2428
1921
|
constructor({
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
database = DEFAULT_DATABASE
|
|
1922
|
+
model = "Xenova/all-MiniLM-L6-v2",
|
|
1923
|
+
revision = "main",
|
|
1924
|
+
quantized = false,
|
|
1925
|
+
progress_callback = null
|
|
2434
1926
|
} = {}) {
|
|
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;
|
|
1927
|
+
this.model = model;
|
|
1928
|
+
this.revision = revision;
|
|
1929
|
+
this.quantized = quantized;
|
|
1930
|
+
this.progress_callback = progress_callback;
|
|
2499
1931
|
}
|
|
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 };
|
|
1932
|
+
async generate(texts) {
|
|
1933
|
+
await this.loadClient();
|
|
1934
|
+
this.pipelinePromise = new Promise(async (resolve, reject) => {
|
|
1935
|
+
try {
|
|
1936
|
+
const pipeline = this.transformersApi;
|
|
1937
|
+
const quantized = this.quantized;
|
|
1938
|
+
const revision = this.revision;
|
|
1939
|
+
const progress_callback = this.progress_callback;
|
|
1940
|
+
resolve(
|
|
1941
|
+
await pipeline("feature-extraction", this.model, {
|
|
1942
|
+
quantized,
|
|
1943
|
+
revision,
|
|
1944
|
+
progress_callback
|
|
1945
|
+
})
|
|
1946
|
+
);
|
|
1947
|
+
} catch (e) {
|
|
1948
|
+
reject(e);
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
let pipe = await this.pipelinePromise;
|
|
1952
|
+
let output = await pipe(texts, { pooling: "mean", normalize: true });
|
|
1953
|
+
return output.tolist();
|
|
2549
1954
|
}
|
|
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);
|
|
1955
|
+
async loadClient() {
|
|
1956
|
+
if (this.transformersApi)
|
|
1957
|
+
return;
|
|
1958
|
+
try {
|
|
1959
|
+
let { pipeline } = await _TransformersEmbeddingFunction.import();
|
|
1960
|
+
TransformersApi = pipeline;
|
|
1961
|
+
} catch (_a) {
|
|
1962
|
+
if (_a.code === "MODULE_NOT_FOUND") {
|
|
1963
|
+
throw new Error("Please install the @xenova/transformers package to use the TransformersEmbeddingFunction, `npm install -S @xenova/transformers`");
|
|
1964
|
+
}
|
|
1965
|
+
throw _a;
|
|
2575
1966
|
}
|
|
2576
|
-
|
|
1967
|
+
this.transformersApi = TransformersApi;
|
|
2577
1968
|
}
|
|
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);
|
|
1969
|
+
/** @ignore */
|
|
1970
|
+
static async import() {
|
|
1971
|
+
try {
|
|
1972
|
+
const { pipeline } = await import("@xenova/transformers");
|
|
1973
|
+
return { pipeline };
|
|
1974
|
+
} catch (e) {
|
|
1975
|
+
throw new Error(
|
|
1976
|
+
"Please install @xenova/transformers as a dependency with, e.g. `yarn add @xenova/transformers`"
|
|
1977
|
+
);
|
|
2603
1978
|
}
|
|
2604
|
-
return { name: getDatabase.name };
|
|
2605
1979
|
}
|
|
2606
1980
|
};
|
|
2607
1981
|
|
|
2608
1982
|
// src/ChromaClient.ts
|
|
2609
|
-
var DEFAULT_TENANT2 = "default_tenant";
|
|
2610
|
-
var DEFAULT_DATABASE2 = "default_database";
|
|
2611
1983
|
var ChromaClient = class {
|
|
2612
1984
|
/**
|
|
2613
1985
|
* Creates a new ChromaClient instance.
|
|
@@ -2625,16 +1997,10 @@ var ChromaClient = class {
|
|
|
2625
1997
|
constructor({
|
|
2626
1998
|
path,
|
|
2627
1999
|
fetchOptions,
|
|
2628
|
-
auth
|
|
2629
|
-
tenant = DEFAULT_TENANT2,
|
|
2630
|
-
database = DEFAULT_DATABASE2
|
|
2000
|
+
auth
|
|
2631
2001
|
} = {}) {
|
|
2632
|
-
this.tenant = DEFAULT_TENANT2;
|
|
2633
|
-
this.database = DEFAULT_DATABASE2;
|
|
2634
2002
|
if (path === void 0)
|
|
2635
2003
|
path = "http://localhost:8000";
|
|
2636
|
-
this.tenant = tenant;
|
|
2637
|
-
this.database = database;
|
|
2638
2004
|
const apiConfig = new Configuration({
|
|
2639
2005
|
basePath: path
|
|
2640
2006
|
});
|
|
@@ -2644,13 +2010,6 @@ var ChromaClient = class {
|
|
|
2644
2010
|
} else {
|
|
2645
2011
|
this.api = new ApiApi(apiConfig);
|
|
2646
2012
|
}
|
|
2647
|
-
this._adminClient = new AdminClient({
|
|
2648
|
-
path,
|
|
2649
|
-
fetchOptions,
|
|
2650
|
-
auth,
|
|
2651
|
-
tenant,
|
|
2652
|
-
database
|
|
2653
|
-
});
|
|
2654
2013
|
this.api.options = fetchOptions != null ? fetchOptions : {};
|
|
2655
2014
|
}
|
|
2656
2015
|
/**
|
|
@@ -2720,7 +2079,10 @@ var ChromaClient = class {
|
|
|
2720
2079
|
metadata,
|
|
2721
2080
|
embeddingFunction
|
|
2722
2081
|
}) {
|
|
2723
|
-
|
|
2082
|
+
if (embeddingFunction === void 0) {
|
|
2083
|
+
embeddingFunction = new TransformersEmbeddingFunction();
|
|
2084
|
+
}
|
|
2085
|
+
const newCollection = await this.api.createCollection({
|
|
2724
2086
|
name,
|
|
2725
2087
|
metadata
|
|
2726
2088
|
}, this.api.options).then(handleSuccess).catch(handleError);
|
|
@@ -2755,7 +2117,10 @@ var ChromaClient = class {
|
|
|
2755
2117
|
metadata,
|
|
2756
2118
|
embeddingFunction
|
|
2757
2119
|
}) {
|
|
2758
|
-
|
|
2120
|
+
if (embeddingFunction === void 0) {
|
|
2121
|
+
embeddingFunction = new TransformersEmbeddingFunction();
|
|
2122
|
+
}
|
|
2123
|
+
const newCollection = await this.api.createCollection({
|
|
2759
2124
|
name,
|
|
2760
2125
|
metadata,
|
|
2761
2126
|
"get_or_create": true
|
|
@@ -2775,44 +2140,15 @@ var ChromaClient = class {
|
|
|
2775
2140
|
* Lists all collections.
|
|
2776
2141
|
*
|
|
2777
2142
|
* @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
2143
|
* @throws {Error} If there is an issue listing the collections.
|
|
2781
2144
|
*
|
|
2782
2145
|
* @example
|
|
2783
2146
|
* ```typescript
|
|
2784
|
-
* const collections = await client.listCollections(
|
|
2785
|
-
* limit: 10,
|
|
2786
|
-
* offset: 0,
|
|
2787
|
-
* });
|
|
2147
|
+
* const collections = await client.listCollections();
|
|
2788
2148
|
* ```
|
|
2789
2149
|
*/
|
|
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);
|
|
2150
|
+
async listCollections() {
|
|
2151
|
+
const response = await this.api.listCollections(this.api.options);
|
|
2816
2152
|
return handleSuccess(response);
|
|
2817
2153
|
}
|
|
2818
2154
|
/**
|
|
@@ -2834,7 +2170,7 @@ var ChromaClient = class {
|
|
|
2834
2170
|
name,
|
|
2835
2171
|
embeddingFunction
|
|
2836
2172
|
}) {
|
|
2837
|
-
const response = await this.api.getCollection(name, this.
|
|
2173
|
+
const response = await this.api.getCollection(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2838
2174
|
if (response.error) {
|
|
2839
2175
|
throw new Error(response.error);
|
|
2840
2176
|
}
|
|
@@ -2863,33 +2199,7 @@ var ChromaClient = class {
|
|
|
2863
2199
|
async deleteCollection({
|
|
2864
2200
|
name
|
|
2865
2201
|
}) {
|
|
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();
|
|
2202
|
+
return await this.api.deleteCollection(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2893
2203
|
}
|
|
2894
2204
|
};
|
|
2895
2205
|
|
|
@@ -3033,55 +2343,6 @@ var CohereEmbeddingFunction = class _CohereEmbeddingFunction {
|
|
|
3033
2343
|
}
|
|
3034
2344
|
};
|
|
3035
2345
|
|
|
3036
|
-
// src/embeddings/GoogleGeminiEmbeddingFunction.ts
|
|
3037
|
-
var googleGenAiApi;
|
|
3038
|
-
var GoogleGenerativeAiEmbeddingFunction = class _GoogleGenerativeAiEmbeddingFunction {
|
|
3039
|
-
constructor({ googleApiKey, model, taskType }) {
|
|
3040
|
-
this.api_key = googleApiKey;
|
|
3041
|
-
this.model = model || "embedding-001";
|
|
3042
|
-
this.taskType = taskType || "RETRIEVAL_DOCUMENT";
|
|
3043
|
-
}
|
|
3044
|
-
async loadClient() {
|
|
3045
|
-
if (this.googleGenAiApi)
|
|
3046
|
-
return;
|
|
3047
|
-
try {
|
|
3048
|
-
const { googleGenAi } = await _GoogleGenerativeAiEmbeddingFunction.import();
|
|
3049
|
-
googleGenAiApi = googleGenAi;
|
|
3050
|
-
googleGenAiApi = new googleGenAiApi(this.api_key);
|
|
3051
|
-
} catch (_a) {
|
|
3052
|
-
if (_a.code === "MODULE_NOT_FOUND") {
|
|
3053
|
-
throw new Error("Please install the @google/generative-ai package to use the GoogleGenerativeAiEmbeddingFunction, `npm install -S @google/generative-ai`");
|
|
3054
|
-
}
|
|
3055
|
-
throw _a;
|
|
3056
|
-
}
|
|
3057
|
-
this.googleGenAiApi = googleGenAiApi;
|
|
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;
|
|
3070
|
-
}
|
|
3071
|
-
/** @ignore */
|
|
3072
|
-
static async import() {
|
|
3073
|
-
try {
|
|
3074
|
-
const { GoogleGenerativeAI } = await import("@google/generative-ai");
|
|
3075
|
-
const googleGenAi = GoogleGenerativeAI;
|
|
3076
|
-
return { googleGenAi };
|
|
3077
|
-
} catch (e) {
|
|
3078
|
-
throw new Error(
|
|
3079
|
-
"Please install @google/generative-ai as a dependency with, e.g. `yarn add @google/generative-ai`"
|
|
3080
|
-
);
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
};
|
|
3084
|
-
|
|
3085
2346
|
// src/types.ts
|
|
3086
2347
|
var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
3087
2348
|
IncludeEnum2["Documents"] = "documents";
|
|
@@ -3090,76 +2351,13 @@ var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
|
3090
2351
|
IncludeEnum2["Distances"] = "distances";
|
|
3091
2352
|
return IncludeEnum2;
|
|
3092
2353
|
})(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
2354
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3153
2355
|
0 && (module.exports = {
|
|
3154
|
-
AdminClient,
|
|
3155
2356
|
ChromaClient,
|
|
3156
|
-
CloudClient,
|
|
3157
2357
|
CohereEmbeddingFunction,
|
|
3158
2358
|
Collection,
|
|
3159
|
-
GoogleGenerativeAiEmbeddingFunction,
|
|
3160
|
-
HuggingFaceEmbeddingServerFunction,
|
|
3161
2359
|
IncludeEnum,
|
|
3162
|
-
|
|
3163
|
-
|
|
2360
|
+
OpenAIEmbeddingFunction,
|
|
2361
|
+
TransformersEmbeddingFunction
|
|
3164
2362
|
});
|
|
3165
2363
|
//# sourceMappingURL=chromadb.cjs.map
|