chromadb 2.2.1 → 2.3.0

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.
@@ -6836,7 +6836,7 @@ __export(src_exports, {
6836
6836
  module.exports = __toCommonJS(src_exports);
6837
6837
 
6838
6838
  // ../chromadb-core/package.json
6839
- var version = "2.2.1";
6839
+ var version = "2.3.0";
6840
6840
 
6841
6841
  // ../chromadb-core/src/generated/runtime.ts
6842
6842
  var import_isomorphic_fetch = require("isomorphic-fetch");
@@ -7568,6 +7568,67 @@ var ApiApiFetchParamCreator = function(configuration) {
7568
7568
  options: localVarRequestOptions
7569
7569
  };
7570
7570
  },
7571
+ /**
7572
+ * @summary Forks an existing collection.
7573
+ * @param {string} tenant <p>Tenant ID</p>
7574
+ * @param {string} database <p>Database name</p>
7575
+ * @param {string} collectionId <p>UUID of the collection to update</p>
7576
+ * @param {Api.ForkCollectionPayload} request
7577
+ * @param {RequestInit} [options] Override http request option.
7578
+ * @throws {RequiredError}
7579
+ */
7580
+ forkCollection(tenant, database, collectionId, request, options = {}) {
7581
+ if (tenant === null || tenant === void 0) {
7582
+ throw new RequiredError(
7583
+ "tenant",
7584
+ "Required parameter tenant was null or undefined when calling forkCollection."
7585
+ );
7586
+ }
7587
+ if (database === null || database === void 0) {
7588
+ throw new RequiredError(
7589
+ "database",
7590
+ "Required parameter database was null or undefined when calling forkCollection."
7591
+ );
7592
+ }
7593
+ if (collectionId === null || collectionId === void 0) {
7594
+ throw new RequiredError(
7595
+ "collectionId",
7596
+ "Required parameter collectionId was null or undefined when calling forkCollection."
7597
+ );
7598
+ }
7599
+ if (request === null || request === void 0) {
7600
+ throw new RequiredError(
7601
+ "request",
7602
+ "Required parameter request was null or undefined when calling forkCollection."
7603
+ );
7604
+ }
7605
+ let localVarPath = `/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/fork`.replace("{tenant}", encodeURIComponent(String(tenant))).replace("{database}", encodeURIComponent(String(database))).replace("{collection_id}", encodeURIComponent(String(collectionId)));
7606
+ const localVarPathQueryStart = localVarPath.indexOf("?");
7607
+ const localVarRequestOptions = Object.assign(
7608
+ { method: "POST" },
7609
+ options
7610
+ );
7611
+ const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
7612
+ const localVarQueryParameter = new URLSearchParams(
7613
+ localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : ""
7614
+ );
7615
+ if (localVarPathQueryStart !== -1) {
7616
+ localVarPath = localVarPath.substring(0, localVarPathQueryStart);
7617
+ }
7618
+ localVarHeaderParameter.set("Content-Type", "application/json");
7619
+ localVarRequestOptions.headers = localVarHeaderParameter;
7620
+ if (request !== void 0) {
7621
+ localVarRequestOptions.body = JSON.stringify(request || {});
7622
+ }
7623
+ const localVarQueryParameterString = localVarQueryParameter.toString();
7624
+ if (localVarQueryParameterString) {
7625
+ localVarPath += "?" + localVarQueryParameterString;
7626
+ }
7627
+ return {
7628
+ url: localVarPath,
7629
+ options: localVarRequestOptions
7630
+ };
7631
+ },
7571
7632
  /**
7572
7633
  * @summary Retrieves a collection by ID or name.
7573
7634
  * @param {string} tenant <p>Tenant ID</p>
@@ -8605,6 +8666,54 @@ var ApiApiFp = function(configuration) {
8605
8666
  });
8606
8667
  };
8607
8668
  },
8669
+ /**
8670
+ * @summary Forks an existing collection.
8671
+ * @param {string} tenant <p>Tenant ID</p>
8672
+ * @param {string} database <p>Database name</p>
8673
+ * @param {string} collectionId <p>UUID of the collection to update</p>
8674
+ * @param {Api.ForkCollectionPayload} request
8675
+ * @param {RequestInit} [options] Override http request option.
8676
+ * @throws {RequiredError}
8677
+ */
8678
+ forkCollection(tenant, database, collectionId, request, options) {
8679
+ const localVarFetchArgs = ApiApiFetchParamCreator(
8680
+ configuration
8681
+ ).forkCollection(tenant, database, collectionId, request, options);
8682
+ return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
8683
+ return fetch2(
8684
+ basePath + localVarFetchArgs.url,
8685
+ localVarFetchArgs.options
8686
+ ).then((response) => {
8687
+ const contentType = response.headers.get("Content-Type");
8688
+ const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
8689
+ if (response.status === 200) {
8690
+ if (mimeType === "application/json") {
8691
+ return response.json();
8692
+ }
8693
+ throw response;
8694
+ }
8695
+ if (response.status === 401) {
8696
+ if (mimeType === "application/json") {
8697
+ throw response;
8698
+ }
8699
+ throw response;
8700
+ }
8701
+ if (response.status === 404) {
8702
+ if (mimeType === "application/json") {
8703
+ throw response;
8704
+ }
8705
+ throw response;
8706
+ }
8707
+ if (response.status === 500) {
8708
+ if (mimeType === "application/json") {
8709
+ throw response;
8710
+ }
8711
+ throw response;
8712
+ }
8713
+ throw response;
8714
+ });
8715
+ };
8716
+ },
8608
8717
  /**
8609
8718
  * @summary Retrieves a collection by ID or name.
8610
8719
  * @param {string} tenant <p>Tenant ID</p>
@@ -9271,6 +9380,24 @@ var ApiApi = class extends BaseAPI {
9271
9380
  options
9272
9381
  )(this.fetch, this.basePath);
9273
9382
  }
9383
+ /**
9384
+ * @summary Forks an existing collection.
9385
+ * @param {string} tenant <p>Tenant ID</p>
9386
+ * @param {string} database <p>Database name</p>
9387
+ * @param {string} collectionId <p>UUID of the collection to update</p>
9388
+ * @param {Api.ForkCollectionPayload} request
9389
+ * @param {RequestInit} [options] Override http request option.
9390
+ * @throws {RequiredError}
9391
+ */
9392
+ forkCollection(tenant, database, collectionId, request, options) {
9393
+ return ApiApiFp(this.configuration).forkCollection(
9394
+ tenant,
9395
+ database,
9396
+ collectionId,
9397
+ request,
9398
+ options
9399
+ )(this.fetch, this.basePath);
9400
+ }
9274
9401
  /**
9275
9402
  * @summary Retrieves a collection by ID or name.
9276
9403
  * @param {string} tenant <p>Tenant ID</p>
@@ -9435,7 +9562,7 @@ var ApiApi = class extends BaseAPI {
9435
9562
 
9436
9563
  // ../chromadb-core/src/generated/models.ts
9437
9564
  var Api;
9438
- ((Api2) => {
9565
+ ((Api3) => {
9439
9566
  let EmbeddingFunctionConfiguration;
9440
9567
  ((EmbeddingFunctionConfiguration2) => {
9441
9568
  let ObjectValue;
@@ -9452,13 +9579,13 @@ var Api;
9452
9579
  TypeEnum2["Known"] = "known";
9453
9580
  })(TypeEnum = AllofValue2.TypeEnum || (AllofValue2.TypeEnum = {}));
9454
9581
  })(AllofValue = EmbeddingFunctionConfiguration2.AllofValue || (EmbeddingFunctionConfiguration2.AllofValue = {}));
9455
- })(EmbeddingFunctionConfiguration = Api2.EmbeddingFunctionConfiguration || (Api2.EmbeddingFunctionConfiguration = {}));
9582
+ })(EmbeddingFunctionConfiguration = Api3.EmbeddingFunctionConfiguration || (Api3.EmbeddingFunctionConfiguration = {}));
9456
9583
  let HnswSpace;
9457
9584
  ((HnswSpace2) => {
9458
9585
  HnswSpace2["L2"] = "l2";
9459
9586
  HnswSpace2["Cosine"] = "cosine";
9460
9587
  HnswSpace2["Ip"] = "ip";
9461
- })(HnswSpace = Api2.HnswSpace || (Api2.HnswSpace = {}));
9588
+ })(HnswSpace = Api3.HnswSpace || (Api3.HnswSpace = {}));
9462
9589
  let Include;
9463
9590
  ((Include2) => {
9464
9591
  Include2["Distances"] = "distances";
@@ -9466,7 +9593,7 @@ var Api;
9466
9593
  Include2["Embeddings"] = "embeddings";
9467
9594
  Include2["Metadatas"] = "metadatas";
9468
9595
  Include2["Uris"] = "uris";
9469
- })(Include = Api2.Include || (Api2.Include = {}));
9596
+ })(Include = Api3.Include || (Api3.Include = {}));
9470
9597
  })(Api || (Api = {}));
9471
9598
 
9472
9599
  // ../chromadb-core/src/generated/configuration.ts
@@ -9569,17 +9696,135 @@ function createErrorByType(type, message) {
9569
9696
  }
9570
9697
  }
9571
9698
 
9699
+ // ../chromadb-core/src/CollectionConfiguration.ts
9700
+ var InvalidConfigurationError = class extends Error {
9701
+ constructor(message) {
9702
+ super(message);
9703
+ this.name = "InvalidConfigurationError";
9704
+ }
9705
+ };
9706
+ function serializeEmbeddingFunction(ef) {
9707
+ let efConfig = null;
9708
+ if (ef === null || ef === void 0) {
9709
+ efConfig = { type: "legacy" };
9710
+ } else {
9711
+ try {
9712
+ if (ef.getConfig && ef.name) {
9713
+ if (ef.validateConfig) {
9714
+ ef.validateConfig(ef.getConfig());
9715
+ }
9716
+ efConfig = {
9717
+ name: ef.name,
9718
+ type: "known",
9719
+ config: ef.getConfig()
9720
+ };
9721
+ } else {
9722
+ console.warn(
9723
+ "Could not serialize embedding function - missing getConfig or name method."
9724
+ );
9725
+ efConfig = { type: "legacy" };
9726
+ }
9727
+ } catch (e) {
9728
+ console.warn(
9729
+ "Error processing embedding function for serialization, falling back to legacy:",
9730
+ e,
9731
+ "DeprecationWarning"
9732
+ );
9733
+ efConfig = { type: "legacy" };
9734
+ }
9735
+ }
9736
+ return efConfig;
9737
+ }
9738
+ function loadApiCollectionConfigurationFromCreateCollectionConfiguration(config) {
9739
+ return createCollectionConfigurationToJson(
9740
+ config
9741
+ );
9742
+ }
9743
+ function createCollectionConfigurationToJson(config) {
9744
+ if (config.hnsw && config.spann) {
9745
+ throw new InvalidConfigurationError(
9746
+ "Cannot specify both 'hnsw' and 'spann' configurations during creation."
9747
+ );
9748
+ }
9749
+ let hnswConfig = config.hnsw;
9750
+ let spannConfig = config.spann;
9751
+ let ef = config.embedding_function;
9752
+ let efConfig = serializeEmbeddingFunction(ef);
9753
+ if (hnswConfig && typeof hnswConfig !== "object") {
9754
+ throw new Error(
9755
+ "Invalid HNSW config provided in CreateCollectionConfiguration"
9756
+ );
9757
+ }
9758
+ if (spannConfig && typeof spannConfig !== "object") {
9759
+ throw new Error(
9760
+ "Invalid SPANN config provided in CreateCollectionConfiguration"
9761
+ );
9762
+ }
9763
+ return {
9764
+ hnsw: hnswConfig,
9765
+ spann: spannConfig,
9766
+ embedding_function: efConfig
9767
+ };
9768
+ }
9769
+ function updateCollectionConfigurationToJson(config) {
9770
+ if (config.hnsw && config.spann) {
9771
+ throw new InvalidConfigurationError(
9772
+ "Cannot specify both 'hnsw' and 'spann' configurations during update."
9773
+ );
9774
+ }
9775
+ let hnswConfig = config.hnsw;
9776
+ let spannConfig = config.spann;
9777
+ let ef = config.embedding_function;
9778
+ let efConfig = void 0;
9779
+ if (hnswConfig) {
9780
+ if (typeof hnswConfig !== "object") {
9781
+ throw new Error(
9782
+ "Invalid HNSW config provided in UpdateCollectionConfiguration"
9783
+ );
9784
+ }
9785
+ }
9786
+ if (spannConfig) {
9787
+ if (typeof spannConfig !== "object") {
9788
+ throw new Error(
9789
+ "Invalid SPANN config provided in UpdateCollectionConfiguration"
9790
+ );
9791
+ }
9792
+ }
9793
+ if (ef !== void 0) {
9794
+ efConfig = serializeEmbeddingFunction(ef);
9795
+ }
9796
+ const result = {};
9797
+ if (hnswConfig !== void 0)
9798
+ result.hnsw = hnswConfig;
9799
+ if (spannConfig !== void 0)
9800
+ result.spann = spannConfig;
9801
+ if (efConfig !== void 0)
9802
+ result.embedding_function = efConfig;
9803
+ if (Object.keys(result).length === 0) {
9804
+ throw new InvalidConfigurationError(
9805
+ "No valid configuration fields provided for update."
9806
+ );
9807
+ }
9808
+ return result;
9809
+ }
9810
+ function loadApiUpdateCollectionConfigurationFromUpdateCollectionConfiguration(config) {
9811
+ return updateCollectionConfigurationToJson(
9812
+ config
9813
+ );
9814
+ }
9815
+
9572
9816
  // ../chromadb-core/src/Collection.ts
9573
- var Collection = class {
9817
+ var Collection = class _Collection {
9574
9818
  /**
9575
9819
  * @ignore
9576
9820
  */
9577
- constructor(name, id, client, embeddingFunction, metadata) {
9821
+ constructor(name, id, client, embeddingFunction, metadata, configuration) {
9578
9822
  this.name = name;
9579
9823
  this.id = id;
9580
9824
  this.metadata = metadata;
9581
9825
  this.client = client;
9582
9826
  this.embeddingFunction = embeddingFunction;
9827
+ this.configuration = configuration;
9583
9828
  }
9584
9829
  /**
9585
9830
  * Add items to the collection
@@ -9712,7 +9957,14 @@ var Collection = class {
9712
9957
  },
9713
9958
  this.client.api.options
9714
9959
  );
9715
- return resp;
9960
+ const finalResp = {
9961
+ ...resp,
9962
+ metadatas: resp.metadatas,
9963
+ documents: resp.documents,
9964
+ embeddings: resp.embeddings,
9965
+ included: resp.include
9966
+ };
9967
+ return finalResp;
9716
9968
  }
9717
9969
  /**
9718
9970
  * Update items in the collection
@@ -9811,7 +10063,15 @@ var Collection = class {
9811
10063
  },
9812
10064
  this.client.api.options
9813
10065
  );
9814
- return resp;
10066
+ const finalResp = {
10067
+ ...resp,
10068
+ metadatas: resp.metadatas,
10069
+ documents: resp.documents,
10070
+ embeddings: resp.embeddings,
10071
+ distances: resp.distances,
10072
+ included: resp.include
10073
+ };
10074
+ return finalResp;
9815
10075
  }
9816
10076
  /**
9817
10077
  * Modify the collection name or metadata
@@ -9830,16 +10090,24 @@ var Collection = class {
9830
10090
  */
9831
10091
  async modify({
9832
10092
  name,
9833
- metadata
10093
+ metadata,
10094
+ configuration
9834
10095
  }) {
9835
10096
  await this.client.init();
10097
+ let updateCollectionConfiguration = void 0;
10098
+ if (configuration) {
10099
+ updateCollectionConfiguration = loadApiUpdateCollectionConfigurationFromUpdateCollectionConfiguration(
10100
+ configuration
10101
+ );
10102
+ }
9836
10103
  const resp = await this.client.api.updateCollection(
9837
10104
  this.client.tenant,
9838
10105
  this.client.database,
9839
10106
  this.id,
9840
10107
  {
9841
10108
  new_name: name,
9842
- new_metadata: metadata
10109
+ new_metadata: metadata,
10110
+ new_configuration: updateCollectionConfiguration
9843
10111
  },
9844
10112
  this.client.api.options
9845
10113
  );
@@ -9914,6 +10182,42 @@ var Collection = class {
9914
10182
  this.client.api.options
9915
10183
  );
9916
10184
  }
10185
+ /**
10186
+ * Forks the collection into a new collection with a new name and configuration.
10187
+ *
10188
+ * @param {Object} params - The parameters for forking the collection.
10189
+ * @param {string} params.newName - The name for the new forked collection.
10190
+ *
10191
+ * @returns {Promise<Collection>} A promise that resolves to the new forked Collection object.
10192
+ * @throws {Error} If there is an issue forking the collection.
10193
+ *
10194
+ * @example
10195
+ * ```typescript
10196
+ * const newCollection = await collection.fork({
10197
+ * newName: "my_forked_collection",
10198
+ * });
10199
+ * ```
10200
+ */
10201
+ async fork({ newName }) {
10202
+ await this.client.init();
10203
+ const resp = await this.client.api.forkCollection(
10204
+ this.client.tenant,
10205
+ this.client.database,
10206
+ this.id,
10207
+ {
10208
+ new_name: newName
10209
+ },
10210
+ this.client.api.options
10211
+ );
10212
+ const newCollection = new _Collection(
10213
+ resp.name,
10214
+ resp.id,
10215
+ this.client,
10216
+ this.embeddingFunction,
10217
+ resp.metadata
10218
+ );
10219
+ return newCollection;
10220
+ }
9917
10221
  };
9918
10222
 
9919
10223
  // ../chromadb-core/src/utils.ts
@@ -9998,6 +10302,9 @@ async function prepareRecordRequest(reqParams, embeddingFunction, update) {
9998
10302
  `ID's must be unique, found duplicates for: ${duplicateIds}`
9999
10303
  );
10000
10304
  }
10305
+ if (embeddingsArray && embeddingsArray.some((embedding) => embedding.length === 0)) {
10306
+ throw new Error("got empty embedding at pos");
10307
+ }
10001
10308
  return {
10002
10309
  ids,
10003
10310
  metadatas,
@@ -10011,7 +10318,8 @@ function wrapCollection(api, collection) {
10011
10318
  collection.id,
10012
10319
  api,
10013
10320
  collection.embeddingFunction,
10014
- collection.metadata
10321
+ collection.metadata,
10322
+ collection.configuration
10015
10323
  );
10016
10324
  }
10017
10325
 
@@ -10678,6 +10986,30 @@ var jina_default = {
10678
10986
  api_key_env_var: {
10679
10987
  type: "string",
10680
10988
  description: "Parameter api_key_env_var for the jina embedding function"
10989
+ },
10990
+ task: {
10991
+ type: "string",
10992
+ description: "Parameter task for the jina embedding function"
10993
+ },
10994
+ late_chunking: {
10995
+ type: "boolean",
10996
+ description: "Parameter late_chunking for the jina embedding function"
10997
+ },
10998
+ truncate: {
10999
+ type: "boolean",
11000
+ description: "Parameter truncate for the jina embedding function"
11001
+ },
11002
+ dimensions: {
11003
+ type: "integer",
11004
+ description: "Parameter dimensions for the jina embedding function"
11005
+ },
11006
+ embedding_type: {
11007
+ type: "string",
11008
+ description: "Parameter embedding_type for the jina embedding function"
11009
+ },
11010
+ normalized: {
11011
+ type: "boolean",
11012
+ description: "Parameter normalized for the jina embedding function"
10681
11013
  }
10682
11014
  },
10683
11015
  required: [
@@ -11029,7 +11361,9 @@ function getSchemaVersion(schemaName) {
11029
11361
  return schema.version || "1.0.0";
11030
11362
  }
11031
11363
  function getAvailableSchemas() {
11032
- return Object.keys(schemaMap).filter((name) => name !== "base_schema");
11364
+ return Object.keys(schemaMap).filter(
11365
+ (name) => name !== "base_schema"
11366
+ );
11033
11367
  }
11034
11368
  function getSchemaInfo() {
11035
11369
  const schemaInfo = {};
@@ -11148,6 +11482,7 @@ var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
11148
11482
  };
11149
11483
 
11150
11484
  // ../chromadb-core/src/ChromaClient.ts
11485
+ var import_console = require("console");
11151
11486
  var DEFAULT_TENANT2 = "default_tenant";
11152
11487
  var DEFAULT_DATABASE2 = "default_database";
11153
11488
  var ChromaClient = class {
@@ -11300,26 +11635,40 @@ var ChromaClient = class {
11300
11635
  async createCollection({
11301
11636
  name,
11302
11637
  metadata,
11303
- embeddingFunction = new DefaultEmbeddingFunction()
11638
+ embeddingFunction = new DefaultEmbeddingFunction(),
11639
+ configuration
11304
11640
  }) {
11305
11641
  await this.init();
11642
+ let collectionConfiguration = void 0;
11643
+ if (configuration) {
11644
+ collectionConfiguration = loadApiCollectionConfigurationFromCreateCollectionConfiguration(
11645
+ configuration
11646
+ );
11647
+ }
11306
11648
  const newCollection = await this.api.createCollection(
11307
11649
  this.tenant,
11308
11650
  this.database,
11309
11651
  {
11310
11652
  name,
11311
- // @ts-ignore: we need to generate the client libraries again
11312
- configuration: null,
11313
- //TODO: Configuration type in JavaScript
11653
+ configuration: collectionConfiguration,
11314
11654
  metadata
11315
11655
  },
11316
11656
  this.api.options
11317
11657
  );
11658
+ let config = {};
11659
+ try {
11660
+ config = newCollection.configuration_json;
11661
+ } catch {
11662
+ (0, import_console.warn)(
11663
+ "Server does not respond with configuration_json. Please update server"
11664
+ );
11665
+ }
11318
11666
  return wrapCollection(this, {
11319
11667
  name: newCollection.name,
11320
11668
  id: newCollection.id,
11321
11669
  metadata: newCollection.metadata,
11322
- embeddingFunction
11670
+ embeddingFunction,
11671
+ configuration: config
11323
11672
  });
11324
11673
  }
11325
11674
  /**
@@ -11346,27 +11695,41 @@ var ChromaClient = class {
11346
11695
  async getOrCreateCollection({
11347
11696
  name,
11348
11697
  metadata,
11349
- embeddingFunction = new DefaultEmbeddingFunction()
11698
+ embeddingFunction = new DefaultEmbeddingFunction(),
11699
+ configuration
11350
11700
  }) {
11351
11701
  await this.init();
11702
+ let collectionConfiguration = void 0;
11703
+ if (configuration) {
11704
+ collectionConfiguration = loadApiCollectionConfigurationFromCreateCollectionConfiguration(
11705
+ configuration
11706
+ );
11707
+ }
11352
11708
  const newCollection = await this.api.createCollection(
11353
11709
  this.tenant,
11354
11710
  this.database,
11355
11711
  {
11356
11712
  name,
11357
- // @ts-ignore: we need to generate the client libraries again
11358
- configuration: null,
11359
- //TODO: Configuration type in JavaScript
11713
+ configuration: collectionConfiguration,
11360
11714
  metadata,
11361
11715
  get_or_create: true
11362
11716
  },
11363
11717
  this.api.options
11364
11718
  );
11719
+ let config = {};
11720
+ try {
11721
+ config = newCollection.configuration_json;
11722
+ } catch {
11723
+ (0, import_console.warn)(
11724
+ "Server does not respond with configuration_json. Please update server"
11725
+ );
11726
+ }
11365
11727
  return wrapCollection(this, {
11366
11728
  name: newCollection.name,
11367
11729
  id: newCollection.id,
11368
11730
  metadata: newCollection.metadata,
11369
- embeddingFunction
11731
+ embeddingFunction,
11732
+ configuration: config
11370
11733
  });
11371
11734
  }
11372
11735
  /**
@@ -11471,11 +11834,20 @@ var ChromaClient = class {
11471
11834
  name,
11472
11835
  this.api.options
11473
11836
  );
11837
+ let config = {};
11838
+ try {
11839
+ config = response.configuration_json;
11840
+ } catch {
11841
+ (0, import_console.warn)(
11842
+ "Server does not respond with configuration_json. Please update server"
11843
+ );
11844
+ }
11474
11845
  return wrapCollection(this, {
11475
11846
  id: response.id,
11476
11847
  name: response.name,
11477
11848
  metadata: response.metadata,
11478
- embeddingFunction: embeddingFunction !== void 0 ? embeddingFunction : new DefaultEmbeddingFunction()
11849
+ embeddingFunction: embeddingFunction !== void 0 ? embeddingFunction : new DefaultEmbeddingFunction(),
11850
+ configuration: config
11479
11851
  });
11480
11852
  }
11481
11853
  /**
@@ -11822,7 +12194,13 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
11822
12194
  constructor({
11823
12195
  jinaai_api_key,
11824
12196
  model_name = "jina-embeddings-v2-base-en",
11825
- api_key_env_var = "JINAAI_API_KEY"
12197
+ api_key_env_var = "JINAAI_API_KEY",
12198
+ task,
12199
+ late_chunking,
12200
+ truncate,
12201
+ dimensions,
12202
+ embedding_type,
12203
+ normalized
11826
12204
  }) {
11827
12205
  this.name = "jina";
11828
12206
  const apiKey = jinaai_api_key ?? process.env[api_key_env_var];
@@ -11833,6 +12211,12 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
11833
12211
  }
11834
12212
  this.model_name = model_name;
11835
12213
  this.api_key_env_var = api_key_env_var;
12214
+ this.task = task;
12215
+ this.late_chunking = late_chunking;
12216
+ this.truncate = truncate;
12217
+ this.dimensions = dimensions;
12218
+ this.embedding_type = embedding_type;
12219
+ this.normalized = normalized;
11836
12220
  this.api_url = "https://api.jina.ai/v1/embeddings";
11837
12221
  this.headers = {
11838
12222
  Authorization: `Bearer ${jinaai_api_key}`,
@@ -11841,14 +12225,33 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
11841
12225
  };
11842
12226
  }
11843
12227
  async generate(texts) {
12228
+ let json_body = {
12229
+ input: texts,
12230
+ model: this.model_name
12231
+ };
12232
+ if (this.task) {
12233
+ json_body.task = this.task;
12234
+ }
12235
+ if (this.late_chunking) {
12236
+ json_body.late_chunking = this.late_chunking;
12237
+ }
12238
+ if (this.truncate) {
12239
+ json_body.truncate = this.truncate;
12240
+ }
12241
+ if (this.dimensions) {
12242
+ json_body.dimensions = this.dimensions;
12243
+ }
12244
+ if (this.embedding_type) {
12245
+ json_body.embedding_type = this.embedding_type;
12246
+ }
12247
+ if (this.normalized) {
12248
+ json_body.normalized = this.normalized;
12249
+ }
11844
12250
  try {
11845
12251
  const response = await fetch(this.api_url, {
11846
12252
  method: "POST",
11847
12253
  headers: this.headers,
11848
- body: JSON.stringify({
11849
- input: texts,
11850
- model: this.model_name
11851
- })
12254
+ body: JSON.stringify(json_body)
11852
12255
  });
11853
12256
  const data = await response.json();
11854
12257
  if (!data || !data.data) {
@@ -11868,13 +12271,25 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
11868
12271
  buildFromConfig(config) {
11869
12272
  return new _JinaEmbeddingFunction({
11870
12273
  model_name: config.model_name,
11871
- api_key_env_var: config.api_key_env_var
12274
+ api_key_env_var: config.api_key_env_var,
12275
+ task: config.task,
12276
+ late_chunking: config.late_chunking,
12277
+ truncate: config.truncate,
12278
+ dimensions: config.dimensions,
12279
+ embedding_type: config.embedding_type,
12280
+ normalized: config.normalized
11872
12281
  });
11873
12282
  }
11874
12283
  getConfig() {
11875
12284
  return {
11876
12285
  api_key_env_var: this.api_key_env_var,
11877
- model_name: this.model_name
12286
+ model_name: this.model_name,
12287
+ task: this.task,
12288
+ late_chunking: this.late_chunking,
12289
+ truncate: this.truncate,
12290
+ dimensions: this.dimensions,
12291
+ embedding_type: this.embedding_type,
12292
+ normalized: this.normalized
11878
12293
  };
11879
12294
  }
11880
12295
  validateConfig(config) {