import { ConversationHistory, Message } from "gpt-turbo"; import { MessageStats } from "./MessageStats.js"; import { StatsPluginData } from "../utils/types/index.js"; import { ConversationStatsStatsUpdateListener } from "../utils/types/conversationStats.types.js"; export declare class ConversationStats { private readonly history; private _cumulativeSize; private _cumulativeCost; private readonly messageStats; private readonly statsUpdateEvents; constructor(history: ConversationHistory, options?: StatsPluginData); /** * Gets the stats for a message in the conversation history. * * @param id The message id to get stats for. * @returns The stats for the message with the given id. * @throws If the message with the given id is not found in the conversation history. */ getMessageStats(id: string): MessageStats; /** * Shortcut for `getMessageStats(id).size`. */ getMessageSize(id: string): number; /** * Shortcut for `getMessageStats(id).cost`. */ getMessageCost(id: string): number; /** * Increments the cumulative size and cost of the conversation by the size and cost of the given message and the current conversation size and cost. * * @internal * Only meant to be used by gpt-turbo. */ onChatCompletion(message: Message): void; /** * Gets the plugin data for the `Conversation` instance. * * @internal * Only meant to be used by gpt-turbo. */ getPluginData(): StatsPluginData; /** * The current amount of tokens that the conversation contains. * This is the minimum amount of tokens that you will be charged for on your next prompt. * * @remarks * This is an estimate using the `gpt-tokenizer` library. Stats may vary with your actual usage of the API. */ get size(): number; /** * The cumulative amount of tokens that were sent/received to/from the OpenAI API. * * @remarks * This is an estimate using the `gpt-tokenizer` library. Stats may vary with your actual usage of the API. */ get cumulativeSize(): number; private set cumulativeSize(value); /** * The current cost of the conversation. * This is the minimum amount of $USD that you will be charged for on your next prompt. * * @remarks * This is an estimate using the `gpt-tokenizer` library. Stats may vary with your actual usage of the API. */ get cost(): number; /** * The cumulative cost of the conversation. * This is the total amount of $USD that you have been charged for the conversation so far. * * @remarks * This is an estimate using the `gpt-tokenizer` library. Stats may vary with your actual usage of the API. */ get cumulativeCost(): number; private set cumulativeCost(value); private createMessageStats; private getMessageById; onStatsUpdate(listener: ConversationStatsStatsUpdateListener): () => void; onceStatsUpdate(listener: ConversationStatsStatsUpdateListener): () => void; offStatsUpdate(listener: ConversationStatsStatsUpdateListener): void; }