Enables calls to the Google Cloud's Vertex AI API to access the embeddings generated by Large Language Models.

To use, you will need to have one of the following authentication methods in place:

  • You are logged into an account permitted to the Google Cloud project using Vertex AI.
  • You are running this on a machine using a service account permitted to the Google Cloud project using Vertex AI.
  • The GOOGLE_APPLICATION_CREDENTIALS environment variable is set to the path of a credentials file for a service account permitted to the Google Cloud project using Vertex AI.

Example

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

Hierarchy

  • Embeddings
    • GoogleVertexAIEmbeddings

Implements

Constructors

Properties

Methods

Constructors

Properties

model: string = "textembedding-gecko"

Model to use

Methods

  • Takes an array of documents as input and returns a promise that resolves to a 2D array of embeddings for each document. It splits the documents into chunks and makes requests to the Google Vertex AI API to generate embeddings.

    Parameters

    • documents: string[]

      An array of documents to be embedded.

    Returns Promise<number[][]>

    A promise that resolves to a 2D array of embeddings for each document.

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

    Parameters

    • document: string

      A document to be embedded.

    Returns Promise<number[]>

    A promise that resolves to an embedding for the document.

Generated using TypeDoc