chromadb 1.6.1 → 1.7.1-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 +460 -182
- package/dist/chromadb.legacy-esm.js +794 -33
- package/dist/chromadb.mjs +794 -33
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +796 -33
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +460 -182
- package/package.json +2 -2
- package/src/AdminClient.ts +272 -0
- package/src/ChromaClient.ts +66 -30
- package/src/Collection.ts +17 -58
- package/src/embeddings/HuggingFaceEmbeddingServerFunction.ts +31 -0
- package/src/generated/api.ts +563 -45
- package/src/generated/configuration.ts +5 -5
- package/src/generated/index.ts +2 -2
- package/src/generated/models.ts +79 -35
- package/src/generated/runtime.ts +5 -5
- package/src/index.ts +33 -1
- package/src/types.ts +75 -0
- package/src/utils.ts +17 -3
|
@@ -180,13 +180,47 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
180
180
|
options: localVarRequestOptions
|
|
181
181
|
};
|
|
182
182
|
},
|
|
183
|
+
/**
|
|
184
|
+
* @summary Count Collections
|
|
185
|
+
* @param {string} [tenant]
|
|
186
|
+
* @param {string} [database]
|
|
187
|
+
* @param {RequestInit} [options] Override http request option.
|
|
188
|
+
* @throws {RequiredError}
|
|
189
|
+
*/
|
|
190
|
+
countCollections(tenant, database, options = {}) {
|
|
191
|
+
let localVarPath = `/api/v1/count_collections`;
|
|
192
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
193
|
+
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
194
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
195
|
+
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
196
|
+
if (localVarPathQueryStart !== -1) {
|
|
197
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
198
|
+
}
|
|
199
|
+
if (tenant !== void 0) {
|
|
200
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
201
|
+
}
|
|
202
|
+
if (database !== void 0) {
|
|
203
|
+
localVarQueryParameter.append("database", String(database));
|
|
204
|
+
}
|
|
205
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
206
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
207
|
+
if (localVarQueryParameterString) {
|
|
208
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
url: localVarPath,
|
|
212
|
+
options: localVarRequestOptions
|
|
213
|
+
};
|
|
214
|
+
},
|
|
183
215
|
/**
|
|
184
216
|
* @summary Create Collection
|
|
217
|
+
* @param {string} [tenant]
|
|
218
|
+
* @param {string} [database]
|
|
185
219
|
* @param {Api.CreateCollection} request
|
|
186
220
|
* @param {RequestInit} [options] Override http request option.
|
|
187
221
|
* @throws {RequiredError}
|
|
188
222
|
*/
|
|
189
|
-
createCollection(request, options = {}) {
|
|
223
|
+
createCollection(tenant, database, request, options = {}) {
|
|
190
224
|
if (request === null || request === void 0) {
|
|
191
225
|
throw new RequiredError("request", "Required parameter request was null or undefined when calling createCollection.");
|
|
192
226
|
}
|
|
@@ -198,6 +232,80 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
198
232
|
if (localVarPathQueryStart !== -1) {
|
|
199
233
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
200
234
|
}
|
|
235
|
+
if (tenant !== void 0) {
|
|
236
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
237
|
+
}
|
|
238
|
+
if (database !== void 0) {
|
|
239
|
+
localVarQueryParameter.append("database", String(database));
|
|
240
|
+
}
|
|
241
|
+
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
242
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
243
|
+
if (request !== void 0) {
|
|
244
|
+
localVarRequestOptions.body = JSON.stringify(request || {});
|
|
245
|
+
}
|
|
246
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
247
|
+
if (localVarQueryParameterString) {
|
|
248
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
url: localVarPath,
|
|
252
|
+
options: localVarRequestOptions
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* @summary Create Database
|
|
257
|
+
* @param {string} [tenant]
|
|
258
|
+
* @param {Api.CreateDatabase} request
|
|
259
|
+
* @param {RequestInit} [options] Override http request option.
|
|
260
|
+
* @throws {RequiredError}
|
|
261
|
+
*/
|
|
262
|
+
createDatabase(tenant, request, options = {}) {
|
|
263
|
+
if (request === null || request === void 0) {
|
|
264
|
+
throw new RequiredError("request", "Required parameter request was null or undefined when calling createDatabase.");
|
|
265
|
+
}
|
|
266
|
+
let localVarPath = `/api/v1/databases`;
|
|
267
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
268
|
+
const localVarRequestOptions = Object.assign({ method: "POST" }, options);
|
|
269
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
270
|
+
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
271
|
+
if (localVarPathQueryStart !== -1) {
|
|
272
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
273
|
+
}
|
|
274
|
+
if (tenant !== void 0) {
|
|
275
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
276
|
+
}
|
|
277
|
+
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
278
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
279
|
+
if (request !== void 0) {
|
|
280
|
+
localVarRequestOptions.body = JSON.stringify(request || {});
|
|
281
|
+
}
|
|
282
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
283
|
+
if (localVarQueryParameterString) {
|
|
284
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
url: localVarPath,
|
|
288
|
+
options: localVarRequestOptions
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
/**
|
|
292
|
+
* @summary Create Tenant
|
|
293
|
+
* @param {Api.CreateTenant} request
|
|
294
|
+
* @param {RequestInit} [options] Override http request option.
|
|
295
|
+
* @throws {RequiredError}
|
|
296
|
+
*/
|
|
297
|
+
createTenant(request, options = {}) {
|
|
298
|
+
if (request === null || request === void 0) {
|
|
299
|
+
throw new RequiredError("request", "Required parameter request was null or undefined when calling createTenant.");
|
|
300
|
+
}
|
|
301
|
+
let localVarPath = `/api/v1/tenants`;
|
|
302
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
303
|
+
const localVarRequestOptions = Object.assign({ method: "POST" }, options);
|
|
304
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
305
|
+
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
306
|
+
if (localVarPathQueryStart !== -1) {
|
|
307
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
308
|
+
}
|
|
201
309
|
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
202
310
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
203
311
|
if (request !== void 0) {
|
|
@@ -215,10 +323,12 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
215
323
|
/**
|
|
216
324
|
* @summary Delete Collection
|
|
217
325
|
* @param {string} collectionName
|
|
326
|
+
* @param {string} [tenant]
|
|
327
|
+
* @param {string} [database]
|
|
218
328
|
* @param {RequestInit} [options] Override http request option.
|
|
219
329
|
* @throws {RequiredError}
|
|
220
330
|
*/
|
|
221
|
-
deleteCollection(collectionName, options = {}) {
|
|
331
|
+
deleteCollection(collectionName, tenant, database, options = {}) {
|
|
222
332
|
if (collectionName === null || collectionName === void 0) {
|
|
223
333
|
throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling deleteCollection.");
|
|
224
334
|
}
|
|
@@ -230,6 +340,12 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
230
340
|
if (localVarPathQueryStart !== -1) {
|
|
231
341
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
232
342
|
}
|
|
343
|
+
if (tenant !== void 0) {
|
|
344
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
345
|
+
}
|
|
346
|
+
if (database !== void 0) {
|
|
347
|
+
localVarQueryParameter.append("database", String(database));
|
|
348
|
+
}
|
|
233
349
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
234
350
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
235
351
|
if (localVarQueryParameterString) {
|
|
@@ -243,10 +359,12 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
243
359
|
/**
|
|
244
360
|
* @summary Get Collection
|
|
245
361
|
* @param {string} collectionName
|
|
362
|
+
* @param {string} [tenant]
|
|
363
|
+
* @param {string} [database]
|
|
246
364
|
* @param {RequestInit} [options] Override http request option.
|
|
247
365
|
* @throws {RequiredError}
|
|
248
366
|
*/
|
|
249
|
-
getCollection(collectionName, options = {}) {
|
|
367
|
+
getCollection(collectionName, tenant, database, options = {}) {
|
|
250
368
|
if (collectionName === null || collectionName === void 0) {
|
|
251
369
|
throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling getCollection.");
|
|
252
370
|
}
|
|
@@ -258,6 +376,44 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
258
376
|
if (localVarPathQueryStart !== -1) {
|
|
259
377
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
260
378
|
}
|
|
379
|
+
if (tenant !== void 0) {
|
|
380
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
381
|
+
}
|
|
382
|
+
if (database !== void 0) {
|
|
383
|
+
localVarQueryParameter.append("database", String(database));
|
|
384
|
+
}
|
|
385
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
386
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
387
|
+
if (localVarQueryParameterString) {
|
|
388
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
url: localVarPath,
|
|
392
|
+
options: localVarRequestOptions
|
|
393
|
+
};
|
|
394
|
+
},
|
|
395
|
+
/**
|
|
396
|
+
* @summary Get Database
|
|
397
|
+
* @param {string} database
|
|
398
|
+
* @param {string} [tenant]
|
|
399
|
+
* @param {RequestInit} [options] Override http request option.
|
|
400
|
+
* @throws {RequiredError}
|
|
401
|
+
*/
|
|
402
|
+
getDatabase(database, tenant, options = {}) {
|
|
403
|
+
if (database === null || database === void 0) {
|
|
404
|
+
throw new RequiredError("database", "Required parameter database was null or undefined when calling getDatabase.");
|
|
405
|
+
}
|
|
406
|
+
let localVarPath = `/api/v1/databases/{database}`.replace("{database}", encodeURIComponent(String(database)));
|
|
407
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
408
|
+
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
409
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
410
|
+
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
411
|
+
if (localVarPathQueryStart !== -1) {
|
|
412
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
413
|
+
}
|
|
414
|
+
if (tenant !== void 0) {
|
|
415
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
416
|
+
}
|
|
261
417
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
262
418
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
263
419
|
if (localVarQueryParameterString) {
|
|
@@ -304,6 +460,34 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
304
460
|
options: localVarRequestOptions
|
|
305
461
|
};
|
|
306
462
|
},
|
|
463
|
+
/**
|
|
464
|
+
* @summary Get Tenant
|
|
465
|
+
* @param {string} tenant
|
|
466
|
+
* @param {RequestInit} [options] Override http request option.
|
|
467
|
+
* @throws {RequiredError}
|
|
468
|
+
*/
|
|
469
|
+
getTenant(tenant, options = {}) {
|
|
470
|
+
if (tenant === null || tenant === void 0) {
|
|
471
|
+
throw new RequiredError("tenant", "Required parameter tenant was null or undefined when calling getTenant.");
|
|
472
|
+
}
|
|
473
|
+
let localVarPath = `/api/v1/tenants/{tenant}`.replace("{tenant}", encodeURIComponent(String(tenant)));
|
|
474
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
475
|
+
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
476
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
477
|
+
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
478
|
+
if (localVarPathQueryStart !== -1) {
|
|
479
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
480
|
+
}
|
|
481
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
482
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
483
|
+
if (localVarQueryParameterString) {
|
|
484
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
url: localVarPath,
|
|
488
|
+
options: localVarRequestOptions
|
|
489
|
+
};
|
|
490
|
+
},
|
|
307
491
|
/**
|
|
308
492
|
* @summary Heartbeat
|
|
309
493
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -330,10 +514,14 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
330
514
|
},
|
|
331
515
|
/**
|
|
332
516
|
* @summary List Collections
|
|
517
|
+
* @param {string} [tenant]
|
|
518
|
+
* @param {string} [database]
|
|
519
|
+
* @param {number} [limit]
|
|
520
|
+
* @param {number} [offset]
|
|
333
521
|
* @param {RequestInit} [options] Override http request option.
|
|
334
522
|
* @throws {RequiredError}
|
|
335
523
|
*/
|
|
336
|
-
listCollections(options = {}) {
|
|
524
|
+
listCollections(tenant, database, limit, offset, options = {}) {
|
|
337
525
|
let localVarPath = `/api/v1/collections`;
|
|
338
526
|
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
339
527
|
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
@@ -342,6 +530,42 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
342
530
|
if (localVarPathQueryStart !== -1) {
|
|
343
531
|
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
344
532
|
}
|
|
533
|
+
if (tenant !== void 0) {
|
|
534
|
+
localVarQueryParameter.append("tenant", String(tenant));
|
|
535
|
+
}
|
|
536
|
+
if (database !== void 0) {
|
|
537
|
+
localVarQueryParameter.append("database", String(database));
|
|
538
|
+
}
|
|
539
|
+
if (limit !== void 0) {
|
|
540
|
+
localVarQueryParameter.append("limit", String(limit));
|
|
541
|
+
}
|
|
542
|
+
if (offset !== void 0) {
|
|
543
|
+
localVarQueryParameter.append("offset", String(offset));
|
|
544
|
+
}
|
|
545
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
546
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
547
|
+
if (localVarQueryParameterString) {
|
|
548
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
url: localVarPath,
|
|
552
|
+
options: localVarRequestOptions
|
|
553
|
+
};
|
|
554
|
+
},
|
|
555
|
+
/**
|
|
556
|
+
* @summary Pre Flight Checks
|
|
557
|
+
* @param {RequestInit} [options] Override http request option.
|
|
558
|
+
* @throws {RequiredError}
|
|
559
|
+
*/
|
|
560
|
+
preFlightChecks(options = {}) {
|
|
561
|
+
let localVarPath = `/api/v1/pre-flight-checks`;
|
|
562
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
563
|
+
const localVarRequestOptions = Object.assign({ method: "GET" }, options);
|
|
564
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
565
|
+
const localVarQueryParameter = new URLSearchParams(localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : "");
|
|
566
|
+
if (localVarPathQueryStart !== -1) {
|
|
567
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
568
|
+
}
|
|
345
569
|
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
346
570
|
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
347
571
|
if (localVarQueryParameterString) {
|
|
@@ -651,14 +875,102 @@ var ApiApiFp = function(configuration) {
|
|
|
651
875
|
});
|
|
652
876
|
};
|
|
653
877
|
},
|
|
878
|
+
/**
|
|
879
|
+
* @summary Count Collections
|
|
880
|
+
* @param {string} [tenant]
|
|
881
|
+
* @param {string} [database]
|
|
882
|
+
* @param {RequestInit} [options] Override http request option.
|
|
883
|
+
* @throws {RequiredError}
|
|
884
|
+
*/
|
|
885
|
+
countCollections(tenant, database, options) {
|
|
886
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).countCollections(tenant, database, options);
|
|
887
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
888
|
+
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
889
|
+
const contentType = response.headers.get("Content-Type");
|
|
890
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
891
|
+
if (response.status === 200) {
|
|
892
|
+
if (mimeType === "application/json") {
|
|
893
|
+
return response.json();
|
|
894
|
+
}
|
|
895
|
+
throw response;
|
|
896
|
+
}
|
|
897
|
+
if (response.status === 422) {
|
|
898
|
+
if (mimeType === "application/json") {
|
|
899
|
+
throw response;
|
|
900
|
+
}
|
|
901
|
+
throw response;
|
|
902
|
+
}
|
|
903
|
+
throw response;
|
|
904
|
+
});
|
|
905
|
+
};
|
|
906
|
+
},
|
|
654
907
|
/**
|
|
655
908
|
* @summary Create Collection
|
|
909
|
+
* @param {string} [tenant]
|
|
910
|
+
* @param {string} [database]
|
|
656
911
|
* @param {Api.CreateCollection} request
|
|
657
912
|
* @param {RequestInit} [options] Override http request option.
|
|
658
913
|
* @throws {RequiredError}
|
|
659
914
|
*/
|
|
660
|
-
createCollection(request, options) {
|
|
661
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(request, options);
|
|
915
|
+
createCollection(tenant, database, request, options) {
|
|
916
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(tenant, database, request, options);
|
|
917
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
918
|
+
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
919
|
+
const contentType = response.headers.get("Content-Type");
|
|
920
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
921
|
+
if (response.status === 200) {
|
|
922
|
+
if (mimeType === "application/json") {
|
|
923
|
+
return response.json();
|
|
924
|
+
}
|
|
925
|
+
throw response;
|
|
926
|
+
}
|
|
927
|
+
if (response.status === 422) {
|
|
928
|
+
if (mimeType === "application/json") {
|
|
929
|
+
throw response;
|
|
930
|
+
}
|
|
931
|
+
throw response;
|
|
932
|
+
}
|
|
933
|
+
throw response;
|
|
934
|
+
});
|
|
935
|
+
};
|
|
936
|
+
},
|
|
937
|
+
/**
|
|
938
|
+
* @summary Create Database
|
|
939
|
+
* @param {string} [tenant]
|
|
940
|
+
* @param {Api.CreateDatabase} request
|
|
941
|
+
* @param {RequestInit} [options] Override http request option.
|
|
942
|
+
* @throws {RequiredError}
|
|
943
|
+
*/
|
|
944
|
+
createDatabase(tenant, request, options) {
|
|
945
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createDatabase(tenant, request, options);
|
|
946
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
947
|
+
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
948
|
+
const contentType = response.headers.get("Content-Type");
|
|
949
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
950
|
+
if (response.status === 200) {
|
|
951
|
+
if (mimeType === "application/json") {
|
|
952
|
+
return response.json();
|
|
953
|
+
}
|
|
954
|
+
throw response;
|
|
955
|
+
}
|
|
956
|
+
if (response.status === 422) {
|
|
957
|
+
if (mimeType === "application/json") {
|
|
958
|
+
throw response;
|
|
959
|
+
}
|
|
960
|
+
throw response;
|
|
961
|
+
}
|
|
962
|
+
throw response;
|
|
963
|
+
});
|
|
964
|
+
};
|
|
965
|
+
},
|
|
966
|
+
/**
|
|
967
|
+
* @summary Create Tenant
|
|
968
|
+
* @param {Api.CreateTenant} request
|
|
969
|
+
* @param {RequestInit} [options] Override http request option.
|
|
970
|
+
* @throws {RequiredError}
|
|
971
|
+
*/
|
|
972
|
+
createTenant(request, options) {
|
|
973
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createTenant(request, options);
|
|
662
974
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
663
975
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
664
976
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -682,11 +994,13 @@ var ApiApiFp = function(configuration) {
|
|
|
682
994
|
/**
|
|
683
995
|
* @summary Delete Collection
|
|
684
996
|
* @param {string} collectionName
|
|
997
|
+
* @param {string} [tenant]
|
|
998
|
+
* @param {string} [database]
|
|
685
999
|
* @param {RequestInit} [options] Override http request option.
|
|
686
1000
|
* @throws {RequiredError}
|
|
687
1001
|
*/
|
|
688
|
-
deleteCollection(collectionName, options) {
|
|
689
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, options);
|
|
1002
|
+
deleteCollection(collectionName, tenant, database, options) {
|
|
1003
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, tenant, database, options);
|
|
690
1004
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
691
1005
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
692
1006
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -710,11 +1024,42 @@ var ApiApiFp = function(configuration) {
|
|
|
710
1024
|
/**
|
|
711
1025
|
* @summary Get Collection
|
|
712
1026
|
* @param {string} collectionName
|
|
1027
|
+
* @param {string} [tenant]
|
|
1028
|
+
* @param {string} [database]
|
|
1029
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1030
|
+
* @throws {RequiredError}
|
|
1031
|
+
*/
|
|
1032
|
+
getCollection(collectionName, tenant, database, options) {
|
|
1033
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName, tenant, database, options);
|
|
1034
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1035
|
+
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1036
|
+
const contentType = response.headers.get("Content-Type");
|
|
1037
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
1038
|
+
if (response.status === 200) {
|
|
1039
|
+
if (mimeType === "application/json") {
|
|
1040
|
+
return response.json();
|
|
1041
|
+
}
|
|
1042
|
+
throw response;
|
|
1043
|
+
}
|
|
1044
|
+
if (response.status === 422) {
|
|
1045
|
+
if (mimeType === "application/json") {
|
|
1046
|
+
throw response;
|
|
1047
|
+
}
|
|
1048
|
+
throw response;
|
|
1049
|
+
}
|
|
1050
|
+
throw response;
|
|
1051
|
+
});
|
|
1052
|
+
};
|
|
1053
|
+
},
|
|
1054
|
+
/**
|
|
1055
|
+
* @summary Get Database
|
|
1056
|
+
* @param {string} database
|
|
1057
|
+
* @param {string} [tenant]
|
|
713
1058
|
* @param {RequestInit} [options] Override http request option.
|
|
714
1059
|
* @throws {RequiredError}
|
|
715
1060
|
*/
|
|
716
|
-
|
|
717
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).
|
|
1061
|
+
getDatabase(database, tenant, options) {
|
|
1062
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getDatabase(database, tenant, options);
|
|
718
1063
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
719
1064
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
720
1065
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -764,6 +1109,34 @@ var ApiApiFp = function(configuration) {
|
|
|
764
1109
|
});
|
|
765
1110
|
};
|
|
766
1111
|
},
|
|
1112
|
+
/**
|
|
1113
|
+
* @summary Get Tenant
|
|
1114
|
+
* @param {string} tenant
|
|
1115
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1116
|
+
* @throws {RequiredError}
|
|
1117
|
+
*/
|
|
1118
|
+
getTenant(tenant, options) {
|
|
1119
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getTenant(tenant, options);
|
|
1120
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1121
|
+
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1122
|
+
const contentType = response.headers.get("Content-Type");
|
|
1123
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
1124
|
+
if (response.status === 200) {
|
|
1125
|
+
if (mimeType === "application/json") {
|
|
1126
|
+
return response.json();
|
|
1127
|
+
}
|
|
1128
|
+
throw response;
|
|
1129
|
+
}
|
|
1130
|
+
if (response.status === 422) {
|
|
1131
|
+
if (mimeType === "application/json") {
|
|
1132
|
+
throw response;
|
|
1133
|
+
}
|
|
1134
|
+
throw response;
|
|
1135
|
+
}
|
|
1136
|
+
throw response;
|
|
1137
|
+
});
|
|
1138
|
+
};
|
|
1139
|
+
},
|
|
767
1140
|
/**
|
|
768
1141
|
* @summary Heartbeat
|
|
769
1142
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -787,11 +1160,42 @@ var ApiApiFp = function(configuration) {
|
|
|
787
1160
|
},
|
|
788
1161
|
/**
|
|
789
1162
|
* @summary List Collections
|
|
1163
|
+
* @param {string} [tenant]
|
|
1164
|
+
* @param {string} [database]
|
|
1165
|
+
* @param {number} [limit]
|
|
1166
|
+
* @param {number} [offset]
|
|
1167
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1168
|
+
* @throws {RequiredError}
|
|
1169
|
+
*/
|
|
1170
|
+
listCollections(tenant, database, limit, offset, options) {
|
|
1171
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(tenant, database, limit, offset, options);
|
|
1172
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
1173
|
+
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
1174
|
+
const contentType = response.headers.get("Content-Type");
|
|
1175
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
1176
|
+
if (response.status === 200) {
|
|
1177
|
+
if (mimeType === "application/json") {
|
|
1178
|
+
return response.json();
|
|
1179
|
+
}
|
|
1180
|
+
throw response;
|
|
1181
|
+
}
|
|
1182
|
+
if (response.status === 422) {
|
|
1183
|
+
if (mimeType === "application/json") {
|
|
1184
|
+
throw response;
|
|
1185
|
+
}
|
|
1186
|
+
throw response;
|
|
1187
|
+
}
|
|
1188
|
+
throw response;
|
|
1189
|
+
});
|
|
1190
|
+
};
|
|
1191
|
+
},
|
|
1192
|
+
/**
|
|
1193
|
+
* @summary Pre Flight Checks
|
|
790
1194
|
* @param {RequestInit} [options] Override http request option.
|
|
791
1195
|
* @throws {RequiredError}
|
|
792
1196
|
*/
|
|
793
|
-
|
|
794
|
-
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).
|
|
1197
|
+
preFlightChecks(options) {
|
|
1198
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(configuration).preFlightChecks(options);
|
|
795
1199
|
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
796
1200
|
return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
|
797
1201
|
const contentType = response.headers.get("Content-Type");
|
|
@@ -998,32 +1402,77 @@ var ApiApi = class extends BaseAPI {
|
|
|
998
1402
|
count(collectionId, options) {
|
|
999
1403
|
return ApiApiFp(this.configuration).count(collectionId, options)(this.fetch, this.basePath);
|
|
1000
1404
|
}
|
|
1405
|
+
/**
|
|
1406
|
+
* @summary Count Collections
|
|
1407
|
+
* @param {string} [tenant]
|
|
1408
|
+
* @param {string} [database]
|
|
1409
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1410
|
+
* @throws {RequiredError}
|
|
1411
|
+
*/
|
|
1412
|
+
countCollections(tenant, database, options) {
|
|
1413
|
+
return ApiApiFp(this.configuration).countCollections(tenant, database, options)(this.fetch, this.basePath);
|
|
1414
|
+
}
|
|
1001
1415
|
/**
|
|
1002
1416
|
* @summary Create Collection
|
|
1417
|
+
* @param {string} [tenant]
|
|
1418
|
+
* @param {string} [database]
|
|
1003
1419
|
* @param {Api.CreateCollection} request
|
|
1004
1420
|
* @param {RequestInit} [options] Override http request option.
|
|
1005
1421
|
* @throws {RequiredError}
|
|
1006
1422
|
*/
|
|
1007
|
-
createCollection(request, options) {
|
|
1008
|
-
return ApiApiFp(this.configuration).createCollection(request, options)(this.fetch, this.basePath);
|
|
1423
|
+
createCollection(tenant, database, request, options) {
|
|
1424
|
+
return ApiApiFp(this.configuration).createCollection(tenant, database, request, options)(this.fetch, this.basePath);
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* @summary Create Database
|
|
1428
|
+
* @param {string} [tenant]
|
|
1429
|
+
* @param {Api.CreateDatabase} request
|
|
1430
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1431
|
+
* @throws {RequiredError}
|
|
1432
|
+
*/
|
|
1433
|
+
createDatabase(tenant, request, options) {
|
|
1434
|
+
return ApiApiFp(this.configuration).createDatabase(tenant, request, options)(this.fetch, this.basePath);
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* @summary Create Tenant
|
|
1438
|
+
* @param {Api.CreateTenant} request
|
|
1439
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1440
|
+
* @throws {RequiredError}
|
|
1441
|
+
*/
|
|
1442
|
+
createTenant(request, options) {
|
|
1443
|
+
return ApiApiFp(this.configuration).createTenant(request, options)(this.fetch, this.basePath);
|
|
1009
1444
|
}
|
|
1010
1445
|
/**
|
|
1011
1446
|
* @summary Delete Collection
|
|
1012
1447
|
* @param {string} collectionName
|
|
1448
|
+
* @param {string} [tenant]
|
|
1449
|
+
* @param {string} [database]
|
|
1013
1450
|
* @param {RequestInit} [options] Override http request option.
|
|
1014
1451
|
* @throws {RequiredError}
|
|
1015
1452
|
*/
|
|
1016
|
-
deleteCollection(collectionName, options) {
|
|
1017
|
-
return ApiApiFp(this.configuration).deleteCollection(collectionName, options)(this.fetch, this.basePath);
|
|
1453
|
+
deleteCollection(collectionName, tenant, database, options) {
|
|
1454
|
+
return ApiApiFp(this.configuration).deleteCollection(collectionName, tenant, database, options)(this.fetch, this.basePath);
|
|
1018
1455
|
}
|
|
1019
1456
|
/**
|
|
1020
1457
|
* @summary Get Collection
|
|
1021
1458
|
* @param {string} collectionName
|
|
1459
|
+
* @param {string} [tenant]
|
|
1460
|
+
* @param {string} [database]
|
|
1461
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1462
|
+
* @throws {RequiredError}
|
|
1463
|
+
*/
|
|
1464
|
+
getCollection(collectionName, tenant, database, options) {
|
|
1465
|
+
return ApiApiFp(this.configuration).getCollection(collectionName, tenant, database, options)(this.fetch, this.basePath);
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* @summary Get Database
|
|
1469
|
+
* @param {string} database
|
|
1470
|
+
* @param {string} [tenant]
|
|
1022
1471
|
* @param {RequestInit} [options] Override http request option.
|
|
1023
1472
|
* @throws {RequiredError}
|
|
1024
1473
|
*/
|
|
1025
|
-
|
|
1026
|
-
return ApiApiFp(this.configuration).
|
|
1474
|
+
getDatabase(database, tenant, options) {
|
|
1475
|
+
return ApiApiFp(this.configuration).getDatabase(database, tenant, options)(this.fetch, this.basePath);
|
|
1027
1476
|
}
|
|
1028
1477
|
/**
|
|
1029
1478
|
* @summary Get Nearest Neighbors
|
|
@@ -1035,6 +1484,15 @@ var ApiApi = class extends BaseAPI {
|
|
|
1035
1484
|
getNearestNeighbors(collectionId, request, options) {
|
|
1036
1485
|
return ApiApiFp(this.configuration).getNearestNeighbors(collectionId, request, options)(this.fetch, this.basePath);
|
|
1037
1486
|
}
|
|
1487
|
+
/**
|
|
1488
|
+
* @summary Get Tenant
|
|
1489
|
+
* @param {string} tenant
|
|
1490
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1491
|
+
* @throws {RequiredError}
|
|
1492
|
+
*/
|
|
1493
|
+
getTenant(tenant, options) {
|
|
1494
|
+
return ApiApiFp(this.configuration).getTenant(tenant, options)(this.fetch, this.basePath);
|
|
1495
|
+
}
|
|
1038
1496
|
/**
|
|
1039
1497
|
* @summary Heartbeat
|
|
1040
1498
|
* @param {RequestInit} [options] Override http request option.
|
|
@@ -1045,11 +1503,23 @@ var ApiApi = class extends BaseAPI {
|
|
|
1045
1503
|
}
|
|
1046
1504
|
/**
|
|
1047
1505
|
* @summary List Collections
|
|
1506
|
+
* @param {string} [tenant]
|
|
1507
|
+
* @param {string} [database]
|
|
1508
|
+
* @param {number} [limit]
|
|
1509
|
+
* @param {number} [offset]
|
|
1048
1510
|
* @param {RequestInit} [options] Override http request option.
|
|
1049
1511
|
* @throws {RequiredError}
|
|
1050
1512
|
*/
|
|
1051
|
-
listCollections(options) {
|
|
1052
|
-
return ApiApiFp(this.configuration).listCollections(options)(this.fetch, this.basePath);
|
|
1513
|
+
listCollections(tenant, database, limit, offset, options) {
|
|
1514
|
+
return ApiApiFp(this.configuration).listCollections(tenant, database, limit, offset, options)(this.fetch, this.basePath);
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* @summary Pre Flight Checks
|
|
1518
|
+
* @param {RequestInit} [options] Override http request option.
|
|
1519
|
+
* @throws {RequiredError}
|
|
1520
|
+
*/
|
|
1521
|
+
preFlightChecks(options) {
|
|
1522
|
+
return ApiApiFp(this.configuration).preFlightChecks(options)(this.fetch, this.basePath);
|
|
1053
1523
|
}
|
|
1054
1524
|
/**
|
|
1055
1525
|
* @summary Reset
|
|
@@ -1115,8 +1585,8 @@ var Api;
|
|
|
1115
1585
|
let Include;
|
|
1116
1586
|
((Include2) => {
|
|
1117
1587
|
let EnumValueEnum;
|
|
1118
|
-
((
|
|
1119
|
-
|
|
1588
|
+
((EnumValueEnum7) => {
|
|
1589
|
+
EnumValueEnum7["Documents"] = "documents";
|
|
1120
1590
|
})(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
|
|
1121
1591
|
let EnumValueEnum2;
|
|
1122
1592
|
((EnumValueEnum22) => {
|
|
@@ -1130,6 +1600,14 @@ var Api;
|
|
|
1130
1600
|
((EnumValueEnum42) => {
|
|
1131
1601
|
EnumValueEnum42["Distances"] = "distances";
|
|
1132
1602
|
})(EnumValueEnum4 = Include2.EnumValueEnum4 || (Include2.EnumValueEnum4 = {}));
|
|
1603
|
+
let EnumValueEnum5;
|
|
1604
|
+
((EnumValueEnum52) => {
|
|
1605
|
+
EnumValueEnum52["Uris"] = "uris";
|
|
1606
|
+
})(EnumValueEnum5 = Include2.EnumValueEnum5 || (Include2.EnumValueEnum5 = {}));
|
|
1607
|
+
let EnumValueEnum6;
|
|
1608
|
+
((EnumValueEnum62) => {
|
|
1609
|
+
EnumValueEnum62["Data"] = "data";
|
|
1610
|
+
})(EnumValueEnum6 = Include2.EnumValueEnum6 || (Include2.EnumValueEnum6 = {}));
|
|
1133
1611
|
})(Include = GetEmbedding2.Include || (GetEmbedding2.Include = {}));
|
|
1134
1612
|
})(GetEmbedding = Api2.GetEmbedding || (Api2.GetEmbedding = {}));
|
|
1135
1613
|
let QueryEmbedding;
|
|
@@ -1137,8 +1615,8 @@ var Api;
|
|
|
1137
1615
|
let Include;
|
|
1138
1616
|
((Include2) => {
|
|
1139
1617
|
let EnumValueEnum;
|
|
1140
|
-
((
|
|
1141
|
-
|
|
1618
|
+
((EnumValueEnum7) => {
|
|
1619
|
+
EnumValueEnum7["Documents"] = "documents";
|
|
1142
1620
|
})(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
|
|
1143
1621
|
let EnumValueEnum2;
|
|
1144
1622
|
((EnumValueEnum22) => {
|
|
@@ -1152,6 +1630,14 @@ var Api;
|
|
|
1152
1630
|
((EnumValueEnum42) => {
|
|
1153
1631
|
EnumValueEnum42["Distances"] = "distances";
|
|
1154
1632
|
})(EnumValueEnum4 = Include2.EnumValueEnum4 || (Include2.EnumValueEnum4 = {}));
|
|
1633
|
+
let EnumValueEnum5;
|
|
1634
|
+
((EnumValueEnum52) => {
|
|
1635
|
+
EnumValueEnum52["Uris"] = "uris";
|
|
1636
|
+
})(EnumValueEnum5 = Include2.EnumValueEnum5 || (Include2.EnumValueEnum5 = {}));
|
|
1637
|
+
let EnumValueEnum6;
|
|
1638
|
+
((EnumValueEnum62) => {
|
|
1639
|
+
EnumValueEnum62["Data"] = "data";
|
|
1640
|
+
})(EnumValueEnum6 = Include2.EnumValueEnum6 || (Include2.EnumValueEnum6 = {}));
|
|
1155
1641
|
})(Include = QueryEmbedding2.Include || (QueryEmbedding2.Include = {}));
|
|
1156
1642
|
})(QueryEmbedding = Api2.QueryEmbedding || (Api2.QueryEmbedding = {}));
|
|
1157
1643
|
})(Api || (Api = {}));
|
|
@@ -1202,7 +1688,6 @@ async function handleError(error) {
|
|
|
1202
1688
|
}
|
|
1203
1689
|
} catch (e) {
|
|
1204
1690
|
return {
|
|
1205
|
-
//@ts-ignore
|
|
1206
1691
|
error: e && typeof e === "object" && "message" in e ? e.message : "unknown error"
|
|
1207
1692
|
};
|
|
1208
1693
|
}
|
|
@@ -1219,6 +1704,18 @@ async function handleSuccess(response) {
|
|
|
1219
1704
|
return repack(response);
|
|
1220
1705
|
}
|
|
1221
1706
|
}
|
|
1707
|
+
async function validateTenantDatabase(adminClient, tenant, database) {
|
|
1708
|
+
try {
|
|
1709
|
+
await adminClient.getTenant({ name: tenant });
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
throw new Error(`Error: ${error}, Could not connect to tenant ${tenant}. Are you sure it exists?`);
|
|
1712
|
+
}
|
|
1713
|
+
try {
|
|
1714
|
+
await adminClient.getDatabase({ name: database, tenantName: tenant });
|
|
1715
|
+
} catch (error) {
|
|
1716
|
+
throw new Error(`Error: ${error}, Could not connect to database ${database} for tenant ${tenant}. Are you sure it exists?`);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1222
1719
|
|
|
1223
1720
|
// src/Collection.ts
|
|
1224
1721
|
var Collection = class {
|
|
@@ -1869,7 +2366,206 @@ var IsomorphicFetchClientAuthProtocolAdapter = class {
|
|
|
1869
2366
|
}
|
|
1870
2367
|
};
|
|
1871
2368
|
|
|
2369
|
+
// src/AdminClient.ts
|
|
2370
|
+
var DEFAULT_TENANT = "default_tenant";
|
|
2371
|
+
var DEFAULT_DATABASE = "default_database";
|
|
2372
|
+
var AdminClient = class {
|
|
2373
|
+
/**
|
|
2374
|
+
* Creates a new AdminClient instance.
|
|
2375
|
+
* @param {Object} params - The parameters for creating a new client
|
|
2376
|
+
* @param {string} [params.path] - The base path for the Chroma API.
|
|
2377
|
+
* @returns {AdminClient} A new AdminClient instance.
|
|
2378
|
+
*
|
|
2379
|
+
* @example
|
|
2380
|
+
* ```typescript
|
|
2381
|
+
* const client = new AdminClient({
|
|
2382
|
+
* path: "http://localhost:8000"
|
|
2383
|
+
* });
|
|
2384
|
+
* ```
|
|
2385
|
+
*/
|
|
2386
|
+
constructor({
|
|
2387
|
+
path,
|
|
2388
|
+
fetchOptions,
|
|
2389
|
+
auth,
|
|
2390
|
+
tenant = DEFAULT_TENANT,
|
|
2391
|
+
database = DEFAULT_DATABASE
|
|
2392
|
+
} = {}) {
|
|
2393
|
+
this.tenant = DEFAULT_TENANT;
|
|
2394
|
+
this.database = DEFAULT_DATABASE;
|
|
2395
|
+
if (path === void 0)
|
|
2396
|
+
path = "http://localhost:8000";
|
|
2397
|
+
this.tenant = tenant;
|
|
2398
|
+
this.database = database;
|
|
2399
|
+
const apiConfig = new Configuration({
|
|
2400
|
+
basePath: path
|
|
2401
|
+
});
|
|
2402
|
+
if (auth !== void 0) {
|
|
2403
|
+
this.apiAdapter = new IsomorphicFetchClientAuthProtocolAdapter(new ApiApi(apiConfig), auth);
|
|
2404
|
+
this.api = this.apiAdapter.getApi();
|
|
2405
|
+
} else {
|
|
2406
|
+
this.api = new ApiApi(apiConfig);
|
|
2407
|
+
}
|
|
2408
|
+
this.api.options = fetchOptions != null ? fetchOptions : {};
|
|
2409
|
+
}
|
|
2410
|
+
/**
|
|
2411
|
+
* Sets the tenant and database for the client.
|
|
2412
|
+
*
|
|
2413
|
+
* @param {Object} params - The parameters for setting tenant and database.
|
|
2414
|
+
* @param {string} params.tenant - The name of the tenant.
|
|
2415
|
+
* @param {string} params.database - The name of the database.
|
|
2416
|
+
*
|
|
2417
|
+
* @returns {Promise<void>} A promise that returns nothing
|
|
2418
|
+
* @throws {Error} Any issues
|
|
2419
|
+
*
|
|
2420
|
+
* @example
|
|
2421
|
+
* ```typescript
|
|
2422
|
+
* await adminClient.setTenant({
|
|
2423
|
+
* tenant: "my_tenant",
|
|
2424
|
+
* database: "my_database",
|
|
2425
|
+
* });
|
|
2426
|
+
* ```
|
|
2427
|
+
*/
|
|
2428
|
+
async setTenant({
|
|
2429
|
+
tenant = DEFAULT_TENANT,
|
|
2430
|
+
database = DEFAULT_DATABASE
|
|
2431
|
+
}) {
|
|
2432
|
+
await validateTenantDatabase(this, tenant, database);
|
|
2433
|
+
this.tenant = tenant;
|
|
2434
|
+
this.database = database;
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* Sets the database for the client.
|
|
2438
|
+
*
|
|
2439
|
+
* @param {Object} params - The parameters for setting the database.
|
|
2440
|
+
* @param {string} params.database - The name of the database.
|
|
2441
|
+
*
|
|
2442
|
+
* @returns {Promise<void>} A promise that returns nothing
|
|
2443
|
+
* @throws {Error} Any issues
|
|
2444
|
+
*
|
|
2445
|
+
* @example
|
|
2446
|
+
* ```typescript
|
|
2447
|
+
* await adminClient.setDatabase({
|
|
2448
|
+
* database: "my_database",
|
|
2449
|
+
* });
|
|
2450
|
+
* ```
|
|
2451
|
+
*/
|
|
2452
|
+
async setDatabase({
|
|
2453
|
+
database = DEFAULT_DATABASE
|
|
2454
|
+
}) {
|
|
2455
|
+
await validateTenantDatabase(this, this.tenant, database);
|
|
2456
|
+
this.database = database;
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Creates a new tenant with the specified properties.
|
|
2460
|
+
*
|
|
2461
|
+
* @param {Object} params - The parameters for creating a new tenant.
|
|
2462
|
+
* @param {string} params.name - The name of the tenant.
|
|
2463
|
+
*
|
|
2464
|
+
* @returns {Promise<Tenant>} A promise that resolves to the created tenant.
|
|
2465
|
+
* @throws {Error} If there is an issue creating the tenant.
|
|
2466
|
+
*
|
|
2467
|
+
* @example
|
|
2468
|
+
* ```typescript
|
|
2469
|
+
* await adminClient.createTenant({
|
|
2470
|
+
* name: "my_tenant",
|
|
2471
|
+
* });
|
|
2472
|
+
* ```
|
|
2473
|
+
*/
|
|
2474
|
+
async createTenant({
|
|
2475
|
+
name
|
|
2476
|
+
}) {
|
|
2477
|
+
const newTenant = await this.api.createTenant({ name }, this.api.options).then(handleSuccess).catch(handleError);
|
|
2478
|
+
if (newTenant && newTenant.error) {
|
|
2479
|
+
throw new Error(newTenant.error);
|
|
2480
|
+
}
|
|
2481
|
+
return { name };
|
|
2482
|
+
}
|
|
2483
|
+
/**
|
|
2484
|
+
* Gets a tenant with the specified properties.
|
|
2485
|
+
*
|
|
2486
|
+
* @param {Object} params - The parameters for getting a tenant.
|
|
2487
|
+
* @param {string} params.name - The name of the tenant.
|
|
2488
|
+
*
|
|
2489
|
+
* @returns {Promise<Tenant>} A promise that resolves to the tenant.
|
|
2490
|
+
* @throws {Error} If there is an issue getting the tenant.
|
|
2491
|
+
*
|
|
2492
|
+
* @example
|
|
2493
|
+
* ```typescript
|
|
2494
|
+
* await adminClient.getTenant({
|
|
2495
|
+
* name: "my_tenant",
|
|
2496
|
+
* });
|
|
2497
|
+
* ```
|
|
2498
|
+
*/
|
|
2499
|
+
async getTenant({
|
|
2500
|
+
name
|
|
2501
|
+
}) {
|
|
2502
|
+
const getTenant = await this.api.getTenant(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2503
|
+
if (getTenant.error) {
|
|
2504
|
+
throw new Error(getTenant.error);
|
|
2505
|
+
}
|
|
2506
|
+
return { name: getTenant.name };
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Creates a new database with the specified properties.
|
|
2510
|
+
*
|
|
2511
|
+
* @param {Object} params - The parameters for creating a new database.
|
|
2512
|
+
* @param {string} params.name - The name of the database.
|
|
2513
|
+
* @param {string} params.tenantName - The name of the tenant.
|
|
2514
|
+
*
|
|
2515
|
+
* @returns {Promise<Database>} A promise that resolves to the created database.
|
|
2516
|
+
* @throws {Error} If there is an issue creating the database.
|
|
2517
|
+
*
|
|
2518
|
+
* @example
|
|
2519
|
+
* ```typescript
|
|
2520
|
+
* await adminClient.createDatabase({
|
|
2521
|
+
* name: "my_database",
|
|
2522
|
+
* tenantName: "my_tenant",
|
|
2523
|
+
* });
|
|
2524
|
+
* ```
|
|
2525
|
+
*/
|
|
2526
|
+
async createDatabase({
|
|
2527
|
+
name,
|
|
2528
|
+
tenantName
|
|
2529
|
+
}) {
|
|
2530
|
+
const newDatabase = await this.api.createDatabase(tenantName, { name }, this.api.options).then(handleSuccess).catch(handleError);
|
|
2531
|
+
if (newDatabase && newDatabase.error) {
|
|
2532
|
+
throw new Error(newDatabase.error);
|
|
2533
|
+
}
|
|
2534
|
+
return { name };
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Gets a database with the specified properties.
|
|
2538
|
+
*
|
|
2539
|
+
* @param {Object} params - The parameters for getting a database.
|
|
2540
|
+
* @param {string} params.name - The name of the database.
|
|
2541
|
+
* @param {string} params.tenantName - The name of the tenant.
|
|
2542
|
+
*
|
|
2543
|
+
* @returns {Promise<Database>} A promise that resolves to the database.
|
|
2544
|
+
* @throws {Error} If there is an issue getting the database.
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* ```typescript
|
|
2548
|
+
* await adminClient.getDatabase({
|
|
2549
|
+
* name: "my_database",
|
|
2550
|
+
* tenantName: "my_tenant",
|
|
2551
|
+
* });
|
|
2552
|
+
* ```
|
|
2553
|
+
*/
|
|
2554
|
+
async getDatabase({
|
|
2555
|
+
name,
|
|
2556
|
+
tenantName
|
|
2557
|
+
}) {
|
|
2558
|
+
const getDatabase = await this.api.getDatabase(name, tenantName, this.api.options).then(handleSuccess).catch(handleError);
|
|
2559
|
+
if (getDatabase.error) {
|
|
2560
|
+
throw new Error(getDatabase.error);
|
|
2561
|
+
}
|
|
2562
|
+
return { name: getDatabase.name };
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
|
|
1872
2566
|
// src/ChromaClient.ts
|
|
2567
|
+
var DEFAULT_TENANT2 = "default_tenant";
|
|
2568
|
+
var DEFAULT_DATABASE2 = "default_database";
|
|
1873
2569
|
var ChromaClient = class {
|
|
1874
2570
|
/**
|
|
1875
2571
|
* Creates a new ChromaClient instance.
|
|
@@ -1887,10 +2583,16 @@ var ChromaClient = class {
|
|
|
1887
2583
|
constructor({
|
|
1888
2584
|
path,
|
|
1889
2585
|
fetchOptions,
|
|
1890
|
-
auth
|
|
2586
|
+
auth,
|
|
2587
|
+
tenant = DEFAULT_TENANT2,
|
|
2588
|
+
database = DEFAULT_DATABASE2
|
|
1891
2589
|
} = {}) {
|
|
2590
|
+
this.tenant = DEFAULT_TENANT2;
|
|
2591
|
+
this.database = DEFAULT_DATABASE2;
|
|
1892
2592
|
if (path === void 0)
|
|
1893
2593
|
path = "http://localhost:8000";
|
|
2594
|
+
this.tenant = tenant;
|
|
2595
|
+
this.database = database;
|
|
1894
2596
|
const apiConfig = new Configuration({
|
|
1895
2597
|
basePath: path
|
|
1896
2598
|
});
|
|
@@ -1900,6 +2602,13 @@ var ChromaClient = class {
|
|
|
1900
2602
|
} else {
|
|
1901
2603
|
this.api = new ApiApi(apiConfig);
|
|
1902
2604
|
}
|
|
2605
|
+
this._adminClient = new AdminClient({
|
|
2606
|
+
path,
|
|
2607
|
+
fetchOptions,
|
|
2608
|
+
auth,
|
|
2609
|
+
tenant,
|
|
2610
|
+
database
|
|
2611
|
+
});
|
|
1903
2612
|
this.api.options = fetchOptions != null ? fetchOptions : {};
|
|
1904
2613
|
}
|
|
1905
2614
|
/**
|
|
@@ -1969,7 +2678,7 @@ var ChromaClient = class {
|
|
|
1969
2678
|
metadata,
|
|
1970
2679
|
embeddingFunction
|
|
1971
2680
|
}) {
|
|
1972
|
-
const newCollection = await this.api.createCollection({
|
|
2681
|
+
const newCollection = await this.api.createCollection(this.tenant, this.database, {
|
|
1973
2682
|
name,
|
|
1974
2683
|
metadata
|
|
1975
2684
|
}, this.api.options).then(handleSuccess).catch(handleError);
|
|
@@ -2004,7 +2713,7 @@ var ChromaClient = class {
|
|
|
2004
2713
|
metadata,
|
|
2005
2714
|
embeddingFunction
|
|
2006
2715
|
}) {
|
|
2007
|
-
const newCollection = await this.api.createCollection({
|
|
2716
|
+
const newCollection = await this.api.createCollection(this.tenant, this.database, {
|
|
2008
2717
|
name,
|
|
2009
2718
|
metadata,
|
|
2010
2719
|
"get_or_create": true
|
|
@@ -2024,15 +2733,44 @@ var ChromaClient = class {
|
|
|
2024
2733
|
* Lists all collections.
|
|
2025
2734
|
*
|
|
2026
2735
|
* @returns {Promise<CollectionType[]>} A promise that resolves to a list of collection names.
|
|
2736
|
+
* @param {PositiveInteger} [params.limit] - Optional limit on the number of items to get.
|
|
2737
|
+
* @param {PositiveInteger} [params.offset] - Optional offset on the items to get.
|
|
2027
2738
|
* @throws {Error} If there is an issue listing the collections.
|
|
2028
2739
|
*
|
|
2029
2740
|
* @example
|
|
2030
2741
|
* ```typescript
|
|
2031
|
-
* const collections = await client.listCollections(
|
|
2742
|
+
* const collections = await client.listCollections({
|
|
2743
|
+
* limit: 10,
|
|
2744
|
+
* offset: 0,
|
|
2745
|
+
* });
|
|
2746
|
+
* ```
|
|
2747
|
+
*/
|
|
2748
|
+
async listCollections({
|
|
2749
|
+
limit,
|
|
2750
|
+
offset
|
|
2751
|
+
} = {}) {
|
|
2752
|
+
const response = await this.api.listCollections(
|
|
2753
|
+
this.tenant,
|
|
2754
|
+
this.database,
|
|
2755
|
+
limit,
|
|
2756
|
+
offset,
|
|
2757
|
+
this.api.options
|
|
2758
|
+
);
|
|
2759
|
+
return handleSuccess(response);
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Counts all collections.
|
|
2763
|
+
*
|
|
2764
|
+
* @returns {Promise<number>} A promise that resolves to the number of collections.
|
|
2765
|
+
* @throws {Error} If there is an issue counting the collections.
|
|
2766
|
+
*
|
|
2767
|
+
* @example
|
|
2768
|
+
* ```typescript
|
|
2769
|
+
* const collections = await client.countCollections();
|
|
2032
2770
|
* ```
|
|
2033
2771
|
*/
|
|
2034
|
-
async
|
|
2035
|
-
const response = await this.api.
|
|
2772
|
+
async countCollections() {
|
|
2773
|
+
const response = await this.api.countCollections(this.tenant, this.database, this.api.options);
|
|
2036
2774
|
return handleSuccess(response);
|
|
2037
2775
|
}
|
|
2038
2776
|
/**
|
|
@@ -2054,7 +2792,7 @@ var ChromaClient = class {
|
|
|
2054
2792
|
name,
|
|
2055
2793
|
embeddingFunction
|
|
2056
2794
|
}) {
|
|
2057
|
-
const response = await this.api.getCollection(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2795
|
+
const response = await this.api.getCollection(name, this.tenant, this.database, this.api.options).then(handleSuccess).catch(handleError);
|
|
2058
2796
|
if (response.error) {
|
|
2059
2797
|
throw new Error(response.error);
|
|
2060
2798
|
}
|
|
@@ -2083,7 +2821,7 @@ var ChromaClient = class {
|
|
|
2083
2821
|
async deleteCollection({
|
|
2084
2822
|
name
|
|
2085
2823
|
}) {
|
|
2086
|
-
return await this.api.deleteCollection(name, this.api.options).then(handleSuccess).catch(handleError);
|
|
2824
|
+
return await this.api.deleteCollection(name, this.tenant, this.database, this.api.options).then(handleSuccess).catch(handleError);
|
|
2087
2825
|
}
|
|
2088
2826
|
};
|
|
2089
2827
|
|
|
@@ -2235,10 +2973,33 @@ var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
|
|
|
2235
2973
|
IncludeEnum2["Distances"] = "distances";
|
|
2236
2974
|
return IncludeEnum2;
|
|
2237
2975
|
})(IncludeEnum || {});
|
|
2976
|
+
|
|
2977
|
+
// src/embeddings/HuggingFaceEmbeddingServerFunction.ts
|
|
2978
|
+
var HuggingFaceEmbeddingServerFunction = class {
|
|
2979
|
+
constructor({ url }) {
|
|
2980
|
+
this.url = url;
|
|
2981
|
+
}
|
|
2982
|
+
async generate(texts) {
|
|
2983
|
+
const response = await fetch(this.url, {
|
|
2984
|
+
method: "POST",
|
|
2985
|
+
headers: {
|
|
2986
|
+
"Content-Type": "application/json"
|
|
2987
|
+
},
|
|
2988
|
+
body: JSON.stringify({ "inputs": texts })
|
|
2989
|
+
});
|
|
2990
|
+
if (!response.ok) {
|
|
2991
|
+
throw new Error(`Failed to generate embeddings: ${response.statusText}`);
|
|
2992
|
+
}
|
|
2993
|
+
const data = await response.json();
|
|
2994
|
+
return data;
|
|
2995
|
+
}
|
|
2996
|
+
};
|
|
2238
2997
|
export {
|
|
2998
|
+
AdminClient,
|
|
2239
2999
|
ChromaClient,
|
|
2240
3000
|
CohereEmbeddingFunction,
|
|
2241
3001
|
Collection,
|
|
3002
|
+
HuggingFaceEmbeddingServerFunction,
|
|
2242
3003
|
IncludeEnum,
|
|
2243
3004
|
OpenAIEmbeddingFunction
|
|
2244
3005
|
};
|