import Ai360ModelLogo from '@renderer/assets/images/models/360.png'
import Ai360ModelLogoDark from '@renderer/assets/images/models/360_dark.png'
import AdeptModelLogo from '@renderer/assets/images/models/adept.png'
import AdeptModelLogoDark from '@renderer/assets/images/models/adept_dark.png'
import Ai21ModelLogo from '@renderer/assets/images/models/ai21.png'
import Ai21ModelLogoDark from '@renderer/assets/images/models/ai21_dark.png'
import AimassModelLogo from '@renderer/assets/images/models/aimass.png'
import AimassModelLogoDark from '@renderer/assets/images/models/aimass_dark.png'
import AisingaporeModelLogo from '@renderer/assets/images/models/aisingapore.png'
import AisingaporeModelLogoDark from '@renderer/assets/images/models/aisingapore_dark.png'
import BaichuanModelLogo from '@renderer/assets/images/models/baichuan.png'
import BaichuanModelLogoDark from '@renderer/assets/images/models/baichuan_dark.png'
import BigcodeModelLogo from '@renderer/assets/images/models/bigcode.png'
import BigcodeModelLogoDark from '@renderer/assets/images/models/bigcode_dark.png'
import ChatGLMModelLogo from '@renderer/assets/images/models/chatglm.png'
import ChatGLMModelLogoDark from '@renderer/assets/images/models/chatglm_dark.png'
import ChatGptModelLogo from '@renderer/assets/images/models/chatgpt.jpeg'
import ClaudeModelLogo from '@renderer/assets/images/models/claude.png'
import ClaudeModelLogoDark from '@renderer/assets/images/models/claude_dark.png'
import CodegeexModelLogo from '@renderer/assets/images/models/codegeex.png'
import CodegeexModelLogoDark from '@renderer/assets/images/models/codegeex_dark.png'
import CohereModelLogo from '@renderer/assets/images/models/cohere.png'
import CohereModelLogoDark from '@renderer/assets/images/models/cohere_dark.png'
import CopilotModelLogo from '@renderer/assets/images/models/copilot.png'
import CopilotModelLogoDark from '@renderer/assets/images/models/copilot_dark.png'
import DalleModelLogo from '@renderer/assets/images/models/dalle.png'
import DalleModelLogoDark from '@renderer/assets/images/models/dalle_dark.png'
import DbrxModelLogo from '@renderer/assets/images/models/dbrx.png'
import DeepSeekModelLogo from '@renderer/assets/images/models/deepseek.png'
import DeepSeekModelLogoDark from '@renderer/assets/images/models/deepseek_dark.png'
import DianxinModelLogo from '@renderer/assets/images/models/dianxin.png'
import DianxinModelLogoDark from '@renderer/assets/images/models/dianxin_dark.png'
import DoubaoModelLogo from '@renderer/assets/images/models/doubao.png'
import DoubaoModelLogoDark from '@renderer/assets/images/models/doubao_dark.png'
import EmbeddingModelLogo from '@renderer/assets/images/models/embedding.png'
import EmbeddingModelLogoDark from '@renderer/assets/images/models/embedding.png'
import FlashaudioModelLogo from '@renderer/assets/images/models/flashaudio.png'
import FlashaudioModelLogoDark from '@renderer/assets/images/models/flashaudio_dark.png'
import FluxModelLogo from '@renderer/assets/images/models/flux.png'
import FluxModelLogoDark from '@renderer/assets/images/models/flux_dark.png'
import GeminiModelLogo from '@renderer/assets/images/models/gemini.png'
import GeminiModelLogoDark from '@renderer/assets/images/models/gemini_dark.png'
import GemmaModelLogo from '@renderer/assets/images/models/gemma.png'
import GemmaModelLogoDark from '@renderer/assets/images/models/gemma_dark.png'
import GoogleModelLogo from '@renderer/assets/images/models/google.png'
import GoogleModelLogoDark from '@renderer/assets/images/models/google.png'
import GorkModelLogo from '@renderer/assets/images/models/gork.png'
import GorkModelLogoDark from '@renderer/assets/images/models/gork_dark.png'
import ChatGPT35ModelLogo from '@renderer/assets/images/models/gpt_3.5.png'
import ChatGPT4ModelLogo from '@renderer/assets/images/models/gpt_4.png'
import ChatGptModelLogoDakr from '@renderer/assets/images/models/gpt_dark.png'
import ChatGPT35ModelLogoDark from '@renderer/assets/images/models/gpt_dark.png'
import ChatGPT4ModelLogoDark from '@renderer/assets/images/models/gpt_dark.png'
import ChatGPTo1ModelLogoDark from '@renderer/assets/images/models/gpt_dark.png'
import ChatGPTo1ModelLogo from '@renderer/assets/images/models/gpt_o1.png'
import GrypheModelLogo from '@renderer/assets/images/models/gryphe.png'
import GrypheModelLogoDark from '@renderer/assets/images/models/gryphe_dark.png'
import HailuoModelLogo from '@renderer/assets/images/models/hailuo.png'
import HailuoModelLogoDark from '@renderer/assets/images/models/hailuo_dark.png'
import HuggingfaceModelLogo from '@renderer/assets/images/models/huggingface.png'
import HuggingfaceModelLogoDark from '@renderer/assets/images/models/huggingface_dark.png'
import HunyuanModelLogo from '@renderer/assets/images/models/hunyuan.png'
import HunyuanModelLogoDark from '@renderer/assets/images/models/hunyuan_dark.png'
import IbmModelLogo from '@renderer/assets/images/models/ibm.png'
import IbmModelLogoDark from '@renderer/assets/images/models/ibm_dark.png'
import InternlmModelLogo from '@renderer/assets/images/models/internlm.png'
import InternlmModelLogoDark from '@renderer/assets/images/models/internlm_dark.png'
import KeLingModelLogo from '@renderer/assets/images/models/keling.png'
import KeLingModelLogoDark from '@renderer/assets/images/models/keling_dark.png'
import LlamaModelLogo from '@renderer/assets/images/models/llama.png'
import LlamaModelLogoDark from '@renderer/assets/images/models/llama_dark.png'
import LLavaModelLogo from '@renderer/assets/images/models/llava.png'
import LLavaModelLogoDark from '@renderer/assets/images/models/llava_dark.png'
import LumaModelLogo from '@renderer/assets/images/models/luma.png'
import LumaModelLogoDark from '@renderer/assets/images/models/luma_dark.png'
import MagicModelLogo from '@renderer/assets/images/models/magic.png'
import MagicModelLogoDark from '@renderer/assets/images/models/magic_dark.png'
import MediatekModelLogo from '@renderer/assets/images/models/mediatek.png'
import MediatekModelLogoDark from '@renderer/assets/images/models/mediatek_dark.png'
import MicrosoftModelLogo from '@renderer/assets/images/models/microsoft.png'
import MicrosoftModelLogoDark from '@renderer/assets/images/models/microsoft_dark.png'
import MidjourneyModelLogo from '@renderer/assets/images/models/midjourney.png'
import MidjourneyModelLogoDark from '@renderer/assets/images/models/midjourney_dark.png'
import MinicpmModelLogo from '@renderer/assets/images/models/minicpm.webp'
import MinicpmModelLogoDark from '@renderer/assets/images/models/minicpm.webp'
import MinimaxModelLogo from '@renderer/assets/images/models/minimax.png'
import MinimaxModelLogoDark from '@renderer/assets/images/models/minimax_dark.png'
import MistralModelLogo from '@renderer/assets/images/models/mixtral.png'
import MistralModelLogoDark from '@renderer/assets/images/models/mixtral_dark.png'
import MoonshotModelLogo from '@renderer/assets/images/models/moonshot.png'
import MoonshotModelLogoDark from '@renderer/assets/images/models/moonshot_dark.png'
import NousResearchModelLogo from '@renderer/assets/images/models/nousresearch.png'
import NousResearchModelLogoDark from '@renderer/assets/images/models/nousresearch.png'
import NvidiaModelLogo from '@renderer/assets/images/models/nvidia.png'
import NvidiaModelLogoDark from '@renderer/assets/images/models/nvidia_dark.png'
import PalmModelLogo from '@renderer/assets/images/models/palm.png'
import PalmModelLogoDark from '@renderer/assets/images/models/palm_dark.png'
import QwenModelLogo from '@renderer/assets/images/models/qwen.png'
import QwenModelLogoDark from '@renderer/assets/images/models/qwen_dark.png'
import RakutenaiModelLogo from '@renderer/assets/images/models/rakutenai.png'
import RakutenaiModelLogoDark from '@renderer/assets/images/models/rakutenai_dark.png'
import SparkDeskModelLogo from '@renderer/assets/images/models/sparkdesk.png'
import SparkDeskModelLogoDark from '@renderer/assets/images/models/sparkdesk_dark.png'
import StabilityModelLogo from '@renderer/assets/images/models/stability.png'
import StabilityModelLogoDark from '@renderer/assets/images/models/stability_dark.png'
import StepModelLogo from '@renderer/assets/images/models/step.png'
import StepModelLogoDark from '@renderer/assets/images/models/step_dark.png'
import SunoModelLogo from '@renderer/assets/images/models/suno.png'
import SunoModelLogoDark from '@renderer/assets/images/models/suno_dark.png'
import TeleModelLogo from '@renderer/assets/images/models/tele.png'
import TeleModelLogoDark from '@renderer/assets/images/models/tele_dark.png'
import UpstageModelLogo from '@renderer/assets/images/models/upstage.png'
import UpstageModelLogoDark from '@renderer/assets/images/models/upstage_dark.png'
import ViduModelLogo from '@renderer/assets/images/models/vidu.png'
import ViduModelLogoDark from '@renderer/assets/images/models/vidu_dark.png'
import WenxinModelLogo from '@renderer/assets/images/models/wenxin.png'
import WenxinModelLogoDark from '@renderer/assets/images/models/wenxin_dark.png'
import YiModelLogo from '@renderer/assets/images/models/yi.png'
import YiModelLogoDark from '@renderer/assets/images/models/yi_dark.png'
import { Model } from '@renderer/types'
import OpenAI from 'openai'

const visionAllowedModels = [
  'llava',
  'moondream',
  'minicpm',
  'gemini-1\\.5',
  'claude-3',
  'vision',
  'glm-4v',
  'qwen-vl',
  'qwen2-vl',
  'internvl2',
  'gpt-4(?:-[\\w-]+)',
  'gpt-4o(?:-[\\w-]+)?'
]

const visionExcludedModels = ['gpt-4-\\d+-preview', 'gpt-4-turbo-preview', 'gpt-4-32k', 'gpt-4-\\d+']

const VISION_REGEX = new RegExp(
  `\\b(?!(?:${visionExcludedModels.join('|')})\\b)(${visionAllowedModels.join('|')})\\b`,
  'i'
)

const TEXT_TO_IMAGE_REGEX = /flux|diffusion|stabilityai|sd-|dall|cogview/i
const EMBEDDING_REGEX = /(?:^text-|embed|rerank|davinci|babbage|bge-|base|retrieval|uae-)/i
const NOT_SUPPORTED_REGEX = /(?:^text-|embed|tts|rerank|whisper|speech|davinci|babbage|bge-|base|retrieval|uae-)/i

export function getModelLogo(modelId: string) {
  const isLight = true

  if (!modelId) {
    return undefined
  }

  const logoMap = {
    abab: isLight ? MinimaxModelLogo : MinimaxModelLogoDark,
    'o1-': isLight ? ChatGPTo1ModelLogo : ChatGPTo1ModelLogoDark,
    'gpt-3': isLight ? ChatGPT35ModelLogo : ChatGPT35ModelLogoDark,
    'gpt-4': isLight ? ChatGPT4ModelLogo : ChatGPT4ModelLogoDark,
    gpts: isLight ? ChatGPT4ModelLogo : ChatGPT4ModelLogoDark,
    'text-moderation': isLight ? ChatGptModelLogo : ChatGptModelLogoDakr,
    'babbage-': isLight ? ChatGptModelLogo : ChatGptModelLogoDakr,
    'text-embedding': isLight ? ChatGptModelLogo : ChatGptModelLogoDakr,
    'davinci-': isLight ? ChatGptModelLogo : ChatGptModelLogoDakr,
    glm: isLight ? ChatGLMModelLogo : ChatGLMModelLogoDark,
    deepseek: isLight ? DeepSeekModelLogo : DeepSeekModelLogoDark,
    qwen: isLight ? QwenModelLogo : QwenModelLogoDark,
    gemma: isLight ? GemmaModelLogo : GemmaModelLogoDark,
    'yi-': isLight ? YiModelLogo : YiModelLogoDark,
    llama: isLight ? LlamaModelLogo : LlamaModelLogoDark,
    mixtral: isLight ? MistralModelLogo : MistralModelLogo,
    mistral: isLight ? MistralModelLogo : MistralModelLogoDark,
    moonshot: isLight ? MoonshotModelLogo : MoonshotModelLogoDark,
    phi: isLight ? MicrosoftModelLogo : MicrosoftModelLogoDark,
    baichuan: isLight ? BaichuanModelLogo : BaichuanModelLogoDark,
    claude: isLight ? ClaudeModelLogo : ClaudeModelLogoDark,
    gemini: isLight ? GeminiModelLogo : GeminiModelLogoDark,
    embedding: isLight ? EmbeddingModelLogo : EmbeddingModelLogoDark,
    bison: isLight ? PalmModelLogo : PalmModelLogoDark,
    palm: isLight ? PalmModelLogo : PalmModelLogoDark,
    step: isLight ? StepModelLogo : StepModelLogoDark,
    hailuo: isLight ? HailuoModelLogo : HailuoModelLogoDark,
    'ep-202': isLight ? DoubaoModelLogo : DoubaoModelLogoDark,
    cohere: isLight ? CohereModelLogo : CohereModelLogoDark,
    command: isLight ? CohereModelLogo : CohereModelLogoDark,
    minicpm: isLight ? MinicpmModelLogo : MinicpmModelLogoDark,
    '360': isLight ? Ai360ModelLogo : Ai360ModelLogoDark,
    aimass: isLight ? AimassModelLogo : AimassModelLogoDark,
    codegeex: isLight ? CodegeexModelLogo : CodegeexModelLogoDark,
    copilot: isLight ? CopilotModelLogo : CopilotModelLogoDark,
    creative: isLight ? CopilotModelLogo : CopilotModelLogoDark,
    balanced: isLight ? CopilotModelLogo : CopilotModelLogoDark,
    precise: isLight ? CopilotModelLogo : CopilotModelLogoDark,
    dalle: isLight ? DalleModelLogo : DalleModelLogoDark,
    'dall-e': isLight ? DalleModelLogo : DalleModelLogoDark,
    dbrx: isLight ? DbrxModelLogo : DbrxModelLogo,
    flashaudio: isLight ? FlashaudioModelLogo : FlashaudioModelLogoDark,
    flux: isLight ? FluxModelLogo : FluxModelLogoDark,
    gork: isLight ? GorkModelLogo : GorkModelLogoDark,
    hunyuan: isLight ? HunyuanModelLogo : HunyuanModelLogoDark,
    internlm: isLight ? InternlmModelLogo : InternlmModelLogoDark,
    llava: isLight ? LLavaModelLogo : LLavaModelLogoDark,
    magic: isLight ? MagicModelLogo : MagicModelLogoDark,
    midjourney: isLight ? MidjourneyModelLogo : MidjourneyModelLogoDark,
    'mj-': isLight ? MidjourneyModelLogo : MidjourneyModelLogoDark,
    'ernie-': isLight ? WenxinModelLogo : WenxinModelLogoDark,
    voice: isLight ? FlashaudioModelLogo : FlashaudioModelLogoDark,
    'tts-1': isLight ? ChatGptModelLogo : ChatGptModelLogoDakr,
    'whisper-': isLight ? ChatGptModelLogo : ChatGptModelLogoDakr,
    'stable-': isLight ? StabilityModelLogo : StabilityModelLogoDark,
    sd2: isLight ? StabilityModelLogo : StabilityModelLogoDark,
    sd3: isLight ? StabilityModelLogo : StabilityModelLogoDark,
    sdxl: isLight ? StabilityModelLogo : StabilityModelLogoDark,
    sparkdesk: isLight ? SparkDeskModelLogo : SparkDeskModelLogoDark,
    generalv: isLight ? SparkDeskModelLogo : SparkDeskModelLogoDark,
    wizardlm: isLight ? MicrosoftModelLogo : MicrosoftModelLogoDark,
    microsoft: isLight ? MicrosoftModelLogo : MicrosoftModelLogoDark,
    hermes: isLight ? NousResearchModelLogo : NousResearchModelLogoDark,
    gryphe: isLight ? GrypheModelLogo : GrypheModelLogoDark,
    suno: isLight ? SunoModelLogo : SunoModelLogoDark,
    chirp: isLight ? SunoModelLogo : SunoModelLogoDark,
    luma: isLight ? LumaModelLogo : LumaModelLogoDark,
    keling: isLight ? KeLingModelLogo : KeLingModelLogoDark,
    'vidu-': isLight ? ViduModelLogo : ViduModelLogoDark,
    ai21: isLight ? Ai21ModelLogo : Ai21ModelLogoDark,
    'jamba-': isLight ? Ai21ModelLogo : Ai21ModelLogoDark,
    mythomax: isLight ? GrypheModelLogo : GrypheModelLogoDark,
    nvidia: isLight ? NvidiaModelLogo : NvidiaModelLogoDark,
    dianxin: isLight ? DianxinModelLogo : DianxinModelLogoDark,
    tele: isLight ? TeleModelLogo : TeleModelLogoDark,
    adept: isLight ? AdeptModelLogo : AdeptModelLogoDark,
    aisingapore: isLight ? AisingaporeModelLogo : AisingaporeModelLogoDark,
    bigcode: isLight ? BigcodeModelLogo : BigcodeModelLogoDark,
    mediatek: isLight ? MediatekModelLogo : MediatekModelLogoDark,
    upstage: isLight ? UpstageModelLogo : UpstageModelLogoDark,
    rakutenai: isLight ? RakutenaiModelLogo : RakutenaiModelLogoDark,
    ibm: isLight ? IbmModelLogo : IbmModelLogoDark,
    'google/': isLight ? GoogleModelLogo : GoogleModelLogoDark,
    hugging: isLight ? HuggingfaceModelLogo : HuggingfaceModelLogoDark
  }

  for (const key in logoMap) {
    if (modelId.toLowerCase().includes(key)) {
      return logoMap[key]
    }
  }

  return undefined
}

export const SYSTEM_MODELS: Record<string, Model[]> = {
  ollama: [],
  silicon: [
    {
      id: 'Qwen/Qwen2.5-72B-Instruct',
      provider: 'silicon',
      name: 'Qwen2.5-72B-Instruct',
      group: 'Qwen2.5'
    },
    {
      id: 'Qwen/Qwen2.5-32B-Instruct',
      provider: 'silicon',
      name: 'Qwen2.5-32B-Instruct',
      group: 'Qwen2.5'
    },
    {
      id: 'Qwen/Qwen2.5-14B-Instruct',
      provider: 'silicon',
      name: 'Qwen2.5-14B-Instruct',
      group: 'Qwen2.5'
    },
    {
      id: 'Qwen/Qwen2.5-7B-Instruct',
      provider: 'silicon',
      name: 'Qwen2.5-7B-Instruct',
      group: 'Qwen2.5'
    },
    {
      id: 'Qwen/Qwen2-7B-Instruct',
      provider: 'silicon',
      name: 'Qwen2-7B-Instruct',
      group: 'Qwen2'
    },
    {
      id: 'Qwen/Qwen2-72B-Instruct',
      provider: 'silicon',
      name: 'Qwen2-72B-Instruct',
      group: 'Qwen2'
    },
    {
      id: 'THUDM/glm-4-9b-chat',
      provider: 'silicon',
      name: 'GLM-4-9B-Chat',
      group: 'GLM'
    },
    {
      id: 'deepseek-ai/DeepSeek-V2-Chat',
      provider: 'silicon',
      name: 'DeepSeek-V2-Chat',
      group: 'DeepSeek'
    },
    {
      id: 'deepseek-ai/DeepSeek-Coder-V2-Instruct',
      provider: 'silicon',
      name: 'DeepSeek-Coder-V2-Instruct',
      group: 'DeepSeek'
    }
  ],
  openai: [
    {
      id: 'gpt-4o',
      provider: 'openai',
      name: ' GPT-4o',
      group: 'GPT 4o'
    },
    {
      id: 'gpt-4o-mini',
      provider: 'openai',
      name: ' GPT-4o-mini',
      group: 'GPT 4o'
    },
    {
      id: 'gpt-4-turbo',
      provider: 'openai',
      name: ' GPT-4 Turbo',
      group: 'GPT 4'
    },
    {
      id: 'gpt-4',
      provider: 'openai',
      name: ' GPT-4',
      group: 'GPT 4'
    },
    {
      id: 'gpt-3.5-turbo',
      provider: 'openai',
      name: ' GPT-3.5-turbo',
      group: 'GPT 3.5'
    },
    {
      id: 'o1-mini',
      provider: 'openai',
      name: ' o1-mini',
      group: 'o1'
    },
    {
      id: 'o1-preview',
      provider: 'openai',
      name: ' o1-preview',
      group: 'o1'
    }
  ],
  'azure-openai': [
    {
      id: 'gpt-4o',
      provider: 'azure-openai',
      name: ' GPT-4o',
      group: 'GPT 4o'
    },
    {
      id: 'gpt-4o-mini',
      provider: 'azure-openai',
      name: ' GPT-4o-mini',
      group: 'GPT 4o'
    }
  ],
  gemini: [
    {
      id: 'gemini-1.5-flash',
      provider: 'gemini',
      name: 'Gemini 1.5 Flash',
      group: 'Gemini 1.5'
    },
    {
      id: 'gemini-1.5-pro-exp-0801',
      provider: 'gemini',
      name: 'Gemini 1.5 Pro Experimental 0801',
      group: 'Gemini 1.5'
    }
  ],
  anthropic: [
    {
      id: 'claude-3-5-sonnet-20240620',
      provider: 'anthropic',
      name: 'Claude 3.5 Sonnet',
      group: 'Claude 3.5'
    },
    {
      id: 'claude-3-opus-20240229',
      provider: 'anthropic',
      name: 'Claude 3 Opus',
      group: 'Claude 3'
    },
    {
      id: 'claude-3-sonnet-20240229',
      provider: 'anthropic',
      name: 'Claude 3 Sonnet',
      group: 'Claude 3'
    },
    {
      id: 'claude-3-haiku-20240307',
      provider: 'anthropic',
      name: 'Claude 3 Haiku',
      group: 'Claude 3'
    }
  ],
  deepseek: [
    {
      id: 'deepseek-chat',
      provider: 'deepseek',
      name: 'DeepSeek Chat',
      group: 'DeepSeek Chat'
    },
    {
      id: 'deepseek-coder',
      provider: 'deepseek',
      name: 'DeepSeek Coder',
      group: 'DeepSeek Coder'
    }
  ],
  together: [
    {
      id: 'meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo',
      provider: 'together',
      name: 'Llama-3.2-11B-Vision',
      group: 'Llama-3.2'
    },
    {
      id: 'meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo',
      provider: 'together',
      name: 'Llama-3.2-90B-Vision',
      group: 'Llama-3.2'
    },
    {
      id: 'google/gemma-2-27b-it',
      provider: 'together',
      name: 'gemma-2-27b-it',
      group: 'Gemma'
    },
    {
      id: 'google/gemma-2-9b-it',
      provider: 'together',
      name: 'gemma-2-9b-it',
      group: 'Gemma'
    }
  ],
  ocoolai: [
    {
      id: 'gpt-4o',
      provider: 'ocoolai',
      name: 'gpt-4o',
      group: 'OpenAI'
    },
    {
      id: 'gpt-4o-all',
      provider: 'ocoolai',
      name: 'gpt-4o-all',
      group: 'OpenAI'
    },
    {
      id: 'gpt-4-all',
      provider: 'ocoolai',
      name: 'gpt-4-all',
      group: 'OpenAI'
    },
    {
      id: 'gpt-4o-mini',
      provider: 'ocoolai',
      name: 'gpt-4o-mini',
      group: 'OpenAI'
    },
    {
      id: 'gpt-4',
      provider: 'ocoolai',
      name: 'gpt-4',
      group: 'OpenAI'
    },
    {
      id: 'gpt-4-turbo',
      provider: 'ocoolai',
      name: 'gpt-4-turbo',
      group: 'OpenAI'
    },
    {
      id: 'o1-preview',
      provider: 'ocoolai',
      name: 'o1-preview',
      group: 'OpenAI'
    },
    {
      id: 'o1-mini',
      provider: 'ocoolai',
      name: 'o1-mini',
      group: 'OpenAI'
    },
    {
      id: 'gpt-3.5-turbo',
      provider: 'ocoolai',
      name: 'gpt-3.5-turbo',
      group: 'OpenAI'
    },
    {
      id: 'claude-3-5-sonnet-20240620',
      provider: 'ocoolai',
      name: 'claude-3-5-sonnet-20240620',
      group: 'Anthropic'
    },
    {
      id: 'claude-3-opus-20240229',
      provider: 'ocoolai',
      name: 'claude-3-opus-20240229',
      group: 'Anthropic'
    },
    {
      id: 'claude-3-sonnet-20240229',
      provider: 'ocoolai',
      name: 'claude-3-sonnet-20240229',
      group: 'Anthropic'
    },
    {
      id: 'claude-3-haiku-20240307',
      provider: 'ocoolai',
      name: 'claude-3-haiku-20240307',
      group: 'Anthropic'
    },
    {
      id: 'gemini-pro',
      provider: 'ocoolai',
      name: 'gemini-pro',
      group: 'Gemini'
    },
    {
      id: 'gemini-1.5-pro',
      provider: 'ocoolai',
      name: 'gemini-1.5-pro',
      group: 'Gemini'
    },
    {
      id: 'meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo',
      provider: 'ocoolai',
      name: 'Llama-3.2-90B-Vision-Instruct-Turbo',
      group: 'Llama-3.2'
    },
    {
      id: 'meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo',
      provider: 'ocoolai',
      name: 'Llama-3.2-11B-Vision-Instruct-Turbo',
      group: 'Llama-3.2'
    },
    {
      id: 'meta-llama/Llama-3.2-3B-Vision-Instruct-Turbo',
      provider: 'ocoolai',
      name: 'Llama-3.2-3B-Vision-Instruct-Turbo',
      group: 'Llama-3.2'
    },
    {
      id: 'google/gemma-2-27b-it',
      provider: 'ocoolai',
      name: 'gemma-2-27b-it',
      group: 'Gemma'
    },
    {
      id: 'google/gemma-2-9b-it',
      provider: 'ocoolai',
      name: 'gemma-2-9b-it',
      group: 'Gemma'
    }
  ],
  github: [
    {
      id: 'gpt-4o',
      provider: 'github',
      name: 'OpenAI GPT-4o',
      group: 'OpenAI'
    }
  ],
  yi: [
    {
      id: 'yi-large',
      provider: 'yi',
      name: 'Yi-Large',
      group: 'Yi'
    },
    {
      id: 'yi-large-turbo',
      provider: 'yi',
      name: 'Yi-Large-Turbo',
      group: 'Yi'
    },
    {
      id: 'yi-large-rag',
      provider: 'yi',
      name: 'Yi-Large-Rag',
      group: 'Yi'
    },
    {
      id: 'yi-medium',
      provider: 'yi',
      name: 'Yi-Medium',
      group: 'Yi'
    },
    {
      id: 'yi-medium-200k',
      provider: 'yi',
      name: 'Yi-Medium-200k',
      group: 'Yi'
    },
    {
      id: 'yi-spark',
      provider: 'yi',
      name: 'Yi-Spark',
      group: 'Yi'
    }
  ],
  zhipu: [
    {
      id: 'glm-4',
      provider: 'zhipu',
      name: 'GLM-4',
      group: 'GLM-4'
    },
    {
      id: 'glm-4-plus',
      provider: 'zhipu',
      name: 'GLM-4-Plus',
      group: 'GLM-4'
    },
    {
      id: 'glm-4-air',
      provider: 'zhipu',
      name: 'GLM-4-Air',
      group: 'GLM-4'
    },
    {
      id: 'glm-4-airx',
      provider: 'zhipu',
      name: 'GLM-4-AirX',
      group: 'GLM-4'
    },
    {
      id: 'glm-4-flash',
      provider: 'zhipu',
      name: 'GLM-4-Flash',
      group: 'GLM-4'
    },
    {
      id: 'glm-4v',
      provider: 'zhipu',
      name: 'GLM 4V',
      group: 'GLM-4v'
    },
    {
      id: 'glm-4v-plus',
      provider: 'zhipu',
      name: 'GLM-4V-Plus',
      group: 'GLM-4v'
    },
    {
      id: 'glm-4-alltools',
      provider: 'zhipu',
      name: 'GLM-4-AllTools',
      group: 'GLM-4-AllTools'
    }
  ],
  moonshot: [
    {
      id: 'moonshot-v1-8k',
      provider: 'moonshot',
      name: 'Moonshot V1 8k',
      group: 'Moonshot V1'
    },
    {
      id: 'moonshot-v1-32k',
      provider: 'moonshot',
      name: 'Moonshot V1 32k',
      group: 'Moonshot V1'
    },
    {
      id: 'moonshot-v1-128k',
      provider: 'moonshot',
      name: 'Moonshot V1 128k',
      group: 'Moonshot V1'
    }
  ],
  baichuan: [
    {
      id: 'Baichuan4',
      provider: 'baichuan',
      name: 'Baichuan4',
      group: 'Baichuan4'
    },
    {
      id: 'Baichuan3-Turbo',
      provider: 'baichuan',
      name: 'Baichuan3 Turbo',
      group: 'Baichuan3'
    },
    {
      id: 'Baichuan3-Turbo-128k',
      provider: 'baichuan',
      name: 'Baichuan3 Turbo 128k',
      group: 'Baichuan3'
    }
  ],
  bailian: [
    {
      id: 'qwen-turbo',
      provider: 'dashscope',
      name: 'Qwen Turbo',
      group: 'Qwen'
    },
    {
      id: 'qwen-plus',
      provider: 'dashscope',
      name: 'Qwen Plus',
      group: 'Qwen'
    },
    {
      id: 'qwen-max',
      provider: 'dashscope',
      name: 'Qwen Max',
      group: 'Qwen'
    }
  ],
  stepfun: [
    {
      id: 'step-1-8k',
      provider: 'stepfun',
      name: 'Step 1 8K',
      group: 'Step 1'
    },
    {
      id: 'step-1-flash',
      provider: 'stepfun',
      name: 'Step 1 Flash',
      group: 'Step 1'
    }
  ],
  doubao: [],
  minimax: [
    {
      id: 'abab6.5s-chat',
      provider: 'minimax',
      name: 'abab6.5s',
      group: 'abab6'
    },
    {
      id: 'abab6.5g-chat',
      provider: 'minimax',
      name: 'abab6.5g',
      group: 'abab6'
    },
    {
      id: 'abab6.5t-chat',
      provider: 'minimax',
      name: 'abab6.5t',
      group: 'abab6'
    },
    {
      id: 'abab5.5s-chat',
      provider: 'minimax',
      name: 'abab5.5s',
      group: 'abab5'
    }
  ],
  aihubmix: [
    {
      id: 'gpt-4o-mini',
      provider: 'aihubmix',
      name: 'GPT-4o Mini',
      group: 'GPT-4o'
    },
    {
      id: 'aihubmix-Llama-3-70B-Instruct',
      provider: 'aihubmix',
      name: 'Llama 3 70B Instruct',
      group: 'Llama3'
    }
  ],
  fireworks: [
    {
      id: 'accounts/fireworks/models/mythomax-l2-13b',
      provider: 'fireworks',
      name: 'mythomax-l2-13b',
      group: 'Gryphe'
    },
    {
      id: 'accounts/fireworks/models/llama-v3-70b-instruct',
      provider: 'fireworks',
      name: 'Llama-3-70B-Instruct',
      group: 'Llama3'
    }
  ],
  zhinao: [
    {
      id: '360gpt-pro',
      provider: 'zhinao',
      name: '360gpt-pro',
      group: '360Gpt'
    },
    {
      id: '360gpt-turbo',
      provider: 'zhinao',
      name: '360gpt-turbo',
      group: '360Gpt'
    }
  ],
  hunyuan: [
    {
      id: 'hunyuan-pro',
      provider: 'hunyuan',
      name: 'hunyuan-pro',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-standard',
      provider: 'hunyuan',
      name: 'hunyuan-standard',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-lite',
      provider: 'hunyuan',
      name: 'hunyuan-lite',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-standard-256k',
      provider: 'hunyuan',
      name: 'hunyuan-standard-256k',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-vision',
      provider: 'hunyuan',
      name: 'hunyuan-vision',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-code',
      provider: 'hunyuan',
      name: 'hunyuan-code',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-role',
      provider: 'hunyuan',
      name: 'hunyuan-role',
      group: 'Hunyuan'
    },
    {
      id: 'hunyuan-turbo',
      provider: 'hunyuan',
      name: 'hunyuan-turbo',
      group: 'Hunyuan'
    }
  ],
  nvidia: [
    {
      id: '01-ai/yi-large',
      provider: 'nvidia',
      name: 'yi-large',
      group: 'Yi'
    },
    {
      id: 'meta/llama-3.1-405b-instruct',
      provider: 'nvidia',
      name: 'llama-3.1-405b-instruct',
      group: 'llama-3.1'
    }
  ],
  openrouter: [
    {
      id: 'google/gemma-2-9b-it:free',
      provider: 'openrouter',
      name: 'Google: Gemma 2 9B',
      group: 'Gemma'
    },
    {
      id: 'microsoft/phi-3-mini-128k-instruct:free',
      provider: 'openrouter',
      name: 'Phi-3 Mini 128K Instruct',
      group: 'Phi'
    },
    {
      id: 'microsoft/phi-3-medium-128k-instruct:free',
      provider: 'openrouter',
      name: 'Phi-3 Medium 128K Instruct',
      group: 'Phi'
    },
    {
      id: 'meta-llama/llama-3-8b-instruct:free',
      provider: 'openrouter',
      name: 'Meta: Llama 3 8B Instruct',
      group: 'Llama3'
    },
    {
      id: 'mistralai/mistral-7b-instruct:free',
      provider: 'openrouter',
      name: 'Mistral: Mistral 7B Instruct',
      group: 'Mistral'
    }
  ],
  groq: [
    {
      id: 'llama3-8b-8192',
      provider: 'groq',
      name: 'LLaMA3 8B',
      group: 'Llama3'
    },
    {
      id: 'llama3-70b-8192',
      provider: 'groq',
      name: 'LLaMA3 70B',
      group: 'Llama3'
    },
    {
      id: 'mixtral-8x7b-32768',
      provider: 'groq',
      name: 'Mixtral 8x7B',
      group: 'Mixtral'
    },
    {
      id: 'gemma-7b-it',
      provider: 'groq',
      name: 'Gemma 7B',
      group: 'Gemma'
    }
  ]
}

export function isTextToImageModel(model: Model): boolean {
  return TEXT_TO_IMAGE_REGEX.test(model.id)
}

export function isEmbeddingModel(model: Model): boolean {
  return EMBEDDING_REGEX.test(model.id)
}

export function isVisionModel(model: Model): boolean {
  return VISION_REGEX.test(model.id)
}

export function isSupportedModel(model: OpenAI.Models.Model): boolean {
  return !NOT_SUPPORTED_REGEX.test(model.id)
}
