XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Cleanup model list

f5518bb9
Heiner Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +53 -185
Modified g4f/Provider/HuggingChat.py +18 -7
@@ -8,14 +8,23 @@ from ..typing import AsyncResult, Messages
8 8 from .base_provider import AsyncGeneratorProvider
9 9 from .helper import format_prompt, get_cookies
10 10
11 map = {
12 "openchat/openchat_3.5": "openchat/openchat-3.5-1210",
13 }
14 11
15 12 class HuggingChat(AsyncGeneratorProvider):
16 13 url = "https://huggingface.co/chat"
17 14 working = True
18 model = "meta-llama/Llama-2-70b-chat-hf"
15 default_model = "meta-llama/Llama-2-70b-chat-hf"
16 models = [
17 "mistralai/Mixtral-8x7B-Instruct-v0.1",
18 "meta-llama/Llama-2-70b-chat-hf",
19 "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
20 "codellama/CodeLlama-34b-Instruct-hf",
21 "mistralai/Mistral-7B-Instruct-v0.2",
22 "openchat/openchat-3.5-0106"
23 ]
24 model_map = {
25 "openchat/openchat_3.5": "openchat/openchat-3.5-1210",
26 "mistralai/Mixtral-8x7B-Instruct-v0.1": "mistralai/Mistral-7B-Instruct-v0.2"
27 }
19 28
20 29 @classmethod
21 30 async def create_async_generator(
@@ -29,9 +38,11 @@ class HuggingChat(AsyncGeneratorProvider):
29 38 **kwargs
30 39 ) -> AsyncResult:
31 40 if not model:
32 model = cls.model
33 elif model in map:
34 model = map[model]
41 model = cls.default_model
42 elif model in cls.model_map:
43 model = cls.model_map[model]
44 elif model not in cls.models:
45 raise ValueError(f"Model is not supported: {model}")
35 46 if not cookies:
36 47 cookies = get_cookies(".huggingface.co")
37 48
Modified g4f/Provider/PerplexityLabs.py +15 -14
@@ -2,27 +2,28 @@ from __future__ import annotations
2 2
3 3 import random
4 4 import json
5 from aiohttp import ClientSession, WSMsgType
5 from aiohttp import ClientSession
6 6
7 7 from ..typing import AsyncResult, Messages
8 8 from .base_provider import AsyncGeneratorProvider
9 9
10 10 API_URL = "https://labs-api.perplexity.ai/socket.io/"
11 11 WS_URL = "wss://labs-api.perplexity.ai/socket.io/"
12 MODELS = ['pplx-7b-online', 'pplx-70b-online', 'pplx-7b-chat', 'pplx-70b-chat', 'mistral-7b-instruct',
13 'codellama-34b-instruct', 'llama-2-70b-chat', 'llava-7b-chat', 'mixtral-8x7b-instruct',
14 'mistral-medium', 'related']
15 DEFAULT_MODEL = MODELS[1]
16 MODEL_MAP = {
17 "mistralai/Mistral-7B-Instruct-v0.1": "mistral-7b-instruct",
18 "meta-llama/Llama-2-70b-chat-hf": "llama-2-70b-chat",
19 "mistralai/Mixtral-8x7B-Instruct-v0.1": "mixtral-8x7b-instruct",
20 }
21 12
22 13 class PerplexityLabs(AsyncGeneratorProvider):
23 14 url = "https://labs.perplexity.ai"
24 15 working = True
25 16 supports_gpt_35_turbo = True
17 models = ['pplx-7b-online', 'pplx-70b-online', 'pplx-7b-chat', 'pplx-70b-chat', 'mistral-7b-instruct',
18 'codellama-34b-instruct', 'llama-2-70b-chat', 'llava-7b-chat', 'mixtral-8x7b-instruct',
19 'mistral-medium', 'related']
20 default_model = 'pplx-70b-online'
21 model_map = {
22 "mistralai/Mistral-7B-Instruct-v0.1": "mistral-7b-instruct",
23 "meta-llama/Llama-2-70b-chat-hf": "llama-2-70b-chat",
24 "mistralai/Mixtral-8x7B-Instruct-v0.1": "mixtral-8x7b-instruct",
25 "codellama/CodeLlama-34b-Instruct-hf": "codellama-34b-instruct"
26 }
26 27
27 28 @classmethod
28 29 async def create_async_generator(
@@ -33,10 +34,10 @@ class PerplexityLabs(AsyncGeneratorProvider):
33 34 **kwargs
34 35 ) -> AsyncResult:
35 36 if not model:
36 model = DEFAULT_MODEL
37 elif model in MODEL_MAP:
38 model = MODEL_MAP[model]
39 elif model not in MODELS:
37 model = cls.default_model
38 elif model in cls.model_map:
39 model = cls.model_map[model]
40 elif model not in cls.models:
40 41 raise ValueError(f"Model is not supported: {model}")
41 42 headers = {
42 43 "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0",
Modified g4f/models.py +20 -164
@@ -3,9 +3,9 @@ from dataclasses import dataclass
3 3 from .Provider import RetryProvider, ProviderType
4 4 from .Provider import (
5 5 Chatgpt4Online,
6 PerplexityLabs,
6 7 ChatgptDemoAi,
7 8 GeminiProChat,
8 PerplexityAi,
9 9 ChatgptNext,
10 10 HuggingChat,
11 11 ChatgptDemo,
@@ -26,7 +26,6 @@ from .Provider import (
26 26 Bard,
27 27 Bing,
28 28 You,
29 H2o,
30 29 Pi,
31 30 )
32 31
@@ -115,20 +114,26 @@ llama2_13b = Model(
115 114 llama2_70b = Model(
116 115 name = "meta-llama/Llama-2-70b-chat-hf",
117 116 base_provider = "huggingface",
118 best_provider = RetryProvider([Llama2, DeepInfra, HuggingChat, PerplexityAi])
117 best_provider = RetryProvider([Llama2, DeepInfra, HuggingChat, PerplexityLabs])
118 )
119
120 codellama_34b_instruct = Model(
121 name = "codellama/CodeLlama-34b-Instruct-hf",
122 base_provider = "huggingface",
123 best_provider = RetryProvider([HuggingChat, PerplexityLabs])
119 124 )
120 125
121 126 # Mistal
122 127 mixtral_8x7b = Model(
123 128 name = "mistralai/Mixtral-8x7B-Instruct-v0.1",
124 129 base_provider = "huggingface",
125 best_provider = RetryProvider([DeepInfra, HuggingChat, PerplexityAi])
130 best_provider = RetryProvider([DeepInfra, HuggingChat, PerplexityLabs])
126 131 )
127 132
128 133 mistral_7b = Model(
129 134 name = "mistralai/Mistral-7B-Instruct-v0.1",
130 135 base_provider = "huggingface",
131 best_provider = RetryProvider([DeepInfra, HuggingChat, PerplexityAi])
136 best_provider = RetryProvider([DeepInfra, HuggingChat, PerplexityLabs])
132 137 )
133 138
134 139 # Dolphin
@@ -146,92 +151,23 @@ openchat_35 = Model(
146 151 )
147 152
148 153 # Bard
149 palm = Model(
154 bard = palm = Model(
150 155 name = 'palm',
151 156 base_provider = 'google',
152 best_provider = Bard)
153
154 # H2o
155 falcon_7b = Model(
156 name = 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3',
157 base_provider = 'huggingface',
158 best_provider = H2o)
159
160 falcon_40b = Model(
161 name = 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v1',
162 base_provider = 'huggingface',
163 best_provider = H2o)
164
165 llama_13b = Model(
166 name = 'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-13b',
167 base_provider = 'huggingface',
168 best_provider = H2o)
169
170 # Vercel
171 claude_instant_v1 = Model(
172 name = 'claude-instant-v1',
173 base_provider = 'anthropic',
174 best_provider = Vercel)
175
176 claude_v1 = Model(
177 name = 'claude-v1',
178 base_provider = 'anthropic',
179 best_provider = Vercel)
157 best_provider = Bard
158 )
180 159
181 160 claude_v2 = Model(
182 161 name = 'claude-v2',
183 162 base_provider = 'anthropic',
184 best_provider = RetryProvider([FreeChatgpt, Vercel]))
185
186 command_light_nightly = Model(
187 name = 'command-light-nightly',
188 base_provider = 'cohere',
189 best_provider = Vercel)
190
191 command_nightly = Model(
192 name = 'command-nightly',
193 base_provider = 'cohere',
194 best_provider = Vercel)
195
196 gpt_neox_20b = Model(
197 name = 'EleutherAI/gpt-neox-20b',
198 base_provider = 'huggingface',
199 best_provider = Vercel)
200
201 oasst_sft_1_pythia_12b = Model(
202 name = 'OpenAssistant/oasst-sft-1-pythia-12b',
203 base_provider = 'huggingface',
204 best_provider = Vercel)
205
206 oasst_sft_4_pythia_12b_epoch_35 = Model(
207 name = 'OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5',
208 base_provider = 'huggingface',
209 best_provider = Vercel)
210
211 santacoder = Model(
212 name = 'bigcode/santacoder',
213 base_provider = 'huggingface',
214 best_provider = Vercel)
215
216 bloom = Model(
217 name = 'bigscience/bloom',
218 base_provider = 'huggingface',
219 best_provider = Vercel)
220
221 flan_t5_xxl = Model(
222 name = 'google/flan-t5-xxl',
223 base_provider = 'huggingface',
224 best_provider = Vercel)
225
226 code_davinci_002 = Model(
227 name = 'code-davinci-002',
228 base_provider = 'openai',
229 best_provider = Vercel)
163 best_provider = RetryProvider([FreeChatgpt, Vercel])
164 )
230 165
231 166 gpt_35_turbo_16k = Model(
232 167 name = 'gpt-3.5-turbo-16k',
233 168 base_provider = 'openai',
234 best_provider = gpt_35_long.best_provider)
169 best_provider = gpt_35_long.best_provider
170 )
235 171
236 172 gpt_35_turbo_16k_0613 = Model(
237 173 name = 'gpt-3.5-turbo-16k-0613',
@@ -269,46 +205,6 @@ gemini_pro = Model(
269 205 best_provider = RetryProvider([FreeChatgpt, GeminiProChat])
270 206 )
271 207
272 text_ada_001 = Model(
273 name = 'text-ada-001',
274 base_provider = 'openai',
275 best_provider = Vercel)
276
277 text_babbage_001 = Model(
278 name = 'text-babbage-001',
279 base_provider = 'openai',
280 best_provider = Vercel)
281
282 text_curie_001 = Model(
283 name = 'text-curie-001',
284 base_provider = 'openai',
285 best_provider = Vercel)
286
287 text_davinci_002 = Model(
288 name = 'text-davinci-002',
289 base_provider = 'openai',
290 best_provider = Vercel)
291
292 text_davinci_003 = Model(
293 name = 'text-davinci-003',
294 base_provider = 'openai',
295 best_provider = Vercel)
296
297 llama13b_v2_chat = Model(
298 name = 'replicate:a16z-infra/llama13b-v2-chat',
299 base_provider = 'replicate',
300 best_provider = Vercel)
301
302 llama7b_v2_chat = Model(
303 name = 'replicate:a16z-infra/llama7b-v2-chat',
304 base_provider = 'replicate',
305 best_provider = Vercel)
306
307 llama70b_v2_chat = Model(
308 name = 'replicate/llama70b-v2-chat',
309 base_provider = 'replicate',
310 best_provider = Vercel)
311
312 208 pi = Model(
313 209 name = 'pi',
314 210 base_provider = 'inflection',
@@ -342,55 +238,15 @@ class ModelUtils:
342 238 'llama2-7b' : llama2_7b,
343 239 'llama2-13b': llama2_13b,
344 240 'llama2-70b': llama2_70b,
241 'codellama-34b-instruct': codellama_34b_instruct,
345 242
346 # Mistral
347 243 'mixtral-8x7b': mixtral_8x7b,
348 244 'mistral-7b': mistral_7b,
349
350 # Dolphin
351 245 'dolphin-mixtral-8x7b': dolphin_mixtral_8x7b,
352
353 # OpenChat
354 246 'openchat_3.5': openchat_35,
355
356 # Gemini Pro
357 247 'gemini-pro': gemini_pro,
358 # Bard
359 'palm2' : palm,
360 'palm' : palm,
361 'google' : palm,
362 'google-bard' : palm,
363 'google-palm' : palm,
364 'bard' : palm,
365
366 # H2o
367 'falcon-40b' : falcon_40b,
368 'falcon-7b' : falcon_7b,
369 'llama-13b' : llama_13b,
370
371 # Vercel
372 #'claude-instant-v1' : claude_instant_v1,
373 #'claude-v1' : claude_v1,
374 #'claude-v2' : claude_v2,
375 'command-nightly' : command_nightly,
376 'gpt-neox-20b' : gpt_neox_20b,
377 'santacoder' : santacoder,
378 'bloom' : bloom,
379 'flan-t5-xxl' : flan_t5_xxl,
380 'code-davinci-002' : code_davinci_002,
381 'text-ada-001' : text_ada_001,
382 'text-babbage-001' : text_babbage_001,
383 'text-curie-001' : text_curie_001,
384 'text-davinci-002' : text_davinci_002,
385 'text-davinci-003' : text_davinci_003,
386 'llama70b-v2-chat' : llama70b_v2_chat,
387 'llama13b-v2-chat' : llama13b_v2_chat,
388 'llama7b-v2-chat' : llama7b_v2_chat,
389
390 'oasst-sft-1-pythia-12b' : oasst_sft_1_pythia_12b,
391 'oasst-sft-4-pythia-12b-epoch-3.5' : oasst_sft_4_pythia_12b_epoch_35,
392 'command-light-nightly' : command_light_nightly,
393
248 'bard': bard,
249 'claude-v2': claude_v2,
394 250 'pi': pi
395 251 }
396 252