chromadb 3.3.2 → 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.
@@ -757,7 +757,6 @@ declare const registerSparseEmbeddingFunction: (name: string, fn: SparseEmbeddin
757
757
  * @returns EmbeddingFunction instance or undefined if it cannot be constructed
758
758
  */
759
759
  declare const getEmbeddingFunction: (args: {
760
- collectionName: string;
761
760
  client: ChromaClient;
762
761
  efConfig?: EmbeddingFunctionConfiguration;
763
762
  }) => Promise<EmbeddingFunction | undefined>;
@@ -765,7 +764,7 @@ declare const getEmbeddingFunction: (args: {
765
764
  * Retrieves and instantiates a sparse embedding function from configuration.
766
765
  * @returns SparseEmbeddingFunction instance or undefined if it cannot be constructed
767
766
  */
768
- declare const getSparseEmbeddingFunction: (collectionName: string, client: ChromaClient, efConfig?: EmbeddingFunctionConfiguration) => Promise<SparseEmbeddingFunction | undefined>;
767
+ declare const getSparseEmbeddingFunction: (client: ChromaClient, efConfig?: EmbeddingFunctionConfiguration) => Promise<SparseEmbeddingFunction | undefined>;
769
768
  /**
770
769
  * Serializes an embedding function to configuration format.
771
770
  * @param embeddingFunction - User provided embedding function
@@ -1722,6 +1721,7 @@ interface Collection {
1722
1721
  /**
1723
1722
  * Performs hybrid search on the collection using expression builders.
1724
1723
  * @param searches - Single search payload or array of payloads
1724
+ * @param options
1725
1725
  * @returns Promise resolving to column-major search results
1726
1726
  */
1727
1727
  search(searches: SearchLike | SearchLike[], options?: {
@@ -1516,7 +1516,9 @@ var pythonEmbeddingFunctions = {
1516
1516
  default: "default-embed",
1517
1517
  together_ai: "together-ai",
1518
1518
  sentence_transformer: "sentence-transformer",
1519
+ google_gemini: "google-gemini",
1519
1520
  google_genai: "google-gemini"
1521
+ // Backward compatibility alias
1520
1522
  };
1521
1523
  var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
1522
1524
  "amazon_bedrock",
@@ -1555,32 +1557,11 @@ var registerSparseEmbeddingFunction = (name, fn) => {
1555
1557
  knownSparseEmbeddingFunctions.set(name, fn);
1556
1558
  };
1557
1559
  var getEmbeddingFunction = async (args) => {
1558
- const { collectionName, client: client2, efConfig } = args;
1559
- if (!efConfig) {
1560
- console.warn(
1561
- `No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1562
- );
1563
- return void 0;
1564
- }
1565
- if (efConfig.type === "legacy") {
1566
- console.warn(
1567
- `No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1568
- );
1569
- return void 0;
1570
- }
1571
- if (efConfig.type === "unknown") {
1572
- console.warn(
1573
- `Unknown embedding function configuration for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1574
- );
1575
- return void 0;
1576
- }
1577
- if (efConfig.type !== "known") {
1560
+ const { client: client2, efConfig } = args;
1561
+ if (efConfig?.type !== "known") {
1578
1562
  return void 0;
1579
1563
  }
1580
1564
  if (unsupportedEmbeddingFunctions.has(efConfig.name)) {
1581
- console.warn(
1582
- `Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly.`
1583
- );
1584
1565
  return void 0;
1585
1566
  }
1586
1567
  const packageName = pythonEmbeddingFunctions[efConfig.name] || efConfig.name;
@@ -1596,42 +1577,24 @@ var getEmbeddingFunction = async (args) => {
1596
1577
  } catch (error) {
1597
1578
  }
1598
1579
  if (!embeddingFunction) {
1599
- console.warn(
1600
- `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.`
1601
- );
1602
1580
  return void 0;
1603
1581
  }
1604
1582
  }
1605
- let constructorConfig = efConfig.type === "known" ? efConfig.config : {};
1583
+ const constructorConfig = efConfig.config ?? {};
1606
1584
  try {
1607
1585
  if (embeddingFunction.buildFromConfig) {
1608
1586
  return embeddingFunction.buildFromConfig(constructorConfig, client2);
1609
1587
  }
1610
- console.warn(
1611
- `Embedding function ${packageName} does not define a 'buildFromConfig' function. 'add' and 'query' will fail unless you provide them embeddings directly.`
1612
- );
1613
1588
  return void 0;
1614
1589
  } catch (e) {
1615
- console.warn(
1616
- `Embedding function ${packageName} failed to build with config: ${constructorConfig}. 'add' and 'query' will fail unless you provide them embeddings directly. Error: ${e}`
1617
- );
1618
1590
  return void 0;
1619
1591
  }
1620
1592
  };
1621
- var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
1622
- if (!efConfig) {
1623
- return void 0;
1624
- }
1625
- if (efConfig.type === "legacy") {
1626
- return void 0;
1627
- }
1628
- if (efConfig.type !== "known") {
1593
+ var getSparseEmbeddingFunction = async (client2, efConfig) => {
1594
+ if (efConfig?.type !== "known") {
1629
1595
  return void 0;
1630
1596
  }
1631
1597
  if (unsupportedSparseEmbeddingFunctions.has(efConfig.name)) {
1632
- console.warn(
1633
- "Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly."
1634
- );
1635
1598
  return void 0;
1636
1599
  }
1637
1600
  const packageName = pythonSparseEmbeddingFunctions[efConfig.name] || efConfig.name;
@@ -1644,25 +1607,16 @@ var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
1644
1607
  } catch (error) {
1645
1608
  }
1646
1609
  if (!sparseEmbeddingFunction) {
1647
- console.warn(
1648
- `Collection ${collectionName} was created with the ${packageName} sparse embedding function. However, the @chroma-core/${packageName} package is not installed.`
1649
- );
1650
1610
  return void 0;
1651
1611
  }
1652
1612
  }
1653
- let constructorConfig = efConfig.type === "known" ? efConfig.config : {};
1613
+ const constructorConfig = efConfig.config ?? {};
1654
1614
  try {
1655
1615
  if (sparseEmbeddingFunction.buildFromConfig) {
1656
1616
  return sparseEmbeddingFunction.buildFromConfig(constructorConfig, client2);
1657
1617
  }
1658
- console.warn(
1659
- `Sparse embedding function ${packageName} does not define a 'buildFromConfig' function.`
1660
- );
1661
1618
  return void 0;
1662
1619
  } catch (e) {
1663
- console.warn(
1664
- `Sparse embedding function ${packageName} failed to build with config: ${constructorConfig}. Error: ${e}`
1665
- );
1666
1620
  return void 0;
1667
1621
  }
1668
1622
  };
@@ -1788,7 +1742,6 @@ var processUpdateCollectionConfig = async ({
1788
1742
  );
1789
1743
  }
1790
1744
  const embeddingFunction = currentEmbeddingFunction || await getEmbeddingFunction({
1791
- collectionName,
1792
1745
  client: client2,
1793
1746
  efConfig: currentConfiguration.embeddingFunction ?? void 0
1794
1747
  });
@@ -3886,7 +3839,6 @@ var Schema = class _Schema {
3886
3839
  spann: json.spann ? cloneObject(json.spann) : null
3887
3840
  });
3888
3841
  config.embeddingFunction = await getEmbeddingFunction({
3889
- collectionName: "schema deserialization",
3890
3842
  client: client2,
3891
3843
  efConfig: json.embedding_function
3892
3844
  });
@@ -3901,7 +3853,6 @@ var Schema = class _Schema {
3901
3853
  bm25: typeof json.bm25 === "boolean" ? json.bm25 : null
3902
3854
  });
3903
3855
  const embeddingFunction = await getSparseEmbeddingFunction(
3904
- "schema deserialization",
3905
3856
  client2,
3906
3857
  json.embedding_function
3907
3858
  ) ?? config.embeddingFunction ?? void 0;
@@ -3987,7 +3938,7 @@ var CollectionImpl = class _CollectionImpl {
3987
3938
  const embeddingFunction = this._embeddingFunction ?? this.getSchemaEmbeddingFunction();
3988
3939
  if (!embeddingFunction) {
3989
3940
  throw new ChromaValueError(
3990
- "Embedding function must be defined for operations requiring embeddings."
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.`
3991
3942
  );
3992
3943
  }
3993
3944
  if (isQuery && embeddingFunction.generateForQueries) {
@@ -4048,10 +3999,8 @@ var CollectionImpl = class _CollectionImpl {
4048
3999
  }
4049
4000
  if (index < documentsList.length) {
4050
4001
  const doc = documentsList[index];
4051
- if (typeof doc === "string") {
4052
- inputs.push(doc);
4053
- positions.push(index);
4054
- }
4002
+ inputs.push(doc);
4003
+ positions.push(index);
4055
4004
  }
4056
4005
  });
4057
4006
  if (inputs.length === 0) {
@@ -4918,7 +4867,6 @@ var ChromaClient = class {
4918
4867
  );
4919
4868
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
4920
4869
  const resolvedEmbeddingFunction = await getEmbeddingFunction({
4921
- collectionName: collection.name,
4922
4870
  client: this,
4923
4871
  efConfig: collection.configuration_json.embedding_function ?? void 0
4924
4872
  }) ?? schemaEmbeddingFunction;
@@ -4988,7 +4936,6 @@ var ChromaClient = class {
4988
4936
  );
4989
4937
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
4990
4938
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
4991
- collectionName: data.name,
4992
4939
  client: this,
4993
4940
  efConfig: data.configuration_json.embedding_function ?? void 0
4994
4941
  }) ?? schemaEmbeddingFunction;
@@ -5024,7 +4971,6 @@ var ChromaClient = class {
5024
4971
  const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
5025
4972
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5026
4973
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5027
- collectionName: data.name,
5028
4974
  client: this,
5029
4975
  efConfig: data.configuration_json.embedding_function ?? void 0
5030
4976
  }) ?? schemaEmbeddingFunction;
@@ -5055,7 +5001,6 @@ var ChromaClient = class {
5055
5001
  const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
5056
5002
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5057
5003
  const resolvedEmbeddingFunction = await getEmbeddingFunction({
5058
- collectionName: data.name,
5059
5004
  efConfig: data.configuration_json.embedding_function ?? void 0,
5060
5005
  client: this
5061
5006
  }) ?? schemaEmbeddingFunction;
@@ -5131,7 +5076,6 @@ var ChromaClient = class {
5131
5076
  );
5132
5077
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
5133
5078
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5134
- collectionName: name,
5135
5079
  efConfig: data.configuration_json.embedding_function ?? void 0,
5136
5080
  client: this
5137
5081
  }) ?? schemaEmbeddingFunction;
package/dist/chromadb.mjs CHANGED
@@ -1516,7 +1516,9 @@ var pythonEmbeddingFunctions = {
1516
1516
  default: "default-embed",
1517
1517
  together_ai: "together-ai",
1518
1518
  sentence_transformer: "sentence-transformer",
1519
+ google_gemini: "google-gemini",
1519
1520
  google_genai: "google-gemini"
1521
+ // Backward compatibility alias
1520
1522
  };
1521
1523
  var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
1522
1524
  "amazon_bedrock",
@@ -1555,32 +1557,11 @@ var registerSparseEmbeddingFunction = (name, fn) => {
1555
1557
  knownSparseEmbeddingFunctions.set(name, fn);
1556
1558
  };
1557
1559
  var getEmbeddingFunction = async (args) => {
1558
- const { collectionName, client: client2, efConfig } = args;
1559
- if (!efConfig) {
1560
- console.warn(
1561
- `No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1562
- );
1563
- return void 0;
1564
- }
1565
- if (efConfig.type === "legacy") {
1566
- console.warn(
1567
- `No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1568
- );
1569
- return void 0;
1570
- }
1571
- if (efConfig.type === "unknown") {
1572
- console.warn(
1573
- `Unknown embedding function configuration for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1574
- );
1575
- return void 0;
1576
- }
1577
- if (efConfig.type !== "known") {
1560
+ const { client: client2, efConfig } = args;
1561
+ if (efConfig?.type !== "known") {
1578
1562
  return void 0;
1579
1563
  }
1580
1564
  if (unsupportedEmbeddingFunctions.has(efConfig.name)) {
1581
- console.warn(
1582
- `Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly.`
1583
- );
1584
1565
  return void 0;
1585
1566
  }
1586
1567
  const packageName = pythonEmbeddingFunctions[efConfig.name] || efConfig.name;
@@ -1596,42 +1577,24 @@ var getEmbeddingFunction = async (args) => {
1596
1577
  } catch (error) {
1597
1578
  }
1598
1579
  if (!embeddingFunction) {
1599
- console.warn(
1600
- `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.`
1601
- );
1602
1580
  return void 0;
1603
1581
  }
1604
1582
  }
1605
- let constructorConfig = efConfig.type === "known" ? efConfig.config : {};
1583
+ const constructorConfig = efConfig.config ?? {};
1606
1584
  try {
1607
1585
  if (embeddingFunction.buildFromConfig) {
1608
1586
  return embeddingFunction.buildFromConfig(constructorConfig, client2);
1609
1587
  }
1610
- console.warn(
1611
- `Embedding function ${packageName} does not define a 'buildFromConfig' function. 'add' and 'query' will fail unless you provide them embeddings directly.`
1612
- );
1613
1588
  return void 0;
1614
1589
  } catch (e) {
1615
- console.warn(
1616
- `Embedding function ${packageName} failed to build with config: ${constructorConfig}. 'add' and 'query' will fail unless you provide them embeddings directly. Error: ${e}`
1617
- );
1618
1590
  return void 0;
1619
1591
  }
1620
1592
  };
1621
- var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
1622
- if (!efConfig) {
1623
- return void 0;
1624
- }
1625
- if (efConfig.type === "legacy") {
1626
- return void 0;
1627
- }
1628
- if (efConfig.type !== "known") {
1593
+ var getSparseEmbeddingFunction = async (client2, efConfig) => {
1594
+ if (efConfig?.type !== "known") {
1629
1595
  return void 0;
1630
1596
  }
1631
1597
  if (unsupportedSparseEmbeddingFunctions.has(efConfig.name)) {
1632
- console.warn(
1633
- "Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly."
1634
- );
1635
1598
  return void 0;
1636
1599
  }
1637
1600
  const packageName = pythonSparseEmbeddingFunctions[efConfig.name] || efConfig.name;
@@ -1644,25 +1607,16 @@ var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
1644
1607
  } catch (error) {
1645
1608
  }
1646
1609
  if (!sparseEmbeddingFunction) {
1647
- console.warn(
1648
- `Collection ${collectionName} was created with the ${packageName} sparse embedding function. However, the @chroma-core/${packageName} package is not installed.`
1649
- );
1650
1610
  return void 0;
1651
1611
  }
1652
1612
  }
1653
- let constructorConfig = efConfig.type === "known" ? efConfig.config : {};
1613
+ const constructorConfig = efConfig.config ?? {};
1654
1614
  try {
1655
1615
  if (sparseEmbeddingFunction.buildFromConfig) {
1656
1616
  return sparseEmbeddingFunction.buildFromConfig(constructorConfig, client2);
1657
1617
  }
1658
- console.warn(
1659
- `Sparse embedding function ${packageName} does not define a 'buildFromConfig' function.`
1660
- );
1661
1618
  return void 0;
1662
1619
  } catch (e) {
1663
- console.warn(
1664
- `Sparse embedding function ${packageName} failed to build with config: ${constructorConfig}. Error: ${e}`
1665
- );
1666
1620
  return void 0;
1667
1621
  }
1668
1622
  };
@@ -1788,7 +1742,6 @@ var processUpdateCollectionConfig = async ({
1788
1742
  );
1789
1743
  }
1790
1744
  const embeddingFunction = currentEmbeddingFunction || await getEmbeddingFunction({
1791
- collectionName,
1792
1745
  client: client2,
1793
1746
  efConfig: currentConfiguration.embeddingFunction ?? void 0
1794
1747
  });
@@ -3886,7 +3839,6 @@ var Schema = class _Schema {
3886
3839
  spann: json.spann ? cloneObject(json.spann) : null
3887
3840
  });
3888
3841
  config.embeddingFunction = await getEmbeddingFunction({
3889
- collectionName: "schema deserialization",
3890
3842
  client: client2,
3891
3843
  efConfig: json.embedding_function
3892
3844
  });
@@ -3901,7 +3853,6 @@ var Schema = class _Schema {
3901
3853
  bm25: typeof json.bm25 === "boolean" ? json.bm25 : null
3902
3854
  });
3903
3855
  const embeddingFunction = await getSparseEmbeddingFunction(
3904
- "schema deserialization",
3905
3856
  client2,
3906
3857
  json.embedding_function
3907
3858
  ) ?? config.embeddingFunction ?? void 0;
@@ -3987,7 +3938,7 @@ var CollectionImpl = class _CollectionImpl {
3987
3938
  const embeddingFunction = this._embeddingFunction ?? this.getSchemaEmbeddingFunction();
3988
3939
  if (!embeddingFunction) {
3989
3940
  throw new ChromaValueError(
3990
- "Embedding function must be defined for operations requiring embeddings."
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.`
3991
3942
  );
3992
3943
  }
3993
3944
  if (isQuery && embeddingFunction.generateForQueries) {
@@ -4048,10 +3999,8 @@ var CollectionImpl = class _CollectionImpl {
4048
3999
  }
4049
4000
  if (index < documentsList.length) {
4050
4001
  const doc = documentsList[index];
4051
- if (typeof doc === "string") {
4052
- inputs.push(doc);
4053
- positions.push(index);
4054
- }
4002
+ inputs.push(doc);
4003
+ positions.push(index);
4055
4004
  }
4056
4005
  });
4057
4006
  if (inputs.length === 0) {
@@ -4918,7 +4867,6 @@ var ChromaClient = class {
4918
4867
  );
4919
4868
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
4920
4869
  const resolvedEmbeddingFunction = await getEmbeddingFunction({
4921
- collectionName: collection.name,
4922
4870
  client: this,
4923
4871
  efConfig: collection.configuration_json.embedding_function ?? void 0
4924
4872
  }) ?? schemaEmbeddingFunction;
@@ -4988,7 +4936,6 @@ var ChromaClient = class {
4988
4936
  );
4989
4937
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
4990
4938
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
4991
- collectionName: data.name,
4992
4939
  client: this,
4993
4940
  efConfig: data.configuration_json.embedding_function ?? void 0
4994
4941
  }) ?? schemaEmbeddingFunction;
@@ -5024,7 +4971,6 @@ var ChromaClient = class {
5024
4971
  const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
5025
4972
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5026
4973
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5027
- collectionName: data.name,
5028
4974
  client: this,
5029
4975
  efConfig: data.configuration_json.embedding_function ?? void 0
5030
4976
  }) ?? schemaEmbeddingFunction;
@@ -5055,7 +5001,6 @@ var ChromaClient = class {
5055
5001
  const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
5056
5002
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5057
5003
  const resolvedEmbeddingFunction = await getEmbeddingFunction({
5058
- collectionName: data.name,
5059
5004
  efConfig: data.configuration_json.embedding_function ?? void 0,
5060
5005
  client: this
5061
5006
  }) ?? schemaEmbeddingFunction;
@@ -5131,7 +5076,6 @@ var ChromaClient = class {
5131
5076
  );
5132
5077
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
5133
5078
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5134
- collectionName: name,
5135
5079
  efConfig: data.configuration_json.embedding_function ?? void 0,
5136
5080
  client: this
5137
5081
  }) ?? schemaEmbeddingFunction;