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

XFEstudio/gpt4free

Improve provider list

69ca98ac
Heiner Lohaus <heiner.lohaus@netformic.com>
提交于

代码差异

8 个文件 +88 -65
Modified README.md +27 -24
@@ -185,30 +185,33 @@ if __name__ == "__main__":
185 185
186 186 | Website| Provider| gpt-3.5 | gpt-4 | Streaming | Status | Auth |
187 187 | ------ | ------- | ------- | ----- | --------- | ------ | ---- |
188 | [www.aitianhu.com](https://www.aitianhu.com/api/chat-process) | g4f.Provider.AItianhu | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
189 | [chat.acytoo.com](https://chat.acytoo.com/api/completions) | g4f.Provider.Acytoo | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
190 | [aiservice.vercel.app](https://aiservice.vercel.app/api/chat/answer) | g4f.Provider.AiService | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
191 | [chat-gpt.org](https://chat-gpt.org/chat) | g4f.Provider.Aichat | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
192 | [ai.ls](https://ai.ls) | g4f.Provider.Ails | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
193 | [bard.google.com](https://bard.google.com) | g4f.Provider.Bard | ❌ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
194 | [bing.com](https://bing.com/chat) | g4f.Provider.Bing | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
195 | [chatgpt.ai](https://chatgpt.ai/gpt-4/) | g4f.Provider.ChatgptAi | ❌ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
196 | [chatgptlogin.ac](https://chatgptlogin.ac) | g4f.Provider.ChatgptLogin | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
197 | [deepai.org](https://deepai.org) | g4f.Provider.DeepAi | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
198 | [chat.dfehub.com](https://chat.dfehub.com/api/chat) | g4f.Provider.DfeHub | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
199 | [free.easychat.work](https://free.easychat.work) | g4f.Provider.EasyChat | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
200 | [forefront.com](https://forefront.com) | g4f.Provider.Forefront | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
201 | [chat.getgpt.world](https://chat.getgpt.world/) | g4f.Provider.GetGpt | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
202 | [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.Provider.H2o | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
203 | [liaobots.com](https://liaobots.com) | g4f.Provider.Liaobots | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ✔️ |
204 | [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.Provider.Lockchat | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
205 | [opchatgpts.net](https://opchatgpts.net) | g4f.Provider.Opchatgpts | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
206 | [backend.raycast.com](https://backend.raycast.com/api/v1/ai/chat_completions) | g4f.Provider.Raycast | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
207 | [theb.ai](https://theb.ai) | g4f.Provider.Theb | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
208 | [play.vercel.ai](https://play.vercel.ai) | g4f.Provider.Vercel | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
209 | [wewordle.org](https://wewordle.org/gptapi/v1/android/turbo) | g4f.Provider.Wewordle | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
210 | [you.com](https://you.com) | g4f.Provider.You | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
211 | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.Provider.Yqcloud | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
188 | [chat.acytoo.com](https://chat.acytoo.com/) | g4f.provider.Acytoo | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
189 | [chat-gpt.org](https://chat-gpt.org/chat) | g4f.provider.Aichat | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
190 | [ai.ls](https://ai.ls) | g4f.provider.Ails | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
191 | [bard.google.com](https://bard.google.com) | g4f.provider.Bard | ❌ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
192 | [chatgpt.ai](https://chatgpt.ai/gpt-4/) | g4f.provider.ChatgptAi | ❌ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
193 | [opchatgpts.net](https://opchatgpts.net) | g4f.provider.ChatgptLogin | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
194 | [deepai.org](https://deepai.org) | g4f.provider.DeepAi | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
195 | [free.easychat.work](https://free.easychat.work) | g4f.provider.EasyChat | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
196 | [next.eqing.tech](https://next.eqing.tech/) | g4f.provider.Equing | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
197 | [chat.getgpt.world](https://chat.getgpt.world/) | g4f.provider.GetGpt | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
198 | [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.provider.H2o | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
199 | [opchatgpts.net](https://opchatgpts.net) | g4f.provider.Opchatgpts | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
200 | [raycast.com](https://raycast.com) | g4f.provider.Raycast | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
201 | [theb.ai](https://theb.ai) | g4f.provider.Theb | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
202 | [play.vercel.ai](https://play.vercel.ai) | g4f.provider.Vercel | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
203 | [wewordle.org](https://wewordle.org/) | g4f.provider.Wewordle | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
204 | [you.com](https://you.com) | g4f.provider.You | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
205 | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.provider.Yqcloud | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
206 | [www.aitianhu.com](https://www.aitianhu.com/) | g4f.provider.AItianhu | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
207 | [aiservice.vercel.app](https://aiservice.vercel.app/) | g4f.provider.AiService | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
208 | [bing.com](https://bing.com/chat) | g4f.provider.Bing | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
209 | [chat.dfehub.com](https://chat.dfehub.com/) | g4f.provider.DfeHub | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
210 | [chat9.fastgpt.me](https://chat9.fastgpt.me/) | g4f.provider.FastGpt | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
211 | [forefront.com](https://forefront.com) | g4f.provider.Forefront | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
212 | [liaobots.com](https://liaobots.com) | g4f.provider.Liaobots | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ✔️ |
213 | [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.provider.Lockchat | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
214 | [p5.v50.ltd](https://p5.v50.ltd) | g4f.provider.V50 | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
212 215
213 216 ### Other Models
214 217
Modified g4f/Provider/AItianhu.py +1 -1
@@ -7,7 +7,7 @@ from .base_provider import BaseProvider
7 7
8 8
9 9 class AItianhu(BaseProvider):
10 url = "https://www.aitianhu.com/api/chat-process"
10 url = "https://www.aitianhu.com/"
11 11 working = False
12 12 supports_gpt_35_turbo = True
13 13
Modified g4f/Provider/Acytoo.py +4 -4
@@ -7,12 +7,13 @@ from .base_provider import BaseProvider
7 7
8 8
9 9 class Acytoo(BaseProvider):
10 url = "https://chat.acytoo.com/api/completions"
10 url = "https://chat.acytoo.com/"
11 11 working = True
12 12 supports_gpt_35_turbo = True
13 13
14 @staticmethod
14 @classmethod
15 15 def create_completion(
16 cls,
16 17 model: str,
17 18 messages: list[dict[str, str]],
18 19 stream: bool,
@@ -21,8 +22,7 @@ class Acytoo(BaseProvider):
21 22 headers = _create_header()
22 23 payload = _create_payload(messages, kwargs.get('temperature', 0.5))
23 24
24 url = "https://chat.acytoo.com/api/completions"
25 response = requests.post(url=url, headers=headers, json=payload)
25 response = requests.post("{cls.url}api/completions", headers=headers, json=payload)
26 26 response.raise_for_status()
27 27 response.encoding = "utf-8"
28 28 yield response.text
Modified g4f/Provider/AiService.py +1 -1
@@ -5,7 +5,7 @@ from .base_provider import BaseProvider
5 5
6 6
7 7 class AiService(BaseProvider):
8 url = "https://aiservice.vercel.app/api/chat/answer"
8 url = "https://aiservice.vercel.app/"
9 9 working = False
10 10 supports_gpt_35_turbo = True
11 11
Modified g4f/Provider/DfeHub.py +1 -1
@@ -9,7 +9,7 @@ from .base_provider import BaseProvider
9 9
10 10
11 11 class DfeHub(BaseProvider):
12 url = "https://chat.dfehub.com/api/chat"
12 url = "https://chat.dfehub.com/"
13 13 supports_stream = True
14 14 supports_gpt_35_turbo = True
15 15
Modified g4f/Provider/Wewordle.py +4 -4
@@ -10,12 +10,13 @@ from .base_provider import BaseProvider
10 10
11 11
12 12 class Wewordle(BaseProvider):
13 url = "https://wewordle.org/gptapi/v1/android/turbo"
13 url = "https://wewordle.org/"
14 14 working = True
15 15 supports_gpt_35_turbo = True
16 16
17 @staticmethod
17 @classmethod
18 18 def create_completion(
19 cls,
19 20 model: str,
20 21 messages: list[dict[str, str]],
21 22 stream: bool,
@@ -62,8 +63,7 @@ class Wewordle(BaseProvider):
62 63 },
63 64 }
64 65
65 url = "https://wewordle.org/gptapi/v1/android/turbo"
66 response = requests.post(url, headers=headers, data=json.dumps(data))
66 response = requests.post(f"{cls.url}gptapi/v1/android/turbo", headers=headers, data=json.dumps(data))
67 67 response.raise_for_status()
68 68 _json = response.json()
69 69 if "message" in _json:
Modified testing/test_providers.py +23 -10
@@ -1,5 +1,6 @@
1 1 import sys
2 2 from pathlib import Path
3 from colorama import Fore
3 4
4 5 sys.path.append(str(Path(__file__).parent.parent))
5 6
@@ -20,9 +21,14 @@ def main():
20 21 if _provider.working and not result:
21 22 failed_providers.append([_provider, result])
22 23
23 print("Failed providers:")
24 for _provider, result in failed_providers:
25 print(f"{_provider.__name__}: {result}")
24 print()
25
26 if failed_providers:
27 print(f"{Fore.RED}Failed providers:\n")
28 for _provider, result in failed_providers:
29 print(f"{Fore.RED}{_provider.__name__}")
30 else:
31 print(f"{Fore.GREEN}All providers are working")
26 32
27 33
28 34 def get_providers() -> list[type[BaseProvider]]:
@@ -36,18 +42,21 @@ def get_providers() -> list[type[BaseProvider]]:
36 42 for provider_name in provider_names
37 43 if not provider_name.startswith("__") and provider_name not in ignore_names
38 44 ]
39 return [getattr(Provider, provider_name) for provider_name in provider_names]
45 return [getattr(Provider, provider_name) for provider_name in sorted(provider_names)]
40 46
41 47
42 48 def create_response(_provider: type[BaseProvider]) -> str:
43 model = (
44 models.gpt_35_turbo.name
45 if _provider.supports_gpt_35_turbo
46 else _provider.model
47 )
49 if _provider.supports_gpt_35_turbo:
50 model = models.gpt_35_turbo.name
51 elif _provider.supports_gpt_4:
52 model = models.gpt_4
53 elif hasattr(_provider, "model"):
54 model = _provider.model
55 else:
56 model = None
48 57 response = _provider.create_completion(
49 58 model=model,
50 messages=[{"role": "user", "content": "Hello world!"}],
59 messages=[{"role": "user", "content": "Hello"}],
51 60 stream=False,
52 61 )
53 62 return "".join(response)
@@ -57,9 +66,13 @@ def judge(_provider: type[BaseProvider]) -> bool:
57 66 if _provider.needs_auth:
58 67 return _provider.working
59 68
69 return test(_provider)
70
71 def test(_provider: type[BaseProvider]) -> bool:
60 72 try:
61 73 response = create_response(_provider)
62 74 assert type(response) is str
75 assert len(response) > 0
63 76 return response
64 77 except Exception as e:
65 78 if logging:
Modified tool/readme_table.py +27 -20
@@ -7,7 +7,7 @@ sys.path.append(str(Path(__file__).parent.parent))
7 7
8 8 from g4f import models, Provider
9 9 from g4f.Provider.base_provider import BaseProvider
10
10 from testing.test_providers import test
11 11
12 12 def main():
13 13 print_providers()
@@ -21,25 +21,30 @@ def print_providers():
21 21 "| ------ | ------- | ------- | ----- | --------- | ------ | ---- |",
22 22 ]
23 23 providers = get_providers()
24 for _provider in providers:
25 netloc = urlparse(_provider.url).netloc
26 website = f"[{netloc}]({_provider.url})"
27
28 provider_name = f"g4f.provider.{_provider.__name__}"
29
30 has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else "❌"
31 has_gpt_4 = "✔️" if _provider.supports_gpt_4 else "❌"
32 stream = "✔️" if _provider.supports_stream else "❌"
33 status = (
34 "![Active](https://img.shields.io/badge/Active-brightgreen)"
35 if _provider.working
36 else "![Inactive](https://img.shields.io/badge/Inactive-red)"
37 )
38 auth = "✔️" if _provider.needs_auth else "❌"
39
40 lines.append(
41 f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {status} | {auth} |"
42 )
24 for is_working in (True, False):
25 for _provider in providers:
26 if is_working != _provider.working:
27 continue
28 netloc = urlparse(_provider.url).netloc
29 website = f"[{netloc}]({_provider.url})"
30
31 provider_name = f"g4f.provider.{_provider.__name__}"
32
33 has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else "❌"
34 has_gpt_4 = "✔️" if _provider.supports_gpt_4 else "❌"
35 stream = "✔️" if _provider.supports_stream else "❌"
36 if _provider.working:
37 if test(_provider):
38 status = '![Active](https://img.shields.io/badge/Active-brightgreen)'
39 else:
40 status = '![Unknown](https://img.shields.io/badge/Unknown-grey)'
41 else:
42 status = '![Inactive](https://img.shields.io/badge/Inactive-red)'
43 auth = "✔️" if _provider.needs_auth else "❌"
44
45 lines.append(
46 f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {status} | {auth} |"
47 )
43 48 print("\n".join(lines))
44 49
45 50
@@ -79,6 +84,8 @@ def print_models():
79 84
80 85 _models = get_models()
81 86 for model in _models:
87 if model.best_provider.__name__ not in provider_urls:
88 continue
82 89 split_name = re.split(r":|/", model.name)
83 90 name = split_name[-1]
84 91