UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and

247 lines (246 loc) 7.33 kB
/** * Model Configuration System * * Replaces hardcoded model-specific logic with configurable, runtime-updateable configurations. * This addresses GitHub Copilot review comment about making model-specific logic configuration-based. */ import type { JsonValue } from "../types/common.js"; /** * Model name constants - extracted from hardcoded values for better maintainability * These constants can be overridden by environment variables */ export declare const MODEL_NAMES: { readonly GOOGLE_AI: { readonly FAST: "gemini-2.5-flash"; readonly BALANCED: "gemini-2.5-pro"; readonly QUALITY: "gemini-2.5-pro"; }; readonly GOOGLE_VERTEX: { readonly FAST: "gemini-2.5-flash"; readonly BALANCED: "gemini-2.5-pro"; readonly QUALITY: "gemini-2.5-pro"; }; readonly OPENAI: { readonly FAST: "gpt-4o-mini"; readonly BALANCED: "gpt-4o"; readonly QUALITY: "gpt-4o"; }; readonly ANTHROPIC: { readonly FAST: "claude-3-haiku-20240307"; readonly BALANCED: "claude-3-sonnet-20240229"; readonly QUALITY: "claude-3-5-sonnet-20241022"; }; readonly VERTEX: { readonly FAST: "gemini-2.5-flash"; readonly BALANCED: "gemini-2.5-pro"; readonly QUALITY: "gemini-2.5-pro"; }; readonly BEDROCK: { readonly FAST: "anthropic.claude-3-haiku-20240307-v1:0"; readonly BALANCED: "anthropic.claude-3-sonnet-20240229-v1:0"; readonly QUALITY: "anthropic.claude-3-opus-20240229-v1:0"; }; readonly AZURE: { readonly FAST: "gpt-4o-mini"; readonly BALANCED: "gpt-4o"; readonly QUALITY: "gpt-4o"; }; readonly OLLAMA: { readonly FAST: "llama3.2:latest"; readonly BALANCED: "llama3.1:8b"; readonly QUALITY: "llama3.1:70b"; }; readonly HUGGINGFACE: { readonly FAST: "microsoft/DialoGPT-medium"; readonly BALANCED: "microsoft/DialoGPT-large"; readonly QUALITY: "meta-llama/Llama-2-7b-chat-hf"; }; readonly MISTRAL: { readonly FAST: "mistral-small-latest"; readonly BALANCED: "mistral-medium-latest"; readonly QUALITY: "mistral-large-latest"; }; }; /** * Model performance tier definition */ export type ModelTier = "fast" | "balanced" | "quality"; /** * Model configuration for a specific provider */ export interface ModelConfig { /** Model identifier */ id: string; /** Display name */ name: string; /** Performance tier */ tier: ModelTier; /** Cost per 1K tokens */ cost: { input: number; output: number; }; /** Model capabilities */ capabilities: string[]; /** Model-specific options */ options?: Record<string, JsonValue>; } /** * Provider configuration with models */ export interface ProviderConfig { /** Provider name */ provider: string; /** Available models by tier */ models: Record<ModelTier, string>; /** Default cost per token (fallback) */ defaultCost: { input: number; output: number; }; /** Required environment variables */ requiredEnvVars: string[]; /** Provider-specific performance metrics */ performance: { speed: number; quality: number; cost: number; }; /** Provider-specific model configurations */ modelConfigs?: Record<string, ModelConfig>; /** Provider-specific model behavior configurations */ modelBehavior?: { /** Models that have issues with maxTokens parameter */ maxTokensIssues?: string[]; /** Models that require special handling */ specialHandling?: Record<string, JsonValue>; /** Models that support tool calling (Ollama-specific) */ toolCapableModels?: string[]; }; } /** * Configuration source type */ export type ConfigSource = "default" | "environment" | "file" | "dynamic"; /** * Model configuration manager */ export declare class ModelConfigurationManager { private static instance; private configurations; private configSource; private lastUpdated; private constructor(); static getInstance(): ModelConfigurationManager; /** * Load default configurations (replaces hardcoded values) */ private loadDefaultConfigurations; /** * Helper method to get configuration value with fallback and validation */ private getConfigValue; /** * Validate configuration values for security and correctness */ private isValidConfigValue; /** * Helper method to get configuration array with fallback * Parses comma-separated environment variable values */ private getConfigArray; /** * Helper method to parse float with fallback */ private parseFloat; /** * Helper method to parse int with fallback */ private parseInt; /** * Helper method to get configuration object with fallback * Parses JSON environment variable values */ private getConfigObject; /** * Get provider configuration */ getProviderConfig(provider: string): ProviderConfig | null; /** * Get all provider configurations */ getAllConfigurations(): Map<string, ProviderConfig>; /** * Update provider configuration (runtime updates) */ updateProviderConfig(provider: string, config: ProviderConfig): void; /** * Load configurations from external source */ loadConfigurationsFromFile(configPath: string): void; /** * Validate provider configuration structure */ private isValidProviderConfig; /** * Apply model name overrides from configuration file */ private applyModelNameOverrides; /** * Apply global default configurations */ private applyGlobalDefaults; /** * Get configuration metadata */ getConfigurationMeta(): { source: ConfigSource; lastUpdated: number; providerCount: number; }; /** * Get model for specific tier and provider */ getModelForTier(provider: string, tier: ModelTier): string | null; /** * Get cost information for provider and model */ getCostInfo(provider: string, model?: string): { input: number; output: number; } | null; /** * Check if provider is available (has required environment variables) */ isProviderAvailable(provider: string): boolean; /** * Get available providers */ getAvailableProviders(): ProviderConfig[]; } /** * Global instance accessor */ export declare const modelConfig: ModelConfigurationManager; /** * Convenience functions for common operations */ /** * Get provider configuration (backwards compatible) */ export declare function getProviderConfig(provider: string): ProviderConfig | null; /** * Get model for tier (backwards compatible) */ export declare function getModelForTier(provider: string, tier: ModelTier): string | null; /** * Get cost information (backwards compatible) */ export declare function getCostInfo(provider: string, model?: string): { input: number; output: number; } | null; /** * Check provider availability (backwards compatible) */ export declare function isProviderAvailable(provider: string): boolean;