models.py 8.7 KB

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