langchain.js
    Preparing search index...

    A class for generating embeddings using the Cohere API.

    // Embed a query using the CohereEmbeddings class
    const model = new ChatOpenAI({ model: "gpt-4o-mini" });
    const res = await model.embedQuery(
    "What would be a good company name for a company that makes colorful socks?",
    );
    console.log({ res });

    Use CohereEmbeddings from @langchain/cohere instead.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Constructor for the CohereEmbeddings class.

      Parameters

      • Optionalfields: Partial<CohereEmbeddingsParams> & { apiKey?: string; verbose?: boolean }

        An optional object with properties to configure the instance.

      Returns CohereEmbeddings

    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.

    modelName: string = "small"

    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.