models.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. from __future__ import annotations
  2. from dataclasses import dataclass
  3. from .Provider import IterListProvider, ProviderType
  4. from .Provider import (
  5. Ai4Chat,
  6. AIChatFree,
  7. Airforce,
  8. AIUncensored,
  9. Allyfy,
  10. Bing,
  11. Blackbox,
  12. ChatGpt,
  13. Chatgpt4Online,
  14. ChatGptEs,
  15. Cloudflare,
  16. DarkAI,
  17. DDG,
  18. DeepInfraChat,
  19. Free2GPT,
  20. FreeGpt,
  21. FreeNetfly,
  22. Gemini,
  23. GeminiPro,
  24. GizAI,
  25. GigaChat,
  26. HuggingChat,
  27. HuggingFace,
  28. Liaobots,
  29. MagickPen,
  30. Mhystical,
  31. MetaAI,
  32. OpenaiChat,
  33. PerplexityLabs,
  34. Pi,
  35. Pizzagpt,
  36. Reka,
  37. ReplicateHome,
  38. RubiksAI,
  39. TeachAnything,
  40. Upstage,
  41. )
  42. @dataclass(unsafe_hash=True)
  43. class Model:
  44. """
  45. Represents a machine learning model configuration.
  46. Attributes:
  47. name (str): Name of the model.
  48. base_provider (str): Default provider for the model.
  49. best_provider (ProviderType): The preferred provider for the model, typically with retry logic.
  50. """
  51. name: str
  52. base_provider: str
  53. best_provider: ProviderType = None
  54. @staticmethod
  55. def __all__() -> list[str]:
  56. """Returns a list of all model names."""
  57. return _all_models
  58. ### Default ###
  59. default = Model(
  60. name = "",
  61. base_provider = "",
  62. best_provider = IterListProvider([
  63. DDG,
  64. Pizzagpt,
  65. ReplicateHome,
  66. Upstage,
  67. Blackbox,
  68. Free2GPT,
  69. MagickPen,
  70. DeepInfraChat,
  71. Airforce,
  72. ChatGptEs,
  73. Cloudflare,
  74. AIUncensored,
  75. DarkAI,
  76. Mhystical,
  77. ])
  78. )
  79. ############
  80. ### Text ###
  81. ############
  82. ### OpenAI ###
  83. # gpt-3.5
  84. gpt_35_turbo = Model(
  85. name = 'gpt-3.5-turbo',
  86. base_provider = 'OpenAI',
  87. best_provider = IterListProvider([Airforce, DarkAI])
  88. )
  89. # gpt-4
  90. gpt_4o = Model(
  91. name = 'gpt-4o',
  92. base_provider = 'OpenAI',
  93. best_provider = IterListProvider([Blackbox, ChatGptEs, DarkAI, ChatGpt, Airforce, Liaobots, OpenaiChat])
  94. )
  95. gpt_4o_mini = Model(
  96. name = 'gpt-4o-mini',
  97. base_provider = 'OpenAI',
  98. best_provider = IterListProvider([DDG, ChatGptEs, FreeNetfly, Pizzagpt, ChatGpt, Airforce, RubiksAI, MagickPen, Liaobots, OpenaiChat])
  99. )
  100. gpt_4_turbo = Model(
  101. name = 'gpt-4-turbo',
  102. base_provider = 'OpenAI',
  103. best_provider = IterListProvider([ChatGpt, Airforce, Liaobots, Bing])
  104. )
  105. gpt_4 = Model(
  106. name = 'gpt-4',
  107. base_provider = 'OpenAI',
  108. best_provider = IterListProvider([Mhystical, Chatgpt4Online, ChatGpt, Bing, OpenaiChat, gpt_4_turbo.best_provider, gpt_4o.best_provider, gpt_4o_mini.best_provider])
  109. )
  110. # o1
  111. o1 = Model(
  112. name = 'o1',
  113. base_provider = 'OpenAI',
  114. best_provider = None
  115. )
  116. o1_mini = Model(
  117. name = 'o1-mini',
  118. base_provider = 'OpenAI',
  119. best_provider = None
  120. )
  121. ### GigaChat ###
  122. gigachat = Model(
  123. name = 'GigaChat:latest',
  124. base_provider = 'gigachat',
  125. best_provider = GigaChat
  126. )
  127. ### Meta ###
  128. meta = Model(
  129. name = "meta-ai",
  130. base_provider = "Meta",
  131. best_provider = MetaAI
  132. )
  133. # llama 2
  134. llama_2_7b = Model(
  135. name = "llama-2-7b",
  136. base_provider = "Meta Llama",
  137. best_provider = IterListProvider([Cloudflare, Airforce])
  138. )
  139. # llama 3
  140. llama_3_8b = Model(
  141. name = "llama-3-8b",
  142. base_provider = "Meta Llama",
  143. best_provider = IterListProvider([Cloudflare])
  144. )
  145. # llama 3.1
  146. llama_3_1_8b = Model(
  147. name = "llama-3.1-8b",
  148. base_provider = "Meta Llama",
  149. best_provider = IterListProvider([Blackbox, DeepInfraChat, Cloudflare, Airforce, PerplexityLabs])
  150. )
  151. llama_3_1_70b = Model(
  152. name = "llama-3.1-70b",
  153. base_provider = "Meta Llama",
  154. best_provider = IterListProvider([DDG, DeepInfraChat, Blackbox, TeachAnything, DarkAI, Airforce, RubiksAI, HuggingChat, HuggingFace, PerplexityLabs])
  155. )
  156. llama_3_1_405b = Model(
  157. name = "llama-3.1-405b",
  158. base_provider = "Meta Llama",
  159. best_provider = IterListProvider([Blackbox, DarkAI])
  160. )
  161. # llama 3.2
  162. llama_3_2_1b = Model(
  163. name = "llama-3.2-1b",
  164. base_provider = "Meta Llama",
  165. best_provider = IterListProvider([Cloudflare])
  166. )
  167. llama_3_2_11b = Model(
  168. name = "llama-3.2-11b",
  169. base_provider = "Meta Llama",
  170. best_provider = IterListProvider([HuggingChat, HuggingFace])
  171. )
  172. ### Mistral ###
  173. mistral_7b = Model(
  174. name = "mistral-7b",
  175. base_provider = "Mistral",
  176. best_provider = IterListProvider([Free2GPT])
  177. )
  178. mixtral_8x7b = Model(
  179. name = "mixtral-8x7b",
  180. base_provider = "Mistral",
  181. best_provider = DDG
  182. )
  183. mistral_nemo = Model(
  184. name = "mistral-nemo",
  185. base_provider = "Mistral",
  186. best_provider = IterListProvider([HuggingChat, HuggingFace])
  187. )
  188. ### NousResearch ###
  189. hermes_2_pro = Model(
  190. name = "hermes-2-pro",
  191. base_provider = "NousResearch",
  192. best_provider = Airforce
  193. )
  194. hermes_2_dpo = Model(
  195. name = "hermes-2-dpo",
  196. base_provider = "NousResearch",
  197. best_provider = Airforce
  198. )
  199. hermes_3 = Model(
  200. name = "hermes-3",
  201. base_provider = "NousResearch",
  202. best_provider = IterListProvider([HuggingChat, HuggingFace])
  203. )
  204. ### Microsoft ###
  205. phi_2 = Model(
  206. name = "phi-2",
  207. base_provider = "Microsoft",
  208. best_provider = IterListProvider([Airforce])
  209. )
  210. phi_3_5_mini = Model(
  211. name = "phi-3.5-mini",
  212. base_provider = "Microsoft",
  213. best_provider = IterListProvider([HuggingChat, HuggingFace])
  214. )
  215. ### Google DeepMind ###
  216. # gemini
  217. gemini_pro = Model(
  218. name = 'gemini-pro',
  219. base_provider = 'Google DeepMind',
  220. best_provider = IterListProvider([GeminiPro, Blackbox, AIChatFree, FreeGpt, Liaobots])
  221. )
  222. gemini_flash = Model(
  223. name = 'gemini-flash',
  224. base_provider = 'Google DeepMind',
  225. best_provider = IterListProvider([Blackbox, GizAI, Liaobots])
  226. )
  227. gemini = Model(
  228. name = 'gemini',
  229. base_provider = 'Google DeepMind',
  230. best_provider = Gemini
  231. )
  232. # gemma
  233. gemma_2b = Model(
  234. name = 'gemma-2b',
  235. base_provider = 'Google',
  236. best_provider = ReplicateHome
  237. )
  238. ### Anthropic ###
  239. claude_2_1 = Model(
  240. name = 'claude-2.1',
  241. base_provider = 'Anthropic',
  242. best_provider = Liaobots
  243. )
  244. # claude 3
  245. claude_3_opus = Model(
  246. name = 'claude-3-opus',
  247. base_provider = 'Anthropic',
  248. best_provider = IterListProvider([Liaobots])
  249. )
  250. claude_3_sonnet = Model(
  251. name = 'claude-3-sonnet',
  252. base_provider = 'Anthropic',
  253. best_provider = IterListProvider([Liaobots])
  254. )
  255. claude_3_haiku = Model(
  256. name = 'claude-3-haiku',
  257. base_provider = 'Anthropic',
  258. best_provider = IterListProvider([DDG, Liaobots])
  259. )
  260. # claude 3.5
  261. claude_3_5_sonnet = Model(
  262. name = 'claude-3.5-sonnet',
  263. base_provider = 'Anthropic',
  264. best_provider = IterListProvider([Blackbox, Liaobots])
  265. )
  266. ### Reka AI ###
  267. reka_core = Model(
  268. name = 'reka-core',
  269. base_provider = 'Reka AI',
  270. best_provider = Reka
  271. )
  272. ### Blackbox AI ###
  273. blackboxai = Model(
  274. name = 'blackboxai',
  275. base_provider = 'Blackbox AI',
  276. best_provider = Blackbox
  277. )
  278. blackboxai_pro = Model(
  279. name = 'blackboxai-pro',
  280. base_provider = 'Blackbox AI',
  281. best_provider = Blackbox
  282. )
  283. ### CohereForAI ###
  284. command_r_plus = Model(
  285. name = 'command-r-plus',
  286. base_provider = 'CohereForAI',
  287. best_provider = HuggingChat
  288. )
  289. ### Qwen ###
  290. # qwen 1_5
  291. qwen_1_5_7b = Model(
  292. name = 'qwen-1.5-7b',
  293. base_provider = 'Qwen',
  294. best_provider = Cloudflare
  295. )
  296. # qwen 2
  297. qwen_2_72b = Model(
  298. name = 'qwen-2-72b',
  299. base_provider = 'Qwen',
  300. best_provider = IterListProvider([DeepInfraChat, HuggingChat, HuggingFace])
  301. )
  302. # qwen 2.5
  303. qwen_2_5_coder_32b = Model(
  304. name = 'qwen-2.5-coder-32b',
  305. base_provider = 'Qwen',
  306. best_provider = IterListProvider([HuggingChat, HuggingFace])
  307. )
  308. ### Upstage ###
  309. solar_mini = Model(
  310. name = 'solar-mini',
  311. base_provider = 'Upstage',
  312. best_provider = Upstage
  313. )
  314. solar_pro = Model(
  315. name = 'solar-pro',
  316. base_provider = 'Upstage',
  317. best_provider = Upstage
  318. )
  319. ### Inflection ###
  320. pi = Model(
  321. name = 'pi',
  322. base_provider = 'Inflection',
  323. best_provider = Pi
  324. )
  325. ### DeepSeek ###
  326. deepseek_coder = Model(
  327. name = 'deepseek-coder',
  328. base_provider = 'DeepSeek',
  329. best_provider = Airforce
  330. )
  331. ### WizardLM ###
  332. wizardlm_2_8x22b = Model(
  333. name = 'wizardlm-2-8x22b',
  334. base_provider = 'WizardLM',
  335. best_provider = IterListProvider([DeepInfraChat])
  336. )
  337. ### Yorickvp ###
  338. llava_13b = Model(
  339. name = 'llava-13b',
  340. base_provider = 'Yorickvp',
  341. best_provider = ReplicateHome
  342. )
  343. ### OpenChat ###
  344. openchat_3_5 = Model(
  345. name = 'openchat-3.5',
  346. base_provider = 'OpenChat',
  347. best_provider = Airforce
  348. )
  349. ### x.ai ###
  350. grok_2 = Model(
  351. name = 'grok-2',
  352. base_provider = 'x.ai',
  353. best_provider = Liaobots
  354. )
  355. grok_2_mini = Model(
  356. name = 'grok-2-mini',
  357. base_provider = 'x.ai',
  358. best_provider = Liaobots
  359. )
  360. grok_beta = Model(
  361. name = 'grok-beta',
  362. base_provider = 'x.ai',
  363. best_provider = Liaobots
  364. )
  365. ### Perplexity AI ###
  366. sonar_online = Model(
  367. name = 'sonar-online',
  368. base_provider = 'Perplexity AI',
  369. best_provider = IterListProvider([PerplexityLabs])
  370. )
  371. sonar_chat = Model(
  372. name = 'sonar-chat',
  373. base_provider = 'Perplexity AI',
  374. best_provider = PerplexityLabs
  375. )
  376. ### Nvidia ###
  377. nemotron_70b = Model(
  378. name = 'nemotron-70b',
  379. base_provider = 'Nvidia',
  380. best_provider = IterListProvider([HuggingChat, HuggingFace])
  381. )
  382. ### Teknium ###
  383. openhermes_2_5 = Model(
  384. name = 'openhermes-2.5',
  385. base_provider = 'Teknium',
  386. best_provider = Airforce
  387. )
  388. ### Liquid ###
  389. lfm_40b = Model(
  390. name = 'lfm-40b',
  391. base_provider = 'Liquid',
  392. best_provider = IterListProvider([Airforce, PerplexityLabs])
  393. )
  394. ### DiscoResearch ###
  395. german_7b = Model(
  396. name = 'german-7b',
  397. base_provider = 'DiscoResearch',
  398. best_provider = Airforce
  399. )
  400. ### HuggingFaceH4 ###
  401. zephyr_7b = Model(
  402. name = 'zephyr-7b',
  403. base_provider = 'HuggingFaceH4',
  404. best_provider = Airforce
  405. )
  406. ### Inferless ###
  407. neural_7b = Model(
  408. name = 'neural-7b',
  409. base_provider = 'inferless',
  410. best_provider = Airforce
  411. )
  412. #############
  413. ### Image ###
  414. #############
  415. ### Stability AI ###
  416. sdxl = Model(
  417. name = 'sdxl',
  418. base_provider = 'Stability AI',
  419. best_provider = IterListProvider([ReplicateHome])
  420. )
  421. sd_3 = Model(
  422. name = 'sd-3',
  423. base_provider = 'Stability AI',
  424. best_provider = ReplicateHome
  425. )
  426. ### Playground ###
  427. playground_v2_5 = Model(
  428. name = 'playground-v2.5',
  429. base_provider = 'Playground AI',
  430. best_provider = ReplicateHome
  431. )
  432. ### Flux AI ###
  433. flux = Model(
  434. name = 'flux',
  435. base_provider = 'Flux AI',
  436. best_provider = IterListProvider([Blackbox, AIUncensored, Airforce])
  437. )
  438. flux_pro = Model(
  439. name = 'flux-pro',
  440. base_provider = 'Flux AI',
  441. best_provider = IterListProvider([Airforce])
  442. )
  443. flux_realism = Model(
  444. name = 'flux-realism',
  445. base_provider = 'Flux AI',
  446. best_provider = IterListProvider([Airforce])
  447. )
  448. flux_anime = Model(
  449. name = 'flux-anime',
  450. base_provider = 'Flux AI',
  451. best_provider = Airforce
  452. )
  453. flux_3d = Model(
  454. name = 'flux-3d',
  455. base_provider = 'Flux AI',
  456. best_provider = Airforce
  457. )
  458. flux_disney = Model(
  459. name = 'flux-disney',
  460. base_provider = 'Flux AI',
  461. best_provider = Airforce
  462. )
  463. flux_pixel = Model(
  464. name = 'flux-pixel',
  465. base_provider = 'Flux AI',
  466. best_provider = Airforce
  467. )
  468. flux_4o = Model(
  469. name = 'flux-4o',
  470. base_provider = 'Flux AI',
  471. best_provider = Airforce
  472. )
  473. ### Other ###
  474. any_dark = Model(
  475. name = 'any-dark',
  476. base_provider = '',
  477. best_provider = Airforce
  478. )
  479. class ModelUtils:
  480. """
  481. Utility class for mapping string identifiers to Model instances.
  482. Attributes:
  483. convert (dict[str, Model]): Dictionary mapping model string identifiers to Model instances.
  484. """
  485. convert: dict[str, Model] = {
  486. ############
  487. ### Text ###
  488. ############
  489. ### OpenAI ###
  490. # gpt-3.5
  491. 'gpt-3.5-turbo': gpt_35_turbo,
  492. # gpt-4
  493. 'gpt-4o': gpt_4o,
  494. 'gpt-4o-mini': gpt_4o_mini,
  495. 'gpt-4': gpt_4,
  496. 'gpt-4-turbo': gpt_4_turbo,
  497. # o1
  498. 'o1': o1,
  499. 'o1-mini': o1_mini,
  500. ### Meta ###
  501. "meta-ai": meta,
  502. # llama-2
  503. 'llama-2-7b': llama_2_7b,
  504. # llama-3
  505. 'llama-3-8b': llama_3_8b,
  506. # llama-3.1
  507. 'llama-3.1-8b': llama_3_1_8b,
  508. 'llama-3.1-70b': llama_3_1_70b,
  509. 'llama-3.1-405b': llama_3_1_405b,
  510. # llama-3.2
  511. 'llama-3.2-1b': llama_3_2_1b,
  512. 'llama-3.2-11b': llama_3_2_11b,
  513. ### Mistral ###
  514. 'mistral-7b': mistral_7b,
  515. 'mixtral-8x7b': mixtral_8x7b,
  516. 'mistral-nemo': mistral_nemo,
  517. ### NousResearch ###
  518. 'hermes-2-pro': hermes_2_pro,
  519. 'hermes-2-dpo': hermes_2_dpo,
  520. 'hermes-3': hermes_3,
  521. ### Microsoft ###
  522. 'phi-2': phi_2,
  523. 'phi-3.5-mini': phi_3_5_mini,
  524. ### Google ###
  525. # gemini
  526. 'gemini': gemini,
  527. 'gemini-pro': gemini_pro,
  528. 'gemini-flash': gemini_flash,
  529. # gemma
  530. 'gemma-2b': gemma_2b,
  531. ### Anthropic ###
  532. 'claude-2.1': claude_2_1,
  533. # claude 3
  534. 'claude-3-opus': claude_3_opus,
  535. 'claude-3-sonnet': claude_3_sonnet,
  536. 'claude-3-haiku': claude_3_haiku,
  537. # claude 3.5
  538. 'claude-3.5-sonnet': claude_3_5_sonnet,
  539. ### Reka AI ###
  540. 'reka-core': reka_core,
  541. ### Blackbox AI ###
  542. 'blackboxai': blackboxai,
  543. 'blackboxai-pro': blackboxai_pro,
  544. ### CohereForAI ###
  545. 'command-r+': command_r_plus,
  546. ### GigaChat ###
  547. 'gigachat': gigachat,
  548. ### Qwen ###
  549. # qwen 1.5
  550. 'qwen-1.5-7b': qwen_1_5_7b,
  551. # qwen 2
  552. 'qwen-2-72b': qwen_2_72b,
  553. # qwen 2.5
  554. 'qwen-2.5-coder-32b': qwen_2_5_coder_32b,
  555. ### Upstage ###
  556. 'solar-mini': solar_mini,
  557. 'solar-pro': solar_pro,
  558. ### Inflection ###
  559. 'pi': pi,
  560. ### DeepSeek ###
  561. 'deepseek-coder': deepseek_coder,
  562. ### Yorickvp ###
  563. 'llava-13b': llava_13b,
  564. ### WizardLM ###
  565. 'wizardlm-2-8x22b': wizardlm_2_8x22b,
  566. ### OpenChat ###
  567. 'openchat-3.5': openchat_3_5,
  568. ### x.ai ###
  569. 'grok-2': grok_2,
  570. 'grok-2-mini': grok_2_mini,
  571. 'grok-beta': grok_beta,
  572. ### Perplexity AI ###
  573. 'sonar-online': sonar_online,
  574. 'sonar-chat': sonar_chat,
  575. ### TheBloke ###
  576. 'german-7b': german_7b,
  577. ### Nvidia ###
  578. 'nemotron-70b': nemotron_70b,
  579. ### Teknium ###
  580. 'openhermes-2.5': openhermes_2_5,
  581. ### Liquid ###
  582. 'lfm-40b': lfm_40b,
  583. ### DiscoResearch ###
  584. 'german-7b': german_7b,
  585. ### HuggingFaceH4 ###
  586. 'zephyr-7b': zephyr_7b,
  587. ### Inferless ###
  588. 'neural-7b': neural_7b,
  589. #############
  590. ### Image ###
  591. #############
  592. ### Stability AI ###
  593. 'sdxl': sdxl,
  594. 'sd-3': sd_3,
  595. ### Playground ###
  596. 'playground-v2.5': playground_v2_5,
  597. ### Flux AI ###
  598. 'flux': flux,
  599. 'flux-pro': flux_pro,
  600. 'flux-realism': flux_realism,
  601. 'flux-anime': flux_anime,
  602. 'flux-3d': flux_3d,
  603. 'flux-disney': flux_disney,
  604. 'flux-pixel': flux_pixel,
  605. 'flux-4o': flux_4o,
  606. ### Other ###
  607. 'any-dark': any_dark,
  608. }
  609. _all_models = list(ModelUtils.convert.keys())