import type { ActorData, Message } from "./types.js"; /** * Reduce a map to a record. Optionally sort the entries before reducing. * @param map The map to reduce * @param sort The sort function to use, if any * @returns A record of the map's entries */ export declare function reduce(map: Record, sort?: (a: T, b: T) => number): Record; /** * Mask the messages in a conversation. Masking the messages in a conversation * removes the messages that are outside of the window. The window is the * maximum combined length of the embeddings of the messages. A heuristic is * used to approximate the length of the embeddings for messages that do not * have embeddings. * @param messages The messages to mask. * @param window The maximum combined length of the embeddings of the messages. * @returns The unmasked messages. */ export declare function mask(messages: Message[], window: number): Message[]; /** * Get the dot product of two vectors. * @param x The first vector. * @param y The second vector. * @returns The dot product of the two vectors. */ export declare function dotProduct(x: number[], y: number[]): number; /** * Get the cosine similarity of two vectors. The cosine similarity is a measure * of similarity between two vectors. The similarity value is a number between * -1 and 1. A value of 1 means the vectors are identical. A value of -1 means * the vectors are opposite. A value of 0 means the vectors are orthogonal. * @param a The first vector. * @param b The second vector. * @returns The cosine similarity of the two vectors. */ export declare function cosineSimilarity(a: number[], b: number[]): number; /** * Get the approximate length of a text. This method is used when a text * does not have tokens. The heuristic is based on OpenAI's notion that * 1k tokens is roughly 750 words (3/4ths). */ export declare function heuristic(text: string): number; export interface IndexedActorData extends ActorData { section: string; type: string; index: number; } /** * Build a window of values. The window is built by adding values in order * until the maximum number of tokens is reached. The values are sorted by * `keep` (true first), then by `priority` (high first), then by index * (low first). Then the values are sorted by the original index, so that * the values are returned in the original order. * @param inputValues The values to build the window from * @param maxTokens The maximum number of tokens in the window * @returns The values in the window in the original order */ export declare function buildWindow(inputValues: Record>, maxTokens: number): Record; /** * Load a prompt template from the templates directory. * @param name The name of the template to load * @returns The template as a string */ export declare function loadTemplate(name: string): Promise;