@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
22 lines (21 loc) • 829 B
TypeScript
/**
* Emergency Content Truncation
*
* When message-level removal (sliding window) can't fit context into budget,
* this truncates the CONTENT of the longest messages as a last resort.
*/
import type { ChatMessage } from "../types/index.js";
/**
* Emergency content truncation: truncate the content of the longest messages
* to fit within the available token budget.
*
* Strategy: Sort messages by content length (descending), truncate each
* to a proportional share of the available budget until total fits.
*/
export declare function emergencyContentTruncation(messages: ChatMessage[], availableTokensForHistory: number, breakdown: {
systemPrompt: number;
conversationHistory: number;
currentPrompt: number;
toolDefinitions: number;
fileAttachments: number;
}, provider?: string): ChatMessage[];