UNPKG

@iota-big3/sdk-gateway

Version:

Universal API Gateway with protocol translation, intelligent routing, rate limiting, health checking, and caching

312 lines 11.3 kB
"use strict"; /** * AI & Machine Learning Type Definitions * * @module ai-ml-types * @description Comprehensive types for AI/ML operations including: * - Model definitions and lifecycle * - Training configurations and datasets * - Inference and predictions * - Feature engineering * - Experiment tracking * - Model monitoring and drift detection * - AI assistants and agents * - Prompt engineering * * Designed for maximum AI/debugging friendliness */ Object.defineProperty(exports, "__esModule", { value: true }); exports.aiMLTypes = exports.AICapability = exports.DriftType = exports.DeploymentStatus = exports.DeploymentEnvironment = exports.TrainingStatus = exports.PreprocessingType = exports.DataType = exports.FeatureType = exports.DataFormat = exports.DatasetType = exports.ModelStatus = exports.MLFramework = exports.ModelType = void 0; exports.validateModelProduction = validateModelProduction; exports.calculateModelComplexity = calculateModelComplexity; exports.estimateTrainingTime = estimateTrainingTime; /** * Types of ML models */ var ModelType; (function (ModelType) { // Traditional ML ModelType["Classification"] = "CLASSIFICATION"; ModelType["Regression"] = "REGRESSION"; ModelType["Clustering"] = "CLUSTERING"; ModelType["DimensionalityReduction"] = "DIMENSIONALITY_REDUCTION"; ModelType["AnomalyDetection"] = "ANOMALY_DETECTION"; ModelType["RecommendationSystem"] = "RECOMMENDATION_SYSTEM"; // Deep Learning ModelType["CNN"] = "CNN"; ModelType["RNN"] = "RNN"; ModelType["LSTM"] = "LSTM"; ModelType["GRU"] = "GRU"; ModelType["Transformer"] = "TRANSFORMER"; ModelType["GAN"] = "GAN"; ModelType["VAE"] = "VAE"; // Specialized ModelType["NLP"] = "NLP"; ModelType["ComputerVision"] = "COMPUTER_VISION"; ModelType["TimeSeries"] = "TIME_SERIES"; ModelType["ReinforcementLearning"] = "REINFORCEMENT_LEARNING"; ModelType["GraphNeural"] = "GRAPH_NEURAL"; // AI Models ModelType["LLM"] = "LLM"; ModelType["VisionLanguageModel"] = "VISION_LANGUAGE_MODEL"; ModelType["SpeechModel"] = "SPEECH_MODEL"; ModelType["MultiModal"] = "MULTI_MODAL"; })(ModelType || (exports.ModelType = ModelType = {})); /** * ML frameworks */ var MLFramework; (function (MLFramework) { MLFramework["TensorFlow"] = "TENSORFLOW"; MLFramework["PyTorch"] = "PYTORCH"; MLFramework["ScikitLearn"] = "SCIKIT_LEARN"; MLFramework["XGBoost"] = "XGBOOST"; MLFramework["LightGBM"] = "LIGHTGBM"; MLFramework["Keras"] = "KERAS"; MLFramework["JAX"] = "JAX"; MLFramework["ONNX"] = "ONNX"; MLFramework["HuggingFace"] = "HUGGING_FACE"; MLFramework["OpenAI"] = "OPENAI"; MLFramework["Anthropic"] = "ANTHROPIC"; MLFramework["Custom"] = "CUSTOM"; })(MLFramework || (exports.MLFramework = MLFramework = {})); /** * Model status in lifecycle */ var ModelStatus; (function (ModelStatus) { ModelStatus["Draft"] = "DRAFT"; ModelStatus["Training"] = "TRAINING"; ModelStatus["Evaluating"] = "EVALUATING"; ModelStatus["Validated"] = "VALIDATED"; ModelStatus["Deployed"] = "DEPLOYED"; ModelStatus["Deprecated"] = "DEPRECATED"; ModelStatus["Archived"] = "ARCHIVED"; })(ModelStatus || (exports.ModelStatus = ModelStatus = {})); /** * Dataset types */ var DatasetType; (function (DatasetType) { DatasetType["Tabular"] = "TABULAR"; DatasetType["Text"] = "TEXT"; DatasetType["Image"] = "IMAGE"; DatasetType["Audio"] = "AUDIO"; DatasetType["Video"] = "VIDEO"; DatasetType["TimeSeries"] = "TIME_SERIES"; DatasetType["Graph"] = "GRAPH"; DatasetType["MultiModal"] = "MULTI_MODAL"; })(DatasetType || (exports.DatasetType = DatasetType = {})); /** * Data formats */ var DataFormat; (function (DataFormat) { DataFormat["CSV"] = "CSV"; DataFormat["JSON"] = "JSON"; DataFormat["Parquet"] = "PARQUET"; DataFormat["TFRecord"] = "TFRECORD"; DataFormat["ImageFolder"] = "IMAGE_FOLDER"; DataFormat["COCO"] = "COCO"; DataFormat["YOLO"] = "YOLO"; DataFormat["HuggingFaceDataset"] = "HUGGING_FACE_DATASET"; DataFormat["Custom"] = "CUSTOM"; })(DataFormat || (exports.DataFormat = DataFormat = {})); /** * Feature types */ var FeatureType; (function (FeatureType) { FeatureType["Numeric"] = "NUMERIC"; FeatureType["Categorical"] = "CATEGORICAL"; FeatureType["Text"] = "TEXT"; FeatureType["DateTime"] = "DATETIME"; FeatureType["Binary"] = "BINARY"; FeatureType["Embedding"] = "EMBEDDING"; FeatureType["Image"] = "IMAGE"; FeatureType["Audio"] = "AUDIO"; FeatureType["Video"] = "VIDEO"; })(FeatureType || (exports.FeatureType = FeatureType = {})); /** * Data types */ var DataType; (function (DataType) { DataType["Int8"] = "INT8"; DataType["Int16"] = "INT16"; DataType["Int32"] = "INT32"; DataType["Int64"] = "INT64"; DataType["Float16"] = "FLOAT16"; DataType["Float32"] = "FLOAT32"; DataType["Float64"] = "FLOAT64"; DataType["String"] = "STRING"; DataType["Boolean"] = "BOOLEAN"; DataType["Bytes"] = "BYTES"; })(DataType || (exports.DataType = DataType = {})); /** * Preprocessing types */ var PreprocessingType; (function (PreprocessingType) { // Numeric PreprocessingType["Normalize"] = "NORMALIZE"; PreprocessingType["Standardize"] = "STANDARDIZE"; PreprocessingType["MinMaxScale"] = "MIN_MAX_SCALE"; PreprocessingType["RobustScale"] = "ROBUST_SCALE"; PreprocessingType["LogTransform"] = "LOG_TRANSFORM"; // Categorical PreprocessingType["OneHotEncode"] = "ONE_HOT_ENCODE"; PreprocessingType["LabelEncode"] = "LABEL_ENCODE"; PreprocessingType["TargetEncode"] = "TARGET_ENCODE"; // Text PreprocessingType["Tokenize"] = "TOKENIZE"; PreprocessingType["Lowercase"] = "LOWERCASE"; PreprocessingType["RemoveStopwords"] = "REMOVE_STOPWORDS"; PreprocessingType["Stemming"] = "STEMMING"; PreprocessingType["Lemmatization"] = "LEMMATIZATION"; // General PreprocessingType["ImputeMissing"] = "IMPUTE_MISSING"; PreprocessingType["RemoveOutliers"] = "REMOVE_OUTLIERS"; PreprocessingType["FeatureEngineering"] = "FEATURE_ENGINEERING"; })(PreprocessingType || (exports.PreprocessingType = PreprocessingType = {})); /** * Training status */ var TrainingStatus; (function (TrainingStatus) { TrainingStatus["Pending"] = "PENDING"; TrainingStatus["Running"] = "RUNNING"; TrainingStatus["Completed"] = "COMPLETED"; TrainingStatus["Failed"] = "FAILED"; TrainingStatus["Cancelled"] = "CANCELLED"; TrainingStatus["Paused"] = "PAUSED"; })(TrainingStatus || (exports.TrainingStatus = TrainingStatus = {})); /** * Deployment environments */ var DeploymentEnvironment; (function (DeploymentEnvironment) { DeploymentEnvironment["Development"] = "DEVELOPMENT"; DeploymentEnvironment["Staging"] = "STAGING"; DeploymentEnvironment["Production"] = "PRODUCTION"; DeploymentEnvironment["Edge"] = "EDGE"; DeploymentEnvironment["Mobile"] = "MOBILE"; })(DeploymentEnvironment || (exports.DeploymentEnvironment = DeploymentEnvironment = {})); /** * Deployment status */ var DeploymentStatus; (function (DeploymentStatus) { DeploymentStatus["Pending"] = "PENDING"; DeploymentStatus["Deploying"] = "DEPLOYING"; DeploymentStatus["Running"] = "RUNNING"; DeploymentStatus["Updating"] = "UPDATING"; DeploymentStatus["Scaling"] = "SCALING"; DeploymentStatus["Failed"] = "FAILED"; DeploymentStatus["Stopped"] = "STOPPED"; })(DeploymentStatus || (exports.DeploymentStatus = DeploymentStatus = {})); /** * Types of model drift */ var DriftType; (function (DriftType) { DriftType["DataDrift"] = "DATA_DRIFT"; DriftType["ConceptDrift"] = "CONCEPT_DRIFT"; DriftType["PredictionDrift"] = "PREDICTION_DRIFT"; DriftType["PerformanceDrift"] = "PERFORMANCE_DRIFT"; // Accuracy degradation })(DriftType || (exports.DriftType = DriftType = {})); /** * AI capabilities */ var AICapability; (function (AICapability) { AICapability["TextGeneration"] = "TEXT_GENERATION"; AICapability["CodeGeneration"] = "CODE_GENERATION"; AICapability["QuestionAnswering"] = "QUESTION_ANSWERING"; AICapability["Summarization"] = "SUMMARIZATION"; AICapability["Translation"] = "TRANSLATION"; AICapability["SentimentAnalysis"] = "SENTIMENT_ANALYSIS"; AICapability["ImageGeneration"] = "IMAGE_GENERATION"; AICapability["ImageAnalysis"] = "IMAGE_ANALYSIS"; AICapability["SpeechRecognition"] = "SPEECH_RECOGNITION"; AICapability["SpeechSynthesis"] = "SPEECH_SYNTHESIS"; AICapability["ReasoningChain"] = "REASONING_CHAIN"; AICapability["ToolUse"] = "TOOL_USE"; })(AICapability || (exports.AICapability = AICapability = {})); // ============================================ // Validation Functions // ============================================ /** * Validate model readiness for production */ function validateModelProduction(model, performance) { const errors = []; // Check model status if (model.status !== ModelStatus.Validated && model.status !== ModelStatus.Deployed) { errors.push('Model must be validated before production deployment'); } // Check performance thresholds const metrics = performance.metrics; if (metrics.accuracy !== undefined && metrics.accuracy < 0.8) { errors.push('Model accuracy below 80% threshold'); } // Check for bias/fairness metrics if (!model.metadata.ethicalConsiderations) { errors.push('Missing ethical considerations documentation'); } // Check for model documentation if (!model.metadata.limitations || model.metadata.limitations.length === 0) { errors.push('Model limitations must be documented'); } if (errors.length > 0) { return { success: false, error: errors }; } return { success: true, data: true }; } /** * Calculate model complexity score */ function calculateModelComplexity(architecture) { const paramCount = architecture.parameters.total; const layerCount = architecture.layers?.length || 0; // Simple heuristic: log scale of parameters + layer depth const paramScore = Math.log10(paramCount + 1); const depthScore = layerCount * 0.1; return Math.min(10, paramScore + depthScore); } /** * Estimate training time */ function estimateTrainingTime(modelComplexity, datasetSize, config) { // Simple estimation formula (would be more complex in reality) const baseTime = 60; // seconds const complexityFactor = modelComplexity; const dataFactor = Math.log10(datasetSize + 1); const epochFactor = config.training.epochs || 1; const gpuSpeedup = config.resources.gpu ? 0.1 : 1; return baseTime * complexityFactor * dataFactor * epochFactor * gpuSpeedup; } // ============================================ // Export AI/ML Types // ============================================ exports.aiMLTypes = { // Enums ModelType, MLFramework, ModelStatus, DatasetType, DataFormat, FeatureType, DataType, PreprocessingType, TrainingStatus, DeploymentEnvironment, DeploymentStatus, DriftType, AICapability, // Functions validateModelProduction, calculateModelComplexity, estimateTrainingTime }; //# sourceMappingURL=ai-ml-types.js.map