chromadb 3.0.14 → 3.0.15

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.
@@ -42,6 +42,19 @@ type SpannConfiguration = {
42
42
  split_threshold?: number | null;
43
43
  write_nprobe?: number | null;
44
44
  };
45
+ /**
46
+ * Represents a sparse vector using parallel arrays for indices and values.
47
+ */
48
+ type SparseVector = {
49
+ /**
50
+ * Dimension indices
51
+ */
52
+ indices: Array<number>;
53
+ /**
54
+ * Values corresponding to each index
55
+ */
56
+ values: Array<number>;
57
+ };
45
58
  type UpdateCollectionConfiguration$1 = {
46
59
  embedding_function?: null | EmbeddingFunctionConfiguration;
47
60
  hnsw?: null | UpdateHnswConfiguration;
@@ -68,12 +81,12 @@ type UserIdentity = GetUserIdentityResponse;
68
81
  * Metadata that can be associated with a collection.
69
82
  * Values must be boolean, number, or string types.
70
83
  */
71
- type CollectionMetadata = Record<string, boolean | number | string | null>;
84
+ type CollectionMetadata = Record<string, boolean | number | string | SparseVector | null>;
72
85
  /**
73
86
  * Metadata that can be associated with individual records.
74
87
  * Values must be boolean, number, or string types.
75
88
  */
76
- type Metadata = Record<string, boolean | number | string | null>;
89
+ type Metadata = Record<string, boolean | number | string | SparseVector | null>;
77
90
  /**
78
91
  * Base interface for record sets containing optional fields.
79
92
  */
@@ -371,6 +371,15 @@ var DefaultService = class {
371
371
  ...options
372
372
  });
373
373
  }
374
+ /**
375
+ * Retrieves a collection by Chroma Resource Name.
376
+ */
377
+ static getCollectionByCrn(options) {
378
+ return (options.client ?? client).get({
379
+ url: "/api/v2/collections/{crn}",
380
+ ...options
381
+ });
382
+ }
374
383
  /**
375
384
  * Health check endpoint that returns 200 if the server and executor are ready
376
385
  */
@@ -609,6 +618,19 @@ var DefaultService = class {
609
618
  }
610
619
  });
611
620
  }
621
+ /**
622
+ * Search records from a collection with hybrid criterias.
623
+ */
624
+ static collectionSearch(options) {
625
+ return (options.client ?? client).post({
626
+ url: "/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/search",
627
+ ...options,
628
+ headers: {
629
+ "Content-Type": "application/json",
630
+ ...options?.headers
631
+ }
632
+ });
633
+ }
612
634
  /**
613
635
  * Updates records in a collection by ID.
614
636
  */
@@ -901,6 +923,9 @@ var validateIDs = (ids) => {
901
923
  );
902
924
  }
903
925
  };
926
+ var validateSparseVector = (v) => {
927
+ return typeof v === "object" && v !== null && "indices" in v && "values" in v && Array.isArray(v.indices) && v.indices.every((e) => typeof e === "number") && Array.isArray(v.values) && v.values.every((e) => typeof e === "number");
928
+ };
904
929
  var validateMetadata = (metadata) => {
905
930
  if (!metadata) {
906
931
  return;
@@ -909,10 +934,10 @@ var validateMetadata = (metadata) => {
909
934
  throw new ChromaValueError("Expected metadata to be non-empty");
910
935
  }
911
936
  if (!Object.values(metadata).every(
912
- (v) => v === null || v === void 0 || typeof v === "string" || typeof v === "number" || typeof v === "boolean"
937
+ (v) => v === null || v === void 0 || typeof v === "string" || typeof v === "number" || typeof v === "boolean" || validateSparseVector(v)
913
938
  )) {
914
939
  throw new ChromaValueError(
915
- "Expected metadata to be a string, number, boolean, or nullable"
940
+ "Expected metadata to be a string, number, boolean, SparseVector, or nullable"
916
941
  );
917
942
  }
918
943
  };
package/dist/chromadb.mjs CHANGED
@@ -371,6 +371,15 @@ var DefaultService = class {
371
371
  ...options
372
372
  });
373
373
  }
374
+ /**
375
+ * Retrieves a collection by Chroma Resource Name.
376
+ */
377
+ static getCollectionByCrn(options) {
378
+ return (options.client ?? client).get({
379
+ url: "/api/v2/collections/{crn}",
380
+ ...options
381
+ });
382
+ }
374
383
  /**
375
384
  * Health check endpoint that returns 200 if the server and executor are ready
376
385
  */
@@ -609,6 +618,19 @@ var DefaultService = class {
609
618
  }
610
619
  });
611
620
  }
621
+ /**
622
+ * Search records from a collection with hybrid criterias.
623
+ */
624
+ static collectionSearch(options) {
625
+ return (options.client ?? client).post({
626
+ url: "/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/search",
627
+ ...options,
628
+ headers: {
629
+ "Content-Type": "application/json",
630
+ ...options?.headers
631
+ }
632
+ });
633
+ }
612
634
  /**
613
635
  * Updates records in a collection by ID.
614
636
  */
@@ -901,6 +923,9 @@ var validateIDs = (ids) => {
901
923
  );
902
924
  }
903
925
  };
926
+ var validateSparseVector = (v) => {
927
+ return typeof v === "object" && v !== null && "indices" in v && "values" in v && Array.isArray(v.indices) && v.indices.every((e) => typeof e === "number") && Array.isArray(v.values) && v.values.every((e) => typeof e === "number");
928
+ };
904
929
  var validateMetadata = (metadata) => {
905
930
  if (!metadata) {
906
931
  return;
@@ -909,10 +934,10 @@ var validateMetadata = (metadata) => {
909
934
  throw new ChromaValueError("Expected metadata to be non-empty");
910
935
  }
911
936
  if (!Object.values(metadata).every(
912
- (v) => v === null || v === void 0 || typeof v === "string" || typeof v === "number" || typeof v === "boolean"
937
+ (v) => v === null || v === void 0 || typeof v === "string" || typeof v === "number" || typeof v === "boolean" || validateSparseVector(v)
913
938
  )) {
914
939
  throw new ChromaValueError(
915
- "Expected metadata to be a string, number, boolean, or nullable"
940
+ "Expected metadata to be a string, number, boolean, SparseVector, or nullable"
916
941
  );
917
942
  }
918
943
  };