@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
37 lines (36 loc) • 1.41 kB
TypeScript
/**
* Context Overflow Error Detection
*
* Cross-provider regex patterns to detect context window overflow errors.
* Modeled on Cline + pi-mono patterns.
*/
/**
* Check if an error is a context overflow error from any provider.
*/
export declare function isContextOverflowError(error: unknown): boolean;
/**
* Identify which provider produced the context overflow error.
*/
export declare function getContextOverflowProvider(error: unknown): string | null;
/**
* Extract actual token counts from provider overflow error messages.
*
* Many providers include the actual/max token counts in their error messages:
* - OpenAI: "This model's maximum context length is 128000 tokens. However, your messages resulted in 145000 tokens."
* - Anthropic: "prompt is too long: 180000 tokens > 200000 token limit"
* - Google: "exceeds the maximum number of tokens (180000 > 100000)"
*/
export declare function parseProviderOverflowDetails(error: unknown): {
actualTokens: number;
budgetTokens: number;
/**
* Output tokens the rejected request asked for, when the message states
* them separately (vllm/LiteLLM phrasing). Lets recovery re-fit
* max_tokens instead of shrinking the input.
*/
requestedOutputTokens?: number;
} | null;
/**
* Extract error message from various error formats.
*/
export declare function extractErrorMessage(error: unknown): string | null;