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

XFEstudio/gpt4free

Disable not working providers: EasyChat, Equing, GetGpt, Liaobots and Wuguokai No and random best provider for a model Update providers in Readme

618addd0
Heiner Lohaus <heiner@lohaus.eu>
提交于

代码差异

10 个文件 +122 -96
Modified README.md +41 -52
@@ -194,9 +194,6 @@ from g4f.Provider import (
194 194 ChatgptLogin,
195 195 CodeLinkAva,
196 196 DeepAi,
197 EasyChat,
198 Equing,
199 GetGpt,
200 197 H2o,
201 198 HuggingChat,
202 199 Opchatgpts,
@@ -207,7 +204,6 @@ from g4f.Provider import (
207 204 Vercel,
208 205 Vitalentum,
209 206 Wewordle,
210 Wuguokai,
211 207 Ylokh,
212 208 You,
213 209 Yqcloud,
@@ -218,7 +214,8 @@ response = g4f.ChatCompletion.create(..., provider=ProviderName)
218 214
219 215 ##### Cookies Required:
220 216
221 Cookies are essential for the proper functioning of many service providers. When using Bing, it's necessary to have a session where you have successfully passed the captcha. For other providers, logging into your account is a prerequisite.
217 Cookies are essential for the proper functioning of some service providers.
218 It is imperative to maintain an active session, typically achieved by logging into your account.
222 219
223 220 When running the g4f package locally, the package automatically retrieves cookies from your web browser using the `get_cookies` function. However, if you're not running it locally, you'll need to provide the cookies manually by passing them as parameters using the `cookies` parameter.
224 221
@@ -227,11 +224,9 @@ import g4f
227 224 from g4f.Provider import (
228 225 Bard,
229 226 Bing,
230 H2o,
231 227 HuggingChat,
232 228 OpenAssistant,
233 229 OpenaiChat,
234 You,
235 230 )
236 231 # Usage:
237 232 response = g4f.ChatCompletion.create(
@@ -258,18 +253,12 @@ async def run_async():
258 253 g4f.Provider.Aichat,
259 254 g4f.Provider.Ails,
260 255 g4f.Provider.Aivvm,
261 g4f.Provider.Bard,
262 g4f.Provider.Bing,
263 256 g4f.Provider.ChatBase,
264 257 g4f.Provider.ChatgptAi,
265 258 g4f.Provider.ChatgptLogin,
266 259 g4f.Provider.CodeLinkAva,
267 260 g4f.Provider.DeepAi,
268 g4f.Provider.H2o,
269 g4f.Provider.HuggingChat,
270 261 g4f.Provider.Opchatgpts,
271 g4f.Provider.OpenAssistant,
272 g4f.Provider.OpenaiChat,
273 262 g4f.Provider.Vercel,
274 263 g4f.Provider.Vitalentum,
275 264 g4f.Provider.Wewordle,
@@ -279,7 +268,7 @@ async def run_async():
279 268 ]
280 269 responses = [
281 270 provider.create_async(
282 model=None,
271 model=g4f.models.default,
283 272 messages=[{"role": "user", "content": "Hello"}],
284 273 )
285 274 for provider in _providers
@@ -338,44 +327,44 @@ if __name__ == "__main__":
338 327
339 328 ### gpt-3.5 / gpt-4
340 329
341 | Website| Provider| gpt-3.5 | gpt-4 | Streaming | Status | Auth |
342 | ------ | ------- | ------- | ----- | --------- | ------ | ---- |
343 | [www.aitianhu.com](https://www.aitianhu.com) | g4f.provider.AItianhu | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
344 | [chat.acytoo.com](https://chat.acytoo.com) | g4f.provider.Acytoo | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
345 | [chat-gpt.org](https://chat-gpt.org/chat) | g4f.provider.Aichat | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
346 | [ai.ls](https://ai.ls) | g4f.provider.Ails | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
347 | [chat.aivvm.com](https://chat.aivvm.com) | g4f.provider.Aivvm | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
348 | [bard.google.com](https://bard.google.com) | g4f.provider.Bard | ❌ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
349 | [bing.com](https://bing.com/chat) | g4f.provider.Bing | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
350 | [www.chatbase.co](https://www.chatbase.co) | g4f.provider.ChatBase | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
351 | [chatgpt.ai](https://chatgpt.ai/) | g4f.provider.ChatgptAi | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
352 | [opchatgpts.net](https://opchatgpts.net) | g4f.provider.ChatgptLogin | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
353 | [ava-ai-ef611.web.app](https://ava-ai-ef611.web.app) | g4f.provider.CodeLinkAva | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
354 | [deepai.org](https://deepai.org) | g4f.provider.DeepAi | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
355 | [free.easychat.work](https://free.easychat.work) | g4f.provider.EasyChat | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
356 | [next.eqing.tech](https://next.eqing.tech/) | g4f.provider.Equing | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
357 | [chat.getgpt.world](https://chat.getgpt.world/) | g4f.provider.GetGpt | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
358 | [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.provider.H2o | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
359 | [huggingface.co](https://huggingface.co/chat/) | g4f.provider.HuggingChat | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
360 | [liaobots.com](https://liaobots.com) | g4f.provider.Liaobots | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
361 | [opchatgpts.net](https://opchatgpts.net) | g4f.provider.Opchatgpts | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
362 | [open-assistant.io](https://open-assistant.io/chat) | g4f.provider.OpenAssistant | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
363 | [chat.openai.com](https://chat.openai.com) | g4f.provider.OpenaiChat | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
364 | [raycast.com](https://raycast.com) | g4f.provider.Raycast | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
365 | [theb.ai](https://theb.ai) | g4f.provider.Theb | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
366 | [sdk.vercel.ai](https://sdk.vercel.ai) | g4f.provider.Vercel | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
367 | [app.vitalentum.io](https://app.vitalentum.io) | g4f.provider.Vitalentum | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
368 | [wewordle.org](https://wewordle.org) | g4f.provider.Wewordle | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
369 | [chat.wuguokai.xyz](https://chat.wuguokai.xyz) | g4f.provider.Wuguokai | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
370 | [chat.ylokh.xyz](https://chat.ylokh.xyz) | g4f.provider.Ylokh | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
371 | [you.com](https://you.com) | g4f.provider.You | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
372 | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.provider.Yqcloud | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
373 | [aiservice.vercel.app](https://aiservice.vercel.app/) | g4f.provider.AiService | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
374 | [chat.dfehub.com](https://chat.dfehub.com/) | g4f.provider.DfeHub | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
375 | [chat9.fastgpt.me](https://chat9.fastgpt.me/) | g4f.provider.FastGpt | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
376 | [forefront.com](https://forefront.com) | g4f.provider.Forefront | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
377 | [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.provider.Lockchat | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
378 | [p5.v50.ltd](https://p5.v50.ltd) | g4f.provider.V50 | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
330 | Website| Provider| gpt-3.5 | gpt-4 | Streaming | Asynchron | Status | Auth |
331 | ------ | ------- | ------- | ----- | --------- | --------- | ------ | ---- |
332 | [www.aitianhu.com](https://www.aitianhu.com) | g4f.provider.AItianhu | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
333 | [chat.acytoo.com](https://chat.acytoo.com) | g4f.provider.Acytoo | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
334 | [chat-gpt.org](https://chat-gpt.org/chat) | g4f.provider.Aichat | ✔️ | ❌ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
335 | [ai.ls](https://ai.ls) | g4f.provider.Ails | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
336 | [chat.aivvm.com](https://chat.aivvm.com) | g4f.provider.Aivvm | ✔️ | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
337 | [bard.google.com](https://bard.google.com) | g4f.provider.Bard | ❌ | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
338 | [bing.com](https://bing.com/chat) | g4f.provider.Bing | ❌ | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
339 | [www.chatbase.co](https://www.chatbase.co) | g4f.provider.ChatBase | ✔️ | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
340 | [chatgpt.ai](https://chatgpt.ai/) | g4f.provider.ChatgptAi | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
341 | [opchatgpts.net](https://opchatgpts.net) | g4f.provider.ChatgptLogin | ✔️ | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
342 | [ava-ai-ef611.web.app](https://ava-ai-ef611.web.app) | g4f.provider.CodeLinkAva | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
343 | [deepai.org](https://deepai.org) | g4f.provider.DeepAi | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
344 | [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.provider.H2o | ❌ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
345 | [huggingface.co](https://huggingface.co/chat/) | g4f.provider.HuggingChat | ❌ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
346 | [opchatgpts.net](https://opchatgpts.net) | g4f.provider.Opchatgpts | ✔️ | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
347 | [open-assistant.io](https://open-assistant.io/chat) | g4f.provider.OpenAssistant | ❌ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
348 | [chat.openai.com](https://chat.openai.com) | g4f.provider.OpenaiChat | ✔️ | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
349 | [raycast.com](https://raycast.com) | g4f.provider.Raycast | ✔️ | ✔️ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
350 | [theb.ai](https://theb.ai) | g4f.provider.Theb | ✔️ | ❌ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
351 | [sdk.vercel.ai](https://sdk.vercel.ai) | g4f.provider.Vercel | ✔️ | ❌ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
352 | [app.vitalentum.io](https://app.vitalentum.io) | g4f.provider.Vitalentum | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
353 | [wewordle.org](https://wewordle.org) | g4f.provider.Wewordle | ✔️ | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
354 | [chat.ylokh.xyz](https://chat.ylokh.xyz) | g4f.provider.Ylokh | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
355 | [you.com](https://you.com) | g4f.provider.You | ✔️ | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
356 | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.provider.Yqcloud | ✔️ | ❌ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
357 | [aiservice.vercel.app](https://aiservice.vercel.app/) | g4f.provider.AiService | ✔️ | ❌ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
358 | [chat.dfehub.com](https://chat.dfehub.com/) | g4f.provider.DfeHub | ✔️ | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
359 | [free.easychat.work](https://free.easychat.work) | g4f.provider.EasyChat | ✔️ | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
360 | [next.eqing.tech](https://next.eqing.tech/) | g4f.provider.Equing | ✔️ | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
361 | [chat9.fastgpt.me](https://chat9.fastgpt.me/) | g4f.provider.FastGpt | ✔️ | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
362 | [forefront.com](https://forefront.com) | g4f.provider.Forefront | ✔️ | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
363 | [chat.getgpt.world](https://chat.getgpt.world/) | g4f.provider.GetGpt | ✔️ | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
364 | [liaobots.com](https://liaobots.com) | g4f.provider.Liaobots | ✔️ | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
365 | [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.provider.Lockchat | ✔️ | ✔️ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
366 | [p5.v50.ltd](https://p5.v50.ltd) | g4f.provider.V50 | ✔️ | ❌ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
367 | [chat.wuguokai.xyz](https://chat.wuguokai.xyz) | g4f.provider.Wuguokai | ✔️ | ❌ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
379 368
380 369
381 370 ### Other Models
Modified g4f/Provider/EasyChat.py +1 -1
@@ -13,7 +13,7 @@ class EasyChat(BaseProvider):
13 13 url: str = "https://free.easychat.work"
14 14 supports_stream = True
15 15 supports_gpt_35_turbo = True
16 working = True
16 working = False
17 17
18 18 @staticmethod
19 19 def create_completion(
Modified g4f/Provider/Equing.py +3 -3
@@ -6,12 +6,12 @@ from abc import ABC, abstractmethod
6 6 import requests
7 7
8 8 from ..typing import Any, CreateResult
9 from .base_provider import BaseProvider
9 10
10 11
11 class Equing(ABC):
12 class Equing(BaseProvider):
12 13 url: str = 'https://next.eqing.tech/'
13 working = True
14 needs_auth = False
14 working = False
15 15 supports_stream = True
16 16 supports_gpt_35_turbo = True
17 17 supports_gpt_4 = False
Modified g4f/Provider/GetGpt.py +1 -1
@@ -14,7 +14,7 @@ from .base_provider import BaseProvider
14 14 class GetGpt(BaseProvider):
15 15 url = 'https://chat.getgpt.world/'
16 16 supports_stream = True
17 working = True
17 working = False
18 18 supports_gpt_35_turbo = True
19 19
20 20 @staticmethod
Modified g4f/Provider/Liaobots.py +1 -1
@@ -31,7 +31,7 @@ models = {
31 31
32 32 class Liaobots(AsyncGeneratorProvider):
33 33 url = "https://liaobots.com"
34 working = True
34 working = False
35 35 supports_gpt_35_turbo = True
36 36 supports_gpt_4 = True
37 37 _auth_code = None
Modified g4f/Provider/Wuguokai.py +3 -8
@@ -5,13 +5,13 @@ import random
5 5 import requests
6 6
7 7 from ..typing import Any, CreateResult
8 from .base_provider import BaseProvider
8 from .base_provider import BaseProvider, format_prompt
9 9
10 10
11 11 class Wuguokai(BaseProvider):
12 12 url = 'https://chat.wuguokai.xyz'
13 13 supports_gpt_35_turbo = True
14 working = True
14 working = False
15 15
16 16 @staticmethod
17 17 def create_completion(
@@ -20,11 +20,6 @@ class Wuguokai(BaseProvider):
20 20 stream: bool,
21 21 **kwargs: Any,
22 22 ) -> CreateResult:
23 base = ''
24 for message in messages:
25 base += '%s: %s\n' % (message['role'], message['content'])
26 base += 'assistant:'
27
28 23 headers = {
29 24 'authority': 'ai-api.wuguokai.xyz',
30 25 'accept': 'application/json, text/plain, */*',
@@ -41,7 +36,7 @@ class Wuguokai(BaseProvider):
41 36 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'
42 37 }
43 38 data ={
44 "prompt": base,
39 "prompt": format_prompt(messages),
45 40 "options": {},
46 41 "userId": f"#/chat/{random.randint(1,99999999)}",
47 42 "usingContext": True
Modified g4f/__init__.py +11 -2
@@ -2,6 +2,7 @@ from __future__ import annotations
2 2 from . import models
3 3 from .Provider import BaseProvider
4 4 from .typing import Any, CreateResult, Union
5 import random
5 6
6 7 logging = False
7 8
@@ -13,14 +14,22 @@ class ChatCompletion:
13 14 provider : Union[type[BaseProvider], None] = None,
14 15 stream : bool = False,
15 16 auth : Union[str, None] = None, **kwargs: Any) -> Union[CreateResult, str]:
16
17
17 18 if isinstance(model, str):
18 19 try:
19 20 model = models.ModelUtils.convert[model]
20 21 except KeyError:
21 22 raise Exception(f'The model: {model} does not exist')
22 23
23 provider = model.best_provider if provider == None else provider
24
25 if not provider:
26 if isinstance(model.best_provider, tuple):
27 provider = random.choice(model.best_provider)
28 else:
29 provider = model.best_provider
30
31 if not provider:
32 raise Exception(f'No provider found')
24 33
25 34 if not provider.working:
26 35 raise Exception(f'{provider.__name__} is not working')
Modified g4f/models.py +13 -8
@@ -1,31 +1,37 @@
1 1 from __future__ import annotations
2 2 from dataclasses import dataclass
3 from .Provider import Bard, BaseProvider, GetGpt, H2o, Liaobots, Vercel, Equing
3 from .Provider import BaseProvider, Bard, H2o, Vercel
4 from .Provider import Aichat, Aivvm, ChatBase, ChatgptAi, ChatgptLogin, CodeLinkAva
5 from .Provider import DeepAi, Vercel, Vitalentum, Ylokh, You, Yqcloud
6 from .typing import Union
4 7
5 8 @dataclass
6 9 class Model:
7 10 name: str
8 11 base_provider: str
9 best_provider: type[BaseProvider]
12 best_provider: Union[type[BaseProvider], tuple[type[BaseProvider]]] = None
10 13
11 14 # Config for HuggingChat, OpenAssistant
12 15 # Works for Liaobots, H2o, OpenaiChat, Yqcloud, You
13 16 default = Model(
14 17 name="",
15 base_provider="huggingface",
16 best_provider=H2o,
18 base_provider="huggingface"
17 19 )
18 20
19 21 # GPT-3.5 / GPT-4
20 22 gpt_35_turbo = Model(
21 23 name = 'gpt-3.5-turbo',
22 24 base_provider = 'openai',
23 best_provider = GetGpt)
25 best_provider = (
26 Vercel, Aichat, Aivvm, ChatBase, ChatgptAi, ChatgptLogin,
27 CodeLinkAva, DeepAi, Vitalentum, Ylokh, You, Yqcloud
28 )
29 )
24 30
25 31 gpt_4 = Model(
26 32 name = 'gpt-4',
27 33 base_provider = 'openai',
28 best_provider = Liaobots)
34 )
29 35
30 36 # Bard
31 37 palm = Model(
@@ -117,8 +123,7 @@ gpt_35_turbo_16k = Model(
117 123
118 124 gpt_35_turbo_16k_0613 = Model(
119 125 name = 'openai:gpt-3.5-turbo-16k-0613',
120 base_provider = 'openai',
121 best_provider = Equing)
126 base_provider = 'openai')
122 127
123 128 gpt_4_0613 = Model(
124 129 name = 'openai:gpt-4-0613',
Modified testing/test_chat_completion.py +3 -8
@@ -5,13 +5,8 @@ sys.path.append(str(Path(__file__).parent.parent))
5 5
6 6 import g4f
7 7
8 stream = False
9 8 response = g4f.ChatCompletion.create(
10 model="gpt-3.5-turbo",
11 provider=g4f.Provider.Ails,
12 messages=[{"role": "user", "content": "hello"}],
13 stream=stream,
14 active_server=5,
9 model=g4f.models.gpt_35_turbo,
10 messages=[{"role": "user", "content": "hello, are you GPT 4?"}]
15 11 )
16
17 print(response)
12 print(response)
Modified tool/readme_table.py +45 -12
@@ -5,9 +5,13 @@ from urllib.parse import urlparse
5 5
6 6 sys.path.append(str(Path(__file__).parent.parent))
7 7
8 import asyncio
8 9 from g4f import models
9 from g4f.Provider.base_provider import AsyncProvider
10 from testing.test_providers import test, get_providers
10 from g4f.Provider.base_provider import AsyncProvider, BaseProvider
11 from testing.test_providers import get_providers
12
13 logging = False
14
11 15
12 16 def print_imports():
13 17 print("##### Providers:")
@@ -28,21 +32,50 @@ def print_async():
28 32 print("```py")
29 33 print("_providers = [")
30 34 for _provider in get_providers():
31 if issubclass(_provider, AsyncProvider):
35 if _provider.working and issubclass(_provider, AsyncProvider):
32 36 print(f" g4f.Provider.{_provider.__name__},")
33 37 print("]")
34 38 print("```")
35 39 print()
36 40 print()
37 41
42
43 async def test_async(provider: type[BaseProvider]):
44 if not provider.working:
45 return False
46 model = models.gpt_35_turbo.name if provider.supports_gpt_35_turbo else models.default.name
47 messages = [{"role": "user", "content": "Hello Assistant!"}]
48 try:
49 if issubclass(provider, AsyncProvider):
50 response = await provider.create_async(model=model, messages=messages)
51 else:
52 response = provider.create_completion(model=model, messages=messages, stream=False)
53 return True if response else False
54 except Exception as e:
55 if logging:
56 print(f"{provider.__name__}: {e.__class__.__name__}: {e}")
57 return False
58
59
60 async def test_async_list(providers: list[type[BaseProvider]]):
61 responses: list = [
62 test_async(_provider)
63 for _provider in providers
64 ]
65 return await asyncio.gather(*responses)
66
67
38 68 def print_providers():
39 69 lines = [
40 "| Website| Provider| gpt-3.5 | gpt-4 | Streaming | Status | Auth |",
41 "| ------ | ------- | ------- | ----- | --------- | ------ | ---- |",
70 "| Website| Provider| gpt-3.5 | gpt-4 | Streaming | Asynchron | Status | Auth |",
71 "| ------ | ------- | ------- | ----- | --------- | --------- | ------ | ---- |",
42 72 ]
73
43 74 providers = get_providers()
75 responses = asyncio.run(test_async_list(providers))
76
44 77 for is_working in (True, False):
45 for _provider in providers:
78 for idx, _provider in enumerate(providers):
46 79 if is_working != _provider.working:
47 80 continue
48 81 netloc = urlparse(_provider.url).netloc
@@ -53,8 +86,9 @@ def print_providers():
53 86 has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else "❌"
54 87 has_gpt_4 = "✔️" if _provider.supports_gpt_4 else "❌"
55 88 stream = "✔️" if _provider.supports_stream else "❌"
89 can_async = "✔️" if issubclass(_provider, AsyncProvider) else "❌"
56 90 if _provider.working:
57 if test(_provider):
91 if responses[idx]:
58 92 status = '![Active](https://img.shields.io/badge/Active-brightgreen)'
59 93 else:
60 94 status = '![Unknown](https://img.shields.io/badge/Unknown-grey)'
@@ -63,7 +97,7 @@ def print_providers():
63 97 auth = "✔️" if _provider.needs_auth else "❌"
64 98
65 99 lines.append(
66 f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {status} | {auth} |"
100 f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {can_async} | {status} | {auth} |"
67 101 )
68 102 print("\n".join(lines))
69 103
@@ -89,17 +123,16 @@ def print_models():
89 123
90 124 _models = get_models()
91 125 for model in _models:
92 if model.best_provider.__name__ not in provider_urls:
126 if not model.best_provider or model.best_provider.__name__ not in provider_urls:
93 127 continue
94 split_name = re.split(r":|/", model.name)
95 name = split_name[-1]
96 128
129 name = re.split(r":|/", model.name)[-1]
97 130 base_provider = base_provider_names[model.base_provider]
98 131 provider_name = f"g4f.provider.{model.best_provider.__name__}"
99
100 132 provider_url = provider_urls[model.best_provider.__name__]
101 133 netloc = urlparse(provider_url).netloc
102 134 website = f"[{netloc}]({provider_url})"
135
103 136 lines.append(f"| {name} | {base_provider} | {provider_name} | {website} |")
104 137
105 138 print("\n".join(lines))