Skip to content

calculateQueryEmbedding

calculateQueryEmbedding(item, embeddings): Promise<number[] | null>

Defined in: packages/core/src/embeddings/query.ts:30

Calculates query embeddings based on the content detail and available embedding functions.

MessageContentDetail

The message content detail (text or image)

EmbeddingsByType

Map of modality type to embedding function

Promise<number[] | null>

The query embedding as a number array, or null if no embedding could be calculated

const textItem: MessageContentTextDetail = {
type: "text",
text: "What did the author do in college?"
};
const embeddings = {
text: getOpenAIEmbedding("text-embedding-3-small"),
};
const queryEmbedding = await calculateQueryEmbedding(textItem, embeddings);