Class that extends the Embeddings class and provides methods for generating embeddings using the Google Palm API.

Example

const model = new GooglePaLMEmbeddings({
apiKey: "<YOUR API KEY>",
modelName: "models/embedding-gecko-001",
});

// Embed a single query
const res = await model.embedQuery(
"What would be a good company name for a company that makes colorful socks?"
);
console.log({ res });

// Embed multiple documents
const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });

Hierarchy

  • Embeddings
    • GooglePaLMEmbeddings

Implements

Constructors

Properties

Methods

Constructors

Properties

modelName: string = "models/embedding-gecko-001"

Model Name to use

Note: The format must follow the pattern - models/{model}

apiKey?: string

Google Palm API key to use

Methods

  • Method that takes an array of documents as input and returns a promise that resolves to a 2D array of embeddings for each document. It calls the _embedText method for each document in the array.

    Parameters

    • documents: string[]

      Array of documents for which to generate embeddings.

    Returns Promise<number[][]>

    Promise that resolves to a 2D array of embeddings for each input document.

  • Method that takes a document as input and returns a promise that resolves to an embedding for the document. It calls the _embedText method with the document as the input.

    Parameters

    • document: string

      Document for which to generate an embedding.

    Returns Promise<number[]>

    Promise that resolves to an embedding for the input document.

Generated using TypeDoc