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.
- package/README.md +7 -4
- package/dist/chromadb.d.ts +626 -515
- package/dist/chromadb.legacy-esm.js +446 -31
- package/dist/chromadb.mjs +446 -31
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +446 -31
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +626 -515
- package/dist/cjs/cli.cjs +5 -5
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/cli.mjs.map +1 -1
- package/package.json +2 -2
- package/src/bindings.ts +18 -16
- package/src/browser-entry.js +2 -3
- package/src/cli.ts +19 -22
- package/src/index.ts +1 -1
- package/src/punycode-shim.js +2 -2
package/dist/chromadb.mjs
CHANGED
|
@@ -6772,7 +6772,7 @@ var require_ajv = __commonJS({
|
|
|
6772
6772
|
});
|
|
6773
6773
|
|
|
6774
6774
|
// ../chromadb-core/package.json
|
|
6775
|
-
var version = "2.
|
|
6775
|
+
var version = "2.3.0";
|
|
6776
6776
|
|
|
6777
6777
|
// ../chromadb-core/src/generated/runtime.ts
|
|
6778
6778
|
import "isomorphic-fetch";
|
|
@@ -7504,6 +7504,67 @@ var ApiApiFetchParamCreator = function(configuration) {
|
|
|
7504
7504
|
options: localVarRequestOptions
|
|
7505
7505
|
};
|
|
7506
7506
|
},
|
|
7507
|
+
/**
|
|
7508
|
+
* @summary Forks an existing collection.
|
|
7509
|
+
* @param {string} tenant <p>Tenant ID</p>
|
|
7510
|
+
* @param {string} database <p>Database name</p>
|
|
7511
|
+
* @param {string} collectionId <p>UUID of the collection to update</p>
|
|
7512
|
+
* @param {Api.ForkCollectionPayload} request
|
|
7513
|
+
* @param {RequestInit} [options] Override http request option.
|
|
7514
|
+
* @throws {RequiredError}
|
|
7515
|
+
*/
|
|
7516
|
+
forkCollection(tenant, database, collectionId, request, options = {}) {
|
|
7517
|
+
if (tenant === null || tenant === void 0) {
|
|
7518
|
+
throw new RequiredError(
|
|
7519
|
+
"tenant",
|
|
7520
|
+
"Required parameter tenant was null or undefined when calling forkCollection."
|
|
7521
|
+
);
|
|
7522
|
+
}
|
|
7523
|
+
if (database === null || database === void 0) {
|
|
7524
|
+
throw new RequiredError(
|
|
7525
|
+
"database",
|
|
7526
|
+
"Required parameter database was null or undefined when calling forkCollection."
|
|
7527
|
+
);
|
|
7528
|
+
}
|
|
7529
|
+
if (collectionId === null || collectionId === void 0) {
|
|
7530
|
+
throw new RequiredError(
|
|
7531
|
+
"collectionId",
|
|
7532
|
+
"Required parameter collectionId was null or undefined when calling forkCollection."
|
|
7533
|
+
);
|
|
7534
|
+
}
|
|
7535
|
+
if (request === null || request === void 0) {
|
|
7536
|
+
throw new RequiredError(
|
|
7537
|
+
"request",
|
|
7538
|
+
"Required parameter request was null or undefined when calling forkCollection."
|
|
7539
|
+
);
|
|
7540
|
+
}
|
|
7541
|
+
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)));
|
|
7542
|
+
const localVarPathQueryStart = localVarPath.indexOf("?");
|
|
7543
|
+
const localVarRequestOptions = Object.assign(
|
|
7544
|
+
{ method: "POST" },
|
|
7545
|
+
options
|
|
7546
|
+
);
|
|
7547
|
+
const localVarHeaderParameter = options.headers ? new Headers(options.headers) : new Headers();
|
|
7548
|
+
const localVarQueryParameter = new URLSearchParams(
|
|
7549
|
+
localVarPathQueryStart !== -1 ? localVarPath.substring(localVarPathQueryStart + 1) : ""
|
|
7550
|
+
);
|
|
7551
|
+
if (localVarPathQueryStart !== -1) {
|
|
7552
|
+
localVarPath = localVarPath.substring(0, localVarPathQueryStart);
|
|
7553
|
+
}
|
|
7554
|
+
localVarHeaderParameter.set("Content-Type", "application/json");
|
|
7555
|
+
localVarRequestOptions.headers = localVarHeaderParameter;
|
|
7556
|
+
if (request !== void 0) {
|
|
7557
|
+
localVarRequestOptions.body = JSON.stringify(request || {});
|
|
7558
|
+
}
|
|
7559
|
+
const localVarQueryParameterString = localVarQueryParameter.toString();
|
|
7560
|
+
if (localVarQueryParameterString) {
|
|
7561
|
+
localVarPath += "?" + localVarQueryParameterString;
|
|
7562
|
+
}
|
|
7563
|
+
return {
|
|
7564
|
+
url: localVarPath,
|
|
7565
|
+
options: localVarRequestOptions
|
|
7566
|
+
};
|
|
7567
|
+
},
|
|
7507
7568
|
/**
|
|
7508
7569
|
* @summary Retrieves a collection by ID or name.
|
|
7509
7570
|
* @param {string} tenant <p>Tenant ID</p>
|
|
@@ -8541,6 +8602,54 @@ var ApiApiFp = function(configuration) {
|
|
|
8541
8602
|
});
|
|
8542
8603
|
};
|
|
8543
8604
|
},
|
|
8605
|
+
/**
|
|
8606
|
+
* @summary Forks an existing collection.
|
|
8607
|
+
* @param {string} tenant <p>Tenant ID</p>
|
|
8608
|
+
* @param {string} database <p>Database name</p>
|
|
8609
|
+
* @param {string} collectionId <p>UUID of the collection to update</p>
|
|
8610
|
+
* @param {Api.ForkCollectionPayload} request
|
|
8611
|
+
* @param {RequestInit} [options] Override http request option.
|
|
8612
|
+
* @throws {RequiredError}
|
|
8613
|
+
*/
|
|
8614
|
+
forkCollection(tenant, database, collectionId, request, options) {
|
|
8615
|
+
const localVarFetchArgs = ApiApiFetchParamCreator(
|
|
8616
|
+
configuration
|
|
8617
|
+
).forkCollection(tenant, database, collectionId, request, options);
|
|
8618
|
+
return (fetch2 = defaultFetch, basePath = BASE_PATH) => {
|
|
8619
|
+
return fetch2(
|
|
8620
|
+
basePath + localVarFetchArgs.url,
|
|
8621
|
+
localVarFetchArgs.options
|
|
8622
|
+
).then((response) => {
|
|
8623
|
+
const contentType = response.headers.get("Content-Type");
|
|
8624
|
+
const mimeType = contentType ? contentType.replace(/;.*/, "") : void 0;
|
|
8625
|
+
if (response.status === 200) {
|
|
8626
|
+
if (mimeType === "application/json") {
|
|
8627
|
+
return response.json();
|
|
8628
|
+
}
|
|
8629
|
+
throw response;
|
|
8630
|
+
}
|
|
8631
|
+
if (response.status === 401) {
|
|
8632
|
+
if (mimeType === "application/json") {
|
|
8633
|
+
throw response;
|
|
8634
|
+
}
|
|
8635
|
+
throw response;
|
|
8636
|
+
}
|
|
8637
|
+
if (response.status === 404) {
|
|
8638
|
+
if (mimeType === "application/json") {
|
|
8639
|
+
throw response;
|
|
8640
|
+
}
|
|
8641
|
+
throw response;
|
|
8642
|
+
}
|
|
8643
|
+
if (response.status === 500) {
|
|
8644
|
+
if (mimeType === "application/json") {
|
|
8645
|
+
throw response;
|
|
8646
|
+
}
|
|
8647
|
+
throw response;
|
|
8648
|
+
}
|
|
8649
|
+
throw response;
|
|
8650
|
+
});
|
|
8651
|
+
};
|
|
8652
|
+
},
|
|
8544
8653
|
/**
|
|
8545
8654
|
* @summary Retrieves a collection by ID or name.
|
|
8546
8655
|
* @param {string} tenant <p>Tenant ID</p>
|
|
@@ -9207,6 +9316,24 @@ var ApiApi = class extends BaseAPI {
|
|
|
9207
9316
|
options
|
|
9208
9317
|
)(this.fetch, this.basePath);
|
|
9209
9318
|
}
|
|
9319
|
+
/**
|
|
9320
|
+
* @summary Forks an existing collection.
|
|
9321
|
+
* @param {string} tenant <p>Tenant ID</p>
|
|
9322
|
+
* @param {string} database <p>Database name</p>
|
|
9323
|
+
* @param {string} collectionId <p>UUID of the collection to update</p>
|
|
9324
|
+
* @param {Api.ForkCollectionPayload} request
|
|
9325
|
+
* @param {RequestInit} [options] Override http request option.
|
|
9326
|
+
* @throws {RequiredError}
|
|
9327
|
+
*/
|
|
9328
|
+
forkCollection(tenant, database, collectionId, request, options) {
|
|
9329
|
+
return ApiApiFp(this.configuration).forkCollection(
|
|
9330
|
+
tenant,
|
|
9331
|
+
database,
|
|
9332
|
+
collectionId,
|
|
9333
|
+
request,
|
|
9334
|
+
options
|
|
9335
|
+
)(this.fetch, this.basePath);
|
|
9336
|
+
}
|
|
9210
9337
|
/**
|
|
9211
9338
|
* @summary Retrieves a collection by ID or name.
|
|
9212
9339
|
* @param {string} tenant <p>Tenant ID</p>
|
|
@@ -9371,7 +9498,7 @@ var ApiApi = class extends BaseAPI {
|
|
|
9371
9498
|
|
|
9372
9499
|
// ../chromadb-core/src/generated/models.ts
|
|
9373
9500
|
var Api;
|
|
9374
|
-
((
|
|
9501
|
+
((Api3) => {
|
|
9375
9502
|
let EmbeddingFunctionConfiguration;
|
|
9376
9503
|
((EmbeddingFunctionConfiguration2) => {
|
|
9377
9504
|
let ObjectValue;
|
|
@@ -9388,13 +9515,13 @@ var Api;
|
|
|
9388
9515
|
TypeEnum2["Known"] = "known";
|
|
9389
9516
|
})(TypeEnum = AllofValue2.TypeEnum || (AllofValue2.TypeEnum = {}));
|
|
9390
9517
|
})(AllofValue = EmbeddingFunctionConfiguration2.AllofValue || (EmbeddingFunctionConfiguration2.AllofValue = {}));
|
|
9391
|
-
})(EmbeddingFunctionConfiguration =
|
|
9518
|
+
})(EmbeddingFunctionConfiguration = Api3.EmbeddingFunctionConfiguration || (Api3.EmbeddingFunctionConfiguration = {}));
|
|
9392
9519
|
let HnswSpace;
|
|
9393
9520
|
((HnswSpace2) => {
|
|
9394
9521
|
HnswSpace2["L2"] = "l2";
|
|
9395
9522
|
HnswSpace2["Cosine"] = "cosine";
|
|
9396
9523
|
HnswSpace2["Ip"] = "ip";
|
|
9397
|
-
})(HnswSpace =
|
|
9524
|
+
})(HnswSpace = Api3.HnswSpace || (Api3.HnswSpace = {}));
|
|
9398
9525
|
let Include;
|
|
9399
9526
|
((Include2) => {
|
|
9400
9527
|
Include2["Distances"] = "distances";
|
|
@@ -9402,7 +9529,7 @@ var Api;
|
|
|
9402
9529
|
Include2["Embeddings"] = "embeddings";
|
|
9403
9530
|
Include2["Metadatas"] = "metadatas";
|
|
9404
9531
|
Include2["Uris"] = "uris";
|
|
9405
|
-
})(Include =
|
|
9532
|
+
})(Include = Api3.Include || (Api3.Include = {}));
|
|
9406
9533
|
})(Api || (Api = {}));
|
|
9407
9534
|
|
|
9408
9535
|
// ../chromadb-core/src/generated/configuration.ts
|
|
@@ -9505,17 +9632,135 @@ function createErrorByType(type, message) {
|
|
|
9505
9632
|
}
|
|
9506
9633
|
}
|
|
9507
9634
|
|
|
9635
|
+
// ../chromadb-core/src/CollectionConfiguration.ts
|
|
9636
|
+
var InvalidConfigurationError = class extends Error {
|
|
9637
|
+
constructor(message) {
|
|
9638
|
+
super(message);
|
|
9639
|
+
this.name = "InvalidConfigurationError";
|
|
9640
|
+
}
|
|
9641
|
+
};
|
|
9642
|
+
function serializeEmbeddingFunction(ef) {
|
|
9643
|
+
let efConfig = null;
|
|
9644
|
+
if (ef === null || ef === void 0) {
|
|
9645
|
+
efConfig = { type: "legacy" };
|
|
9646
|
+
} else {
|
|
9647
|
+
try {
|
|
9648
|
+
if (ef.getConfig && ef.name) {
|
|
9649
|
+
if (ef.validateConfig) {
|
|
9650
|
+
ef.validateConfig(ef.getConfig());
|
|
9651
|
+
}
|
|
9652
|
+
efConfig = {
|
|
9653
|
+
name: ef.name,
|
|
9654
|
+
type: "known",
|
|
9655
|
+
config: ef.getConfig()
|
|
9656
|
+
};
|
|
9657
|
+
} else {
|
|
9658
|
+
console.warn(
|
|
9659
|
+
"Could not serialize embedding function - missing getConfig or name method."
|
|
9660
|
+
);
|
|
9661
|
+
efConfig = { type: "legacy" };
|
|
9662
|
+
}
|
|
9663
|
+
} catch (e) {
|
|
9664
|
+
console.warn(
|
|
9665
|
+
"Error processing embedding function for serialization, falling back to legacy:",
|
|
9666
|
+
e,
|
|
9667
|
+
"DeprecationWarning"
|
|
9668
|
+
);
|
|
9669
|
+
efConfig = { type: "legacy" };
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
return efConfig;
|
|
9673
|
+
}
|
|
9674
|
+
function loadApiCollectionConfigurationFromCreateCollectionConfiguration(config) {
|
|
9675
|
+
return createCollectionConfigurationToJson(
|
|
9676
|
+
config
|
|
9677
|
+
);
|
|
9678
|
+
}
|
|
9679
|
+
function createCollectionConfigurationToJson(config) {
|
|
9680
|
+
if (config.hnsw && config.spann) {
|
|
9681
|
+
throw new InvalidConfigurationError(
|
|
9682
|
+
"Cannot specify both 'hnsw' and 'spann' configurations during creation."
|
|
9683
|
+
);
|
|
9684
|
+
}
|
|
9685
|
+
let hnswConfig = config.hnsw;
|
|
9686
|
+
let spannConfig = config.spann;
|
|
9687
|
+
let ef = config.embedding_function;
|
|
9688
|
+
let efConfig = serializeEmbeddingFunction(ef);
|
|
9689
|
+
if (hnswConfig && typeof hnswConfig !== "object") {
|
|
9690
|
+
throw new Error(
|
|
9691
|
+
"Invalid HNSW config provided in CreateCollectionConfiguration"
|
|
9692
|
+
);
|
|
9693
|
+
}
|
|
9694
|
+
if (spannConfig && typeof spannConfig !== "object") {
|
|
9695
|
+
throw new Error(
|
|
9696
|
+
"Invalid SPANN config provided in CreateCollectionConfiguration"
|
|
9697
|
+
);
|
|
9698
|
+
}
|
|
9699
|
+
return {
|
|
9700
|
+
hnsw: hnswConfig,
|
|
9701
|
+
spann: spannConfig,
|
|
9702
|
+
embedding_function: efConfig
|
|
9703
|
+
};
|
|
9704
|
+
}
|
|
9705
|
+
function updateCollectionConfigurationToJson(config) {
|
|
9706
|
+
if (config.hnsw && config.spann) {
|
|
9707
|
+
throw new InvalidConfigurationError(
|
|
9708
|
+
"Cannot specify both 'hnsw' and 'spann' configurations during update."
|
|
9709
|
+
);
|
|
9710
|
+
}
|
|
9711
|
+
let hnswConfig = config.hnsw;
|
|
9712
|
+
let spannConfig = config.spann;
|
|
9713
|
+
let ef = config.embedding_function;
|
|
9714
|
+
let efConfig = void 0;
|
|
9715
|
+
if (hnswConfig) {
|
|
9716
|
+
if (typeof hnswConfig !== "object") {
|
|
9717
|
+
throw new Error(
|
|
9718
|
+
"Invalid HNSW config provided in UpdateCollectionConfiguration"
|
|
9719
|
+
);
|
|
9720
|
+
}
|
|
9721
|
+
}
|
|
9722
|
+
if (spannConfig) {
|
|
9723
|
+
if (typeof spannConfig !== "object") {
|
|
9724
|
+
throw new Error(
|
|
9725
|
+
"Invalid SPANN config provided in UpdateCollectionConfiguration"
|
|
9726
|
+
);
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
if (ef !== void 0) {
|
|
9730
|
+
efConfig = serializeEmbeddingFunction(ef);
|
|
9731
|
+
}
|
|
9732
|
+
const result = {};
|
|
9733
|
+
if (hnswConfig !== void 0)
|
|
9734
|
+
result.hnsw = hnswConfig;
|
|
9735
|
+
if (spannConfig !== void 0)
|
|
9736
|
+
result.spann = spannConfig;
|
|
9737
|
+
if (efConfig !== void 0)
|
|
9738
|
+
result.embedding_function = efConfig;
|
|
9739
|
+
if (Object.keys(result).length === 0) {
|
|
9740
|
+
throw new InvalidConfigurationError(
|
|
9741
|
+
"No valid configuration fields provided for update."
|
|
9742
|
+
);
|
|
9743
|
+
}
|
|
9744
|
+
return result;
|
|
9745
|
+
}
|
|
9746
|
+
function loadApiUpdateCollectionConfigurationFromUpdateCollectionConfiguration(config) {
|
|
9747
|
+
return updateCollectionConfigurationToJson(
|
|
9748
|
+
config
|
|
9749
|
+
);
|
|
9750
|
+
}
|
|
9751
|
+
|
|
9508
9752
|
// ../chromadb-core/src/Collection.ts
|
|
9509
|
-
var Collection = class {
|
|
9753
|
+
var Collection = class _Collection {
|
|
9510
9754
|
/**
|
|
9511
9755
|
* @ignore
|
|
9512
9756
|
*/
|
|
9513
|
-
constructor(name, id, client, embeddingFunction, metadata) {
|
|
9757
|
+
constructor(name, id, client, embeddingFunction, metadata, configuration) {
|
|
9514
9758
|
this.name = name;
|
|
9515
9759
|
this.id = id;
|
|
9516
9760
|
this.metadata = metadata;
|
|
9517
9761
|
this.client = client;
|
|
9518
9762
|
this.embeddingFunction = embeddingFunction;
|
|
9763
|
+
this.configuration = configuration;
|
|
9519
9764
|
}
|
|
9520
9765
|
/**
|
|
9521
9766
|
* Add items to the collection
|
|
@@ -9648,7 +9893,14 @@ var Collection = class {
|
|
|
9648
9893
|
},
|
|
9649
9894
|
this.client.api.options
|
|
9650
9895
|
);
|
|
9651
|
-
|
|
9896
|
+
const finalResp = {
|
|
9897
|
+
...resp,
|
|
9898
|
+
metadatas: resp.metadatas,
|
|
9899
|
+
documents: resp.documents,
|
|
9900
|
+
embeddings: resp.embeddings,
|
|
9901
|
+
included: resp.include
|
|
9902
|
+
};
|
|
9903
|
+
return finalResp;
|
|
9652
9904
|
}
|
|
9653
9905
|
/**
|
|
9654
9906
|
* Update items in the collection
|
|
@@ -9747,7 +9999,15 @@ var Collection = class {
|
|
|
9747
9999
|
},
|
|
9748
10000
|
this.client.api.options
|
|
9749
10001
|
);
|
|
9750
|
-
|
|
10002
|
+
const finalResp = {
|
|
10003
|
+
...resp,
|
|
10004
|
+
metadatas: resp.metadatas,
|
|
10005
|
+
documents: resp.documents,
|
|
10006
|
+
embeddings: resp.embeddings,
|
|
10007
|
+
distances: resp.distances,
|
|
10008
|
+
included: resp.include
|
|
10009
|
+
};
|
|
10010
|
+
return finalResp;
|
|
9751
10011
|
}
|
|
9752
10012
|
/**
|
|
9753
10013
|
* Modify the collection name or metadata
|
|
@@ -9766,16 +10026,24 @@ var Collection = class {
|
|
|
9766
10026
|
*/
|
|
9767
10027
|
async modify({
|
|
9768
10028
|
name,
|
|
9769
|
-
metadata
|
|
10029
|
+
metadata,
|
|
10030
|
+
configuration
|
|
9770
10031
|
}) {
|
|
9771
10032
|
await this.client.init();
|
|
10033
|
+
let updateCollectionConfiguration = void 0;
|
|
10034
|
+
if (configuration) {
|
|
10035
|
+
updateCollectionConfiguration = loadApiUpdateCollectionConfigurationFromUpdateCollectionConfiguration(
|
|
10036
|
+
configuration
|
|
10037
|
+
);
|
|
10038
|
+
}
|
|
9772
10039
|
const resp = await this.client.api.updateCollection(
|
|
9773
10040
|
this.client.tenant,
|
|
9774
10041
|
this.client.database,
|
|
9775
10042
|
this.id,
|
|
9776
10043
|
{
|
|
9777
10044
|
new_name: name,
|
|
9778
|
-
new_metadata: metadata
|
|
10045
|
+
new_metadata: metadata,
|
|
10046
|
+
new_configuration: updateCollectionConfiguration
|
|
9779
10047
|
},
|
|
9780
10048
|
this.client.api.options
|
|
9781
10049
|
);
|
|
@@ -9850,6 +10118,42 @@ var Collection = class {
|
|
|
9850
10118
|
this.client.api.options
|
|
9851
10119
|
);
|
|
9852
10120
|
}
|
|
10121
|
+
/**
|
|
10122
|
+
* Forks the collection into a new collection with a new name and configuration.
|
|
10123
|
+
*
|
|
10124
|
+
* @param {Object} params - The parameters for forking the collection.
|
|
10125
|
+
* @param {string} params.newName - The name for the new forked collection.
|
|
10126
|
+
*
|
|
10127
|
+
* @returns {Promise<Collection>} A promise that resolves to the new forked Collection object.
|
|
10128
|
+
* @throws {Error} If there is an issue forking the collection.
|
|
10129
|
+
*
|
|
10130
|
+
* @example
|
|
10131
|
+
* ```typescript
|
|
10132
|
+
* const newCollection = await collection.fork({
|
|
10133
|
+
* newName: "my_forked_collection",
|
|
10134
|
+
* });
|
|
10135
|
+
* ```
|
|
10136
|
+
*/
|
|
10137
|
+
async fork({ newName }) {
|
|
10138
|
+
await this.client.init();
|
|
10139
|
+
const resp = await this.client.api.forkCollection(
|
|
10140
|
+
this.client.tenant,
|
|
10141
|
+
this.client.database,
|
|
10142
|
+
this.id,
|
|
10143
|
+
{
|
|
10144
|
+
new_name: newName
|
|
10145
|
+
},
|
|
10146
|
+
this.client.api.options
|
|
10147
|
+
);
|
|
10148
|
+
const newCollection = new _Collection(
|
|
10149
|
+
resp.name,
|
|
10150
|
+
resp.id,
|
|
10151
|
+
this.client,
|
|
10152
|
+
this.embeddingFunction,
|
|
10153
|
+
resp.metadata
|
|
10154
|
+
);
|
|
10155
|
+
return newCollection;
|
|
10156
|
+
}
|
|
9853
10157
|
};
|
|
9854
10158
|
|
|
9855
10159
|
// ../chromadb-core/src/utils.ts
|
|
@@ -9934,6 +10238,9 @@ async function prepareRecordRequest(reqParams, embeddingFunction, update) {
|
|
|
9934
10238
|
`ID's must be unique, found duplicates for: ${duplicateIds}`
|
|
9935
10239
|
);
|
|
9936
10240
|
}
|
|
10241
|
+
if (embeddingsArray && embeddingsArray.some((embedding) => embedding.length === 0)) {
|
|
10242
|
+
throw new Error("got empty embedding at pos");
|
|
10243
|
+
}
|
|
9937
10244
|
return {
|
|
9938
10245
|
ids,
|
|
9939
10246
|
metadatas,
|
|
@@ -9947,7 +10254,8 @@ function wrapCollection(api, collection) {
|
|
|
9947
10254
|
collection.id,
|
|
9948
10255
|
api,
|
|
9949
10256
|
collection.embeddingFunction,
|
|
9950
|
-
collection.metadata
|
|
10257
|
+
collection.metadata,
|
|
10258
|
+
collection.configuration
|
|
9951
10259
|
);
|
|
9952
10260
|
}
|
|
9953
10261
|
|
|
@@ -10614,6 +10922,30 @@ var jina_default = {
|
|
|
10614
10922
|
api_key_env_var: {
|
|
10615
10923
|
type: "string",
|
|
10616
10924
|
description: "Parameter api_key_env_var for the jina embedding function"
|
|
10925
|
+
},
|
|
10926
|
+
task: {
|
|
10927
|
+
type: "string",
|
|
10928
|
+
description: "Parameter task for the jina embedding function"
|
|
10929
|
+
},
|
|
10930
|
+
late_chunking: {
|
|
10931
|
+
type: "boolean",
|
|
10932
|
+
description: "Parameter late_chunking for the jina embedding function"
|
|
10933
|
+
},
|
|
10934
|
+
truncate: {
|
|
10935
|
+
type: "boolean",
|
|
10936
|
+
description: "Parameter truncate for the jina embedding function"
|
|
10937
|
+
},
|
|
10938
|
+
dimensions: {
|
|
10939
|
+
type: "integer",
|
|
10940
|
+
description: "Parameter dimensions for the jina embedding function"
|
|
10941
|
+
},
|
|
10942
|
+
embedding_type: {
|
|
10943
|
+
type: "string",
|
|
10944
|
+
description: "Parameter embedding_type for the jina embedding function"
|
|
10945
|
+
},
|
|
10946
|
+
normalized: {
|
|
10947
|
+
type: "boolean",
|
|
10948
|
+
description: "Parameter normalized for the jina embedding function"
|
|
10617
10949
|
}
|
|
10618
10950
|
},
|
|
10619
10951
|
required: [
|
|
@@ -10965,7 +11297,9 @@ function getSchemaVersion(schemaName) {
|
|
|
10965
11297
|
return schema.version || "1.0.0";
|
|
10966
11298
|
}
|
|
10967
11299
|
function getAvailableSchemas() {
|
|
10968
|
-
return Object.keys(schemaMap).filter(
|
|
11300
|
+
return Object.keys(schemaMap).filter(
|
|
11301
|
+
(name) => name !== "base_schema"
|
|
11302
|
+
);
|
|
10969
11303
|
}
|
|
10970
11304
|
function getSchemaInfo() {
|
|
10971
11305
|
const schemaInfo = {};
|
|
@@ -11084,6 +11418,7 @@ var DefaultEmbeddingFunction = class _DefaultEmbeddingFunction {
|
|
|
11084
11418
|
};
|
|
11085
11419
|
|
|
11086
11420
|
// ../chromadb-core/src/ChromaClient.ts
|
|
11421
|
+
import { warn } from "console";
|
|
11087
11422
|
var DEFAULT_TENANT2 = "default_tenant";
|
|
11088
11423
|
var DEFAULT_DATABASE2 = "default_database";
|
|
11089
11424
|
var ChromaClient = class {
|
|
@@ -11236,26 +11571,40 @@ var ChromaClient = class {
|
|
|
11236
11571
|
async createCollection({
|
|
11237
11572
|
name,
|
|
11238
11573
|
metadata,
|
|
11239
|
-
embeddingFunction = new DefaultEmbeddingFunction()
|
|
11574
|
+
embeddingFunction = new DefaultEmbeddingFunction(),
|
|
11575
|
+
configuration
|
|
11240
11576
|
}) {
|
|
11241
11577
|
await this.init();
|
|
11578
|
+
let collectionConfiguration = void 0;
|
|
11579
|
+
if (configuration) {
|
|
11580
|
+
collectionConfiguration = loadApiCollectionConfigurationFromCreateCollectionConfiguration(
|
|
11581
|
+
configuration
|
|
11582
|
+
);
|
|
11583
|
+
}
|
|
11242
11584
|
const newCollection = await this.api.createCollection(
|
|
11243
11585
|
this.tenant,
|
|
11244
11586
|
this.database,
|
|
11245
11587
|
{
|
|
11246
11588
|
name,
|
|
11247
|
-
|
|
11248
|
-
configuration: null,
|
|
11249
|
-
//TODO: Configuration type in JavaScript
|
|
11589
|
+
configuration: collectionConfiguration,
|
|
11250
11590
|
metadata
|
|
11251
11591
|
},
|
|
11252
11592
|
this.api.options
|
|
11253
11593
|
);
|
|
11594
|
+
let config = {};
|
|
11595
|
+
try {
|
|
11596
|
+
config = newCollection.configuration_json;
|
|
11597
|
+
} catch {
|
|
11598
|
+
warn(
|
|
11599
|
+
"Server does not respond with configuration_json. Please update server"
|
|
11600
|
+
);
|
|
11601
|
+
}
|
|
11254
11602
|
return wrapCollection(this, {
|
|
11255
11603
|
name: newCollection.name,
|
|
11256
11604
|
id: newCollection.id,
|
|
11257
11605
|
metadata: newCollection.metadata,
|
|
11258
|
-
embeddingFunction
|
|
11606
|
+
embeddingFunction,
|
|
11607
|
+
configuration: config
|
|
11259
11608
|
});
|
|
11260
11609
|
}
|
|
11261
11610
|
/**
|
|
@@ -11282,27 +11631,41 @@ var ChromaClient = class {
|
|
|
11282
11631
|
async getOrCreateCollection({
|
|
11283
11632
|
name,
|
|
11284
11633
|
metadata,
|
|
11285
|
-
embeddingFunction = new DefaultEmbeddingFunction()
|
|
11634
|
+
embeddingFunction = new DefaultEmbeddingFunction(),
|
|
11635
|
+
configuration
|
|
11286
11636
|
}) {
|
|
11287
11637
|
await this.init();
|
|
11638
|
+
let collectionConfiguration = void 0;
|
|
11639
|
+
if (configuration) {
|
|
11640
|
+
collectionConfiguration = loadApiCollectionConfigurationFromCreateCollectionConfiguration(
|
|
11641
|
+
configuration
|
|
11642
|
+
);
|
|
11643
|
+
}
|
|
11288
11644
|
const newCollection = await this.api.createCollection(
|
|
11289
11645
|
this.tenant,
|
|
11290
11646
|
this.database,
|
|
11291
11647
|
{
|
|
11292
11648
|
name,
|
|
11293
|
-
|
|
11294
|
-
configuration: null,
|
|
11295
|
-
//TODO: Configuration type in JavaScript
|
|
11649
|
+
configuration: collectionConfiguration,
|
|
11296
11650
|
metadata,
|
|
11297
11651
|
get_or_create: true
|
|
11298
11652
|
},
|
|
11299
11653
|
this.api.options
|
|
11300
11654
|
);
|
|
11655
|
+
let config = {};
|
|
11656
|
+
try {
|
|
11657
|
+
config = newCollection.configuration_json;
|
|
11658
|
+
} catch {
|
|
11659
|
+
warn(
|
|
11660
|
+
"Server does not respond with configuration_json. Please update server"
|
|
11661
|
+
);
|
|
11662
|
+
}
|
|
11301
11663
|
return wrapCollection(this, {
|
|
11302
11664
|
name: newCollection.name,
|
|
11303
11665
|
id: newCollection.id,
|
|
11304
11666
|
metadata: newCollection.metadata,
|
|
11305
|
-
embeddingFunction
|
|
11667
|
+
embeddingFunction,
|
|
11668
|
+
configuration: config
|
|
11306
11669
|
});
|
|
11307
11670
|
}
|
|
11308
11671
|
/**
|
|
@@ -11407,11 +11770,20 @@ var ChromaClient = class {
|
|
|
11407
11770
|
name,
|
|
11408
11771
|
this.api.options
|
|
11409
11772
|
);
|
|
11773
|
+
let config = {};
|
|
11774
|
+
try {
|
|
11775
|
+
config = response.configuration_json;
|
|
11776
|
+
} catch {
|
|
11777
|
+
warn(
|
|
11778
|
+
"Server does not respond with configuration_json. Please update server"
|
|
11779
|
+
);
|
|
11780
|
+
}
|
|
11410
11781
|
return wrapCollection(this, {
|
|
11411
11782
|
id: response.id,
|
|
11412
11783
|
name: response.name,
|
|
11413
11784
|
metadata: response.metadata,
|
|
11414
|
-
embeddingFunction: embeddingFunction !== void 0 ? embeddingFunction : new DefaultEmbeddingFunction()
|
|
11785
|
+
embeddingFunction: embeddingFunction !== void 0 ? embeddingFunction : new DefaultEmbeddingFunction(),
|
|
11786
|
+
configuration: config
|
|
11415
11787
|
});
|
|
11416
11788
|
}
|
|
11417
11789
|
/**
|
|
@@ -11758,7 +12130,13 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
|
|
|
11758
12130
|
constructor({
|
|
11759
12131
|
jinaai_api_key,
|
|
11760
12132
|
model_name = "jina-embeddings-v2-base-en",
|
|
11761
|
-
api_key_env_var = "JINAAI_API_KEY"
|
|
12133
|
+
api_key_env_var = "JINAAI_API_KEY",
|
|
12134
|
+
task,
|
|
12135
|
+
late_chunking,
|
|
12136
|
+
truncate,
|
|
12137
|
+
dimensions,
|
|
12138
|
+
embedding_type,
|
|
12139
|
+
normalized
|
|
11762
12140
|
}) {
|
|
11763
12141
|
this.name = "jina";
|
|
11764
12142
|
const apiKey = jinaai_api_key ?? process.env[api_key_env_var];
|
|
@@ -11769,6 +12147,12 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
|
|
|
11769
12147
|
}
|
|
11770
12148
|
this.model_name = model_name;
|
|
11771
12149
|
this.api_key_env_var = api_key_env_var;
|
|
12150
|
+
this.task = task;
|
|
12151
|
+
this.late_chunking = late_chunking;
|
|
12152
|
+
this.truncate = truncate;
|
|
12153
|
+
this.dimensions = dimensions;
|
|
12154
|
+
this.embedding_type = embedding_type;
|
|
12155
|
+
this.normalized = normalized;
|
|
11772
12156
|
this.api_url = "https://api.jina.ai/v1/embeddings";
|
|
11773
12157
|
this.headers = {
|
|
11774
12158
|
Authorization: `Bearer ${jinaai_api_key}`,
|
|
@@ -11777,14 +12161,33 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
|
|
|
11777
12161
|
};
|
|
11778
12162
|
}
|
|
11779
12163
|
async generate(texts) {
|
|
12164
|
+
let json_body = {
|
|
12165
|
+
input: texts,
|
|
12166
|
+
model: this.model_name
|
|
12167
|
+
};
|
|
12168
|
+
if (this.task) {
|
|
12169
|
+
json_body.task = this.task;
|
|
12170
|
+
}
|
|
12171
|
+
if (this.late_chunking) {
|
|
12172
|
+
json_body.late_chunking = this.late_chunking;
|
|
12173
|
+
}
|
|
12174
|
+
if (this.truncate) {
|
|
12175
|
+
json_body.truncate = this.truncate;
|
|
12176
|
+
}
|
|
12177
|
+
if (this.dimensions) {
|
|
12178
|
+
json_body.dimensions = this.dimensions;
|
|
12179
|
+
}
|
|
12180
|
+
if (this.embedding_type) {
|
|
12181
|
+
json_body.embedding_type = this.embedding_type;
|
|
12182
|
+
}
|
|
12183
|
+
if (this.normalized) {
|
|
12184
|
+
json_body.normalized = this.normalized;
|
|
12185
|
+
}
|
|
11780
12186
|
try {
|
|
11781
12187
|
const response = await fetch(this.api_url, {
|
|
11782
12188
|
method: "POST",
|
|
11783
12189
|
headers: this.headers,
|
|
11784
|
-
body: JSON.stringify(
|
|
11785
|
-
input: texts,
|
|
11786
|
-
model: this.model_name
|
|
11787
|
-
})
|
|
12190
|
+
body: JSON.stringify(json_body)
|
|
11788
12191
|
});
|
|
11789
12192
|
const data = await response.json();
|
|
11790
12193
|
if (!data || !data.data) {
|
|
@@ -11804,13 +12207,25 @@ var JinaEmbeddingFunction = class _JinaEmbeddingFunction {
|
|
|
11804
12207
|
buildFromConfig(config) {
|
|
11805
12208
|
return new _JinaEmbeddingFunction({
|
|
11806
12209
|
model_name: config.model_name,
|
|
11807
|
-
api_key_env_var: config.api_key_env_var
|
|
12210
|
+
api_key_env_var: config.api_key_env_var,
|
|
12211
|
+
task: config.task,
|
|
12212
|
+
late_chunking: config.late_chunking,
|
|
12213
|
+
truncate: config.truncate,
|
|
12214
|
+
dimensions: config.dimensions,
|
|
12215
|
+
embedding_type: config.embedding_type,
|
|
12216
|
+
normalized: config.normalized
|
|
11808
12217
|
});
|
|
11809
12218
|
}
|
|
11810
12219
|
getConfig() {
|
|
11811
12220
|
return {
|
|
11812
12221
|
api_key_env_var: this.api_key_env_var,
|
|
11813
|
-
model_name: this.model_name
|
|
12222
|
+
model_name: this.model_name,
|
|
12223
|
+
task: this.task,
|
|
12224
|
+
late_chunking: this.late_chunking,
|
|
12225
|
+
truncate: this.truncate,
|
|
12226
|
+
dimensions: this.dimensions,
|
|
12227
|
+
embedding_type: this.embedding_type,
|
|
12228
|
+
normalized: this.normalized
|
|
11814
12229
|
};
|
|
11815
12230
|
}
|
|
11816
12231
|
validateConfig(config) {
|