UNPKG

ai-utils.js

Version:

Build AI applications, chatbots, and agents with JavaScript and TypeScript.

34 lines (33 loc) 1.4 kB
import { Vector } from "../../run/Vector.js"; import { FunctionOptions } from "../FunctionOptions.js"; import { CallMetadata } from "../executeCall.js"; import { TextEmbeddingModel, TextEmbeddingModelSettings } from "./TextEmbeddingModel.js"; /** * Generate embeddings for multiple texts. * * @example * const { embeddings } = await embedTexts( * new OpenAITextEmbeddingModel(...), * [ * "At first, Nox didn't know what to do with the pup.", * "He keenly observed and absorbed everything around him, from the birds in the sky to the trees in the forest.", * ] * ); */ export declare function embedTexts<RESPONSE, SETTINGS extends TextEmbeddingModelSettings>(model: TextEmbeddingModel<RESPONSE, SETTINGS>, texts: string[], options?: FunctionOptions<SETTINGS>): Promise<{ embeddings: Array<Vector>; metadata: CallMetadata<TextEmbeddingModel<RESPONSE, SETTINGS>>; }>; /** * Generate an embedding for a single text. * * @example * const { embedding } = await embedText( * new OpenAITextEmbeddingModel(...), * "At first, Nox didn't know what to do with the pup." * ); */ export declare function embedText<RESPONSE, SETTINGS extends TextEmbeddingModelSettings>(model: TextEmbeddingModel<RESPONSE, SETTINGS>, text: string, options?: FunctionOptions<SETTINGS>): Promise<{ embedding: Vector; metadata: CallMetadata<TextEmbeddingModel<RESPONSE, SETTINGS>>; }>;