models.py 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. from __future__ import annotations
  2. from dataclasses import dataclass
  3. from .Provider import RetryProvider, ProviderType
  4. from .Provider import (
  5. Chatgpt4Online,
  6. ChatgptDemoAi,
  7. ChatAnywhere,
  8. ChatgptNext,
  9. HuggingChat,
  10. ChatgptDemo,
  11. GptForLove,
  12. ChatgptAi,
  13. DeepInfra,
  14. OnlineGpt,
  15. ChatBase,
  16. Liaobots,
  17. GeekGpt,
  18. FakeGpt,
  19. FreeGpt,
  20. Berlin,
  21. Llama2,
  22. Vercel,
  23. Phind,
  24. Koala,
  25. GptGo,
  26. Gpt6,
  27. Bard,
  28. Bing,
  29. You,
  30. H2o,
  31. Pi,
  32. )
  33. @dataclass(unsafe_hash=True)
  34. class Model:
  35. name: str
  36. base_provider: str
  37. best_provider: ProviderType = None
  38. @staticmethod
  39. def __all__() -> list[str]:
  40. return _all_models
  41. default = Model(
  42. name = "",
  43. base_provider = "",
  44. best_provider = RetryProvider([
  45. Bing,
  46. ChatgptAi, GptGo, GeekGpt,
  47. You,
  48. Chatgpt4Online,
  49. ChatAnywhere
  50. ])
  51. )
  52. # GPT-3.5 too, but all providers supports long requests and responses
  53. gpt_35_long = Model(
  54. name = 'gpt-3.5-turbo',
  55. base_provider = 'openai',
  56. best_provider = RetryProvider([
  57. FreeGpt, You,
  58. GeekGpt, FakeGpt,
  59. Berlin, Koala,
  60. Chatgpt4Online,
  61. ChatAnywhere,
  62. ChatgptDemoAi,
  63. OnlineGpt,
  64. ChatgptNext,
  65. ChatgptDemo,
  66. Gpt6,
  67. ])
  68. )
  69. # GPT-3.5 / GPT-4
  70. gpt_35_turbo = Model(
  71. name = 'gpt-3.5-turbo',
  72. base_provider = 'openai',
  73. best_provider=RetryProvider([
  74. GptGo, You,
  75. GptForLove, ChatBase,
  76. Chatgpt4Online,
  77. ChatAnywhere,
  78. ])
  79. )
  80. gpt_4 = Model(
  81. name = 'gpt-4',
  82. base_provider = 'openai',
  83. best_provider = RetryProvider([
  84. Bing, Phind, Liaobots
  85. ])
  86. )
  87. gpt_4_turbo = Model(
  88. name = 'gpt-4-turbo',
  89. base_provider = 'openai',
  90. best_provider = Bing
  91. )
  92. llama2_7b = Model(
  93. name = "meta-llama/Llama-2-7b-chat-hf",
  94. base_provider = 'huggingface',
  95. best_provider = RetryProvider([Llama2, DeepInfra])
  96. )
  97. llama2_13b = Model(
  98. name = "meta-llama/Llama-2-13b-chat-hf",
  99. base_provider = 'huggingface',
  100. best_provider = RetryProvider([Llama2, DeepInfra])
  101. )
  102. llama2_70b = Model(
  103. name = "meta-llama/Llama-2-70b-chat-hf",
  104. base_provider = "huggingface",
  105. best_provider = RetryProvider([Llama2, DeepInfra, HuggingChat])
  106. )
  107. # Mistal
  108. mixtral_8x7b = Model(
  109. name = "mistralai/Mixtral-8x7B-Instruct-v0.1",
  110. base_provider = "huggingface",
  111. best_provider = RetryProvider([DeepInfra, HuggingChat])
  112. )
  113. mistral_7b = Model(
  114. name = "mistralai/Mistral-7B-Instruct-v0.1",
  115. base_provider = "huggingface",
  116. best_provider = RetryProvider([DeepInfra, HuggingChat])
  117. )
  118. openchat_35 = Model(
  119. name = "openchat/openchat_3.5",
  120. base_provider = "huggingface",
  121. best_provider = RetryProvider([DeepInfra, HuggingChat])
  122. )
  123. # Bard
  124. palm = Model(
  125. name = 'palm',
  126. base_provider = 'google',
  127. best_provider = Bard)
  128. # H2o
  129. falcon_7b = Model(
  130. name = 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3',
  131. base_provider = 'huggingface',
  132. best_provider = H2o)
  133. falcon_40b = Model(
  134. name = 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v1',
  135. base_provider = 'huggingface',
  136. best_provider = H2o)
  137. llama_13b = Model(
  138. name = 'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-13b',
  139. base_provider = 'huggingface',
  140. best_provider = H2o)
  141. # Vercel
  142. claude_instant_v1 = Model(
  143. name = 'claude-instant-v1',
  144. base_provider = 'anthropic',
  145. best_provider = Vercel)
  146. claude_v1 = Model(
  147. name = 'claude-v1',
  148. base_provider = 'anthropic',
  149. best_provider = Vercel)
  150. claude_v2 = Model(
  151. name = 'claude-v2',
  152. base_provider = 'anthropic',
  153. best_provider = Vercel)
  154. command_light_nightly = Model(
  155. name = 'command-light-nightly',
  156. base_provider = 'cohere',
  157. best_provider = Vercel)
  158. command_nightly = Model(
  159. name = 'command-nightly',
  160. base_provider = 'cohere',
  161. best_provider = Vercel)
  162. gpt_neox_20b = Model(
  163. name = 'EleutherAI/gpt-neox-20b',
  164. base_provider = 'huggingface',
  165. best_provider = Vercel)
  166. oasst_sft_1_pythia_12b = Model(
  167. name = 'OpenAssistant/oasst-sft-1-pythia-12b',
  168. base_provider = 'huggingface',
  169. best_provider = Vercel)
  170. oasst_sft_4_pythia_12b_epoch_35 = Model(
  171. name = 'OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5',
  172. base_provider = 'huggingface',
  173. best_provider = Vercel)
  174. santacoder = Model(
  175. name = 'bigcode/santacoder',
  176. base_provider = 'huggingface',
  177. best_provider = Vercel)
  178. bloom = Model(
  179. name = 'bigscience/bloom',
  180. base_provider = 'huggingface',
  181. best_provider = Vercel)
  182. flan_t5_xxl = Model(
  183. name = 'google/flan-t5-xxl',
  184. base_provider = 'huggingface',
  185. best_provider = Vercel)
  186. code_davinci_002 = Model(
  187. name = 'code-davinci-002',
  188. base_provider = 'openai',
  189. best_provider = Vercel)
  190. gpt_35_turbo_16k = Model(
  191. name = 'gpt-3.5-turbo-16k',
  192. base_provider = 'openai',
  193. best_provider = gpt_35_long.best_provider)
  194. gpt_35_turbo_16k_0613 = Model(
  195. name = 'gpt-3.5-turbo-16k-0613',
  196. base_provider = 'openai',
  197. best_provider = gpt_35_long.best_provider
  198. )
  199. gpt_35_turbo_0613 = Model(
  200. name = 'gpt-3.5-turbo-0613',
  201. base_provider = 'openai',
  202. best_provider = gpt_35_turbo.best_provider
  203. )
  204. gpt_4_0613 = Model(
  205. name = 'gpt-4-0613',
  206. base_provider = 'openai',
  207. best_provider = gpt_4.best_provider
  208. )
  209. gpt_4_32k = Model(
  210. name = 'gpt-4-32k',
  211. base_provider = 'openai',
  212. best_provider = gpt_4.best_provider
  213. )
  214. gpt_4_32k_0613 = Model(
  215. name = 'gpt-4-32k-0613',
  216. base_provider = 'openai',
  217. best_provider = gpt_4.best_provider
  218. )
  219. text_ada_001 = Model(
  220. name = 'text-ada-001',
  221. base_provider = 'openai',
  222. best_provider = Vercel)
  223. text_babbage_001 = Model(
  224. name = 'text-babbage-001',
  225. base_provider = 'openai',
  226. best_provider = Vercel)
  227. text_curie_001 = Model(
  228. name = 'text-curie-001',
  229. base_provider = 'openai',
  230. best_provider = Vercel)
  231. text_davinci_002 = Model(
  232. name = 'text-davinci-002',
  233. base_provider = 'openai',
  234. best_provider = Vercel)
  235. text_davinci_003 = Model(
  236. name = 'text-davinci-003',
  237. base_provider = 'openai',
  238. best_provider = Vercel)
  239. llama13b_v2_chat = Model(
  240. name = 'replicate:a16z-infra/llama13b-v2-chat',
  241. base_provider = 'replicate',
  242. best_provider = Vercel)
  243. llama7b_v2_chat = Model(
  244. name = 'replicate:a16z-infra/llama7b-v2-chat',
  245. base_provider = 'replicate',
  246. best_provider = Vercel)
  247. llama70b_v2_chat = Model(
  248. name = 'replicate/llama70b-v2-chat',
  249. base_provider = 'replicate',
  250. best_provider = Vercel)
  251. pi = Model(
  252. name = 'pi',
  253. base_provider = 'inflection',
  254. best_provider=Pi
  255. )
  256. class ModelUtils:
  257. convert: dict[str, Model] = {
  258. # gpt-3.5
  259. 'gpt-3.5-turbo' : gpt_35_turbo,
  260. 'gpt-3.5-turbo-0613' : gpt_35_turbo_0613,
  261. 'gpt-3.5-turbo-16k' : gpt_35_turbo_16k,
  262. 'gpt-3.5-turbo-16k-0613' : gpt_35_turbo_16k_0613,
  263. 'gpt-3.5-long': gpt_35_long,
  264. # gpt-4
  265. 'gpt-4' : gpt_4,
  266. 'gpt-4-0613' : gpt_4_0613,
  267. 'gpt-4-32k' : gpt_4_32k,
  268. 'gpt-4-32k-0613' : gpt_4_32k_0613,
  269. 'gpt-4-turbo' : gpt_4_turbo,
  270. # Llama 2
  271. 'llama2-7b' : llama2_7b,
  272. 'llama2-13b': llama2_13b,
  273. 'llama2-70b': llama2_70b,
  274. # Mistral
  275. 'mixtral-8x7b': mixtral_8x7b,
  276. 'mistral-7b': mistral_7b,
  277. 'openchat_3.5': openchat_35,
  278. # Bard
  279. 'palm2' : palm,
  280. 'palm' : palm,
  281. 'google' : palm,
  282. 'google-bard' : palm,
  283. 'google-palm' : palm,
  284. 'bard' : palm,
  285. # H2o
  286. 'falcon-40b' : falcon_40b,
  287. 'falcon-7b' : falcon_7b,
  288. 'llama-13b' : llama_13b,
  289. # Vercel
  290. #'claude-instant-v1' : claude_instant_v1,
  291. #'claude-v1' : claude_v1,
  292. #'claude-v2' : claude_v2,
  293. 'command-nightly' : command_nightly,
  294. 'gpt-neox-20b' : gpt_neox_20b,
  295. 'santacoder' : santacoder,
  296. 'bloom' : bloom,
  297. 'flan-t5-xxl' : flan_t5_xxl,
  298. 'code-davinci-002' : code_davinci_002,
  299. 'text-ada-001' : text_ada_001,
  300. 'text-babbage-001' : text_babbage_001,
  301. 'text-curie-001' : text_curie_001,
  302. 'text-davinci-002' : text_davinci_002,
  303. 'text-davinci-003' : text_davinci_003,
  304. 'llama70b-v2-chat' : llama70b_v2_chat,
  305. 'llama13b-v2-chat' : llama13b_v2_chat,
  306. 'llama7b-v2-chat' : llama7b_v2_chat,
  307. 'oasst-sft-1-pythia-12b' : oasst_sft_1_pythia_12b,
  308. 'oasst-sft-4-pythia-12b-epoch-3.5' : oasst_sft_4_pythia_12b_epoch_35,
  309. 'command-light-nightly' : command_light_nightly,
  310. 'pi': pi
  311. }
  312. _all_models = list(ModelUtils.convert.keys())