chromadb 1.7.2 → 1.7.3-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chromadb.mjs CHANGED
@@ -180,47 +180,13 @@ 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
- },
215
183
  /**
216
184
  * @summary Create Collection
217
- * @param {string} [tenant]
218
- * @param {string} [database]
219
185
  * @param {Api.CreateCollection} request
220
186
  * @param {RequestInit} [options] Override http request option.
221
187
  * @throws {RequiredError}
222
188
  */
223
- createCollection(tenant, database, request, options = {}) {
189
+ createCollection(request, options = {}) {
224
190
  if (request === null || request === void 0) {
225
191
  throw new RequiredError("request", "Required parameter request was null or undefined when calling createCollection.");
226
192
  }
@@ -232,80 +198,6 @@ var ApiApiFetchParamCreator = function(configuration) {
232
198
  if (localVarPathQueryStart !== -1) {
233
199
  localVarPath = localVarPath.substring(0, localVarPathQueryStart);
234
200
  }
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
- }
309
201
  localVarHeaderParameter.set("Content-Type", "application/json");
310
202
  localVarRequestOptions.headers = localVarHeaderParameter;
311
203
  if (request !== void 0) {
@@ -323,12 +215,10 @@ var ApiApiFetchParamCreator = function(configuration) {
323
215
  /**
324
216
  * @summary Delete Collection
325
217
  * @param {string} collectionName
326
- * @param {string} [tenant]
327
- * @param {string} [database]
328
218
  * @param {RequestInit} [options] Override http request option.
329
219
  * @throws {RequiredError}
330
220
  */
331
- deleteCollection(collectionName, tenant, database, options = {}) {
221
+ deleteCollection(collectionName, options = {}) {
332
222
  if (collectionName === null || collectionName === void 0) {
333
223
  throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling deleteCollection.");
334
224
  }
@@ -340,12 +230,6 @@ var ApiApiFetchParamCreator = function(configuration) {
340
230
  if (localVarPathQueryStart !== -1) {
341
231
  localVarPath = localVarPath.substring(0, localVarPathQueryStart);
342
232
  }
343
- if (tenant !== void 0) {
344
- localVarQueryParameter.append("tenant", String(tenant));
345
- }
346
- if (database !== void 0) {
347
- localVarQueryParameter.append("database", String(database));
348
- }
349
233
  localVarRequestOptions.headers = localVarHeaderParameter;
350
234
  const localVarQueryParameterString = localVarQueryParameter.toString();
351
235
  if (localVarQueryParameterString) {
@@ -359,12 +243,10 @@ var ApiApiFetchParamCreator = function(configuration) {
359
243
  /**
360
244
  * @summary Get Collection
361
245
  * @param {string} collectionName
362
- * @param {string} [tenant]
363
- * @param {string} [database]
364
246
  * @param {RequestInit} [options] Override http request option.
365
247
  * @throws {RequiredError}
366
248
  */
367
- getCollection(collectionName, tenant, database, options = {}) {
249
+ getCollection(collectionName, options = {}) {
368
250
  if (collectionName === null || collectionName === void 0) {
369
251
  throw new RequiredError("collectionName", "Required parameter collectionName was null or undefined when calling getCollection.");
370
252
  }
@@ -376,44 +258,6 @@ var ApiApiFetchParamCreator = function(configuration) {
376
258
  if (localVarPathQueryStart !== -1) {
377
259
  localVarPath = localVarPath.substring(0, localVarPathQueryStart);
378
260
  }
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
- }
417
261
  localVarRequestOptions.headers = localVarHeaderParameter;
418
262
  const localVarQueryParameterString = localVarQueryParameter.toString();
419
263
  if (localVarQueryParameterString) {
@@ -460,34 +304,6 @@ var ApiApiFetchParamCreator = function(configuration) {
460
304
  options: localVarRequestOptions
461
305
  };
462
306
  },
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
- },
491
307
  /**
492
308
  * @summary Heartbeat
493
309
  * @param {RequestInit} [options] Override http request option.
@@ -514,14 +330,10 @@ var ApiApiFetchParamCreator = function(configuration) {
514
330
  },
515
331
  /**
516
332
  * @summary List Collections
517
- * @param {string} [tenant]
518
- * @param {string} [database]
519
- * @param {number} [limit]
520
- * @param {number} [offset]
521
333
  * @param {RequestInit} [options] Override http request option.
522
334
  * @throws {RequiredError}
523
335
  */
524
- listCollections(tenant, database, limit, offset, options = {}) {
336
+ listCollections(options = {}) {
525
337
  let localVarPath = `/api/v1/collections`;
526
338
  const localVarPathQueryStart = localVarPath.indexOf("?");
527
339
  const localVarRequestOptions = Object.assign({ method: "GET" }, options);
@@ -530,42 +342,6 @@ var ApiApiFetchParamCreator = function(configuration) {
530
342
  if (localVarPathQueryStart !== -1) {
531
343
  localVarPath = localVarPath.substring(0, localVarPathQueryStart);
532
344
  }
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
- }
569
345
  localVarRequestOptions.headers = localVarHeaderParameter;
570
346
  const localVarQueryParameterString = localVarQueryParameter.toString();
571
347
  if (localVarQueryParameterString) {
@@ -875,102 +651,14 @@ var ApiApiFp = function(configuration) {
875
651
  });
876
652
  };
877
653
  },
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
- },
907
654
  /**
908
655
  * @summary Create Collection
909
- * @param {string} [tenant]
910
- * @param {string} [database]
911
656
  * @param {Api.CreateCollection} request
912
657
  * @param {RequestInit} [options] Override http request option.
913
658
  * @throws {RequiredError}
914
659
  */
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);
660
+ createCollection(request, options) {
661
+ const localVarFetchArgs = ApiApiFetchParamCreator(configuration).createCollection(request, options);
974
662
  return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
975
663
  return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
976
664
  const contentType = response.headers.get("Content-Type");
@@ -994,13 +682,11 @@ var ApiApiFp = function(configuration) {
994
682
  /**
995
683
  * @summary Delete Collection
996
684
  * @param {string} collectionName
997
- * @param {string} [tenant]
998
- * @param {string} [database]
999
685
  * @param {RequestInit} [options] Override http request option.
1000
686
  * @throws {RequiredError}
1001
687
  */
1002
- deleteCollection(collectionName, tenant, database, options) {
1003
- const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, tenant, database, options);
688
+ deleteCollection(collectionName, options) {
689
+ const localVarFetchArgs = ApiApiFetchParamCreator(configuration).deleteCollection(collectionName, options);
1004
690
  return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
1005
691
  return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
1006
692
  const contentType = response.headers.get("Content-Type");
@@ -1024,42 +710,11 @@ var ApiApiFp = function(configuration) {
1024
710
  /**
1025
711
  * @summary Get Collection
1026
712
  * @param {string} collectionName
1027
- * @param {string} [tenant]
1028
- * @param {string} [database]
1029
713
  * @param {RequestInit} [options] Override http request option.
1030
714
  * @throws {RequiredError}
1031
715
  */
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]
1058
- * @param {RequestInit} [options] Override http request option.
1059
- * @throws {RequiredError}
1060
- */
1061
- getDatabase(database, tenant, options) {
1062
- const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getDatabase(database, tenant, options);
716
+ getCollection(collectionName, options) {
717
+ const localVarFetchArgs = ApiApiFetchParamCreator(configuration).getCollection(collectionName, options);
1063
718
  return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
1064
719
  return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
1065
720
  const contentType = response.headers.get("Content-Type");
@@ -1109,34 +764,6 @@ var ApiApiFp = function(configuration) {
1109
764
  });
1110
765
  };
1111
766
  },
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
- },
1140
767
  /**
1141
768
  * @summary Heartbeat
1142
769
  * @param {RequestInit} [options] Override http request option.
@@ -1160,42 +787,11 @@ var ApiApiFp = function(configuration) {
1160
787
  },
1161
788
  /**
1162
789
  * @summary List Collections
1163
- * @param {string} [tenant]
1164
- * @param {string} [database]
1165
- * @param {number} [limit]
1166
- * @param {number} [offset]
1167
790
  * @param {RequestInit} [options] Override http request option.
1168
791
  * @throws {RequiredError}
1169
792
  */
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
1194
- * @param {RequestInit} [options] Override http request option.
1195
- * @throws {RequiredError}
1196
- */
1197
- preFlightChecks(options) {
1198
- const localVarFetchArgs = ApiApiFetchParamCreator(configuration).preFlightChecks(options);
793
+ listCollections(options) {
794
+ const localVarFetchArgs = ApiApiFetchParamCreator(configuration).listCollections(options);
1199
795
  return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
1200
796
  return fetch2(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
1201
797
  const contentType = response.headers.get("Content-Type");
@@ -1402,77 +998,32 @@ var ApiApi = class extends BaseAPI {
1402
998
  count(collectionId, options) {
1403
999
  return ApiApiFp(this.configuration).count(collectionId, options)(this.fetch, this.basePath);
1404
1000
  }
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
- }
1415
1001
  /**
1416
1002
  * @summary Create Collection
1417
- * @param {string} [tenant]
1418
- * @param {string} [database]
1419
1003
  * @param {Api.CreateCollection} request
1420
1004
  * @param {RequestInit} [options] Override http request option.
1421
1005
  * @throws {RequiredError}
1422
1006
  */
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);
1007
+ createCollection(request, options) {
1008
+ return ApiApiFp(this.configuration).createCollection(request, options)(this.fetch, this.basePath);
1444
1009
  }
1445
1010
  /**
1446
1011
  * @summary Delete Collection
1447
1012
  * @param {string} collectionName
1448
- * @param {string} [tenant]
1449
- * @param {string} [database]
1450
1013
  * @param {RequestInit} [options] Override http request option.
1451
1014
  * @throws {RequiredError}
1452
1015
  */
1453
- deleteCollection(collectionName, tenant, database, options) {
1454
- return ApiApiFp(this.configuration).deleteCollection(collectionName, tenant, database, options)(this.fetch, this.basePath);
1016
+ deleteCollection(collectionName, options) {
1017
+ return ApiApiFp(this.configuration).deleteCollection(collectionName, options)(this.fetch, this.basePath);
1455
1018
  }
1456
1019
  /**
1457
1020
  * @summary Get Collection
1458
1021
  * @param {string} collectionName
1459
- * @param {string} [tenant]
1460
- * @param {string} [database]
1461
1022
  * @param {RequestInit} [options] Override http request option.
1462
1023
  * @throws {RequiredError}
1463
1024
  */
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]
1471
- * @param {RequestInit} [options] Override http request option.
1472
- * @throws {RequiredError}
1473
- */
1474
- getDatabase(database, tenant, options) {
1475
- return ApiApiFp(this.configuration).getDatabase(database, tenant, options)(this.fetch, this.basePath);
1025
+ getCollection(collectionName, options) {
1026
+ return ApiApiFp(this.configuration).getCollection(collectionName, options)(this.fetch, this.basePath);
1476
1027
  }
1477
1028
  /**
1478
1029
  * @summary Get Nearest Neighbors
@@ -1484,15 +1035,6 @@ var ApiApi = class extends BaseAPI {
1484
1035
  getNearestNeighbors(collectionId, request, options) {
1485
1036
  return ApiApiFp(this.configuration).getNearestNeighbors(collectionId, request, options)(this.fetch, this.basePath);
1486
1037
  }
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
- }
1496
1038
  /**
1497
1039
  * @summary Heartbeat
1498
1040
  * @param {RequestInit} [options] Override http request option.
@@ -1503,23 +1045,11 @@ var ApiApi = class extends BaseAPI {
1503
1045
  }
1504
1046
  /**
1505
1047
  * @summary List Collections
1506
- * @param {string} [tenant]
1507
- * @param {string} [database]
1508
- * @param {number} [limit]
1509
- * @param {number} [offset]
1510
- * @param {RequestInit} [options] Override http request option.
1511
- * @throws {RequiredError}
1512
- */
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
1048
  * @param {RequestInit} [options] Override http request option.
1519
1049
  * @throws {RequiredError}
1520
1050
  */
1521
- preFlightChecks(options) {
1522
- return ApiApiFp(this.configuration).preFlightChecks(options)(this.fetch, this.basePath);
1051
+ listCollections(options) {
1052
+ return ApiApiFp(this.configuration).listCollections(options)(this.fetch, this.basePath);
1523
1053
  }
1524
1054
  /**
1525
1055
  * @summary Reset
@@ -1585,8 +1115,8 @@ var Api;
1585
1115
  let Include;
1586
1116
  ((Include2) => {
1587
1117
  let EnumValueEnum;
1588
- ((EnumValueEnum7) => {
1589
- EnumValueEnum7["Documents"] = "documents";
1118
+ ((EnumValueEnum5) => {
1119
+ EnumValueEnum5["Documents"] = "documents";
1590
1120
  })(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
1591
1121
  let EnumValueEnum2;
1592
1122
  ((EnumValueEnum22) => {
@@ -1600,14 +1130,6 @@ var Api;
1600
1130
  ((EnumValueEnum42) => {
1601
1131
  EnumValueEnum42["Distances"] = "distances";
1602
1132
  })(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 = {}));
1611
1133
  })(Include = GetEmbedding2.Include || (GetEmbedding2.Include = {}));
1612
1134
  })(GetEmbedding = Api2.GetEmbedding || (Api2.GetEmbedding = {}));
1613
1135
  let QueryEmbedding;
@@ -1615,8 +1137,8 @@ var Api;
1615
1137
  let Include;
1616
1138
  ((Include2) => {
1617
1139
  let EnumValueEnum;
1618
- ((EnumValueEnum7) => {
1619
- EnumValueEnum7["Documents"] = "documents";
1140
+ ((EnumValueEnum5) => {
1141
+ EnumValueEnum5["Documents"] = "documents";
1620
1142
  })(EnumValueEnum = Include2.EnumValueEnum || (Include2.EnumValueEnum = {}));
1621
1143
  let EnumValueEnum2;
1622
1144
  ((EnumValueEnum22) => {
@@ -1630,14 +1152,6 @@ var Api;
1630
1152
  ((EnumValueEnum42) => {
1631
1153
  EnumValueEnum42["Distances"] = "distances";
1632
1154
  })(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 = {}));
1641
1155
  })(Include = QueryEmbedding2.Include || (QueryEmbedding2.Include = {}));
1642
1156
  })(QueryEmbedding = Api2.QueryEmbedding || (Api2.QueryEmbedding = {}));
1643
1157
  })(Api || (Api = {}));
@@ -1688,6 +1202,7 @@ async function handleError(error) {
1688
1202
  }
1689
1203
  } catch (e) {
1690
1204
  return {
1205
+ //@ts-ignore
1691
1206
  error: e && typeof e === "object" && "message" in e ? e.message : "unknown error"
1692
1207
  };
1693
1208
  }
@@ -1704,18 +1219,6 @@ async function handleSuccess(response) {
1704
1219
  return repack(response);
1705
1220
  }
1706
1221
  }
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
- }
1719
1222
 
1720
1223
  // src/Collection.ts
1721
1224
  var Collection = class {
@@ -2366,206 +1869,79 @@ var IsomorphicFetchClientAuthProtocolAdapter = class {
2366
1869
  }
2367
1870
  };
2368
1871
 
2369
- // src/AdminClient.ts
2370
- var DEFAULT_TENANT = "default_tenant";
2371
- var DEFAULT_DATABASE = "default_database";
2372
- var AdminClient = class {
1872
+ // src/embeddings/DefaultEmbeddingFunction.ts
1873
+ var TransformersApi;
1874
+ var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
2373
1875
  /**
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
- * ```
1876
+ * DefaultEmbeddingFunction constructor.
1877
+ * @param options The configuration options.
1878
+ * @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
1879
+ * @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
1880
+ * @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
1881
+ * @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
2385
1882
  */
2386
1883
  constructor({
2387
- path,
2388
- fetchOptions,
2389
- auth,
2390
- tenant = DEFAULT_TENANT,
2391
- database = DEFAULT_DATABASE
1884
+ model = "Xenova/all-MiniLM-L6-v2",
1885
+ revision = "main",
1886
+ quantized = false,
1887
+ progress_callback = null
2392
1888
  } = {}) {
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;
1889
+ this.model = model;
1890
+ this.revision = revision;
1891
+ this.quantized = quantized;
1892
+ this.progress_callback = progress_callback;
2457
1893
  }
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 };
1894
+ async generate(texts) {
1895
+ await this.loadClient();
1896
+ this.pipelinePromise = new Promise(async (resolve, reject) => {
1897
+ try {
1898
+ const pipeline = this.transformersApi;
1899
+ const quantized = this.quantized;
1900
+ const revision = this.revision;
1901
+ const progress_callback = this.progress_callback;
1902
+ resolve(
1903
+ await pipeline("feature-extraction", this.model, {
1904
+ quantized,
1905
+ revision,
1906
+ progress_callback
1907
+ })
1908
+ );
1909
+ } catch (e) {
1910
+ reject(e);
1911
+ }
1912
+ });
1913
+ let pipe = await this.pipelinePromise;
1914
+ let output = await pipe(texts, { pooling: "mean", normalize: true });
1915
+ return output.tolist();
2507
1916
  }
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);
1917
+ async loadClient() {
1918
+ if (this.transformersApi)
1919
+ return;
1920
+ try {
1921
+ let { pipeline } = await _DefaultEmbeddingFunction.import();
1922
+ TransformersApi = pipeline;
1923
+ } catch (_a) {
1924
+ if (_a.code === "MODULE_NOT_FOUND") {
1925
+ throw new Error("Please install the chromadb-default-embed package to use the DefaultEmbeddingFunction, `npm install -S chromadb-default-embed`");
1926
+ }
1927
+ throw _a;
2533
1928
  }
2534
- return { name };
1929
+ this.transformersApi = TransformersApi;
2535
1930
  }
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);
1931
+ /** @ignore */
1932
+ static async import() {
1933
+ try {
1934
+ const { pipeline } = await import("chromadb-default-embed");
1935
+ return { pipeline };
1936
+ } catch (e) {
1937
+ throw new Error(
1938
+ "Please install chromadb-default-embed as a dependency with, e.g. `yarn add chromadb-default-embed`"
1939
+ );
2561
1940
  }
2562
- return { name: getDatabase.name };
2563
1941
  }
2564
1942
  };
2565
1943
 
2566
1944
  // src/ChromaClient.ts
2567
- var DEFAULT_TENANT2 = "default_tenant";
2568
- var DEFAULT_DATABASE2 = "default_database";
2569
1945
  var ChromaClient = class {
2570
1946
  /**
2571
1947
  * Creates a new ChromaClient instance.
@@ -2583,16 +1959,10 @@ var ChromaClient = class {
2583
1959
  constructor({
2584
1960
  path,
2585
1961
  fetchOptions,
2586
- auth,
2587
- tenant = DEFAULT_TENANT2,
2588
- database = DEFAULT_DATABASE2
1962
+ auth
2589
1963
  } = {}) {
2590
- this.tenant = DEFAULT_TENANT2;
2591
- this.database = DEFAULT_DATABASE2;
2592
1964
  if (path === void 0)
2593
1965
  path = "http://localhost:8000";
2594
- this.tenant = tenant;
2595
- this.database = database;
2596
1966
  const apiConfig = new Configuration({
2597
1967
  basePath: path
2598
1968
  });
@@ -2602,13 +1972,6 @@ var ChromaClient = class {
2602
1972
  } else {
2603
1973
  this.api = new ApiApi(apiConfig);
2604
1974
  }
2605
- this._adminClient = new AdminClient({
2606
- path,
2607
- fetchOptions,
2608
- auth,
2609
- tenant,
2610
- database
2611
- });
2612
1975
  this.api.options = fetchOptions != null ? fetchOptions : {};
2613
1976
  }
2614
1977
  /**
@@ -2678,7 +2041,10 @@ var ChromaClient = class {
2678
2041
  metadata,
2679
2042
  embeddingFunction
2680
2043
  }) {
2681
- const newCollection = await this.api.createCollection(this.tenant, this.database, {
2044
+ if (embeddingFunction === void 0) {
2045
+ embeddingFunction = new DefaultEmbeddingFunction();
2046
+ }
2047
+ const newCollection = await this.api.createCollection({
2682
2048
  name,
2683
2049
  metadata
2684
2050
  }, this.api.options).then(handleSuccess).catch(handleError);
@@ -2713,7 +2079,10 @@ var ChromaClient = class {
2713
2079
  metadata,
2714
2080
  embeddingFunction
2715
2081
  }) {
2716
- const newCollection = await this.api.createCollection(this.tenant, this.database, {
2082
+ if (embeddingFunction === void 0) {
2083
+ embeddingFunction = new DefaultEmbeddingFunction();
2084
+ }
2085
+ const newCollection = await this.api.createCollection({
2717
2086
  name,
2718
2087
  metadata,
2719
2088
  "get_or_create": true
@@ -2733,44 +2102,15 @@ var ChromaClient = class {
2733
2102
  * Lists all collections.
2734
2103
  *
2735
2104
  * @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.
2738
2105
  * @throws {Error} If there is an issue listing the collections.
2739
2106
  *
2740
2107
  * @example
2741
2108
  * ```typescript
2742
- * const collections = await client.listCollections({
2743
- * limit: 10,
2744
- * offset: 0,
2745
- * });
2109
+ * const collections = await client.listCollections();
2746
2110
  * ```
2747
2111
  */
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();
2770
- * ```
2771
- */
2772
- async countCollections() {
2773
- const response = await this.api.countCollections(this.tenant, this.database, this.api.options);
2112
+ async listCollections() {
2113
+ const response = await this.api.listCollections(this.api.options);
2774
2114
  return handleSuccess(response);
2775
2115
  }
2776
2116
  /**
@@ -2792,7 +2132,7 @@ var ChromaClient = class {
2792
2132
  name,
2793
2133
  embeddingFunction
2794
2134
  }) {
2795
- const response = await this.api.getCollection(name, this.tenant, this.database, this.api.options).then(handleSuccess).catch(handleError);
2135
+ const response = await this.api.getCollection(name, this.api.options).then(handleSuccess).catch(handleError);
2796
2136
  if (response.error) {
2797
2137
  throw new Error(response.error);
2798
2138
  }
@@ -2821,33 +2161,7 @@ var ChromaClient = class {
2821
2161
  async deleteCollection({
2822
2162
  name
2823
2163
  }) {
2824
- return await this.api.deleteCollection(name, this.tenant, this.database, this.api.options).then(handleSuccess).catch(handleError);
2825
- }
2826
- };
2827
-
2828
- // src/CloudClient.ts
2829
- var CloudClient = class extends ChromaClient {
2830
- constructor({ apiKey, database, cloudHost, cloudPort }) {
2831
- if (!apiKey) {
2832
- apiKey = process.env.CHROMA_API_KEY;
2833
- }
2834
- if (!apiKey) {
2835
- throw new Error("No API key provided");
2836
- }
2837
- cloudHost = cloudHost || "https://api.trychroma.com";
2838
- cloudPort = cloudPort || "8000";
2839
- const path = `${cloudHost}:${cloudPort}`;
2840
- const auth = {
2841
- provider: "token",
2842
- credentials: apiKey,
2843
- providerOptions: { headerType: "X_CHROMA_TOKEN" }
2844
- };
2845
- return new ChromaClient({
2846
- path,
2847
- auth,
2848
- database
2849
- });
2850
- super();
2164
+ return await this.api.deleteCollection(name, this.api.options).then(handleSuccess).catch(handleError);
2851
2165
  }
2852
2166
  };
2853
2167
 
@@ -2991,50 +2305,73 @@ var CohereEmbeddingFunction = class _CohereEmbeddingFunction {
2991
2305
  }
2992
2306
  };
2993
2307
 
2994
- // src/embeddings/GoogleGeminiEmbeddingFunction.ts
2995
- var googleGenAiApi;
2996
- var GoogleGenerativeAiEmbeddingFunction = class _GoogleGenerativeAiEmbeddingFunction {
2997
- constructor({ googleApiKey, model, taskType }) {
2998
- this.api_key = googleApiKey;
2999
- this.model = model || "embedding-001";
3000
- this.taskType = taskType || "RETRIEVAL_DOCUMENT";
2308
+ // src/embeddings/TransformersEmbeddingFunction.ts
2309
+ var TransformersApi2;
2310
+ var TransformersEmbeddingFunction = class _TransformersEmbeddingFunction {
2311
+ /**
2312
+ * TransformersEmbeddingFunction constructor.
2313
+ * @param options The configuration options.
2314
+ * @param options.model The model to use to calculate embeddings. Defaults to 'Xenova/all-MiniLM-L6-v2', which is an ONNX port of `sentence-transformers/all-MiniLM-L6-v2`.
2315
+ * @param options.revision The specific model version to use (can be a branch, tag name, or commit id). Defaults to 'main'.
2316
+ * @param options.quantized Whether to load the 8-bit quantized version of the model. Defaults to `false`.
2317
+ * @param options.progress_callback If specified, this function will be called during model construction, to provide the user with progress updates.
2318
+ */
2319
+ constructor({
2320
+ model = "Xenova/all-MiniLM-L6-v2",
2321
+ revision = "main",
2322
+ quantized = false,
2323
+ progress_callback = null
2324
+ } = {}) {
2325
+ this.model = model;
2326
+ this.revision = revision;
2327
+ this.quantized = quantized;
2328
+ this.progress_callback = progress_callback;
2329
+ }
2330
+ async generate(texts) {
2331
+ await this.loadClient();
2332
+ this.pipelinePromise = new Promise(async (resolve, reject) => {
2333
+ try {
2334
+ const pipeline = this.transformersApi;
2335
+ const quantized = this.quantized;
2336
+ const revision = this.revision;
2337
+ const progress_callback = this.progress_callback;
2338
+ resolve(
2339
+ await pipeline("feature-extraction", this.model, {
2340
+ quantized,
2341
+ revision,
2342
+ progress_callback
2343
+ })
2344
+ );
2345
+ } catch (e) {
2346
+ reject(e);
2347
+ }
2348
+ });
2349
+ let pipe = await this.pipelinePromise;
2350
+ let output = await pipe(texts, { pooling: "mean", normalize: true });
2351
+ return output.tolist();
3001
2352
  }
3002
2353
  async loadClient() {
3003
- if (this.googleGenAiApi)
2354
+ if (this.transformersApi)
3004
2355
  return;
3005
2356
  try {
3006
- const { googleGenAi } = await _GoogleGenerativeAiEmbeddingFunction.import();
3007
- googleGenAiApi = googleGenAi;
3008
- googleGenAiApi = new googleGenAiApi(this.api_key);
2357
+ let { pipeline } = await _TransformersEmbeddingFunction.import();
2358
+ TransformersApi2 = pipeline;
3009
2359
  } catch (_a) {
3010
2360
  if (_a.code === "MODULE_NOT_FOUND") {
3011
- throw new Error("Please install the @google/generative-ai package to use the GoogleGenerativeAiEmbeddingFunction, `npm install -S @google/generative-ai`");
2361
+ throw new Error("Please install the @xenova/transformers package to use the TransformersEmbeddingFunction, `npm install -S @xenova/transformers`");
3012
2362
  }
3013
2363
  throw _a;
3014
2364
  }
3015
- this.googleGenAiApi = googleGenAiApi;
3016
- }
3017
- async generate(texts) {
3018
- await this.loadClient();
3019
- const model = this.googleGenAiApi.getGenerativeModel({ model: this.model });
3020
- const response = await model.batchEmbedContents({
3021
- requests: texts.map((t) => ({
3022
- content: { parts: [{ text: t }] },
3023
- taskType: this.taskType
3024
- }))
3025
- });
3026
- const embeddings = response.embeddings.map((e) => e.values);
3027
- return embeddings;
2365
+ this.transformersApi = TransformersApi2;
3028
2366
  }
3029
2367
  /** @ignore */
3030
2368
  static async import() {
3031
2369
  try {
3032
- const { GoogleGenerativeAI } = await import("@google/generative-ai");
3033
- const googleGenAi = GoogleGenerativeAI;
3034
- return { googleGenAi };
2370
+ const { pipeline } = await import("@xenova/transformers");
2371
+ return { pipeline };
3035
2372
  } catch (e) {
3036
2373
  throw new Error(
3037
- "Please install @google/generative-ai as a dependency with, e.g. `yarn add @google/generative-ai`"
2374
+ "Please install @xenova/transformers as a dependency with, e.g. `yarn add @xenova/transformers`"
3038
2375
  );
3039
2376
  }
3040
2377
  }
@@ -3048,75 +2385,13 @@ var IncludeEnum = /* @__PURE__ */ ((IncludeEnum2) => {
3048
2385
  IncludeEnum2["Distances"] = "distances";
3049
2386
  return IncludeEnum2;
3050
2387
  })(IncludeEnum || {});
3051
-
3052
- // src/embeddings/HuggingFaceEmbeddingServerFunction.ts
3053
- var HuggingFaceEmbeddingServerFunction = class {
3054
- constructor({ url }) {
3055
- this.url = url;
3056
- }
3057
- async generate(texts) {
3058
- const response = await fetch(this.url, {
3059
- method: "POST",
3060
- headers: {
3061
- "Content-Type": "application/json"
3062
- },
3063
- body: JSON.stringify({ "inputs": texts })
3064
- });
3065
- if (!response.ok) {
3066
- throw new Error(`Failed to generate embeddings: ${response.statusText}`);
3067
- }
3068
- const data = await response.json();
3069
- return data;
3070
- }
3071
- };
3072
-
3073
- // src/embeddings/JinaEmbeddingFunction.ts
3074
- var JinaEmbeddingFunction = class {
3075
- constructor({ jinaai_api_key, model_name }) {
3076
- this.model_name = model_name || "jina-embeddings-v2-base-en";
3077
- this.api_url = "https://api.jina.ai/v1/embeddings";
3078
- this.headers = {
3079
- Authorization: `Bearer ${jinaai_api_key}`,
3080
- "Accept-Encoding": "identity",
3081
- "Content-Type": "application/json"
3082
- };
3083
- }
3084
- async generate(texts) {
3085
- try {
3086
- const response = await fetch(this.api_url, {
3087
- method: "POST",
3088
- headers: this.headers,
3089
- body: JSON.stringify({
3090
- input: texts,
3091
- model: this.model_name
3092
- })
3093
- });
3094
- const data = await response.json();
3095
- if (!data || !data.data) {
3096
- throw new Error(data.detail);
3097
- }
3098
- const embeddings = data.data;
3099
- const sortedEmbeddings = embeddings.sort((a, b) => a.index - b.index);
3100
- return sortedEmbeddings.map((result) => result.embedding);
3101
- } catch (error) {
3102
- if (error instanceof Error) {
3103
- throw new Error(`Error calling Jina AI API: ${error.message}`);
3104
- } else {
3105
- throw new Error(`Error calling Jina AI API: ${error}`);
3106
- }
3107
- }
3108
- }
3109
- };
3110
2388
  export {
3111
- AdminClient,
3112
2389
  ChromaClient,
3113
- CloudClient,
3114
2390
  CohereEmbeddingFunction,
3115
2391
  Collection,
3116
- GoogleGenerativeAiEmbeddingFunction,
3117
- HuggingFaceEmbeddingServerFunction,
2392
+ DefaultEmbeddingFunction,
3118
2393
  IncludeEnum,
3119
- JinaEmbeddingFunction,
3120
- OpenAIEmbeddingFunction
2394
+ OpenAIEmbeddingFunction,
2395
+ TransformersEmbeddingFunction
3121
2396
  };
3122
2397
  //# sourceMappingURL=chromadb.mjs.map