chromadb 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chromadb.d.ts +31 -9
- package/dist/chromadb.legacy-esm.js +63 -106
- package/dist/chromadb.mjs +63 -106
- package/dist/chromadb.mjs.map +1 -1
- package/dist/cjs/chromadb.cjs +63 -106
- package/dist/cjs/chromadb.cjs.map +1 -1
- package/dist/cjs/chromadb.d.cts +31 -9
- package/package.json +1 -1
- package/src/api/sdk.gen.ts +2 -2
- package/src/api/types.gen.ts +13 -3
- package/src/chroma-client.ts +0 -5
- package/src/collection-configuration.ts +0 -1
- package/src/collection.ts +48 -19
- package/src/embedding-function.ts +11 -67
- package/src/schema.ts +0 -16
- package/src/types.ts +6 -0
package/dist/chromadb.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ type Database = {
|
|
|
20
20
|
name: string;
|
|
21
21
|
tenant: string;
|
|
22
22
|
};
|
|
23
|
+
type DeleteCollectionRecordsResponse = {
|
|
24
|
+
deleted?: number;
|
|
25
|
+
};
|
|
23
26
|
type EmbeddingFunctionConfiguration = {
|
|
24
27
|
type: 'legacy';
|
|
25
28
|
} | (EmbeddingFunctionNewConfiguration & {
|
|
@@ -177,6 +180,10 @@ type IntValueType$1 = {
|
|
|
177
180
|
type Key$1 = 'Document' | 'Embedding' | 'Metadata' | 'Score' | {
|
|
178
181
|
MetadataField: string;
|
|
179
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* Quantization implementation for SPANN vector index.
|
|
185
|
+
*/
|
|
186
|
+
type Quantization = 'none' | 'four_bit_rabit_q_with_u_search';
|
|
180
187
|
/**
|
|
181
188
|
* Schema representation for collection index configurations
|
|
182
189
|
*
|
|
@@ -263,9 +270,9 @@ type SpannIndexConfig = {
|
|
|
263
270
|
num_centers_to_merge_to?: number | null;
|
|
264
271
|
num_samples_kmeans?: number | null;
|
|
265
272
|
/**
|
|
266
|
-
*
|
|
273
|
+
* Quantization implementation for vector search (cloud-only feature)
|
|
267
274
|
*/
|
|
268
|
-
quantize?:
|
|
275
|
+
quantize?: Quantization;
|
|
269
276
|
reassign_neighbor_count?: number | null;
|
|
270
277
|
search_nprobe?: number | null;
|
|
271
278
|
search_rng_epsilon?: number | null;
|
|
@@ -602,6 +609,10 @@ declare class QueryResult<TMeta extends Metadata = Metadata> {
|
|
|
602
609
|
*/
|
|
603
610
|
rows(): QueryRowResult<TMeta>[][];
|
|
604
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Result of a delete operation.
|
|
614
|
+
*/
|
|
615
|
+
type DeleteResult = DeleteCollectionRecordsResponse;
|
|
605
616
|
/**
|
|
606
617
|
* Re-export IndexStatusResponse type for external use
|
|
607
618
|
*/
|
|
@@ -746,7 +757,6 @@ declare const registerSparseEmbeddingFunction: (name: string, fn: SparseEmbeddin
|
|
|
746
757
|
* @returns EmbeddingFunction instance or undefined if it cannot be constructed
|
|
747
758
|
*/
|
|
748
759
|
declare const getEmbeddingFunction: (args: {
|
|
749
|
-
collectionName: string;
|
|
750
760
|
client: ChromaClient;
|
|
751
761
|
efConfig?: EmbeddingFunctionConfiguration;
|
|
752
762
|
}) => Promise<EmbeddingFunction | undefined>;
|
|
@@ -754,7 +764,7 @@ declare const getEmbeddingFunction: (args: {
|
|
|
754
764
|
* Retrieves and instantiates a sparse embedding function from configuration.
|
|
755
765
|
* @returns SparseEmbeddingFunction instance or undefined if it cannot be constructed
|
|
756
766
|
*/
|
|
757
|
-
declare const getSparseEmbeddingFunction: (
|
|
767
|
+
declare const getSparseEmbeddingFunction: (client: ChromaClient, efConfig?: EmbeddingFunctionConfiguration) => Promise<SparseEmbeddingFunction | undefined>;
|
|
758
768
|
/**
|
|
759
769
|
* Serializes an embedding function to configuration format.
|
|
760
770
|
* @param embeddingFunction - User provided embedding function
|
|
@@ -1274,7 +1284,6 @@ declare class Schema {
|
|
|
1274
1284
|
serializeToJSON(): Schema$1;
|
|
1275
1285
|
static deserializeFromJSON(json: Schema$1 | JsonDict | null, client: ChromaClient): Promise<Schema | undefined>;
|
|
1276
1286
|
private setVectorIndexConfig;
|
|
1277
|
-
private setFtsIndexConfig;
|
|
1278
1287
|
private setIndexInDefaults;
|
|
1279
1288
|
private setIndexForKey;
|
|
1280
1289
|
private enableAllIndexesForKey;
|
|
@@ -1563,8 +1572,18 @@ interface Collection {
|
|
|
1563
1572
|
embeddingFunction?: EmbeddingFunction;
|
|
1564
1573
|
/** Collection schema describing index configuration */
|
|
1565
1574
|
schema?: Schema;
|
|
1566
|
-
/**
|
|
1567
|
-
|
|
1575
|
+
/**
|
|
1576
|
+
* Gets the total number of records in the collection.
|
|
1577
|
+
* @param options - Optional settings
|
|
1578
|
+
*/
|
|
1579
|
+
count(options?: {
|
|
1580
|
+
/**
|
|
1581
|
+
* Controls whether to read from the write-ahead log.
|
|
1582
|
+
* - ReadLevel.INDEX_AND_WAL: Read from both index and WAL (default)
|
|
1583
|
+
* - ReadLevel.INDEX_ONLY: Read only from index, faster but recent writes may not be visible
|
|
1584
|
+
*/
|
|
1585
|
+
readLevel?: ReadLevel;
|
|
1586
|
+
}): Promise<number>;
|
|
1568
1587
|
/**
|
|
1569
1588
|
* Adds new records to the collection.
|
|
1570
1589
|
* @param args - Record data to add
|
|
@@ -1696,10 +1715,13 @@ interface Collection {
|
|
|
1696
1715
|
where?: Where;
|
|
1697
1716
|
/** Document content-based filtering for deletion */
|
|
1698
1717
|
whereDocument?: WhereDocument;
|
|
1699
|
-
|
|
1718
|
+
/** Maximum number of records to delete. Can only be used with where or whereDocument filters. */
|
|
1719
|
+
limit?: number;
|
|
1720
|
+
}): Promise<DeleteResult>;
|
|
1700
1721
|
/**
|
|
1701
1722
|
* Performs hybrid search on the collection using expression builders.
|
|
1702
1723
|
* @param searches - Single search payload or array of payloads
|
|
1724
|
+
* @param options
|
|
1703
1725
|
* @returns Promise resolving to column-major search results
|
|
1704
1726
|
*/
|
|
1705
1727
|
search(searches: SearchLike | SearchLike[], options?: {
|
|
@@ -1934,4 +1956,4 @@ declare class ChromaRateLimitError extends Error {
|
|
|
1934
1956
|
}
|
|
1935
1957
|
declare function createErrorByType(type: string, message: string): InvalidCollectionError | InvalidArgumentError | undefined;
|
|
1936
1958
|
|
|
1937
|
-
export { Abs, AdminClient, type AdminClientArgs, AdminCloudClient, Aggregate, type AggregateInput, type AggregateJSON, type AnyEmbeddingFunction, type BaseRecordSet, BoolInvertedIndexConfig, BoolInvertedIndexType, BoolValueType, ChromaClient, type ChromaClientArgs, ChromaClientError, ChromaConnectionError, ChromaError, ChromaForbiddenError, ChromaNotFoundError, ChromaQuotaExceededError, ChromaRateLimitError, ChromaServerError, ChromaUnauthorizedError, ChromaUniqueError, ChromaValueError, CloudClient, Cmek, CmekProvider, type Collection, type CollectionConfiguration, type CollectionMetadata, type CreateCollectionConfiguration, DOCUMENT_KEY, Div, EMBEDDING_KEY, type EmbeddingFunction, type EmbeddingFunctionClass, type EmbeddingFunctionSpace, Exp, FloatInvertedIndexConfig, FloatInvertedIndexType, FloatListValueType, FloatValueType, FtsIndexConfig, FtsIndexType, GetResult, GroupBy, type GroupByInput, type GroupByJSON, type HNSWConfiguration, IncludeEnum, type IndexConfig, type IndexingStatus, IntInvertedIndexConfig, IntInvertedIndexType, IntValueType, InvalidArgumentError, InvalidCollectionError, K, Key, type KeyFactory, Knn, type KnnOptions, Limit, type LimitInput, type LimitOptions, type ListDatabasesArgs, Log, Max, MaxK, type Metadata, type MetadataScalar, Min, MinK, Mul, type PreparedInsertRecordSet, type PreparedRecordSet, type QueryRecordSet, QueryResult, type QueryRowResult, RankExpression, type RankInput, type RankLiteral, ReadLevel, type RecordSet, Rrf, type RrfOptions, Schema, Search, type SearchInit, type SearchLike, SearchResult, type SearchResultRow, Select, type SelectInput, type SelectKeyInput, type SparseEmbeddingFunction, type SparseEmbeddingFunctionClass, type SparseVector, SparseVectorIndexConfig, type SparseVectorIndexConfigOptions, SparseVectorIndexType, SparseVectorValueType, StringInvertedIndexConfig, StringInvertedIndexType, StringValueType, Sub, Sum, type UpdateCollectionConfiguration, type UpdateHNSWConfiguration, type UpdateSPANNConfiguration, type UserIdentity, Val, ValueTypes, VectorIndexConfig, type VectorIndexConfigOptions, VectorIndexType, type Where, type WhereDocument, WhereExpression, type WhereInput, type WhereJSON, baseRecordSetFields, createErrorByType, getDefaultEFConfig, getEmbeddingFunction, getSparseEmbeddingFunction, knownEmbeddingFunctions, knownSparseEmbeddingFunctions, processCreateCollectionConfig, processUpdateCollectionConfig, recordSetFields, registerEmbeddingFunction, registerSparseEmbeddingFunction, serializeEmbeddingFunction, toSearch, withChroma };
|
|
1959
|
+
export { Abs, AdminClient, type AdminClientArgs, AdminCloudClient, Aggregate, type AggregateInput, type AggregateJSON, type AnyEmbeddingFunction, type BaseRecordSet, BoolInvertedIndexConfig, BoolInvertedIndexType, BoolValueType, ChromaClient, type ChromaClientArgs, ChromaClientError, ChromaConnectionError, ChromaError, ChromaForbiddenError, ChromaNotFoundError, ChromaQuotaExceededError, ChromaRateLimitError, ChromaServerError, ChromaUnauthorizedError, ChromaUniqueError, ChromaValueError, CloudClient, Cmek, CmekProvider, type Collection, type CollectionConfiguration, type CollectionMetadata, type CreateCollectionConfiguration, DOCUMENT_KEY, type DeleteResult, Div, EMBEDDING_KEY, type EmbeddingFunction, type EmbeddingFunctionClass, type EmbeddingFunctionSpace, Exp, FloatInvertedIndexConfig, FloatInvertedIndexType, FloatListValueType, FloatValueType, FtsIndexConfig, FtsIndexType, GetResult, GroupBy, type GroupByInput, type GroupByJSON, type HNSWConfiguration, IncludeEnum, type IndexConfig, type IndexingStatus, IntInvertedIndexConfig, IntInvertedIndexType, IntValueType, InvalidArgumentError, InvalidCollectionError, K, Key, type KeyFactory, Knn, type KnnOptions, Limit, type LimitInput, type LimitOptions, type ListDatabasesArgs, Log, Max, MaxK, type Metadata, type MetadataScalar, Min, MinK, Mul, type PreparedInsertRecordSet, type PreparedRecordSet, type QueryRecordSet, QueryResult, type QueryRowResult, RankExpression, type RankInput, type RankLiteral, ReadLevel, type RecordSet, Rrf, type RrfOptions, Schema, Search, type SearchInit, type SearchLike, SearchResult, type SearchResultRow, Select, type SelectInput, type SelectKeyInput, type SparseEmbeddingFunction, type SparseEmbeddingFunctionClass, type SparseVector, SparseVectorIndexConfig, type SparseVectorIndexConfigOptions, SparseVectorIndexType, SparseVectorValueType, StringInvertedIndexConfig, StringInvertedIndexType, StringValueType, Sub, Sum, type UpdateCollectionConfiguration, type UpdateHNSWConfiguration, type UpdateSPANNConfiguration, type UserIdentity, Val, ValueTypes, VectorIndexConfig, type VectorIndexConfigOptions, VectorIndexType, type Where, type WhereDocument, WhereExpression, type WhereInput, type WhereJSON, baseRecordSetFields, createErrorByType, getDefaultEFConfig, getEmbeddingFunction, getSparseEmbeddingFunction, knownEmbeddingFunctions, knownSparseEmbeddingFunctions, processCreateCollectionConfig, processUpdateCollectionConfig, recordSetFields, registerEmbeddingFunction, registerSparseEmbeddingFunction, serializeEmbeddingFunction, toSearch, withChroma };
|
|
@@ -1515,7 +1515,10 @@ var pythonEmbeddingFunctions = {
|
|
|
1515
1515
|
onnx_mini_lm_l6_v2: "default-embed",
|
|
1516
1516
|
default: "default-embed",
|
|
1517
1517
|
together_ai: "together-ai",
|
|
1518
|
-
sentence_transformer: "sentence-transformer"
|
|
1518
|
+
sentence_transformer: "sentence-transformer",
|
|
1519
|
+
google_gemini: "google-gemini",
|
|
1520
|
+
google_genai: "google-gemini"
|
|
1521
|
+
// Backward compatibility alias
|
|
1519
1522
|
};
|
|
1520
1523
|
var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
|
|
1521
1524
|
"amazon_bedrock",
|
|
@@ -1554,32 +1557,11 @@ var registerSparseEmbeddingFunction = (name, fn) => {
|
|
|
1554
1557
|
knownSparseEmbeddingFunctions.set(name, fn);
|
|
1555
1558
|
};
|
|
1556
1559
|
var getEmbeddingFunction = async (args) => {
|
|
1557
|
-
const {
|
|
1558
|
-
if (
|
|
1559
|
-
console.warn(
|
|
1560
|
-
`No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
1561
|
-
);
|
|
1562
|
-
return void 0;
|
|
1563
|
-
}
|
|
1564
|
-
if (efConfig.type === "legacy") {
|
|
1565
|
-
console.warn(
|
|
1566
|
-
`No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
1567
|
-
);
|
|
1568
|
-
return void 0;
|
|
1569
|
-
}
|
|
1570
|
-
if (efConfig.type === "unknown") {
|
|
1571
|
-
console.warn(
|
|
1572
|
-
`Unknown embedding function configuration for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
1573
|
-
);
|
|
1574
|
-
return void 0;
|
|
1575
|
-
}
|
|
1576
|
-
if (efConfig.type !== "known") {
|
|
1560
|
+
const { client: client2, efConfig } = args;
|
|
1561
|
+
if (efConfig?.type !== "known") {
|
|
1577
1562
|
return void 0;
|
|
1578
1563
|
}
|
|
1579
1564
|
if (unsupportedEmbeddingFunctions.has(efConfig.name)) {
|
|
1580
|
-
console.warn(
|
|
1581
|
-
`Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
1582
|
-
);
|
|
1583
1565
|
return void 0;
|
|
1584
1566
|
}
|
|
1585
1567
|
const packageName = pythonEmbeddingFunctions[efConfig.name] || efConfig.name;
|
|
@@ -1595,42 +1577,24 @@ var getEmbeddingFunction = async (args) => {
|
|
|
1595
1577
|
} catch (error) {
|
|
1596
1578
|
}
|
|
1597
1579
|
if (!embeddingFunction) {
|
|
1598
|
-
console.warn(
|
|
1599
|
-
`Collection ${collectionName} was created with the ${packageName} embedding function. However, the @chroma-core/${packageName} package is not installed. 'add' and 'query' will fail unless you provide them embeddings directly, or install the @chroma-core/${packageName} package.`
|
|
1600
|
-
);
|
|
1601
1580
|
return void 0;
|
|
1602
1581
|
}
|
|
1603
1582
|
}
|
|
1604
|
-
|
|
1583
|
+
const constructorConfig = efConfig.config ?? {};
|
|
1605
1584
|
try {
|
|
1606
1585
|
if (embeddingFunction.buildFromConfig) {
|
|
1607
1586
|
return embeddingFunction.buildFromConfig(constructorConfig, client2);
|
|
1608
1587
|
}
|
|
1609
|
-
console.warn(
|
|
1610
|
-
`Embedding function ${packageName} does not define a 'buildFromConfig' function. 'add' and 'query' will fail unless you provide them embeddings directly.`
|
|
1611
|
-
);
|
|
1612
1588
|
return void 0;
|
|
1613
1589
|
} catch (e) {
|
|
1614
|
-
console.warn(
|
|
1615
|
-
`Embedding function ${packageName} failed to build with config: ${constructorConfig}. 'add' and 'query' will fail unless you provide them embeddings directly. Error: ${e}`
|
|
1616
|
-
);
|
|
1617
1590
|
return void 0;
|
|
1618
1591
|
}
|
|
1619
1592
|
};
|
|
1620
|
-
var getSparseEmbeddingFunction = async (
|
|
1621
|
-
if (
|
|
1622
|
-
return void 0;
|
|
1623
|
-
}
|
|
1624
|
-
if (efConfig.type === "legacy") {
|
|
1625
|
-
return void 0;
|
|
1626
|
-
}
|
|
1627
|
-
if (efConfig.type !== "known") {
|
|
1593
|
+
var getSparseEmbeddingFunction = async (client2, efConfig) => {
|
|
1594
|
+
if (efConfig?.type !== "known") {
|
|
1628
1595
|
return void 0;
|
|
1629
1596
|
}
|
|
1630
1597
|
if (unsupportedSparseEmbeddingFunctions.has(efConfig.name)) {
|
|
1631
|
-
console.warn(
|
|
1632
|
-
"Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly."
|
|
1633
|
-
);
|
|
1634
1598
|
return void 0;
|
|
1635
1599
|
}
|
|
1636
1600
|
const packageName = pythonSparseEmbeddingFunctions[efConfig.name] || efConfig.name;
|
|
@@ -1643,25 +1607,16 @@ var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
|
|
|
1643
1607
|
} catch (error) {
|
|
1644
1608
|
}
|
|
1645
1609
|
if (!sparseEmbeddingFunction) {
|
|
1646
|
-
console.warn(
|
|
1647
|
-
`Collection ${collectionName} was created with the ${packageName} sparse embedding function. However, the @chroma-core/${packageName} package is not installed.`
|
|
1648
|
-
);
|
|
1649
1610
|
return void 0;
|
|
1650
1611
|
}
|
|
1651
1612
|
}
|
|
1652
|
-
|
|
1613
|
+
const constructorConfig = efConfig.config ?? {};
|
|
1653
1614
|
try {
|
|
1654
1615
|
if (sparseEmbeddingFunction.buildFromConfig) {
|
|
1655
1616
|
return sparseEmbeddingFunction.buildFromConfig(constructorConfig, client2);
|
|
1656
1617
|
}
|
|
1657
|
-
console.warn(
|
|
1658
|
-
`Sparse embedding function ${packageName} does not define a 'buildFromConfig' function.`
|
|
1659
|
-
);
|
|
1660
1618
|
return void 0;
|
|
1661
1619
|
} catch (e) {
|
|
1662
|
-
console.warn(
|
|
1663
|
-
`Sparse embedding function ${packageName} failed to build with config: ${constructorConfig}. Error: ${e}`
|
|
1664
|
-
);
|
|
1665
1620
|
return void 0;
|
|
1666
1621
|
}
|
|
1667
1622
|
};
|
|
@@ -1787,7 +1742,6 @@ var processUpdateCollectionConfig = async ({
|
|
|
1787
1742
|
);
|
|
1788
1743
|
}
|
|
1789
1744
|
const embeddingFunction = currentEmbeddingFunction || await getEmbeddingFunction({
|
|
1790
|
-
collectionName,
|
|
1791
1745
|
client: client2,
|
|
1792
1746
|
efConfig: currentConfiguration.embeddingFunction ?? void 0
|
|
1793
1747
|
});
|
|
@@ -3276,9 +3230,19 @@ var Schema = class _Schema {
|
|
|
3276
3230
|
"Cannot enable all index types globally. Must specify either config or key."
|
|
3277
3231
|
);
|
|
3278
3232
|
}
|
|
3279
|
-
if (keyProvided && key &&
|
|
3233
|
+
if (keyProvided && key && key === EMBEDDING_KEY) {
|
|
3280
3234
|
throw new Error(
|
|
3281
|
-
`Cannot create index on special key '${key}'.
|
|
3235
|
+
`Cannot create index on special key '${key}'. This key is managed automatically by the system. Invoke createIndex(new VectorIndexConfig(...)) without specifying a key to configure the vector index globally.`
|
|
3236
|
+
);
|
|
3237
|
+
}
|
|
3238
|
+
if (keyProvided && key === DOCUMENT_KEY && !(config instanceof FtsIndexConfig)) {
|
|
3239
|
+
throw new Error(
|
|
3240
|
+
`Cannot create index on special key '${key}' with this config. Only FtsIndexConfig is allowed for #document.`
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
if (keyProvided && key && key.startsWith("#") && key !== DOCUMENT_KEY) {
|
|
3244
|
+
throw new Error(
|
|
3245
|
+
"key cannot begin with '#'. Keys starting with '#' are reserved for system use."
|
|
3282
3246
|
);
|
|
3283
3247
|
}
|
|
3284
3248
|
if (config instanceof VectorIndexConfig) {
|
|
@@ -3287,21 +3251,17 @@ var Schema = class _Schema {
|
|
|
3287
3251
|
return this;
|
|
3288
3252
|
}
|
|
3289
3253
|
throw new Error(
|
|
3290
|
-
"Vector index cannot be enabled on specific keys. Use createIndex(
|
|
3254
|
+
"Vector index cannot be enabled on specific keys. Use createIndex(new VectorIndexConfig(...)) without specifying a key to configure the vector index globally."
|
|
3291
3255
|
);
|
|
3292
3256
|
}
|
|
3293
|
-
if (config instanceof FtsIndexConfig) {
|
|
3294
|
-
if (!keyProvided) {
|
|
3295
|
-
this.setFtsIndexConfig(config);
|
|
3296
|
-
return this;
|
|
3297
|
-
}
|
|
3257
|
+
if (config instanceof FtsIndexConfig && (!keyProvided || key !== DOCUMENT_KEY)) {
|
|
3298
3258
|
throw new Error(
|
|
3299
|
-
"FTS index
|
|
3259
|
+
"FTS index can only be enabled on #document key. Use createIndex(new FtsIndexConfig(), '#document')"
|
|
3300
3260
|
);
|
|
3301
3261
|
}
|
|
3302
3262
|
if (config instanceof SparseVectorIndexConfig && !keyProvided) {
|
|
3303
3263
|
throw new Error(
|
|
3304
|
-
"Sparse vector index must be created on a specific key. Please specify a key using: createIndex(
|
|
3264
|
+
"Sparse vector index must be created on a specific key. Please specify a key using: createIndex(new SparseVectorIndexConfig(...), 'your_key')"
|
|
3305
3265
|
);
|
|
3306
3266
|
}
|
|
3307
3267
|
if (!configProvided && keyProvided && key) {
|
|
@@ -3324,22 +3284,32 @@ var Schema = class _Schema {
|
|
|
3324
3284
|
"Cannot disable all indexes. Must specify either config or key."
|
|
3325
3285
|
);
|
|
3326
3286
|
}
|
|
3327
|
-
if (keyProvided && key &&
|
|
3287
|
+
if (keyProvided && key && key === EMBEDDING_KEY) {
|
|
3288
|
+
throw new Error(
|
|
3289
|
+
"Cannot modify #embedding. Currently not supported"
|
|
3290
|
+
);
|
|
3291
|
+
}
|
|
3292
|
+
if (keyProvided && key === DOCUMENT_KEY && !(config instanceof FtsIndexConfig)) {
|
|
3293
|
+
throw new Error(
|
|
3294
|
+
`Cannot delete index on special key '${key}' with this config. Only FtsIndexConfig is allowed for #document.`
|
|
3295
|
+
);
|
|
3296
|
+
}
|
|
3297
|
+
if (keyProvided && key && key.startsWith("#") && key !== DOCUMENT_KEY) {
|
|
3328
3298
|
throw new Error(
|
|
3329
|
-
|
|
3299
|
+
"key cannot begin with '#'. Keys starting with '#' are reserved for system use."
|
|
3330
3300
|
);
|
|
3331
3301
|
}
|
|
3332
3302
|
if (config instanceof VectorIndexConfig) {
|
|
3333
3303
|
throw new Error("Deleting vector index is not currently supported.");
|
|
3334
3304
|
}
|
|
3335
|
-
if (config instanceof FtsIndexConfig) {
|
|
3336
|
-
throw new Error("Deleting FTS index is not currently supported.");
|
|
3337
|
-
}
|
|
3338
3305
|
if (config instanceof SparseVectorIndexConfig) {
|
|
3339
3306
|
throw new Error(
|
|
3340
3307
|
"Deleting sparse vector index is not currently supported."
|
|
3341
3308
|
);
|
|
3342
3309
|
}
|
|
3310
|
+
if (config instanceof FtsIndexConfig && (!keyProvided || key !== DOCUMENT_KEY)) {
|
|
3311
|
+
throw new Error("Deleting FTS index is only supported on #document key.");
|
|
3312
|
+
}
|
|
3343
3313
|
if (keyProvided && !configProvided && key) {
|
|
3344
3314
|
throw new Error(
|
|
3345
3315
|
`Cannot disable all index types for key '${key}'. Please specify a specific index configuration.`
|
|
@@ -3423,22 +3393,6 @@ var Schema = class _Schema {
|
|
|
3423
3393
|
})
|
|
3424
3394
|
);
|
|
3425
3395
|
}
|
|
3426
|
-
setFtsIndexConfig(config) {
|
|
3427
|
-
const defaultsString = ensureStringValueType(this.defaults);
|
|
3428
|
-
const currentDefaultsFts = defaultsString.ftsIndex ?? new FtsIndexType(false, new FtsIndexConfig());
|
|
3429
|
-
defaultsString.ftsIndex = new FtsIndexType(
|
|
3430
|
-
currentDefaultsFts.enabled,
|
|
3431
|
-
config
|
|
3432
|
-
);
|
|
3433
|
-
const documentValueTypes = ensureValueTypes(this.keys[DOCUMENT_KEY]);
|
|
3434
|
-
this.keys[DOCUMENT_KEY] = documentValueTypes;
|
|
3435
|
-
const overrideString = ensureStringValueType(documentValueTypes);
|
|
3436
|
-
const currentOverrideFts = overrideString.ftsIndex ?? new FtsIndexType(true, new FtsIndexConfig());
|
|
3437
|
-
overrideString.ftsIndex = new FtsIndexType(
|
|
3438
|
-
currentOverrideFts.enabled,
|
|
3439
|
-
config
|
|
3440
|
-
);
|
|
3441
|
-
}
|
|
3442
3396
|
setIndexInDefaults(config, enabled) {
|
|
3443
3397
|
if (config instanceof FtsIndexConfig) {
|
|
3444
3398
|
const valueType = ensureStringValueType(this.defaults);
|
|
@@ -3885,7 +3839,6 @@ var Schema = class _Schema {
|
|
|
3885
3839
|
spann: json.spann ? cloneObject(json.spann) : null
|
|
3886
3840
|
});
|
|
3887
3841
|
config.embeddingFunction = await getEmbeddingFunction({
|
|
3888
|
-
collectionName: "schema deserialization",
|
|
3889
3842
|
client: client2,
|
|
3890
3843
|
efConfig: json.embedding_function
|
|
3891
3844
|
});
|
|
@@ -3900,7 +3853,6 @@ var Schema = class _Schema {
|
|
|
3900
3853
|
bm25: typeof json.bm25 === "boolean" ? json.bm25 : null
|
|
3901
3854
|
});
|
|
3902
3855
|
const embeddingFunction = await getSparseEmbeddingFunction(
|
|
3903
|
-
"schema deserialization",
|
|
3904
3856
|
client2,
|
|
3905
3857
|
json.embedding_function
|
|
3906
3858
|
) ?? config.embeddingFunction ?? void 0;
|
|
@@ -3986,7 +3938,7 @@ var CollectionImpl = class _CollectionImpl {
|
|
|
3986
3938
|
const embeddingFunction = this._embeddingFunction ?? this.getSchemaEmbeddingFunction();
|
|
3987
3939
|
if (!embeddingFunction) {
|
|
3988
3940
|
throw new ChromaValueError(
|
|
3989
|
-
|
|
3941
|
+
`No embedding function found for collection '${this._name}'. You can either provide embeddings directly, or ensure the appropriate embedding function package (e.g. @chroma-core/default-embed) is installed.`
|
|
3990
3942
|
);
|
|
3991
3943
|
}
|
|
3992
3944
|
if (isQuery && embeddingFunction.generateForQueries) {
|
|
@@ -4047,10 +3999,8 @@ var CollectionImpl = class _CollectionImpl {
|
|
|
4047
3999
|
}
|
|
4048
4000
|
if (index < documentsList.length) {
|
|
4049
4001
|
const doc = documentsList[index];
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
positions.push(index);
|
|
4053
|
-
}
|
|
4002
|
+
inputs.push(doc);
|
|
4003
|
+
positions.push(index);
|
|
4054
4004
|
}
|
|
4055
4005
|
});
|
|
4056
4006
|
if (inputs.length === 0) {
|
|
@@ -4263,15 +4213,24 @@ var CollectionImpl = class _CollectionImpl {
|
|
|
4263
4213
|
embeddings
|
|
4264
4214
|
};
|
|
4265
4215
|
}
|
|
4266
|
-
validateDelete(ids, where, whereDocument) {
|
|
4216
|
+
validateDelete(ids, where, whereDocument, limit) {
|
|
4267
4217
|
if (ids) validateIDs(ids);
|
|
4268
4218
|
if (where) validateWhere(where);
|
|
4269
4219
|
if (whereDocument) validateWhereDocument(whereDocument);
|
|
4220
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit < 0)) {
|
|
4221
|
+
throw new Error("limit must be a non-negative integer");
|
|
4222
|
+
}
|
|
4223
|
+
if (limit !== void 0 && !where && !whereDocument) {
|
|
4224
|
+
throw new Error(
|
|
4225
|
+
"limit can only be specified when a where or whereDocument clause is provided"
|
|
4226
|
+
);
|
|
4227
|
+
}
|
|
4270
4228
|
}
|
|
4271
|
-
async count() {
|
|
4229
|
+
async count(options) {
|
|
4272
4230
|
const { data } = await RecordService.collectionCount({
|
|
4273
4231
|
client: this.apiClient,
|
|
4274
|
-
path: await this.path()
|
|
4232
|
+
path: await this.path(),
|
|
4233
|
+
query: options?.readLevel ? { read_level: options.readLevel } : void 0
|
|
4275
4234
|
});
|
|
4276
4235
|
return data;
|
|
4277
4236
|
}
|
|
@@ -4523,18 +4482,21 @@ var CollectionImpl = class _CollectionImpl {
|
|
|
4523
4482
|
async delete({
|
|
4524
4483
|
ids,
|
|
4525
4484
|
where,
|
|
4526
|
-
whereDocument
|
|
4485
|
+
whereDocument,
|
|
4486
|
+
limit
|
|
4527
4487
|
}) {
|
|
4528
|
-
this.validateDelete(ids, where, whereDocument);
|
|
4529
|
-
await RecordService.collectionDelete({
|
|
4488
|
+
this.validateDelete(ids, where, whereDocument, limit);
|
|
4489
|
+
const { data } = await RecordService.collectionDelete({
|
|
4530
4490
|
client: this.apiClient,
|
|
4531
4491
|
path: await this.path(),
|
|
4532
4492
|
body: {
|
|
4533
4493
|
ids,
|
|
4534
4494
|
where,
|
|
4535
|
-
where_document: whereDocument
|
|
4495
|
+
where_document: whereDocument,
|
|
4496
|
+
limit
|
|
4536
4497
|
}
|
|
4537
4498
|
});
|
|
4499
|
+
return { deleted: data?.deleted ?? 0 };
|
|
4538
4500
|
}
|
|
4539
4501
|
async getIndexingStatus() {
|
|
4540
4502
|
const { data } = await RecordService.indexingStatus({
|
|
@@ -4905,7 +4867,6 @@ var ChromaClient = class {
|
|
|
4905
4867
|
);
|
|
4906
4868
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
4907
4869
|
const resolvedEmbeddingFunction = await getEmbeddingFunction({
|
|
4908
|
-
collectionName: collection.name,
|
|
4909
4870
|
client: this,
|
|
4910
4871
|
efConfig: collection.configuration_json.embedding_function ?? void 0
|
|
4911
4872
|
}) ?? schemaEmbeddingFunction;
|
|
@@ -4975,7 +4936,6 @@ var ChromaClient = class {
|
|
|
4975
4936
|
);
|
|
4976
4937
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
|
|
4977
4938
|
const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
|
|
4978
|
-
collectionName: data.name,
|
|
4979
4939
|
client: this,
|
|
4980
4940
|
efConfig: data.configuration_json.embedding_function ?? void 0
|
|
4981
4941
|
}) ?? schemaEmbeddingFunction;
|
|
@@ -5011,7 +4971,6 @@ var ChromaClient = class {
|
|
|
5011
4971
|
const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
|
|
5012
4972
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
5013
4973
|
const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
|
|
5014
|
-
collectionName: data.name,
|
|
5015
4974
|
client: this,
|
|
5016
4975
|
efConfig: data.configuration_json.embedding_function ?? void 0
|
|
5017
4976
|
}) ?? schemaEmbeddingFunction;
|
|
@@ -5042,7 +5001,6 @@ var ChromaClient = class {
|
|
|
5042
5001
|
const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
|
|
5043
5002
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
|
|
5044
5003
|
const resolvedEmbeddingFunction = await getEmbeddingFunction({
|
|
5045
|
-
collectionName: data.name,
|
|
5046
5004
|
efConfig: data.configuration_json.embedding_function ?? void 0,
|
|
5047
5005
|
client: this
|
|
5048
5006
|
}) ?? schemaEmbeddingFunction;
|
|
@@ -5118,7 +5076,6 @@ var ChromaClient = class {
|
|
|
5118
5076
|
);
|
|
5119
5077
|
const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
|
|
5120
5078
|
const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
|
|
5121
|
-
collectionName: name,
|
|
5122
5079
|
efConfig: data.configuration_json.embedding_function ?? void 0,
|
|
5123
5080
|
client: this
|
|
5124
5081
|
}) ?? schemaEmbeddingFunction;
|