/** * Utility class for optimizing prompt size before sending to AI models. * * For Models: gpt-4o-mini-realtime-preview and gpt-4o-realtime-preview * Max Prompt Size (): 128,000 tokens * * Truncation Strategy: * - Removes 10% of the prompt length from the end each iteration * - Continues until token count is safely under MAX_TOKENS * * Example with a 10-word sentence (each word = 1 token) and MAX_TOKENS = 7: * 1. "The quick white fox jumps over the lazy dog today" (10 tokens) * 2. "The quick white fox jumps over the lazy dog" (9 tokens) * 3. "The quick white fox jumps over the" (8 tokens) * 4. "The quick white fox jumps over" (7 tokens) * 5. "The quick white fox jumps" (6 tokens) ✓ * * We remove from the end because: * - Important context is usually at the beginning of prompts * - System instructions and core functionality are typically defined first * - Later parts often contain supplementary information */ export declare class PromptSizeOptimizer { /** * Optimizes the size of a prompt to ensure it fits within model requirements. * @param prompt The input prompt to optimize * @returns An object with the optimized prompt and its token size */ static optimize(originalPrompt: string): { prompt: string; tokenSize: number; }; /** * Truncates the prompt by removing 10% from the end each iteration until it fits within token limits. * @param prompt The prompt to truncate * @param encoder The token encoder to use * @returns The truncated prompt that fits within token limits */ private static truncatePrompt; }