import { ModelAbility, ModelType } from '@/constants';

export const LANGUAGES_CHECKBOX_OPTIONS = [
  { label: 'English', value: 'en' },
  { label: 'Chinese', value: 'zh' },
];
export const LANGUAGES_OPTIONS = [
  { value: 'ab', label: 'Abkhazian', count: 1 },
  { value: 'aa', label: 'Afar' },
  { value: 'af', label: 'Afrikaans' },
  { value: 'ak', label: 'Akan' },
  { value: 'sq', label: 'Albanian' },
  { value: 'am', label: 'Amharic' },
  { value: 'ar', label: 'Arabic' },
  { value: 'an', label: 'Aragonese' },
  { value: 'hy', label: 'Armenian' },
  { value: 'as', label: 'Assamese' },
  { value: 'av', label: 'Avaric' },
  { value: 'ae', label: 'Avestan' },
  { value: 'ay', label: 'Aymara' },
  { value: 'az', label: 'Azerbaijani' },
  { value: 'bm', label: 'Bambara' },
  { value: 'ba', label: 'Bashkir' },
  { value: 'eu', label: 'Basque' },
  { value: 'be', label: 'Belarusian' },
  { value: 'bn', label: 'Bengali' },
  { value: 'bh', label: 'Bihari' },
  { value: 'bi', label: 'Bislama' },
  { value: 'bs', label: 'Bosnian' },
  { value: 'br', label: 'Breton' },
  { value: 'bg', label: 'Bulgarian' },
  { value: 'my', label: 'Burmese' },
  { value: 'ca', label: 'Catalan, Valencian' },
  { value: 'ch', label: 'Chamorro' },
  { value: 'ce', label: 'Chechen' },
  { value: 'ny', label: 'Chichewa, Chewa, Nyanja' },
  // { value: 'zh', label: 'Chinese' },
  { value: 'cv', label: 'Chuvash' },
  { value: 'kw', label: 'Cornish' },
  { value: 'co', label: 'Corsican' },
  { value: 'cr', label: 'Cree' },
  { value: 'hr', label: 'Croatian' },
  { value: 'cs', label: 'Czech' },
  { value: 'da', label: 'Danish' },
  { value: 'dv', label: 'Divehi, Dhivehi, Maldivian' },
  { value: 'nl', label: 'Dutch, Flemish' },
  { value: 'dz', label: 'Dzongkha' },
  // { value: 'en', label: 'English' },
  { value: 'eo', label: 'Esperanto' },
  { value: 'et', label: 'Estonian' },
  { value: 'ee', label: 'Ewe' },
  { value: 'fo', label: 'Faroese' },
  { value: 'fj', label: 'Fijian' },
  { value: 'fi', label: 'Finnish' },
  { value: 'fr', label: 'French' },
  { value: 'ff', label: 'Fulah' },
  { value: 'gl', label: 'Galician' },
  { value: 'ka', label: 'Georgian' },
  { value: 'de', label: 'German' },
  { value: 'el', label: 'Greek' },
  { value: 'gn', label: 'Guarani' },
  { value: 'gu', label: 'Gujarati' },
  { value: 'ht', label: 'Haitian, Haitian Creole' },
  { value: 'ha', label: 'Hausa' },
  { value: 'he', label: 'Hebrew' },
  { value: 'hz', label: 'Herero' },
  { value: 'hi', label: 'Hindi' },
  { value: 'ho', label: 'Hiri Motu' },
  { value: 'hu', label: 'Hungarian' },
  { value: 'ia', label: 'Interlingua' },
  { value: 'id', label: 'Indonesian' },
  { value: 'ie', label: 'Interlingue, Occidental' },
  { value: 'ga', label: 'Irish' },
  { value: 'ig', label: 'Igbo' },
  { value: 'ik', label: 'Inupiaq' },
  { value: 'io', label: 'Ido' },
  { value: 'is', label: 'Icelandic' },
  { value: 'it', label: 'Italian' },
  { value: 'iu', label: 'Inuktitut' },
  { value: 'ja', label: 'Japanese' },
  { value: 'jv', label: 'Javanese' },
  { value: 'kl', label: 'Kalaallisut, Greenlandic' },
  { value: 'kn', label: 'Kannada' },
  { value: 'kr', label: 'Kanuri' },
  { value: 'ks', label: 'Kashmiri' },
  { value: 'kk', label: 'Kazakh' },
  { value: 'km', label: 'Central Khmer' },
  { value: 'ki', label: 'Kikuyu, Gikuyu' },
  { value: 'rw', label: 'Kinyarwanda' },
  { value: 'ky', label: 'Kirghiz, Kyrgyz' },
  { value: 'kv', label: 'Komi' },
  { value: 'kg', label: 'Kongo' },
  { value: 'ko', label: 'Korean' },
  { value: 'ku', label: 'Kurdish' },
  { value: 'kj', label: 'Kuanyama, Kwanyama' },
  { value: 'la', label: 'Latin' },
  { value: 'lb', label: 'Luxembourgish, Letzeburgesch' },
  { value: 'lg', label: 'Ganda' },
  { value: 'li', label: 'Limburgan, Limburger, Limburgish' },
  { value: 'ln', label: 'Lingala' },
  { value: 'lo', label: 'Lao' },
  { value: 'lt', label: 'Lithuanian' },
  { value: 'lu', label: 'Luba-Katanga' },
  { value: 'lv', label: 'Latvian' },
  { value: 'gv', label: 'Manx' },
  { value: 'mk', label: 'Macedonian' },
  { value: 'mg', label: 'Malagasy' },
  { value: 'ms', label: 'Malay' },
  { value: 'ml', label: 'Malayalam' },
  { value: 'mt', label: 'Maltese' },
  { value: 'mi', label: 'Maori' },
  { value: 'mr', label: 'Marathi' },
  { value: 'mh', label: 'Marshallese' },
  { value: 'mn', label: 'Mongolian' },
  { value: 'na', label: 'Nauru' },
  { value: 'nv', label: 'Navajo, Navaho' },
  { value: 'nd', label: 'North Ndebele' },
  { value: 'ne', label: 'Nepali' },
  { value: 'ng', label: 'Ndonga' },
  { value: 'nb', label: 'Norwegian Bokmål' },
  { value: 'nn', label: 'Norwegian Nynorsk' },
  { value: 'no', label: 'Norwegian' },
  { value: 'ii', label: 'Sichuan Yi, Nuosu' },
  { value: 'nr', label: 'South Ndebele' },
  { value: 'oc', label: 'Occitan' },
  { value: 'oj', label: 'Ojibwa' },
  {
    value: 'cu',
    label: 'Church Slavic, Old Slavonic, Church Slavonic, Old Bulgarian, Old Church Slavonic',
  },
  { value: 'om', label: 'Oromo' },
  { value: 'or', label: 'Oriya' },
  { value: 'os', label: 'Ossetian, Ossetic' },
  { value: 'pa', label: 'Punjabi, Panjabi' },
  { value: 'pi', label: 'Pali' },
  { value: 'fa', label: 'Persian' },
  { value: 'pl', label: 'Polish' },
  { value: 'ps', label: 'Pashto, Pushto' },
  { value: 'pt', label: 'Portuguese' },
  { value: 'qu', label: 'Quechua' },
  { value: 'rm', label: 'Romansh' },
  { value: 'rn', label: 'Rundi' },
  { value: 'ro', label: 'Romanian, Moldavian, Moldovan' },
  { value: 'ru', label: 'Russian' },
  { value: 'sa', label: 'Sanskrit' },
  { value: 'sc', label: 'Sardinian' },
  { value: 'sd', label: 'Sindhi' },
  { value: 'se', label: 'Northern Sami' },
  { value: 'sm', label: 'Samoan' },
  { value: 'sg', label: 'Sango' },
  { value: 'sr', label: 'Serbian' },
  { value: 'gd', label: 'Gaelic, Scottish Gaelic' },
  { value: 'sn', label: 'Shona' },
  { value: 'si', label: 'Sinhala, Sinhalese' },
  { value: 'sk', label: 'Slovak' },
  { value: 'sl', label: 'Slovenian' },
  { value: 'so', label: 'Somali' },
  { value: 'st', label: 'Southern Sotho' },
  { value: 'es', label: 'Spanish, Castilian' },
  { value: 'su', label: 'Sundanese' },
  { value: 'sw', label: 'Swahili' },
  { value: 'ss', label: 'Swati' },
  { value: 'sv', label: 'Swedish' },
  { value: 'ta', label: 'Tamil' },
  { value: 'te', label: 'Telugu' },
  { value: 'tg', label: 'Tajik' },
  { value: 'th', label: 'Thai' },
  { value: 'ti', label: 'Tigrinya' },
  { value: 'bo', label: 'Tibetan' },
  { value: 'tk', label: 'Turkmen' },
  { value: 'tl', label: 'Tagalog' },
  { value: 'tn', label: 'Tswana' },
  { value: 'to', label: 'Tonga' },
  { value: 'tr', label: 'Turkish' },
  { value: 'ts', label: 'Tsonga' },
  { value: 'tt', label: 'Tatar' },
  { value: 'tw', label: 'Twi' },
  { value: 'ty', label: 'Tahitian' },
  { value: 'ug', label: 'Uighur, Uyghur' },
  { value: 'uk', label: 'Ukrainian' },
  { value: 'ur', label: 'Urdu' },
  { value: 'uz', label: 'Uzbek' },
  { value: 've', label: 'Venda' },
  { value: 'vi', label: 'Vietnamese' },
  { value: 'vo', label: 'Volapük' },
  { value: 'wa', label: 'Walloon' },
  { value: 'cy', label: 'Welsh' },
  { value: 'wo', label: 'Wolof' },
  { value: 'fy', label: 'West Frisian' },
  { value: 'xh', label: 'Xhosa' },
  { value: 'yi', label: 'Yiddish' },
  { value: 'yo', label: 'Yoruba' },
  { value: 'za', label: 'Zhuang, Chuang' },
  { value: 'zu', label: 'Zulu' },
];
export const MODEL_ABILITY_LLM_OPTIONS = [
  { label: 'Generate', value: ModelAbility.Generate },
  { label: 'Chat', value: ModelAbility.Chat },
  { label: 'Vision', value: ModelAbility.Vision },
  { label: 'Tools', value: ModelAbility.Tools },
  { label: 'Reasoning', value: ModelAbility.Reasoning },
  { label: 'Audio', value: ModelAbility.Audio },
  { label: 'Omni', value: ModelAbility.Omni },
  { label: 'Hybrid', value: ModelAbility.Hybrid },
];
export const MODEL_ABILITY_HAS_CHAT = [
  ModelAbility.Reasoning,
  ModelAbility.Audio,
  ModelAbility.Omni,
  ModelAbility.Hybrid,
  ModelAbility.Vision,
  ModelAbility.Tools,
];
export enum ModelAbilityForImage {
  Text2Image = 'text2image',
  Image2Image = 'image2image',
  Inpainting = 'inpainting',
  Ocr = 'ocr',
}
export const MODEL_ABILITY_IMAGE_OPTIONS = [
  { label: 'Text2Image', value: ModelAbilityForImage.Text2Image },
  { label: 'Image2Image', value: ModelAbilityForImage.Image2Image },
  { label: 'Inpainting', value: ModelAbilityForImage.Inpainting },
  { label: 'Ocr', value: ModelAbilityForImage.Ocr },
];
export enum ModelAbilityForAudio {
  Text2audio = 'text2audio',
  Audio2text = 'audio2text',
}
export const MODEL_ABILITY_AUDIO_OPTIONS = [
  { label: 'Text2audio', value: ModelAbilityForAudio.Text2audio },
  { label: 'Audio2text', value: ModelAbilityForAudio.Audio2text },
];
export const MODEL_ABILITY_OPTIONS_MAP: Partial<
  Record<ModelType, { label: string; value: string }[]>
> = {
  [ModelType.LLM]: MODEL_ABILITY_LLM_OPTIONS,
  [ModelType.Image]: MODEL_ABILITY_IMAGE_OPTIONS,
  [ModelType.Audio]: MODEL_ABILITY_AUDIO_OPTIONS,
};
export enum ModelFamilyForImage {
  stableDiffusion = 'stable_diffusion',
}
export const MODEL_FAMILY_IMAGE_OPTIONS = [
  { label: ModelFamilyForImage.stableDiffusion, value: ModelFamilyForImage.stableDiffusion },
];

export enum ModelFamilyForAudio {
  Whisper = 'whisper',
  ChatTTS = 'ChatTTS',
  CosyVoice = 'CosyVoice',
  F5TTS = 'F5-TTS',
  F5TTSMLX = 'F5-TTS-MLX',
  FishAudio = 'FishAudio',
  Kokoro = 'Kokoro',
  MegaTTS = 'MegaTTS',
  MeloTTS = 'MeloTTS',
  Funasr = 'funasr',
}
export const MODEL_FAMILY_AUDIO_OPTIONS = [
  { label: ModelFamilyForAudio.Whisper, value: ModelFamilyForAudio.Whisper },
  { label: ModelFamilyForAudio.ChatTTS, value: ModelFamilyForAudio.ChatTTS },
  { label: ModelFamilyForAudio.CosyVoice, value: ModelFamilyForAudio.CosyVoice },
  { label: ModelFamilyForAudio.F5TTS, value: ModelFamilyForAudio.F5TTS },
  { label: ModelFamilyForAudio.F5TTSMLX, value: ModelFamilyForAudio.F5TTSMLX },
  { label: ModelFamilyForAudio.FishAudio, value: ModelFamilyForAudio.FishAudio },
  { label: ModelFamilyForAudio.Kokoro, value: ModelFamilyForAudio.Kokoro },
  { label: ModelFamilyForAudio.MegaTTS, value: ModelFamilyForAudio.MegaTTS },
  { label: ModelFamilyForAudio.MeloTTS, value: ModelFamilyForAudio.MeloTTS },
  { label: ModelFamilyForAudio.Funasr, value: ModelFamilyForAudio.Funasr },
];
export const MODEL_FAMILY_OPTIONS_MAP: Partial<
  Record<ModelType, { label: string; value: string }[]>
> = {
  [ModelType.Image]: MODEL_FAMILY_IMAGE_OPTIONS,
  [ModelType.Audio]: MODEL_FAMILY_AUDIO_OPTIONS,
};

export const MODEL_TEMPLATE_TEST_MSG = [
  {
    role: 'assistant',
    content: 'This is the message content replied by the assistant previously',
  },
  {
    role: 'user',
    content: 'This is the message content sent by the user currently',
  },
];
export enum ModelFormat {
  PyTorch = 'pytorch',
  GGUFV2 = 'ggufv2',
  GPTQ = 'gptq',
  AWQ = 'awq',
  FP8 = 'fp8',
  MLX = 'mlx',
  GGMLV3 ='ggmlv3'
}
export const MODEL_FORMAT_LLM_OPTIONS = [
  { value: ModelFormat.PyTorch, label: 'PyTorch' },
  { value: ModelFormat.GGUFV2, label: 'GGUF' },
  { value: ModelFormat.GPTQ, label: 'GPTQ' },
  { value: ModelFormat.AWQ, label: 'AWQ' },
  { value: ModelFormat.FP8, label: 'FP8' },
  { value: ModelFormat.MLX, label: 'MLX' },
];
export const MODEL_FORMAT_EMBEDDING_OPTIONS = [
  { value: ModelFormat.PyTorch, label: 'PyTorch' },
  { value: ModelFormat.GGUFV2, label: 'GGUF' },
];
export const MODEL_FORMAT_RERANK_OPTIONS = [
  { value: ModelFormat.PyTorch, label: 'PyTorch' },
  { value: ModelFormat.GGUFV2, label: 'GGUF' },
];
export const MODEL_FORMAT_OPTIONS_MAP: Partial<
  Record<ModelType, { label: string; value: string }[]>
> = {
  [ModelType.LLM]: MODEL_FORMAT_LLM_OPTIONS,
  [ModelType.Embedding]: MODEL_FORMAT_EMBEDDING_OPTIONS,
  [ModelType.Rerank]: MODEL_FORMAT_RERANK_OPTIONS,
};

export enum ControlnetModelFamily {
  Controlnet = 'controlnet',
}
export const CONTROLNET_MODEL_FAMILY_OPTIONS = [
 { label: ControlnetModelFamily.Controlnet, value: ControlnetModelFamily.Controlnet}
]
export const REGISTER_MODEL_INIT_DATA = {
  [ModelType.LLM]: {
    version: 2,
    model_name: 'custom-llm',
    model_description: 'This is a custom model description.',
    context_length: 2048,
    model_lang: ['en'],
    model_ability: [ModelAbility.Generate],
    model_specs: [
      {
        model_uri: '/path/to/llama-1',
        model_size_in_billions: 7,
        model_format: ModelFormat.PyTorch,
        quantization: 'none',
      },
    ],
    model_family: 'your_custom_model',
    virtualenv: {
      packages: [],
    },
  },
  [ModelType.Embedding]: {
    version: 2,
    model_name: 'custom-embedding',
    dimensions: 768,
    max_tokens: 512,
    language: ['en'],
    model_specs: [
      {
        model_uri: '/path/to/embedding-1',
        model_format: ModelFormat.PyTorch,
        quantization: 'none',
      },
    ],
    virtualenv: {
      packages: [],
    },
  },
  [ModelType.Rerank]: {
    version: 2,
    model_name: 'custom-rerank',
    language: ['en'],
    max_tokens: 512,
    model_specs: [
      {
        model_uri: '/path/to/rerank-1',
        model_format: ModelFormat.PyTorch,
        quantization: 'none',
      },
    ],
    virtualenv: {
      packages: [],
    },
  },
  [ModelType.Image]: {
    version: 2,
    model_name: 'custom-image',
    model_uri: '/path/to/image-model',
    model_ability: [ModelAbilityForImage.Text2Image],
    model_family: ModelFamilyForImage.stableDiffusion,
    controlnet: [],
    virtualenv: {
      packages: [],
    },
  },
  [ModelType.Audio]: {
    version: 2,
    model_name: 'custom-audio',
    model_uri: '/path/to/audio-model',
    multilingual: false,
    model_family: ModelFamilyForAudio.Whisper,
    model_ability: ModelAbilityForAudio.Text2audio,
    virtualenv: {
      packages: [],
    },
  },
  [ModelType.Flexible]: {
    version: 2,
    model_name: 'flexible-model',
    model_description: 'This is a model description.',
    model_uri: '/path/to/model',
    launcher: 'xinference.model.flexible.launchers.transformers',
    launcher_args: '{}',
    virtualenv: {
      packages: [],
    },
  },
};
