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

Example

const embeddings = new BedrockEmbeddings({
region: "your-aws-region",
credentials: {
accessKeyId: "your-access-key-id",
secretAccessKey: "your-secret-access-key",
},
model: "amazon.titan-embed-text-v1",
});

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

Hierarchy

Implements

Constructors

Properties

Methods

Constructors

Properties

batchSize: number = 512
client: BedrockRuntimeClient

A client provided by the user that allows them to customze any SDK configuration options.

model: string

Model Name to use. Defaults to amazon.titan-embed-text-v1 if not provided

Methods

  • Method to generate embeddings for an array of texts. Calls _embedText method which batches and handles retry logic when calling the AWS Bedrock API.

    Parameters

    • documents: string[]

      Array of texts 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