The main class that extends the VectorStore class. It provides methods for interacting with the Chroma database, such as adding documents, deleting documents, and searching for similar vectors.

Hierarchy

Constructors

Properties

FilterType: Where
collectionName: string
embeddings: Embeddings
lc_kwargs: SerializedFields
lc_namespace: string[] = ...

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

lc_serializable: boolean = false
url: string
collection?: Collection
collectionMetadata?: CollectionMetadata
filter?: object
index?: ChromaClient
numDimensions?: number

Accessors

  • get lc_aliases(): undefined | {
        [key: string]: string;
    }
  • A map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.

    Returns undefined | {
        [key: string]: string;
    }

  • get lc_attributes(): undefined | SerializedFields
  • A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.

    Returns undefined | SerializedFields

  • get lc_secrets(): undefined | {
        [key: string]: string;
    }
  • A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.

    Returns undefined | {
        [key: string]: string;
    }

Methods

  • Adds documents to the Chroma database. The documents are first converted to vectors using the embeddings instance, and then added to the database.

    Parameters

    • documents: Document<Record<string, any>>[]

      An array of Document instances to be added to the database.

    • Optional options: {
          ids?: string[];
      }

      Optional. An object containing an array of ids for the documents.

      • Optional ids?: string[]

    Returns Promise<string[]>

    A promise that resolves when the documents have been added to the database.

  • Adds vectors to the Chroma database. The vectors are associated with the provided documents.

    Parameters

    • vectors: number[][]

      An array of vectors to be added to the database.

    • documents: Document<Record<string, any>>[]

      An array of Document instances associated with the vectors.

    • Optional options: {
          ids?: string[];
      }

      Optional. An object containing an array of ids for the vectors.

      • Optional ids?: string[]

    Returns Promise<string[]>

    A promise that resolves with an array of document IDs when the vectors have been added to the database.

  • Deletes documents from the Chroma database. The documents to be deleted can be specified by providing an array of ids or a filter object.

    Parameters

    • params: ChromaDeleteParams<Where>

      An object containing either an array of ids of the documents to be deleted or a filter object to specify the documents to be deleted.

    Returns Promise<void>

    A promise that resolves when the specified documents have been deleted from the database.

  • Ensures that a collection exists in the Chroma database. If the collection does not exist, it is created.

    Returns Promise<Collection>

    A promise that resolves with the Collection instance.

  • Searches for vectors in the Chroma database that are similar to the provided query vector. The search can be filtered using the provided filter object or the filter property of the Chroma instance.

    Parameters

    • query: number[]

      The query vector.

    • k: number

      The number of similar vectors to return.

    • Optional filter: Where

      Optional. A filter object to filter the search results.

    Returns Promise<[Document<Record<string, any>>, number][]>

    A promise that resolves with an array of tuples, each containing a Document instance and a similarity score.

  • Creates a new Chroma instance from an array of Document instances. The documents are added to the Chroma database.

    Parameters

    • docs: Document<Record<string, any>>[]

      An array of Document instances.

    • embeddings: Embeddings

      An Embeddings instance used to generate embeddings for the documents.

    • dbConfig: ChromaLibArgs

      A ChromaLibArgs object containing the configuration for the Chroma database.

    Returns Promise<Chroma>

    A promise that resolves with a new Chroma instance.

  • Creates a new Chroma instance from an existing collection in the Chroma database.

    Parameters

    • embeddings: Embeddings

      An Embeddings instance used to generate embeddings for the documents.

    • dbConfig: ChromaLibArgs

      A ChromaLibArgs object containing the configuration for the Chroma database.

    Returns Promise<Chroma>

    A promise that resolves with a new Chroma instance.

  • Creates a new Chroma instance from an array of text strings. The text strings are converted to Document instances and added to the Chroma database.

    Parameters

    • texts: string[]

      An array of text strings.

    • metadatas: object | object[]

      An array of metadata objects or a single metadata object. If an array is provided, it must have the same length as the texts array.

    • embeddings: Embeddings

      An Embeddings instance used to generate embeddings for the documents.

    • dbConfig: ChromaLibArgs

      A ChromaLibArgs object containing the configuration for the Chroma database.

    Returns Promise<Chroma>

    A promise that resolves with a new Chroma instance.

  • Imports the ChromaClient from the chromadb module.

    Returns Promise<{
        ChromaClient: typeof ChromaClient;
    }>

    A promise that resolves with an object containing the ChromaClient constructor.

  • The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

    Implemented as a static method to support loading logic.

    Returns string

Generated using TypeDoc