A class for generating embeddings using the Cohere API.

Hierarchy

  • Embeddings
    • CohereEmbeddings

Implements

Constructors

Properties

batchSize: number = 48

The maximum number of documents to embed in a single request. This is limited by the Cohere API to a maximum of 96.

caller: AsyncCaller

The async caller should be used by subclasses to make any async calls, which will thus benefit from the concurrency and retry logic.

embeddingTypes: string[] = ...

Specifies the type of embeddings you want to generate.

model: undefined | string

Methods

  • Generates embeddings for an array of texts.

    Parameters

    • texts: string[]

      An array of strings to generate embeddings for.

    Returns Promise<number[][]>

    A Promise that resolves to an array of embeddings.

  • Generates an embedding for a single text.

    Parameters

    • text: string

      A string to generate an embedding for.

    Returns Promise<number[]>

    A Promise that resolves to an array of numbers representing the embedding.