import { VOCAB } from '@/lib/white-label/constants';

/**
 * ${VOCAB.factory} - Multi-LLM Model Configuration
 * Allows users to pick which model powers each pipeline stage
 */

export interface LLMModelOption {
  id: string;
  name: string;
  provider: 'abacus' | 'openai' | 'grok';
  description: string;
  icon: string;
  strengths: string[];
  speed: 'fast' | 'medium' | 'slow';
  quality: 'good' | 'great' | 'best';
  costTier: 'low' | 'medium' | 'high';
}

export type PipelineStage = 'architecture' | 'database' | 'api' | 'ui';

export interface LLMStageConfig {
  architecture: string; // model id
  database: string;
  api: string;
  ui: string;
}

export const LLM_MODELS: LLMModelOption[] = [
  {
    id: 'claude-sonnet-4-20250514',
    name: 'Claude Sonnet 4',
    provider: 'abacus',
    description: 'Balanced speed & quality. Excellent at code generation and architecture design.',
    icon: '🟣',
    strengths: ['Code generation', 'Architecture', 'Reasoning'],
    speed: 'medium',
    quality: 'best',
    costTier: 'medium',
  },
  {
    id: 'gpt-4o-2024-11-20',
    name: 'GPT-4o',
    provider: 'abacus',
    description: 'Fast multimodal model. Great for rapid code scaffolding and UI components.',
    icon: '🟢',
    strengths: ['Fast output', 'UI components', 'Versatile'],
    speed: 'fast',
    quality: 'great',
    costTier: 'medium',
  },
  {
    id: 'gpt-4o-mini',
    name: 'GPT-4o Mini',
    provider: 'abacus',
    description: 'Lightweight and fast. Good for simpler generation tasks and quick iterations.',
    icon: '⚡',
    strengths: ['Speed', 'Cost-effective', 'Simple tasks'],
    speed: 'fast',
    quality: 'good',
    costTier: 'low',
  },
  {
    id: 'o3-mini',
    name: 'o3-mini',
    provider: 'abacus',
    description: 'Advanced reasoning model. Best for complex architecture and business logic.',
    icon: '🧠',
    strengths: ['Deep reasoning', 'Complex logic', 'Architecture'],
    speed: 'slow',
    quality: 'best',
    costTier: 'high',
  },
  {
    id: 'gemini-2.5-pro',
    name: 'Gemini 2.5 Pro',
    provider: 'abacus',
    description: 'Google\'s flagship. Strong at long-context understanding and code generation.',
    icon: '💎',
    strengths: ['Long context', 'Code generation', 'Analysis'],
    speed: 'medium',
    quality: 'best',
    costTier: 'medium',
  },
  {
    id: 'deepseek-ai/DeepSeek-R1',
    name: 'DeepSeek R1',
    provider: 'abacus',
    description: 'Open-source reasoning model. Great for complex schema and API design.',
    icon: '🔬',
    strengths: ['Reasoning', 'Schema design', 'Open-source'],
    speed: 'medium',
    quality: 'great',
    costTier: 'low',
  },
  {
    id: 'meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo',
    name: 'Llama 3.1 405B',
    provider: 'abacus',
    description: 'Meta\'s largest open model. Strong code and instruction following.',
    icon: '🦙',
    strengths: ['Large-scale', 'Code', 'Instruction following'],
    speed: 'medium',
    quality: 'great',
    costTier: 'medium',
  },
];

/** Default model assignments per stage */
export const DEFAULT_STAGE_CONFIG: LLMStageConfig = {
  architecture: 'claude-sonnet-4-20250514',
  database: 'claude-sonnet-4-20250514',
  api: 'claude-sonnet-4-20250514',
  ui: 'gpt-4o-2024-11-20',
};

export const STAGE_INFO: Record<PipelineStage, { label: string; description: string; icon: string }> = {
  architecture: {
    label: 'Architecture Design',
    description: 'Designs the overall system architecture, models, and endpoints',
    icon: '🏗️',
  },
  database: {
    label: 'Database Models',
    description: 'Generates database schemas, models, and migrations',
    icon: '🗄️',
  },
  api: {
    label: 'API Routes',
    description: 'Generates API endpoints, controllers, and business logic',
    icon: '🔌',
  },
  ui: {
    label: 'UI Components',
    description: 'Generates frontend components, pages, and forms',
    icon: '🎨',
  },
};

export function getModelById(id: string): LLMModelOption | undefined {
  return LLM_MODELS.find(m => m.id === id);
}

export function getModelsForStage(stage: PipelineStage): LLMModelOption[] {
  // All models can be used for any stage, but we could add filtering logic
  return LLM_MODELS;
}
