Skip to main content

getEmbeddings

Calculates the embeddings for an array of content strings.

getEmbeddings(
contents: string[],
options?: {
textSplitter?: SplitterParams
}
): Promise<GetEmbeddingsResponse[]>

Reference

import { myVectorStore } from "#elements";
export default async function () {
const embeddings = await myVectorStore.getEmbeddings([
"content1",
"content2",
]);
console.log(JSON.stringify(embeddings, null, 2));
}

Parameters

  • contents: An array of content strings to retrieve the embeddings for.
  • options: Optional configuration parameters, including:
    • textSplitter: (optional) The text splitter employed to divide the content into multiple vectors. In the absence of a provided splitter, the token splitter is used by default.

Returns

Promise of an array of GetEmbeddingsResponse objects, each containing the original content string and its corresponding embeddings.

  • content: The original content string.
  • embeddings: An array of objects, each representing a chunk of the content and its corresponding vector.
    • chunked: The chunk of the content.
    • index: The index of the chunk in the content.
    • vectors: The embedding vector of the chunk.

Caveats

  • This method only retrieves the embeddings and does not store the results in the VectorStore Element.