chromadb 3.0.12 → 3.0.14

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.
@@ -383,9 +383,10 @@ interface UpdateSPANNConfiguration {
383
383
  * Validate user provided collection configuration and embedding function. Returns a
384
384
  * CollectionConfiguration to be used in collection creation.
385
385
  */
386
- declare const processCreateCollectionConfig: ({ configuration, embeddingFunction, }: {
386
+ declare const processCreateCollectionConfig: ({ configuration, embeddingFunction, metadata, }: {
387
387
  configuration?: CreateCollectionConfiguration;
388
388
  embeddingFunction?: EmbeddingFunction | null;
389
+ metadata?: CollectionMetadata;
389
390
  }) => Promise<CollectionConfiguration>;
390
391
  /**
391
392
  *
@@ -1225,7 +1225,8 @@ var getDefaultEFConfig = async () => {
1225
1225
  // src/collection-configuration.ts
1226
1226
  var processCreateCollectionConfig = async ({
1227
1227
  configuration,
1228
- embeddingFunction
1228
+ embeddingFunction,
1229
+ metadata
1229
1230
  }) => {
1230
1231
  if (configuration?.hnsw && configuration?.spann) {
1231
1232
  throw new ChromaValueError(
@@ -1239,6 +1240,39 @@ var processCreateCollectionConfig = async ({
1239
1240
  if (!embeddingFunctionConfiguration && embeddingFunction !== null) {
1240
1241
  embeddingFunctionConfiguration = await getDefaultEFConfig();
1241
1242
  }
1243
+ const overallEf = embeddingFunction || configuration?.embeddingFunction;
1244
+ if (overallEf && overallEf.defaultSpace && overallEf.supportedSpaces) {
1245
+ if (configuration?.hnsw === void 0 && configuration?.spann === void 0) {
1246
+ if (metadata === void 0 || metadata?.["hnsw:space"] === void 0) {
1247
+ if (!configuration) configuration = {};
1248
+ configuration.hnsw = { space: overallEf.defaultSpace() };
1249
+ }
1250
+ }
1251
+ if (configuration?.hnsw && !configuration.hnsw.space && overallEf.defaultSpace) {
1252
+ configuration.hnsw.space = overallEf.defaultSpace();
1253
+ }
1254
+ if (configuration?.spann && !configuration.spann.space && overallEf.defaultSpace) {
1255
+ configuration.spann.space = overallEf.defaultSpace();
1256
+ }
1257
+ if (overallEf.supportedSpaces) {
1258
+ const supportedSpaces = overallEf.supportedSpaces();
1259
+ if (configuration?.hnsw?.space && !supportedSpaces.includes(configuration.hnsw.space)) {
1260
+ console.warn(
1261
+ `Space '${configuration.hnsw.space}' is not supported by embedding function '${overallEf.name || "unknown"}'. Supported spaces: ${supportedSpaces.join(", ")}`
1262
+ );
1263
+ }
1264
+ if (configuration?.spann?.space && !supportedSpaces.includes(configuration.spann.space)) {
1265
+ console.warn(
1266
+ `Space '${configuration.spann.space}' is not supported by embedding function '${overallEf.name || "unknown"}'. Supported spaces: ${supportedSpaces.join(", ")}`
1267
+ );
1268
+ }
1269
+ if (!configuration?.hnsw && !configuration?.spann && metadata && typeof metadata["hnsw:space"] === "string" && !supportedSpaces.includes(metadata["hnsw:space"])) {
1270
+ console.warn(
1271
+ `Space '${metadata["hnsw:space"]}' from metadata is not supported by embedding function '${overallEf.name || "unknown"}'. Supported spaces: ${supportedSpaces.join(", ")}`
1272
+ );
1273
+ }
1274
+ }
1275
+ }
1242
1276
  return {
1243
1277
  ...configuration || {},
1244
1278
  embedding_function: embeddingFunctionConfiguration
@@ -2005,7 +2039,8 @@ var ChromaClient = class {
2005
2039
  }) {
2006
2040
  const collectionConfig = await processCreateCollectionConfig({
2007
2041
  configuration,
2008
- embeddingFunction
2042
+ embeddingFunction,
2043
+ metadata
2009
2044
  });
2010
2045
  const { data } = await DefaultService.createCollection({
2011
2046
  client: this.apiClient,
@@ -2096,7 +2131,8 @@ var ChromaClient = class {
2096
2131
  }) {
2097
2132
  const collectionConfig = await processCreateCollectionConfig({
2098
2133
  configuration,
2099
- embeddingFunction
2134
+ embeddingFunction,
2135
+ metadata
2100
2136
  });
2101
2137
  const { data } = await DefaultService.createCollection({
2102
2138
  client: this.apiClient,
package/dist/chromadb.mjs CHANGED
@@ -1225,7 +1225,8 @@ var getDefaultEFConfig = async () => {
1225
1225
  // src/collection-configuration.ts
1226
1226
  var processCreateCollectionConfig = async ({
1227
1227
  configuration,
1228
- embeddingFunction
1228
+ embeddingFunction,
1229
+ metadata
1229
1230
  }) => {
1230
1231
  if (configuration?.hnsw && configuration?.spann) {
1231
1232
  throw new ChromaValueError(
@@ -1239,6 +1240,39 @@ var processCreateCollectionConfig = async ({
1239
1240
  if (!embeddingFunctionConfiguration && embeddingFunction !== null) {
1240
1241
  embeddingFunctionConfiguration = await getDefaultEFConfig();
1241
1242
  }
1243
+ const overallEf = embeddingFunction || configuration?.embeddingFunction;
1244
+ if (overallEf && overallEf.defaultSpace && overallEf.supportedSpaces) {
1245
+ if (configuration?.hnsw === void 0 && configuration?.spann === void 0) {
1246
+ if (metadata === void 0 || metadata?.["hnsw:space"] === void 0) {
1247
+ if (!configuration) configuration = {};
1248
+ configuration.hnsw = { space: overallEf.defaultSpace() };
1249
+ }
1250
+ }
1251
+ if (configuration?.hnsw && !configuration.hnsw.space && overallEf.defaultSpace) {
1252
+ configuration.hnsw.space = overallEf.defaultSpace();
1253
+ }
1254
+ if (configuration?.spann && !configuration.spann.space && overallEf.defaultSpace) {
1255
+ configuration.spann.space = overallEf.defaultSpace();
1256
+ }
1257
+ if (overallEf.supportedSpaces) {
1258
+ const supportedSpaces = overallEf.supportedSpaces();
1259
+ if (configuration?.hnsw?.space && !supportedSpaces.includes(configuration.hnsw.space)) {
1260
+ console.warn(
1261
+ `Space '${configuration.hnsw.space}' is not supported by embedding function '${overallEf.name || "unknown"}'. Supported spaces: ${supportedSpaces.join(", ")}`
1262
+ );
1263
+ }
1264
+ if (configuration?.spann?.space && !supportedSpaces.includes(configuration.spann.space)) {
1265
+ console.warn(
1266
+ `Space '${configuration.spann.space}' is not supported by embedding function '${overallEf.name || "unknown"}'. Supported spaces: ${supportedSpaces.join(", ")}`
1267
+ );
1268
+ }
1269
+ if (!configuration?.hnsw && !configuration?.spann && metadata && typeof metadata["hnsw:space"] === "string" && !supportedSpaces.includes(metadata["hnsw:space"])) {
1270
+ console.warn(
1271
+ `Space '${metadata["hnsw:space"]}' from metadata is not supported by embedding function '${overallEf.name || "unknown"}'. Supported spaces: ${supportedSpaces.join(", ")}`
1272
+ );
1273
+ }
1274
+ }
1275
+ }
1242
1276
  return {
1243
1277
  ...configuration || {},
1244
1278
  embedding_function: embeddingFunctionConfiguration
@@ -2005,7 +2039,8 @@ var ChromaClient = class {
2005
2039
  }) {
2006
2040
  const collectionConfig = await processCreateCollectionConfig({
2007
2041
  configuration,
2008
- embeddingFunction
2042
+ embeddingFunction,
2043
+ metadata
2009
2044
  });
2010
2045
  const { data } = await DefaultService.createCollection({
2011
2046
  client: this.apiClient,
@@ -2096,7 +2131,8 @@ var ChromaClient = class {
2096
2131
  }) {
2097
2132
  const collectionConfig = await processCreateCollectionConfig({
2098
2133
  configuration,
2099
- embeddingFunction
2134
+ embeddingFunction,
2135
+ metadata
2100
2136
  });
2101
2137
  const { data } = await DefaultService.createCollection({
2102
2138
  client: this.apiClient,