chromadb 3.0.1 → 3.0.2

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.
@@ -1,14 +1,12 @@
1
- import { createClient } from '@hey-api/client-fetch';
2
-
3
1
  type Database = {
4
2
  id: string;
5
3
  name: string;
6
4
  tenant: string;
7
5
  };
8
6
  type EmbeddingFunctionConfiguration = {
9
- type: "legacy";
7
+ type: 'legacy';
10
8
  } | (EmbeddingFunctionNewConfiguration & {
11
- type: "known";
9
+ type: 'known';
12
10
  });
13
11
  type EmbeddingFunctionNewConfiguration = {
14
12
  config: unknown;
@@ -27,8 +25,8 @@ type HnswConfiguration = {
27
25
  space?: HnswSpace;
28
26
  sync_threshold?: number | null;
29
27
  };
30
- type HnswSpace = "l2" | "cosine" | "ip";
31
- type Include = "distances" | "documents" | "embeddings" | "metadatas" | "uris";
28
+ type HnswSpace = 'l2' | 'cosine' | 'ip';
29
+ type Include = 'distances' | 'documents' | 'embeddings' | 'metadatas' | 'uris';
32
30
  type SpannConfiguration = {
33
31
  ef_construction?: number | null;
34
32
  ef_search?: number | null;
@@ -62,12 +60,12 @@ type UserIdentity = GetUserIdentityResponse;
62
60
  * Metadata that can be associated with a collection.
63
61
  * Values must be boolean, number, or string types.
64
62
  */
65
- type CollectionMetadata = Record<string, boolean | number | string>;
63
+ type CollectionMetadata = Record<string, boolean | number | string | null>;
66
64
  /**
67
65
  * Metadata that can be associated with individual records.
68
66
  * Values must be boolean, number, or string types.
69
67
  */
70
- type Metadata = Record<string, boolean | number | string>;
68
+ type Metadata = Record<string, boolean | number | string | null>;
71
69
  /**
72
70
  * Base interface for record sets containing optional fields.
73
71
  */
@@ -196,38 +194,30 @@ declare class GetResult<TMeta extends Metadata = Metadata> {
196
194
  * @returns Object containing include fields and array of record objects
197
195
  */
198
196
  rows(): {
199
- include: Include[];
200
- records: {
201
- id: string;
202
- document: string | null | undefined;
203
- embedding: number[] | undefined;
204
- metadata: TMeta | null | undefined;
205
- uri: string | null | undefined;
206
- }[];
207
- };
197
+ id: string;
198
+ document: string | null | undefined;
199
+ embedding: number[] | undefined;
200
+ metadata: TMeta | null | undefined;
201
+ uri: string | null | undefined;
202
+ }[];
208
203
  }
209
204
  /**
210
205
  * Interface for query results in row format.
211
206
  * @template TMeta - The type of metadata associated with records
212
207
  */
213
208
  interface QueryRowResult<TMeta extends Metadata = Metadata> {
214
- /** Fields included in the query results */
215
- include: Include[];
216
- /** Array of query results, with each query returning an array of matches */
217
- queries: {
218
- /** Similarity distance to the query (if included) */
219
- distance?: number | null;
220
- /** Document text content (if included) */
221
- document?: string | null;
222
- /** Embedding vector (if included) */
223
- embedding?: number[] | null;
224
- /** Unique record identifier */
225
- id: string;
226
- /** Record metadata (if included) */
227
- metadata?: TMeta | null;
228
- /** Record URI (if included) */
229
- uri?: string | null;
230
- }[][];
209
+ /** Similarity distance to the query (if included) */
210
+ distance?: number | null;
211
+ /** Document text content (if included) */
212
+ document?: string | null;
213
+ /** Embedding vector (if included) */
214
+ embedding?: number[] | null;
215
+ /** Unique record identifier */
216
+ id: string;
217
+ /** Record metadata (if included) */
218
+ metadata?: TMeta | null;
219
+ /** Record URI (if included) */
220
+ uri?: string | null;
231
221
  }
232
222
  /**
233
223
  * Result class for query operations, containing search results.
@@ -258,7 +248,7 @@ declare class QueryResult<TMeta extends Metadata = Metadata> {
258
248
  * Converts the query result to a row-based format for easier iteration.
259
249
  * @returns Object containing include fields and structured query results
260
250
  */
261
- rows(): QueryRowResult<TMeta>;
251
+ rows(): QueryRowResult<TMeta>[][];
262
252
  }
263
253
 
264
254
  /**
@@ -414,6 +404,10 @@ interface ChromaClientArgs {
414
404
  headers?: Record<string, string>;
415
405
  /** Additional fetch options for HTTP requests */
416
406
  fetchOptions?: RequestInit;
407
+ /** @deprecated Use host, port, and ssl instead */
408
+ path?: string;
409
+ /** @deprecated */
410
+ auth?: Record<string, string>;
417
411
  }
418
412
  /**
419
413
  * Main client class for interacting with ChromaDB.
@@ -507,7 +501,7 @@ declare class ChromaClient {
507
501
  getCollections(items: string[] | {
508
502
  name: string;
509
503
  embeddingFunction?: EmbeddingFunction;
510
- }[]): Promise<void[]>;
504
+ }[]): Promise<Collection[]>;
511
505
  /**
512
506
  * Gets an existing collection or creates it if it doesn't exist.
513
507
  * @param options - Collection options
@@ -542,35 +536,21 @@ declare class ChromaClient {
542
536
  * @returns Promise resolving to the server version string
543
537
  */
544
538
  version(): Promise<string>;
545
- /**
546
- * Creates a thin CollectionAPI instance for direct collection operations by ID.
547
- * @param options - Collection API options
548
- * @param options.id - The collection ID
549
- * @param options.embeddingFunction - Optional embedding function to use
550
- * @returns A CollectionAPI instance for the specified collection
551
- */
552
- getCollectionById({ id, embeddingFunction, }: {
553
- id: string;
554
- embeddingFunction?: EmbeddingFunction;
555
- }): CollectionAPI;
556
- /**
557
- * Creates multiple thin CollectionAPI instances for direct collection operations by ID.
558
- * @param items - Array of collection IDs or objects with ID and optional embedding function
559
- * @returns Array of CollectionAPI instances
560
- */
561
- getCollectionsById(items: string[] | {
562
- id: string;
563
- embeddingFunction?: EmbeddingFunction;
564
- }[]): CollectionAPIImpl[];
565
539
  }
566
540
 
567
541
  /**
568
542
  * Interface for collection operations using collection ID.
569
543
  * Provides methods for adding, querying, updating, and deleting records.
570
544
  */
571
- interface CollectionAPI {
545
+ interface Collection {
572
546
  /** Unique identifier for the collection */
573
547
  id: string;
548
+ /** Name of the collection */
549
+ name: string;
550
+ /** Collection-level metadata */
551
+ metadata: CollectionMetadata | undefined;
552
+ /** Collection configuration settings */
553
+ configuration: CollectionConfiguration;
574
554
  /** Optional embedding function. Must match the one used to create the collection. */
575
555
  embeddingFunction?: EmbeddingFunction;
576
556
  /** Gets the total number of records in the collection */
@@ -708,105 +688,6 @@ interface CollectionAPI {
708
688
  whereDocument?: WhereDocument;
709
689
  }): Promise<void>;
710
690
  }
711
- /**
712
- * A Chroma collection retrieved by name, with its metadata and configuration.
713
- */
714
- interface Collection extends CollectionAPI {
715
- /** Human-readable name of the collection */
716
- name: string;
717
- /** Collection-level metadata */
718
- metadata: CollectionMetadata | undefined;
719
- /** Collection configuration settings */
720
- configuration: CollectionConfiguration;
721
- }
722
- /**
723
- * Implementation of CollectionAPI for ID-based collection operations.
724
- * Provides core functionality for interacting with collections using their ID.
725
- */
726
- declare class CollectionAPIImpl implements CollectionAPI {
727
- protected readonly chromaClient: ChromaClient;
728
- protected readonly apiClient: ReturnType<typeof createClient>;
729
- readonly id: string;
730
- protected _embeddingFunction: EmbeddingFunction | undefined;
731
- /**
732
- * Creates a new CollectionAPIImpl instance.
733
- * @param options - Configuration for the collection API
734
- */
735
- constructor({ chromaClient, apiClient, id, embeddingFunction, }: {
736
- chromaClient: ChromaClient;
737
- apiClient: ReturnType<typeof createClient>;
738
- id: string;
739
- embeddingFunction?: EmbeddingFunction;
740
- });
741
- get embeddingFunction(): EmbeddingFunction | undefined;
742
- protected set embeddingFunction(embeddingFunction: EmbeddingFunction | undefined);
743
- protected path(): Promise<{
744
- tenant: string;
745
- database: string;
746
- collection_id: string;
747
- }>;
748
- private embed;
749
- private prepareRecords;
750
- private validateGet;
751
- private prepareQuery;
752
- private validateDelete;
753
- count(): Promise<number>;
754
- add({ ids, embeddings, metadatas, documents, uris, }: {
755
- ids: string[];
756
- embeddings?: number[][];
757
- metadatas?: Metadata[];
758
- documents?: string[];
759
- uris?: string[];
760
- }): Promise<void>;
761
- get<TMeta extends Metadata = Metadata>(args?: Partial<{
762
- ids?: string[];
763
- where?: Where;
764
- limit?: number;
765
- offset?: number;
766
- whereDocument?: WhereDocument;
767
- include?: Include[];
768
- }>): Promise<GetResult<TMeta>>;
769
- peek({ limit }: {
770
- limit?: number;
771
- }): Promise<GetResult>;
772
- query<TMeta extends Metadata = Metadata>({ queryEmbeddings, queryTexts, queryURIs, ids, nResults, where, whereDocument, include, }: {
773
- queryEmbeddings?: number[][];
774
- queryTexts?: string[];
775
- queryURIs?: string[];
776
- ids?: string[];
777
- nResults?: number;
778
- where?: Where;
779
- whereDocument?: WhereDocument;
780
- include?: Include[];
781
- }): Promise<QueryResult<TMeta>>;
782
- modify({ name, metadata, configuration, }: {
783
- name?: string;
784
- metadata?: CollectionMetadata;
785
- configuration?: UpdateCollectionConfiguration;
786
- }): Promise<void>;
787
- fork({ name }: {
788
- name: string;
789
- }): Promise<Collection>;
790
- update({ ids, embeddings, metadatas, documents, uris, }: {
791
- ids: string[];
792
- embeddings?: number[][];
793
- metadatas?: Metadata[];
794
- documents?: string[];
795
- uris?: string[];
796
- }): Promise<void>;
797
- upsert({ ids, embeddings, metadatas, documents, uris, }: {
798
- ids: string[];
799
- embeddings?: number[][];
800
- metadatas?: Metadata[];
801
- documents?: string[];
802
- uris?: string[];
803
- }): Promise<void>;
804
- delete({ ids, where, whereDocument, }: {
805
- ids?: string[];
806
- where?: Where;
807
- whereDocument?: WhereDocument;
808
- }): Promise<void>;
809
- }
810
691
 
811
692
  declare function withChroma(userNextConfig?: any): any;
812
693
 
@@ -1012,4 +893,4 @@ declare class ChromaQuotaExceededError extends Error {
1012
893
  }
1013
894
  declare function createErrorByType(type: string, message: string): InvalidCollectionError | InvalidArgumentError | undefined;
1014
895
 
1015
- export { AdminClient, type AdminClientArgs, AdminCloudClient, type BaseRecordSet, ChromaClient, type ChromaClientArgs, ChromaClientError, ChromaConnectionError, ChromaError, ChromaForbiddenError, ChromaNotFoundError, ChromaQuotaExceededError, ChromaServerError, ChromaUnauthorizedError, ChromaUniqueError, ChromaValueError, CloudClient, type Collection, type CollectionAPI, type CollectionConfiguration, type CollectionMetadata, type CreateCollectionConfiguration, type EmbeddingFunction, type EmbeddingFunctionClass, type EmbeddingFunctionSpace, GetResult, type HNSWConfiguration, IncludeEnum, InvalidArgumentError, InvalidCollectionError, type ListDatabasesArgs, type Metadata, type QueryRecordSet, QueryResult, type QueryRowResult, type RecordSet, type UpdateCollectionConfiguration, type UpdateHNSWConfiguration, type UpdateSPANNConfiguration, type UserIdentity, type Where, type WhereDocument, baseRecordSetFields, createErrorByType, getDefaultEFConfig, getEmbeddingFunction, knownEmbeddingFunctions, processCreateCollectionConfig, processUpdateCollectionConfig, recordSetFields, registerEmbeddingFunction, serializeEmbeddingFunction, withChroma };
896
+ export { AdminClient, type AdminClientArgs, AdminCloudClient, type BaseRecordSet, ChromaClient, type ChromaClientArgs, ChromaClientError, ChromaConnectionError, ChromaError, ChromaForbiddenError, ChromaNotFoundError, ChromaQuotaExceededError, ChromaServerError, ChromaUnauthorizedError, ChromaUniqueError, ChromaValueError, CloudClient, type Collection, type CollectionConfiguration, type CollectionMetadata, type CreateCollectionConfiguration, type EmbeddingFunction, type EmbeddingFunctionClass, type EmbeddingFunctionSpace, GetResult, type HNSWConfiguration, IncludeEnum, InvalidArgumentError, InvalidCollectionError, type ListDatabasesArgs, type Metadata, type QueryRecordSet, QueryResult, type QueryRowResult, type RecordSet, type UpdateCollectionConfiguration, type UpdateHNSWConfiguration, type UpdateSPANNConfiguration, type UserIdentity, type Where, type WhereDocument, baseRecordSetFields, createErrorByType, getDefaultEFConfig, getEmbeddingFunction, knownEmbeddingFunctions, processCreateCollectionConfig, processUpdateCollectionConfig, recordSetFields, registerEmbeddingFunction, serializeEmbeddingFunction, withChroma };