UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

295 lines (294 loc) 10.8 kB
/** * Token Limit Constants for NeuroLink * * Centralized token configuration to replace magic numbers throughout the codebase. * Includes model-specific token limits, use-case optimized limits, and provider constraints. * * @fileoverview Token constants for AI model interactions * @author NeuroLink Team * @version 1.0.0 */ /** * Standard token limit categories * General-purpose token limits for different use cases */ export declare const TOKEN_LIMITS: { /** Conservative limits (reliable across all models) */ readonly CONSERVATIVE: 4096; /** Standard limits (most modern models) */ readonly STANDARD: 8192; /** High-capacity limits (premium models) */ readonly HIGH_CAPACITY: 16384; /** Large context windows (specialized models) */ readonly LARGE_CONTEXT: 100000; /** Ultra-large context windows (latest models) */ readonly ULTRA_LARGE_CONTEXT: 200000; /** Maximum context for any model */ readonly MAXIMUM_CONTEXT: 2097152; }; /** * Use-case specific token limits * Optimized token limits for different application scenarios */ export declare const USE_CASE_TOKENS: { /** Quick evaluation tasks */ readonly EVALUATION: 500; /** Analysis operations */ readonly ANALYSIS: 800; /** Summary generation */ readonly SUMMARY: 1000; /** Documentation generation */ readonly DOCUMENTATION: 12000; /** Code generation */ readonly CODE_GENERATION: 4000; /** Creative writing */ readonly CREATIVE_WRITING: 6000; /** Translation tasks */ readonly TRANSLATION: 2000; /** Conversation responses */ readonly CONVERSATION: 2048; /** Technical explanations */ readonly TECHNICAL_EXPLANATION: 3000; /** Research tasks */ readonly RESEARCH: 8000; }; /** * Provider-specific token limits * Safe token limits for each AI provider based on testing */ export declare const PROVIDER_TOKEN_LIMITS: { /** Anthropic model limits */ readonly ANTHROPIC: { readonly "claude-sonnet-4-5-20250929": 8192; readonly "claude-opus-4-5-20251101": 8192; readonly "claude-haiku-4-5-20251001": 8192; readonly "claude-3-5-sonnet-20241022": 4096; readonly "claude-3-5-haiku-20241022": 4096; readonly "claude-3-haiku-20240307": 4096; readonly "claude-3-opus-20240229": 4096; readonly "claude-3-sonnet-20240229": 4096; readonly default: 4096; }; /** OpenAI model limits */ readonly OPENAI: { readonly "gpt-5.4": 128000; readonly "gpt-5.4-mini": 128000; readonly "gpt-5.4-nano": 128000; readonly "gpt-5.4-pro": 128000; readonly "gpt-4o": 16384; readonly "gpt-4o-mini": 16384; readonly "gpt-3.5-turbo": 4096; readonly "gpt-4": 8192; readonly "gpt-4-turbo": 4096; readonly "o1-preview": 8192; readonly "o1-mini": 8192; readonly default: 8192; }; /** Google AI model limits */ readonly GOOGLE_AI: { readonly "gemini-3.1-pro-preview": 8192; readonly "gemini-3.1-flash-lite-preview": 65536; readonly "gemini-3.1-flash-image-preview": 8192; readonly "gemini-3.1-pro-preview-customtools": 8192; readonly "gemini-3-flash-preview": 65536; readonly "gemini-3-pro-image-preview": 8192; /** @deprecated SHUT DOWN March 9, 2026. Migrate to gemini-3.1-pro-preview. */ readonly "gemini-3-pro-preview": 8192; readonly "gemini-2.5-pro": 8192; readonly "gemini-2.5-flash": 8192; readonly "gemini-2.5-flash-lite": 8192; readonly "gemini-2.0-flash-001": 8192; readonly "gemini-2.0-flash-lite": 8192; readonly "gemini-1.5-pro": 8192; readonly "gemini-1.5-flash": 8192; readonly "gemini-1.5-flash-lite": 8192; readonly default: 4096; }; /** Google Vertex AI model limits */ readonly VERTEX: { readonly "gemini-3.1-pro-preview": 8192; readonly "gemini-3.1-flash-lite-preview": 65536; readonly "gemini-3.1-flash-image-preview": 8192; readonly "gemini-3.1-pro-preview-customtools": 8192; readonly "gemini-3-flash-preview": 65536; readonly "gemini-3-pro-image-preview": 8192; /** @deprecated SHUT DOWN March 9, 2026. Migrate to gemini-3.1-pro-preview. */ readonly "gemini-3-pro-preview": 8192; readonly "gemini-2.5-pro": 8192; readonly "gemini-2.5-flash": 8192; readonly "gemini-2.5-flash-lite": 8192; readonly "gemini-2.0-flash-001": 8192; readonly "gemini-2.0-flash-lite": 8192; readonly "gemini-1.5-pro": 8192; readonly "gemini-1.5-flash": 8192; readonly "claude-sonnet-4-5@20250929": 8192; readonly "claude-opus-4-5@20251124": 8192; readonly "claude-haiku-4-5@20251001": 8192; readonly "claude-sonnet-4@20250514": 4096; readonly "claude-opus-4@20250514": 4096; readonly "claude-3-5-sonnet-20241022": 4096; readonly "claude-3-5-haiku-20241022": 4096; readonly "claude-3-sonnet-20240229": 4096; readonly "claude-3-haiku-20240307": 4096; readonly "claude-3-opus-20240229": 4096; readonly default: 4096; }; /** AWS Bedrock model limits */ readonly BEDROCK: { readonly "anthropic.claude-sonnet-4-5-20250929-v1:0": 8192; readonly "anthropic.claude-opus-4-5-20251101-v1:0": 8192; readonly "anthropic.claude-haiku-4-5-20251001-v1:0": 8192; readonly "us.anthropic.claude-3-7-sonnet-20250219-v1:0": 4096; readonly "anthropic.claude-3-5-sonnet-20241022-v1:0": 4096; readonly "anthropic.claude-3-5-haiku-20241022-v1:0": 4096; readonly "anthropic.claude-3-sonnet-20240229-v1:0": 4096; readonly "anthropic.claude-3-haiku-20240307-v1:0": 4096; readonly "anthropic.claude-3-opus-20240229-v1:0": 4096; readonly default: 4096; }; /** Azure OpenAI model limits */ readonly AZURE: { readonly "gpt-4o": 16384; readonly "gpt-4o-mini": 16384; readonly "gpt-4": 8192; readonly "gpt-35-turbo": 4096; readonly default: 8192; }; /** Ollama model limits (local) */ readonly OLLAMA: { readonly "llama3.2:latest": 8192; readonly llama2: 4096; readonly codellama: 8192; readonly mistral: 4096; readonly default: 8192; }; /** Hugging Face model limits */ readonly HUGGINGFACE: { readonly default: 2048; }; /** Mistral model limits */ readonly MISTRAL: { readonly "mistral-small-latest": 4096; readonly "mistral-medium-latest": 4096; readonly "mistral-large-latest": 8192; readonly default: 4096; }; /** LiteLLM proxy limits */ readonly LITELLM: { readonly default: 4096; }; /** Safe default across all providers */ readonly DEFAULT: 4096; }; /** * Context window sizes for different models * Maximum input token limits (separate from output limits) */ export declare const CONTEXT_WINDOWS: { /** Small context models */ readonly SMALL: 4096; /** Medium context models */ readonly MEDIUM: 32768; /** Large context models */ readonly LARGE: 128000; /** Ultra-large context models */ readonly ULTRA_LARGE: 1048576; /** Maximum theoretical context */ readonly MAXIMUM: 2097152; }; /** * Model-specific token limits with input/output breakdown * For models that require explicit input and output token limits */ export declare const MODEL_TOKEN_LIMITS: { /** Gemini 3.1 Series */ readonly "gemini-3.1-pro-preview": { readonly input: 1048576; readonly output: 65536; }; readonly "gemini-3.1-flash-lite-preview": { readonly input: 1048576; readonly output: 65536; }; readonly "gemini-3.1-flash-image-preview": { readonly input: 1048576; readonly output: 8192; }; readonly "gemini-3.1-pro-preview-customtools": { readonly input: 1048576; readonly output: 65536; }; /** Gemini 3 Flash Series */ readonly "gemini-3-flash-preview": { readonly input: 1000000; readonly output: 65536; }; }; /** * Token estimation utilities * Rough estimates for token counting without full tokenization */ export declare const TOKEN_ESTIMATION: { /** Average characters per token (English) */ readonly CHARS_PER_TOKEN: 4; /** Average words per token */ readonly WORDS_PER_TOKEN: 0.75; /** Code characters per token (more compact) */ readonly CODE_CHARS_PER_TOKEN: 3; /** Safety margin for token estimates */ readonly SAFETY_MARGIN: 0.8; }; /** * Token utility functions */ export declare const TokenUtils: { /** * Get safe token limit for a specific provider and model * @param provider - Provider name * @param model - Model name (optional) * @returns Safe token limit for the provider/model */ readonly getProviderTokenLimit: (provider: string, model?: string) => number; /** * Get token limit for specific use case * @param useCase - Use case type * @returns Appropriate token limit */ readonly getUseCaseTokenLimit: (useCase: keyof typeof USE_CASE_TOKENS) => number; /** * Estimate token count from text * @param text - Input text * @param isCode - Whether the text is code (more compact tokenization) * @returns Estimated token count */ readonly estimateTokenCount: (text: string, isCode?: boolean) => number; /** * Check if text exceeds token limit * @param text - Input text * @param limit - Token limit to check against * @param isCode - Whether the text is code * @returns True if text exceeds limit */ readonly exceedsTokenLimit: (text: string, limit: number, isCode?: boolean) => boolean; /** * Get appropriate token limit category * @param estimatedTokens - Estimated token count * @returns Token limit category */ readonly getTokenLimitCategory: (estimatedTokens: number) => keyof typeof TOKEN_LIMITS; /** * Truncate text to fit within token limit * @param text - Input text * @param tokenLimit - Maximum tokens allowed * @param isCode - Whether the text is code * @returns Truncated text */ readonly truncateToTokenLimit: (text: string, tokenLimit: number, isCode?: boolean) => string; }; export declare const DEFAULT_MAX_TOKENS: 8192; export declare const DEFAULT_EVALUATION_MAX_TOKENS: 500; export declare const DEFAULT_ANALYSIS_MAX_TOKENS: 800; export declare const DEFAULT_DOCUMENTATION_MAX_TOKENS: 12000; export declare const ANTHROPIC_SAFE: 4096; export declare const OPENAI_STANDARD: 8192; export declare const GOOGLE_STANDARD: 4096;