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.
@@ -1635,7 +1635,9 @@ var pythonEmbeddingFunctions = {
1635
1635
  default: "default-embed",
1636
1636
  together_ai: "together-ai",
1637
1637
  sentence_transformer: "sentence-transformer",
1638
+ google_gemini: "google-gemini",
1638
1639
  google_genai: "google-gemini"
1640
+ // Backward compatibility alias
1639
1641
  };
1640
1642
  var unsupportedEmbeddingFunctions = /* @__PURE__ */ new Set([
1641
1643
  "amazon_bedrock",
@@ -1674,32 +1676,11 @@ var registerSparseEmbeddingFunction = (name, fn) => {
1674
1676
  knownSparseEmbeddingFunctions.set(name, fn);
1675
1677
  };
1676
1678
  var getEmbeddingFunction = async (args) => {
1677
- const { collectionName, client: client2, efConfig } = args;
1678
- if (!efConfig) {
1679
- console.warn(
1680
- `No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1681
- );
1682
- return void 0;
1683
- }
1684
- if (efConfig.type === "legacy") {
1685
- console.warn(
1686
- `No embedding function configuration found for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1687
- );
1688
- return void 0;
1689
- }
1690
- if (efConfig.type === "unknown") {
1691
- console.warn(
1692
- `Unknown embedding function configuration for collection ${collectionName}. 'add' and 'query' will fail unless you provide them embeddings directly.`
1693
- );
1694
- return void 0;
1695
- }
1696
- if (efConfig.type !== "known") {
1679
+ const { client: client2, efConfig } = args;
1680
+ if (efConfig?.type !== "known") {
1697
1681
  return void 0;
1698
1682
  }
1699
1683
  if (unsupportedEmbeddingFunctions.has(efConfig.name)) {
1700
- console.warn(
1701
- `Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly.`
1702
- );
1703
1684
  return void 0;
1704
1685
  }
1705
1686
  const packageName = pythonEmbeddingFunctions[efConfig.name] || efConfig.name;
@@ -1715,42 +1696,24 @@ var getEmbeddingFunction = async (args) => {
1715
1696
  } catch (error) {
1716
1697
  }
1717
1698
  if (!embeddingFunction) {
1718
- console.warn(
1719
- `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.`
1720
- );
1721
1699
  return void 0;
1722
1700
  }
1723
1701
  }
1724
- let constructorConfig = efConfig.type === "known" ? efConfig.config : {};
1702
+ const constructorConfig = efConfig.config ?? {};
1725
1703
  try {
1726
1704
  if (embeddingFunction.buildFromConfig) {
1727
1705
  return embeddingFunction.buildFromConfig(constructorConfig, client2);
1728
1706
  }
1729
- console.warn(
1730
- `Embedding function ${packageName} does not define a 'buildFromConfig' function. 'add' and 'query' will fail unless you provide them embeddings directly.`
1731
- );
1732
1707
  return void 0;
1733
1708
  } catch (e) {
1734
- console.warn(
1735
- `Embedding function ${packageName} failed to build with config: ${constructorConfig}. 'add' and 'query' will fail unless you provide them embeddings directly. Error: ${e}`
1736
- );
1737
1709
  return void 0;
1738
1710
  }
1739
1711
  };
1740
- var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
1741
- if (!efConfig) {
1742
- return void 0;
1743
- }
1744
- if (efConfig.type === "legacy") {
1745
- return void 0;
1746
- }
1747
- if (efConfig.type !== "known") {
1712
+ var getSparseEmbeddingFunction = async (client2, efConfig) => {
1713
+ if (efConfig?.type !== "known") {
1748
1714
  return void 0;
1749
1715
  }
1750
1716
  if (unsupportedSparseEmbeddingFunctions.has(efConfig.name)) {
1751
- console.warn(
1752
- "Embedding function ${efConfig.name} is not supported in the JS/TS SDK. 'add' and 'query' will fail unless you provide them embeddings directly."
1753
- );
1754
1717
  return void 0;
1755
1718
  }
1756
1719
  const packageName = pythonSparseEmbeddingFunctions[efConfig.name] || efConfig.name;
@@ -1763,25 +1726,16 @@ var getSparseEmbeddingFunction = async (collectionName, client2, efConfig) => {
1763
1726
  } catch (error) {
1764
1727
  }
1765
1728
  if (!sparseEmbeddingFunction) {
1766
- console.warn(
1767
- `Collection ${collectionName} was created with the ${packageName} sparse embedding function. However, the @chroma-core/${packageName} package is not installed.`
1768
- );
1769
1729
  return void 0;
1770
1730
  }
1771
1731
  }
1772
- let constructorConfig = efConfig.type === "known" ? efConfig.config : {};
1732
+ const constructorConfig = efConfig.config ?? {};
1773
1733
  try {
1774
1734
  if (sparseEmbeddingFunction.buildFromConfig) {
1775
1735
  return sparseEmbeddingFunction.buildFromConfig(constructorConfig, client2);
1776
1736
  }
1777
- console.warn(
1778
- `Sparse embedding function ${packageName} does not define a 'buildFromConfig' function.`
1779
- );
1780
1737
  return void 0;
1781
1738
  } catch (e) {
1782
- console.warn(
1783
- `Sparse embedding function ${packageName} failed to build with config: ${constructorConfig}. Error: ${e}`
1784
- );
1785
1739
  return void 0;
1786
1740
  }
1787
1741
  };
@@ -1907,7 +1861,6 @@ var processUpdateCollectionConfig = async ({
1907
1861
  );
1908
1862
  }
1909
1863
  const embeddingFunction = currentEmbeddingFunction || await getEmbeddingFunction({
1910
- collectionName,
1911
1864
  client: client2,
1912
1865
  efConfig: currentConfiguration.embeddingFunction ?? void 0
1913
1866
  });
@@ -4005,7 +3958,6 @@ var Schema = class _Schema {
4005
3958
  spann: json.spann ? cloneObject(json.spann) : null
4006
3959
  });
4007
3960
  config.embeddingFunction = await getEmbeddingFunction({
4008
- collectionName: "schema deserialization",
4009
3961
  client: client2,
4010
3962
  efConfig: json.embedding_function
4011
3963
  });
@@ -4020,7 +3972,6 @@ var Schema = class _Schema {
4020
3972
  bm25: typeof json.bm25 === "boolean" ? json.bm25 : null
4021
3973
  });
4022
3974
  const embeddingFunction = await getSparseEmbeddingFunction(
4023
- "schema deserialization",
4024
3975
  client2,
4025
3976
  json.embedding_function
4026
3977
  ) ?? config.embeddingFunction ?? void 0;
@@ -4106,7 +4057,7 @@ var CollectionImpl = class _CollectionImpl {
4106
4057
  const embeddingFunction = this._embeddingFunction ?? this.getSchemaEmbeddingFunction();
4107
4058
  if (!embeddingFunction) {
4108
4059
  throw new ChromaValueError(
4109
- "Embedding function must be defined for operations requiring embeddings."
4060
+ `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.`
4110
4061
  );
4111
4062
  }
4112
4063
  if (isQuery && embeddingFunction.generateForQueries) {
@@ -4167,10 +4118,8 @@ var CollectionImpl = class _CollectionImpl {
4167
4118
  }
4168
4119
  if (index < documentsList.length) {
4169
4120
  const doc = documentsList[index];
4170
- if (typeof doc === "string") {
4171
- inputs.push(doc);
4172
- positions.push(index);
4173
- }
4121
+ inputs.push(doc);
4122
+ positions.push(index);
4174
4123
  }
4175
4124
  });
4176
4125
  if (inputs.length === 0) {
@@ -5037,7 +4986,6 @@ var ChromaClient = class {
5037
4986
  );
5038
4987
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5039
4988
  const resolvedEmbeddingFunction = await getEmbeddingFunction({
5040
- collectionName: collection.name,
5041
4989
  client: this,
5042
4990
  efConfig: collection.configuration_json.embedding_function ?? void 0
5043
4991
  }) ?? schemaEmbeddingFunction;
@@ -5107,7 +5055,6 @@ var ChromaClient = class {
5107
5055
  );
5108
5056
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
5109
5057
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5110
- collectionName: data.name,
5111
5058
  client: this,
5112
5059
  efConfig: data.configuration_json.embedding_function ?? void 0
5113
5060
  }) ?? schemaEmbeddingFunction;
@@ -5143,7 +5090,6 @@ var ChromaClient = class {
5143
5090
  const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
5144
5091
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5145
5092
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5146
- collectionName: data.name,
5147
5093
  client: this,
5148
5094
  efConfig: data.configuration_json.embedding_function ?? void 0
5149
5095
  }) ?? schemaEmbeddingFunction;
@@ -5174,7 +5120,6 @@ var ChromaClient = class {
5174
5120
  const schema = await Schema.deserializeFromJSON(data.schema ?? null, this);
5175
5121
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(schema);
5176
5122
  const resolvedEmbeddingFunction = await getEmbeddingFunction({
5177
- collectionName: data.name,
5178
5123
  efConfig: data.configuration_json.embedding_function ?? void 0,
5179
5124
  client: this
5180
5125
  }) ?? schemaEmbeddingFunction;
@@ -5250,7 +5195,6 @@ var ChromaClient = class {
5250
5195
  );
5251
5196
  const schemaEmbeddingFunction = resolveSchemaEmbeddingFunction(serverSchema);
5252
5197
  const resolvedEmbeddingFunction = embeddingFunction ?? await getEmbeddingFunction({
5253
- collectionName: name,
5254
5198
  efConfig: data.configuration_json.embedding_function ?? void 0,
5255
5199
  client: this
5256
5200
  }) ?? schemaEmbeddingFunction;