/**
 * AI 模型配置中心
 *
 * 模型 ID 来源：各大厂商官方文档 + OpenRouter 实时模型列表（2026-05）
 * - OpenAI:    platform.openai.com/docs/models
 * - Anthropic: docs.anthropic.com/en/docs/about-claude/models
 * - Google:    ai.google.dev/gemini-api/docs/models
 * - DeepSeek:  platform.deepseek.com
 * - 阿里云:    help.aliyun.com/zh/model-studio
 * - Moonshot:  platform.moonshot.cn
 * - 智谱AI:    open.bigmodel.cn
 *
 * ⚠️ 每次版本更新后请同步此处
 */

import type { AIModel, ModelProvider, ModelCategory } from '@/core/types';

export interface ModelVerificationMeta {
  checkedAt: string;
  source: string;
  verified: boolean;
  note?: string;
}

export const MODEL_PROVIDERS: Record<
  ModelProvider,
  {
    name: string;
    icon: string;
    website: string;
    apiDocs: string;
    keyFormat: string;
    keyPlaceholder: string;
  }
> = {
  openai: {
    name: 'OpenAI',
    icon: 'https://upload.wikimedia.org/wikipedia/commons/0/04/ChatGPT_logo.svg',
    website: 'https://platform.openai.com',
    apiDocs: 'https://platform.openai.com/docs/models',
    keyFormat: 'sk-...',
    keyPlaceholder: 'sk-xxx...xxxx',
  },
  anthropic: {
    name: 'Anthropic',
    icon: 'https://www.anthropic.com/images/icons/apple-touch-icon.png',
    website: 'https://www.anthropic.com',
    apiDocs: 'https://docs.anthropic.com/en/docs/about-claude/models',
    keyFormat: 'sk-ant-...',
    keyPlaceholder: 'sk-ant...xxxx',
  },
  google: {
    name: 'Google',
    icon: 'https://www.gstatic.com/lamda/images/gemini_sparkle_v002_d4735304ff6292a690345.svg',
    website: 'https://ai.google.dev',
    apiDocs: 'https://ai.google.dev/gemini-api/docs/models',
    keyFormat: 'AIza...',
    keyPlaceholder: 'AIzaSyxxxxxxxxxxxxxxxx',
  },
  alibaba: {
    name: '阿里云',
    icon: 'https://img.alicdn.com/tfs/TB1Ly5oS3HqK1RjSZFPXXcwapXa-238-54.png',
    website: 'https://dashscope.aliyun.com',
    apiDocs: 'https://help.aliyun.com/zh/model-studio/getting-started/models',
    keyFormat: 'sk-...',
    keyPlaceholder: 'sk-xxx...xxxx',
  },
  zhipu: {
    name: '智谱AI',
    icon: 'https://www.zhipuai.cn/favicon.ico',
    website: 'https://open.bigmodel.cn',
    apiDocs: 'https://open.bigmodel.cn',
    keyFormat: '...',
    keyPlaceholder: 'xxxxxxxx.xxxxxxxx',
  },
  iflytek: {
    name: '科大讯飞',
    icon: 'https://xinghuo.xfyun.cn/favicon.ico',
    website: 'https://xinghuo.xfyun.cn',
    apiDocs: 'https://www.xfyun.cn/doc/spark/Web.html',
    keyFormat: 'APPID:API_KEY:API_SECRET',
    keyPlaceholder: '请输入 APPID、API_KEY 和 API_SECRET',
  },
  deepseek: {
    name: 'DeepSeek',
    icon: 'https://www.deepseek.com/favicon.ico',
    website: 'https://platform.deepseek.com',
    apiDocs: 'https://platform.deepseek.com/docs/guides/chat',
    keyFormat: 'sk-...',
    keyPlaceholder: 'sk-xxx...xxxx',
  },
  moonshot: {
    name: '月之暗面',
    icon: 'https://kimi.moonshot.cn/favicon.ico',
    website: 'https://platform.moonshot.cn',
    apiDocs: 'https://platform.moonshot.cn/docs',
    keyFormat: 'sk-...',
    keyPlaceholder: 'sk-xxx...xxxx',
  },
  local: {
    name: '本地模型',
    icon: 'https://localhost/favicon.ico',
    website: 'https://github.com',
    apiDocs: 'https://github.com',
    keyFormat: 'Local Endpoint',
    keyPlaceholder: 'http://localhost:11434',
  },
  custom: {
    name: '自定义',
    icon: 'https://localhost/favicon.ico',
    website: 'https://github.com',
    apiDocs: 'https://github.com',
    keyFormat: 'API Key',
    keyPlaceholder: 'Your Custom API Key',
  },
};

// =============================================================================
// 验证元数据（来源：各大厂商官方文档 + OpenRouter 实时数据，2026-05）
// =============================================================================

export const MODEL_CATALOG_VERIFIED_AT = '2026-05-13';
export const DEFAULT_MODEL_ID = 'gpt-4o' as const;

export const MODEL_VERIFICATION: Record<string, ModelVerificationMeta> = {
  // OpenAI
  'gpt-5.5':      { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.5 (API confirmed)', verified: true },
  'gpt-5.5-pro':  { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.5-pro (API confirmed)', verified: true },
  'gpt-5.4':       { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.4 (API confirmed)', verified: true },
  'gpt-5.4-mini': { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.4-mini (API confirmed)', verified: true },
  'gpt-5.4-nano': { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.4-nano (API confirmed)', verified: true },
  'gpt-5.4-pro':  { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.4-pro (API confirmed)', verified: true },
  'gpt-5.3-codex':{ checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.3-codex (API confirmed)', verified: true },
  'gpt-5.2':       { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.2 (API confirmed)', verified: true },
  'gpt-5.1':       { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5.1 (API confirmed)', verified: true },
  'gpt-5':         { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5 (API confirmed)', verified: true },
  'gpt-5-mini':   { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5-mini (API confirmed)', verified: true },
  'gpt-5-nano':   { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5-nano (API confirmed)', verified: true },
  'gpt-5-pro':    { checkedAt: '2026-05-03', source: 'openrouter/openai/gpt-5-pro (API confirmed)', verified: true },
  'o3':            { checkedAt: '2026-05-03', source: 'platform.openai.com/docs/models', verified: true },
  'o3-mini':      { checkedAt: '2026-05-03', source: 'platform.openai.com/docs/models', verified: true },
  'o3-pro':       { checkedAt: '2026-05-03', source: 'openrouter/openai/o3-pro (API confirmed)', verified: true },
  'gpt-4o':       { checkedAt: '2026-05-03', source: 'platform.openai.com/docs/models', verified: true },
  'gpt-4o-mini':  { checkedAt: '2026-05-03', source: 'platform.openai.com/docs/models', verified: true },
  'gpt-4.1':       { checkedAt: '2026-05-03', source: 'platform.openai.com/docs/models', verified: true },
  // Anthropic
  'claude-sonnet-4.6': { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-sonnet-4.6 (API confirmed)', verified: true },
  'claude-sonnet-4.5': { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-sonnet-4.5 (API confirmed)', verified: true },
  'claude-sonnet-4':   { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-sonnet-4 (API confirmed)', verified: true },
  'claude-opus-4.7':   { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-opus-4.7 (API confirmed)', verified: true },
  'claude-opus-4.6':   { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-opus-4.6 (API confirmed)', verified: true },
  'claude-opus-4.5':   { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-opus-4.5 (API confirmed)', verified: true },
  'claude-opus-4.1':   { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-opus-4.1 (API confirmed)', verified: true },
  'claude-opus-4':     { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-opus-4 (API confirmed)', verified: true },
  'claude-haiku-4.5':  { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-haiku-4.5 (API confirmed)', verified: true },
  'claude-3.5-sonnet': { checkedAt: '2026-05-03', source: 'docs.anthropic.com', verified: true },
  'claude-3.5-sonnet-20241022': { checkedAt: '2026-05-03', source: 'docs.anthropic.com', verified: true },
  'claude-3-opus':     { checkedAt: '2026-05-03', source: 'docs.anthropic.com', verified: true },
  'claude-3.7-sonnet': { checkedAt: '2026-05-03', source: 'openrouter/anthropic/claude-3.7-sonnet (API confirmed)', verified: true },
  // Google（gemini-3.1 为最新旗舰，gemini-2.5 仍可用）
  'gemini-3.1-pro-preview':{ checkedAt: '2026-05-13', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-3.1-flash-lite': { checkedAt: '2026-05-13', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-3-flash-preview':{ checkedAt: '2026-05-03', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-2.5-pro':        { checkedAt: '2026-05-03', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-2.5-flash':      { checkedAt: '2026-05-03', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-2.5-flash-lite': { checkedAt: '2026-05-03', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-2.0-flash':      { checkedAt: '2026-05-03', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  'gemini-2.0-flash-lite': { checkedAt: '2026-05-03', source: 'ai.google.dev/gemini-api/docs/models', verified: true },
  // DeepSeek（官方：deepseek-v4-flash / deepseek-v4-pro 为最新主力，deepseek-chat / deepseek-reasoner 将废弃）
  'deepseek-v4-pro':       { checkedAt: '2026-05-03', source: 'platform.deepseek.com 官方定价页', verified: true },
  'deepseek-v4-flash':     { checkedAt: '2026-05-03', source: 'platform.deepseek.com 官方定价页', verified: true },
  'deepseek-r1':           { checkedAt: '2026-05-03', source: 'platform.deepseek.com', verified: true },
  'deepseek-r1-0528':      { checkedAt: '2026-05-03', source: 'platform.deepseek.com', verified: true },
  'deepseek-chat-v3-0324': { checkedAt: '2026-05-03', source: 'platform.deepseek.com', verified: true },
  // Qwen / 阿里云（qwen3.6 为最新系列）
  'qwen3.6-max-preview':  { checkedAt: '2026-05-03', source: 'openrouter/qwen/qwen3.6-max-preview (API confirmed)', verified: true },
  'qwen3.6-plus':          { checkedAt: '2026-05-03', source: 'openrouter/qwen/qwen3.6-plus (API confirmed)', verified: true },
  'qwen3.6-flash':         { checkedAt: '2026-05-03', source: 'openrouter/qwen/qwen3.6-flash (API confirmed)', verified: true },
  'qwen3.6-27b':           { checkedAt: '2026-05-03', source: 'openrouter/qwen/qwen3.6-27b (API confirmed)', verified: true },
  'qwen3.6-35b-a3b':       { checkedAt: '2026-05-03', source: 'openrouter/qwen/qwen3.6-35b-a3b (API confirmed)', verified: true },
  // Moonshot / Kimi
  'kimi-k2.6':        { checkedAt: '2026-05-03', source: 'openrouter/moonshotai/kimi-k2.6 (API confirmed)', verified: true },
  'kimi-k2.5':        { checkedAt: '2026-05-03', source: 'openrouter/moonshotai/kimi-k2.5 (API confirmed)', verified: true },
  'kimi-k2':          { checkedAt: '2026-05-03', source: 'openrouter/moonshotai/kimi-k2 (API confirmed)', verified: true },
  'kimi-k2-thinking': { checkedAt: '2026-05-03', source: 'openrouter/moonshotai/kimi-k2-thinking (API confirmed)', verified: true },
  'kimi-k2-0905':     { checkedAt: '2026-05-03', source: 'openrouter/moonshotai/kimi-k2-0905 (API confirmed)', verified: true },
  // GLM / 智谱
  'glm-5':       { checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-5 (API confirmed)', verified: true },
  'glm-5-turbo': { checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-5-turbo (API confirmed)', verified: true },
  'glm-5.1':     { checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-5.1 (API confirmed)', verified: true },
  'glm-4.7':     { checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-4.7 (API confirmed)', verified: true },
  'glm-4.7-flash':{ checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-4.7-flash (API confirmed)', verified: true },
  'glm-4.6':     { checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-4.6 (API confirmed)', verified: true },
  'glm-4.5':     { checkedAt: '2026-05-03', source: 'openrouter/z-ai/glm-4.5 (API confirmed)', verified: true },
  'glm-4':       { checkedAt: '2026-05-03', source: 'open.bigmodel.cn', verified: true },
  // 讯飞
  'spark-4.0': { checkedAt: '2026-05-03', source: 'xfyun.cn/doc/spark/Web.html', verified: true },
  'spark-3.5': { checkedAt: '2026-05-03', source: 'xfyun.cn/doc/spark/Web.html', verified: true },
};

/**
 * 模型选择启发式算法
 *
 * 根据任务类型 + 内容特征（长度/复杂度）自动推荐最佳模型，
 * 考虑 tokenLimit + trim 策略，避免内容截断。
 *
 * 启发式规则：
 * 1. 短内容 + 快速任务 → 高性价比模型（gpt-4o-mini / qwen3.6-flash）
 * 2. 长内容 → 大 contextWindow 模型（gemini-2.5-pro / kimi-k2.6）
 * 3. 高复杂度 → 高智能模型（claude-opus-4.7 / gpt-5.5）
 * 4. 超长内容 → 启用 trim 策略，选择支持超长上下文的模型
 */

/** 内容特征 */
export interface ContentProfile {
  /** 预估 token 数量 */
  estimatedTokens: number;
  /** 是否为多模态内容（包含图像/视频） */
  isMultimodal: boolean;
  /** 语言复杂度：simple=日常对话，normal=普通文章，complex=技术/专业 */
  complexity: 'simple' | 'normal' | 'complex';
}

/** 任务类型 */
export type TaskType = 'script' | 'analysis' | 'code' | 'fast' | 'video';

export interface ModelSelectionHint {
  modelId: string;
  reason: string;
  needsTrim: boolean;
  trimRatio: number; // 0-1，建议裁剪比例
  score: number; // 0-100，适配度
}

/**
 * 预估内容所需 token
 * 中文约 1.5 tokens/字，英文约 0.25 tokens/词
 */
export function estimateContentTokens(text: string, isEnglish: boolean = false): number {
  if (isEnglish) {
    const words = text.trim().split(/\s+/).length;
    return Math.round(words * 1.3); // 英文词→token 约 1.3x
  }
  return Math.round(text.length * 1.5); // 中文约 1.5 tokens/字
}

/**
 * 根据内容特征 + 任务类型，选择最佳模型
 * 
 * @param taskType 任务类型
 * @param profile 内容特征
 * @returns 最佳模型 ID + 原因 + 是否需要 trim
 */
export function selectOptimalModel(
  taskType: TaskType,
  profile: ContentProfile,
): ModelSelectionHint {
  const { estimatedTokens, isMultimodal, complexity } = profile;

  // 宽松系数：当预估可能不准确时，给足够 buffer
  const SAFETY_BUFFER = 1.2;
  const effectiveTokens = estimatedTokens * SAFETY_BUFFER;

  // 任务 → 推荐模型列表（已按优先级排序）
  const taskModelIds: Record<TaskType, string[]> = {
    script:    ['gpt-5.5', 'claude-opus-4.7', 'qwen3.6-plus', 'kimi-k2.6', 'gpt-4o'],
    analysis:  ['gpt-5.5', 'gemini-2.5-pro', 'claude-opus-4.7', 'qwen3.6-max-preview', 'gpt-4o'],
    code:      ['o3', 'claude-sonnet-4.6', 'deepseek-v4-pro', 'deepseek-v4-flash'],
    fast:      ['qwen3.6-flash', 'gpt-5.4-mini', 'glm-5-turbo', 'deepseek-v4-flash'],
    video:     ['gpt-5.5', 'gemini-2.5-pro', 'kimi-k2.6', 'gpt-4o'],
  };

  const candidateIds = taskModelIds[taskType] || taskModelIds.script;

  // 如果是多模态任务，排除不支持的模型
  const multimodalExcludes = ['o3', 'o3-mini', 'deepseek-v4-flash', 'deepseek-v4-pro'];
  const candidates = isMultimodal
    ? candidateIds.filter(id => !multimodalExcludes.includes(id))
    : candidateIds;

  let bestHint: ModelSelectionHint | null = null;

  for (const modelId of candidates) {
    const model = getModelById(modelId);
    if (!model) continue;

    // 检查 tokenLimit 是否足够
    const tokenLimit = model.tokenLimit ?? model.contextWindow ?? 0;
    const maxTokens = model.maxTokens ?? tokenLimit;

    if (maxTokens === 0) continue;

    let score = 50; // 基础分
    let needsTrim = false;
    let trimRatio = 0;

    // Token 不足检测
    if (effectiveTokens > maxTokens) {
      needsTrim = true;
      trimRatio = Math.min(1, maxTokens / effectiveTokens);
      score = Math.max(0, 100 - (1 - trimRatio) * 80); // 截断风险越大分数越低
    } else {
      // 宽松范围内，给高分
      const headroom = (maxTokens - effectiveTokens) / maxTokens;
      score = 60 + Math.min(40, headroom * 50);
    }

    // 复杂度加成：高复杂度任务倾向于更智能的模型
    if (complexity === 'complex' && model.isPro) {
      score = Math.min(100, score + 15);
    }

    // 超长内容特殊处理：优先选择大 contextWindow 模型并启用 trim
    if (estimatedTokens > 100000 && tokenLimit >= 1000000) {
      score = Math.min(100, score + 20);
    }

    if (!bestHint || score > bestHint.score) {
      bestHint = {
        modelId,
        reason: buildReason(model, effectiveTokens, maxTokens, taskType, complexity),
        needsTrim,
        trimRatio,
        score: Math.round(score),
      };
    }
  }

  // Fallback：如果所有推荐模型都 token 不足，选择支持最长上下文的模型
  if (!bestHint) {
    const fallback = AI_MODELS
      .filter(m => (m.tokenLimit ?? 0) > 0)
      .sort((a, b) => (b.tokenLimit ?? 0) - (a.tokenLimit ?? 0))[0];
    if (fallback) {
      bestHint = {
        modelId: fallback.id,
        reason: `Fallback：选择最大上下文模型 ${fallback.name}（${(fallback.tokenLimit ?? 0) / 1000}K）`,
        needsTrim: true,
        trimRatio: Math.max(0, 1 - estimatedTokens / (fallback.tokenLimit ?? 1)),
        score: 20,
      };
    }
  }

  return bestHint ?? { modelId: 'gpt-4o', reason: '默认选择', needsTrim: false, trimRatio: 0, score: 50 };
}

/**
 * 生成选择原因描述
 */
function buildReason(
  model: AIModel,
  effectiveTokens: number,
  maxTokens: number,
  taskType: TaskType,
  complexity: ContentProfile['complexity'],
): string {
  const tokenLimitK = ((model.tokenLimit ?? 0) / 1000).toFixed(0);
  const effectiveK = (effectiveTokens / 1000).toFixed(0);

  if (effectiveTokens > maxTokens) {
    return `⚠️ 内容 ${effectiveK}K > 模型上限 ${tokenLimitK}K，将自动 trim`;
  }

  const complexityStr = complexity === 'complex' ? '复杂' : complexity === 'simple' ? '简单' : '';
  const taskLabels: Record<TaskType, string> = {
    script: '脚本生成', analysis: '视频分析', code: '代码任务', fast: '快速响应', video: '视频理解'
  };

  return `${taskLabels[taskType]}${complexityStr} → ${model.name}（${tokenLimitK}K 上限，剩余 ${Math.round((1 - effectiveTokens / maxTokens) * 100)}%）`;
}

/**
 * 批量推荐多个模型（用于展示推荐列表）
 */
export function recommendModelsForTask(
  taskType: TaskType,
  profile: ContentProfile,
  limit: number = 5,
): ModelSelectionHint[] {
  const { estimatedTokens, isMultimodal } = profile;

  const taskModelIds: Record<TaskType, string[]> = {
    script:    ['gpt-5.5', 'claude-opus-4.7', 'qwen3.6-plus', 'kimi-k2.6', 'gpt-4o', 'gemini-2.5-pro'],
    analysis:  ['gpt-5.5', 'gemini-2.5-pro', 'claude-opus-4.7', 'qwen3.6-max-preview', 'gpt-4o'],
    code:      ['o3', 'claude-sonnet-4.6', 'deepseek-v4-pro', 'deepseek-v4-flash', 'gpt-5.4'],
    fast:      ['qwen3.6-flash', 'gpt-5.4-mini', 'glm-5-turbo', 'deepseek-v4-flash'],
    video:     ['gpt-5.5', 'gemini-2.5-pro', 'kimi-k2.6', 'gpt-4o'],
  };

  const multimodalExcludes = ['o3', 'o3-mini', 'deepseek-v4-flash', 'deepseek-v4-pro'];
  const candidateIds = (taskModelIds[taskType] || taskModelIds.script)
    .filter(id => !isMultimodal || !multimodalExcludes.includes(id));

  const hints: ModelSelectionHint[] = [];

  for (const modelId of candidateIds) {
    const model = getModelById(modelId);
    if (!model) continue;

    const tokenLimit = model.tokenLimit ?? model.contextWindow ?? 0;
    const maxTokens = model.maxTokens ?? tokenLimit;

    if (maxTokens === 0) continue;

    const effectiveTokens = estimatedTokens * 1.2;
    const needsTrim = effectiveTokens > maxTokens;
    const trimRatio = needsTrim ? Math.min(1, maxTokens / effectiveTokens) : 0;

    // 计算适配度分数
    let score = 60;
    if (needsTrim) {
      score = Math.max(0, 100 - (1 - trimRatio) * 80);
    } else {
      const headroom = (maxTokens - effectiveTokens) / maxTokens;
      score = 60 + Math.min(40, headroom * 50);
    }

    hints.push({
      modelId,
      reason: buildReason(model, estimatedTokens * 1.2, maxTokens, taskType, profile.complexity),
      needsTrim,
      trimRatio,
      score: Math.round(score),
    });
  }

  return hints
    .sort((a, b) => b.score - a.score)
    .slice(0, limit);
}

// =============================================================================
// AI 模型列表（全部来自真实 API / 官方文档，2026-05）
// =============================================================================

export const AI_MODELS: AIModel[] = [
  {
    id: 'gpt-5.5',
    name: 'GPT-5.5',
    provider: 'openai',
    category: ['text', 'code', 'image', 'video'],
    description: 'OpenAI 最新旗舰模型（2026），支持多模态输入，适合视频素材分析与解说文案生成。',
    features: ['多模态', '最高智能', '视频理解'],
    tokenLimit: 256000,
    contextWindow: 256000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5.5-pro',
    name: 'GPT-5.5 Pro',
    provider: 'openai',
    category: ['text', 'code', 'image', 'video'],
    description: 'OpenAI 最新旗舰 Pro 模型（2026），最高智能水平，适合复杂视频语义分析与高质量解说稿创作。',
    features: ['最高智能', '视频理解', '复杂推理'],
    tokenLimit: 256000,
    contextWindow: 256000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5.4',
    name: 'GPT-5.4',
    provider: 'openai',
    category: ['text', 'code', 'image'],
    description: 'OpenAI 高性能模型（2026），适合高质量脚本生成与改写。',
    features: ['高性能', '多模态', '编程能力'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5.4-mini',
    name: 'GPT-5.4 Mini',
    provider: 'openai',
    category: ['text', 'code', 'image'],
    description: 'OpenAI 高性价比模型（2026），响应快、成本低，适合批量剪辑脚本生成与改写。',
    features: ['高性价比', '快速响应', '多模态'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5.3-codex',
    name: 'GPT-5.3 Codex',
    provider: 'openai',
    category: ['text', 'code'],
    description: 'OpenAI 代码专用模型（2026），编程能力强，适合代码分析与剪辑逻辑生成。',
    features: ['代码专家', '编程能力', '高智能'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5.2',
    name: 'GPT-5.2',
    provider: 'openai',
    category: ['text', 'code', 'image'],
    description: 'OpenAI 主力旗舰模型（2026），多模态能力均衡，适合综合视频分析与内容创作。',
    features: ['多模态', '高智能', '均衡全面'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5.1',
    name: 'GPT-5.1',
    provider: 'openai',
    category: ['text', 'code', 'image'],
    description: 'OpenAI 中高端模型（2026），适合内容分析与高质量文案生成。',
    features: ['多模态', '内容理解', '文案创作'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5',
    name: 'GPT-5',
    provider: 'openai',
    category: ['text', 'code', 'image', 'video'],
    description: 'OpenAI 基础旗舰模型（2026），支持视频理解，适合复杂视频语义分析。',
    features: ['多模态', '视频理解', '最高智能'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-5-mini',
    name: 'GPT-5 Mini',
    provider: 'openai',
    category: ['text', 'code', 'image'],
    description: 'OpenAI 轻量旗舰（2026），高性价比，适合批量脚本生成与改写。',
    features: ['高性价比', '多模态', '快速'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'gpt-4o',
    name: 'GPT-4o',
    provider: 'openai',
    category: ['text', 'code', 'image', 'video'],
    description: 'OpenAI 旗舰多模态模型（2024-05），支持文本/代码/图像/视频理解，适合视频素材分析与解说文案生成。',
    features: ['多模态', '高智能', '视频理解'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: true,
    pricing: { input: 2.5, output: 10, unit: '$/MTokens' },
  },
  {
    id: 'gpt-4o-mini',
    name: 'GPT-4o Mini',
    provider: 'openai',
    category: ['text', 'code', 'image'],
    description: 'OpenAI 高性价比模型（2024-07），响应快、成本低，适合批量剪辑脚本生成与改写。',
    features: ['高性价比', '快速响应', '多模态'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: false,
    pricing: { input: 0.15, output: 0.6, unit: '$/MTokens' },
  },
  {
    id: 'o3',
    name: 'OpenAI o3',
    provider: 'openai',
    category: ['text', 'code'],
    description: 'OpenAI 推理模型（2024-12），擅长复杂推断与规划，适合镜头匹配、时间轴修正等复杂决策。',
    features: ['高级推理', '复杂规划', '可靠判别'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  {
    id: 'o3-mini',
    name: 'OpenAI o3-mini',
    provider: 'openai',
    category: ['text', 'code'],
    description: 'OpenAI 轻量推理模型（2025-01），低成本推理，适合批量脚本评分与镜头优先级排序。',
    features: ['低成本推理', '快速', '编程能力'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: false,
    pricing: { input: 1.1, output: 4.4, unit: '$/MTokens' },
  },
  {
    id: 'o3-pro',
    name: 'OpenAI o3 Pro',
    provider: 'openai',
    category: ['text', 'code'],
    description: 'OpenAI 高端推理模型（2026），最强推理能力，适合最复杂的决策与规划任务。',
    features: ['最强推理', '复杂规划', '高端判别'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.openai.com' },
  },
  // ========== Anthropic ==========
  {
    id: 'claude-sonnet-4.6',
    name: 'Claude Sonnet 4.6',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 高智能模型（2026），长文本组织能力强，适合解说长稿编写与风格润色。',
    features: ['长文处理', '稳定风格', '中文优化'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-sonnet-4.5',
    name: 'Claude Sonnet 4.5',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 高智能模型（2026），长文本能力强，适合解说长稿编写与风格润色。',
    features: ['长文处理', '稳定风格', '中文优化'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-sonnet-4',
    name: 'Claude Sonnet 4',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 主力模型（2026），综合能力均衡，适合各类文本与代码任务。',
    features: ['均衡', '长文处理', '中文优化'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-opus-4.7',
    name: 'Claude Opus 4.7',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 最高智能版本（2026），最高智能水平，适合复杂视频语义分析与高质量脚本创作。',
    features: ['最高智能', '复杂推理', '视频理解'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-opus-4.6',
    name: 'Claude Opus 4.6',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 旗舰模型（2026），适合复杂视频语义分析与高质量脚本创作。',
    features: ['高智能', '复杂推理', '视频理解'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-opus-4.5',
    name: 'Claude Opus 4.5',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 高智能模型（2026），适合复杂视频语义分析与高质量脚本创作。',
    features: ['高智能', '复杂推理', '视频理解'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-opus-4',
    name: 'Claude Opus 4',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 旗舰基础模型（2026），适合复杂内容分析与高质量脚本创作。',
    features: ['高智能', '复杂推理', '视频理解'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-haiku-4.5',
    name: 'Claude Haiku 4.5',
    provider: 'anthropic',
    category: ['text', 'code'],
    description: 'Anthropic 轻量高速模型（2026），适合批量分析与低延迟任务。',
    features: ['高速', '低成本', '精准'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  {
    id: 'claude-3.5-sonnet',
    name: 'Claude 3.5 Sonnet',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 高智能模型（2024-06），长文本组织能力强，适合解说长稿编写与风格润色。',
    features: ['长文处理', '稳定风格', '中文优化'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 3, output: 15, unit: '$/MTokens' },
  },
  {
    id: 'claude-3.7-sonnet',
    name: 'Claude 3.7 Sonnet',
    provider: 'anthropic',
    category: ['text', 'code', 'image'],
    description: 'Anthropic 最新 3.7 系列（2025），长上下文与编程能力全面提升，适合复杂代码与长文本任务。',
    features: ['长上下文', '编程能力', '高智能'],
    tokenLimit: 200000,
    contextWindow: 200000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see anthropic.com/pricing' },
  },
  // ========== Google ==========
  {
    id: 'gemini-3.1-pro',
    name: 'Gemini 3.1 Pro',
    provider: 'google',
    category: ['text', 'code', 'image', 'video'],
    description: 'Google 最新旗舰模型（2026-02），推理能力 2x+ 提升，1M token 上下文，适合超长视频素材理解与多镜头关联分析。',
    features: ['超长上下文', '多模态推理', '视频理解', 'Deep Think模式'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see ai.google.dev/pricing' },
  },
  {
    id: 'gemini-3.1-flash',
    name: 'Gemini 3.1 Flash',
    provider: 'google',
    category: ['text', 'image', 'video'],
    description: 'Google 高性价比模型（2026-03），多模态能力强，适合批量素材分类与标签生成。',
    features: ['高速', '低成本', '多模态'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Free (with quota)' },
  },
  {
    id: 'gemini-3.1-flash-lite',
    name: 'Gemini 3.1 Flash Lite',
    provider: 'google',
    category: ['text', 'image', 'video'],
    description: 'Google 最快最便宜模型（2026-03），适合大批量素材分类与低延迟任务。',
    features: ['高性价比', '快速', '多模态'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Free (with quota)' },
  },
  {
    id: 'gemini-2.5-pro',
    name: 'Gemini 2.5 Pro',
    provider: 'google',
    category: ['text', 'code', 'image', 'video'],
    description: 'Google 旗舰模型（2025），超长上下文，适合长视频素材理解与多镜头关联分析。',
    features: ['超长上下文', '多模态推理', '视频理解'],
    tokenLimit: 2000000,
    contextWindow: 2000000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see ai.google.dev/pricing' },
  },
  {
    id: 'gemini-2.5-flash',
    name: 'Gemini 2.5 Flash',
    provider: 'google',
    category: ['text', 'image', 'video'],
    description: 'Google 高速高性价比模型（2025），多模态能力强，适合批量素材分类与标签生成。',
    features: ['高速', '低成本', '多模态'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Free (with quota)' },
  },
  {
    id: 'gemini-2.5-flash-lite',
    name: 'Gemini 2.5 Flash Lite',
    provider: 'google',
    category: ['text', 'image', 'video'],
    description: 'Google 轻量高性价比模型（2025），适合大批量素材分类与低延迟任务。',
    features: ['高性价比', '快速', '多模态'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Free (with quota)' },
  },
  {
    id: 'gemini-2.0-flash',
    name: 'Gemini 2.0 Flash',
    provider: 'google',
    category: ['text', 'image', 'video'],
    description: 'Google 高速模型（2024-12），多模态能力强，适合批量素材分类与标签生成。',
    features: ['高速', '低成本', '多模态'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Free (with quota)' },
  },
  {
    id: 'gemini-2.0-flash-lite',
    name: 'Gemini 2.0 Flash Lite',
    provider: 'google',
    category: ['text', 'image', 'video'],
    description: 'Google 轻量高速模型（2024-12），适合大批量低延迟任务。',
    features: ['超高速', '最低成本', '多模态'],
    tokenLimit: 1000000,
    contextWindow: 1000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Free (with quota)' },
  },
  {
    id: 'gemini-3-flash-preview',
    name: 'Gemini 3.0 Flash (Preview)',
    provider: 'google',
    category: ['text', 'code', 'image', 'video'],
    description: 'Google 3.0 预览版（2026），最新实验版本，适合尝鲜与测试。',
    features: ['最新预览', '多模态', '超长上下文'],
    tokenLimit: 2000000,
    contextWindow: 2000000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'Preview (free)' },
  },
  // ========== DeepSeek（官方：deepseek-v4-flash / deepseek-v4-pro 为最新主力）==========
  {
    id: 'deepseek-v4-pro',
    name: 'DeepSeek-V4-Pro',
    provider: 'deepseek',
    category: ['text', 'code'],
    description: 'DeepSeek 最新旗舰推理模型（2026），擅长复杂推断，适合镜头到文案的对齐评分与优先级排序。2.5 折优惠中。',
    features: ['高智能推理', '判别', '重排序'],
    tokenLimit: 64000,
    contextWindow: 64000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.deepseek.com' },
  },
  {
    id: 'deepseek-v4-flash',
    name: 'DeepSeek-V4-Flash',
    provider: 'deepseek',
    category: ['text', 'code'],
    description: 'DeepSeek 最新高速模型（2026），高性价比，适合批量脚本生成与改写。（注：原 deepseek-chat / deepseek-reasoner 将废弃，统一迁移至此）',
    features: ['高性价比', '中文可用', '重写能力'],
    tokenLimit: 64000,
    contextWindow: 64000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see platform.deepseek.com' },
  },
  // ========== 阿里云 Qwen ==========
  {
    id: 'qwen3.6-max-preview',
    name: 'Qwen3.6 Max (Preview)',
    provider: 'alibaba',
    category: ['text', 'code', 'image'],
    description: '阿里云通义千问最高智能预览版（2026-04），适合高质量解说稿与复杂文案创作。',
    features: ['最高智能', '中文专家', '复杂推理'],
    tokenLimit: 131072,
    contextWindow: 131072,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see dashscope.aliyun.com' },
  },
  {
    id: 'qwen3.6-plus',
    name: 'Qwen3.6 Plus',
    provider: 'alibaba',
    category: ['text', 'code', 'image'],
    description: '阿里云通义千问旗舰模型（2026-04），中文能力突出，适合中文解说文案生成与改写。',
    features: ['中文优化', '多模态', '成本可控'],
    tokenLimit: 131072,
    contextWindow: 131072,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see dashscope.aliyun.com' },
  },
  {
    id: 'qwen3.6-flash',
    name: 'Qwen3.6 Flash',
    provider: 'alibaba',
    category: ['text', 'code', 'image'],
    description: '阿里云通义千问高速模型（2026-04），响应快，适合批量分析与低延迟任务。',
    features: ['高速', '低成本', '中文优化'],
    tokenLimit: 131072,
    contextWindow: 131072,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see dashscope.aliyun.com' },
  },
  // ========== Moonshot / Kimi ==========
  {
    id: 'kimi-k2.6',
    name: 'Kimi K2.6',
    provider: 'moonshot',
    category: ['text', 'code', 'image'],
    description: '月之暗面最新旗舰（2026），原生多模态，Agent 性能出色，适合高质量解说稿生成。',
    features: ['原生多模态', '中文专家', '长上下文'],
    tokenLimit: 256000,
    contextWindow: 256000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.moonshot.cn' },
  },
  {
    id: 'kimi-k2.5',
    name: 'Kimi K2.5',
    provider: 'moonshot',
    category: ['text', 'code', 'image'],
    description: '月之暗面旗舰（2025），原生多模态，适合高质量解说稿生成与素材分析。',
    features: ['原生多模态', '中文专家', '长上下文'],
    tokenLimit: 256000,
    contextWindow: 256000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.moonshot.cn' },
  },
  {
    id: 'kimi-k2',
    name: 'Kimi K2',
    provider: 'moonshot',
    category: ['text', 'code'],
    description: '月之暗面主力模型（2025），32K 上下文，适合中等长度解说稿一气生成。',
    features: ['长上下文', '中文专家', '快速'],
    tokenLimit: 32000,
    contextWindow: 32000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.moonshot.cn' },
  },
  {
    id: 'kimi-k2-thinking',
    name: 'Kimi K2 Thinking',
    provider: 'moonshot',
    category: ['text', 'code'],
    description: '月之暗面推理增强版（2026），深度思考能力，适合复杂规划与逻辑推理任务。',
    features: ['推理增强', '深度思考', '中文专家'],
    tokenLimit: 32000,
    contextWindow: 32000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see platform.moonshot.cn' },
  },
  // ========== 智谱 AI (Zhipu) ==========
  {
    id: 'glm-5',
    name: 'GLM-5',
    provider: 'zhipu',
    category: ['text', 'code', 'image'],
    description: '智谱 AI 最新旗舰模型（2026），中文能力强，适合中文视频解说与素材分析。',
    features: ['中文优化', '多模态', 'Agentic'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see open.bigmodel.cn' },
  },
  {
    id: 'glm-5-turbo',
    name: 'GLM-5 Turbo',
    provider: 'zhipu',
    category: ['text', 'code', 'image'],
    description: '智谱 AI 高速版（2026），响应快，适合批量分析与低延迟任务。',
    features: ['高速', '低成本', '中文优化'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see open.bigmodel.cn' },
  },
  {
    id: 'glm-5.1',
    name: 'GLM-5.1',
    provider: 'zhipu',
    category: ['text', 'code', 'image'],
    description: '智谱 AI 最新小版本（2026），能力微调，适合高效内容创作与分析。',
    features: ['高效', '中文优化', '多模态'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see open.bigmodel.cn' },
  },
  {
    id: 'glm-4.7',
    name: 'GLM-4.7',
    provider: 'zhipu',
    category: ['text', 'code', 'image'],
    description: '智谱 AI 高性能版本（2025），中文能力强，适合中文视频解说与素材分析。',
    features: ['中文优化', '多模态', '高性能'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see open.bigmodel.cn' },
  },
  {
    id: 'glm-4.6',
    name: 'GLM-4.6',
    provider: 'zhipu',
    category: ['text', 'code', 'image'],
    description: '智谱 AI 高性能版本（2025），适合内容分析与文案创作。',
    features: ['中文优化', '多模态', '高性能'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see open.bigmodel.cn' },
  },
  {
    id: 'glm-4',
    name: 'GLM-4',
    provider: 'zhipu',
    category: ['text', 'code', 'image'],
    description: '智谱 AI 旗舰模型（2024-01），中文能力强，适合中文视频解说与素材分析。',
    features: ['中文优化', '多模态', 'Agentic'],
    tokenLimit: 128000,
    contextWindow: 128000,
    isPro: true,
    pricing: { input: 0.1, output: 0.1, unit: '元/千tokens' },
  },
  // ========== 科大讯飞 (iFlytek) ==========
  {
    id: 'spark-4.0',
    name: 'Spark 4.0',
    provider: 'iflytek',
    category: ['text', 'audio'],
    description: '讯飞星火 4.0（2024-06），语音合成生态完整，适合与 TTS 联动生成配音解说。',
    features: ['语音生态', 'TTS 联动', '中文语音'],
    tokenLimit: 8192,
    contextWindow: 32000,
    isPro: true,
    pricing: { input: 0, output: 0, unit: 'see iflytek pricing' },
  },
  {
    id: 'spark-3.5',
    name: 'Spark 3.5',
    provider: 'iflytek',
    category: ['text', 'audio'],
    description: '讯飞星火 3.5（2024-01），语音识别与合成双能力，适合讯飞系 AI 配音工作流。',
    features: ['语音双能力', '中文', '生态完整'],
    tokenLimit: 8192,
    contextWindow: 32000,
    isPro: false,
    pricing: { input: 0, output: 0, unit: 'see iflytek pricing' },
  },
];

export const MODEL_RECOMMENDATIONS: Record<string, string[]> = {
  script:   ['gpt-5.5', 'claude-opus-4.7', 'qwen3.6-plus', 'deepseek-v4-flash', 'kimi-k2.6'],
  analysis: ['gpt-5.5', 'claude-opus-4.7', 'gemini-2.5-pro', 'qwen3.6-max-preview'],
  code:     ['o3', 'claude-sonnet-4.6', 'deepseek-v4-pro', 'deepseek-v4-flash'],
  fast:     ['qwen3.6-flash', 'gpt-5.4-mini', 'glm-5-turbo', 'deepseek-v4-flash'],
};

export const getModelById = (id: string): AIModel | undefined => {
  return AI_MODELS.find((model) => model.id === id);
};

export const getModelsByProvider = (provider: ModelProvider): AIModel[] => {
  return AI_MODELS.filter((model) => model.provider === provider);
};

export const getModelsByCategory = (category: ModelCategory): AIModel[] => {
  return AI_MODELS.filter((model) => (model.category ?? ['general']).includes(category));
};

export const getRecommendedModels = (task: keyof typeof MODEL_RECOMMENDATIONS): AIModel[] => {
  const modelIds = MODEL_RECOMMENDATIONS[task] || [];
  return modelIds.map((id) => getModelById(id)).filter(Boolean) as AIModel[];
};
