summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md51
-rw-r--r--g4f/Provider/AItianhu.py2
-rw-r--r--g4f/Provider/Acytoo.py8
-rw-r--r--g4f/Provider/AiService.py2
-rw-r--r--g4f/Provider/DfeHub.py2
-rw-r--r--g4f/Provider/Wewordle.py8
-rw-r--r--testing/test_providers.py33
-rw-r--r--tool/readme_table.py47
8 files changed, 88 insertions, 65 deletions
diff --git a/README.md b/README.md
index 39b368cc..22db26cc 100644
--- a/README.md
+++ b/README.md
@@ -185,30 +185,33 @@ if __name__ == "__main__":
| Website| Provider| gpt-3.5 | gpt-4 | Streaming | Status | Auth |
| ------ | ------- | ------- | ----- | --------- | ------ | ---- |
-| [www.aitianhu.com](https://www.aitianhu.com/api/chat-process) | g4f.Provider.AItianhu | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [chat.acytoo.com](https://chat.acytoo.com/api/completions) | g4f.Provider.Acytoo | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [aiservice.vercel.app](https://aiservice.vercel.app/api/chat/answer) | g4f.Provider.AiService | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [chat-gpt.org](https://chat-gpt.org/chat) | g4f.Provider.Aichat | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [ai.ls](https://ai.ls) | g4f.Provider.Ails | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [bard.google.com](https://bard.google.com) | g4f.Provider.Bard | ❌ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
-| [bing.com](https://bing.com/chat) | g4f.Provider.Bing | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [chatgpt.ai](https://chatgpt.ai/gpt-4/) | g4f.Provider.ChatgptAi | ❌ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [chatgptlogin.ac](https://chatgptlogin.ac) | g4f.Provider.ChatgptLogin | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [deepai.org](https://deepai.org) | g4f.Provider.DeepAi | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [chat.dfehub.com](https://chat.dfehub.com/api/chat) | g4f.Provider.DfeHub | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [free.easychat.work](https://free.easychat.work) | g4f.Provider.EasyChat | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [forefront.com](https://forefront.com) | g4f.Provider.Forefront | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [chat.getgpt.world](https://chat.getgpt.world/) | g4f.Provider.GetGpt | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.Provider.H2o | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [liaobots.com](https://liaobots.com) | g4f.Provider.Liaobots | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ✔️ |
-| [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.Provider.Lockchat | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [opchatgpts.net](https://opchatgpts.net) | g4f.Provider.Opchatgpts | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [backend.raycast.com](https://backend.raycast.com/api/v1/ai/chat_completions) | g4f.Provider.Raycast | ✔️ | ✔️ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
-| [theb.ai](https://theb.ai) | g4f.Provider.Theb | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-| [play.vercel.ai](https://play.vercel.ai) | g4f.Provider.Vercel | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [wewordle.org](https://wewordle.org/gptapi/v1/android/turbo) | g4f.Provider.Wewordle | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [you.com](https://you.com) | g4f.Provider.You | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
-| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.Provider.Yqcloud | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [chat.acytoo.com](https://chat.acytoo.com/) | g4f.provider.Acytoo | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
+| [chat-gpt.org](https://chat-gpt.org/chat) | g4f.provider.Aichat | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
+| [ai.ls](https://ai.ls) | g4f.provider.Ails | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [bard.google.com](https://bard.google.com) | g4f.provider.Bard | ❌ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ✔️ |
+| [chatgpt.ai](https://chatgpt.ai/gpt-4/) | g4f.provider.ChatgptAi | ❌ | ✔️ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [opchatgpts.net](https://opchatgpts.net) | g4f.provider.ChatgptLogin | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [deepai.org](https://deepai.org) | g4f.provider.DeepAi | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [free.easychat.work](https://free.easychat.work) | g4f.provider.EasyChat | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
+| [next.eqing.tech](https://next.eqing.tech/) | g4f.provider.Equing | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
+| [chat.getgpt.world](https://chat.getgpt.world/) | g4f.provider.GetGpt | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.provider.H2o | ❌ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [opchatgpts.net](https://opchatgpts.net) | g4f.provider.Opchatgpts | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [raycast.com](https://raycast.com) | g4f.provider.Raycast | ✔️ | ✔️ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
+| [theb.ai](https://theb.ai) | g4f.provider.Theb | ✔️ | ❌ | ✔️ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ✔️ |
+| [play.vercel.ai](https://play.vercel.ai) | g4f.provider.Vercel | ✔️ | ❌ | ❌ | ![Unknown](https://img.shields.io/badge/Unknown-grey) | ❌ |
+| [wewordle.org](https://wewordle.org/) | g4f.provider.Wewordle | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [you.com](https://you.com) | g4f.provider.You | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.provider.Yqcloud | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
+| [www.aitianhu.com](https://www.aitianhu.com/) | g4f.provider.AItianhu | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [aiservice.vercel.app](https://aiservice.vercel.app/) | g4f.provider.AiService | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [bing.com](https://bing.com/chat) | g4f.provider.Bing | ❌ | ✔️ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [chat.dfehub.com](https://chat.dfehub.com/) | g4f.provider.DfeHub | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [chat9.fastgpt.me](https://chat9.fastgpt.me/) | g4f.provider.FastGpt | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [forefront.com](https://forefront.com) | g4f.provider.Forefront | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [liaobots.com](https://liaobots.com) | g4f.provider.Liaobots | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ✔️ |
+| [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.provider.Lockchat | ✔️ | ✔️ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
+| [p5.v50.ltd](https://p5.v50.ltd) | g4f.provider.V50 | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
### Other Models
diff --git a/g4f/Provider/AItianhu.py b/g4f/Provider/AItianhu.py
index e8e5714a..9f5440bc 100644
--- a/g4f/Provider/AItianhu.py
+++ b/g4f/Provider/AItianhu.py
@@ -7,7 +7,7 @@ from .base_provider import BaseProvider
class AItianhu(BaseProvider):
- url = "https://www.aitianhu.com/api/chat-process"
+ url = "https://www.aitianhu.com/"
working = False
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/Acytoo.py b/g4f/Provider/Acytoo.py
index 2edd9efd..975e914b 100644
--- a/g4f/Provider/Acytoo.py
+++ b/g4f/Provider/Acytoo.py
@@ -7,12 +7,13 @@ from .base_provider import BaseProvider
class Acytoo(BaseProvider):
- url = "https://chat.acytoo.com/api/completions"
+ url = "https://chat.acytoo.com/"
working = True
supports_gpt_35_turbo = True
- @staticmethod
+ @classmethod
def create_completion(
+ cls,
model: str,
messages: list[dict[str, str]],
stream: bool,
@@ -21,8 +22,7 @@ class Acytoo(BaseProvider):
headers = _create_header()
payload = _create_payload(messages, kwargs.get('temperature', 0.5))
- url = "https://chat.acytoo.com/api/completions"
- response = requests.post(url=url, headers=headers, json=payload)
+ response = requests.post("{cls.url}api/completions", headers=headers, json=payload)
response.raise_for_status()
response.encoding = "utf-8"
yield response.text
diff --git a/g4f/Provider/AiService.py b/g4f/Provider/AiService.py
index 2c0d5de2..3453bfd9 100644
--- a/g4f/Provider/AiService.py
+++ b/g4f/Provider/AiService.py
@@ -5,7 +5,7 @@ from .base_provider import BaseProvider
class AiService(BaseProvider):
- url = "https://aiservice.vercel.app/api/chat/answer"
+ url = "https://aiservice.vercel.app/"
working = False
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/DfeHub.py b/g4f/Provider/DfeHub.py
index 5a7b22e1..6f96ec7a 100644
--- a/g4f/Provider/DfeHub.py
+++ b/g4f/Provider/DfeHub.py
@@ -9,7 +9,7 @@ from .base_provider import BaseProvider
class DfeHub(BaseProvider):
- url = "https://chat.dfehub.com/api/chat"
+ url = "https://chat.dfehub.com/"
supports_stream = True
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/Wewordle.py b/g4f/Provider/Wewordle.py
index cef209c9..8e106716 100644
--- a/g4f/Provider/Wewordle.py
+++ b/g4f/Provider/Wewordle.py
@@ -10,12 +10,13 @@ from .base_provider import BaseProvider
class Wewordle(BaseProvider):
- url = "https://wewordle.org/gptapi/v1/android/turbo"
+ url = "https://wewordle.org/"
working = True
supports_gpt_35_turbo = True
- @staticmethod
+ @classmethod
def create_completion(
+ cls,
model: str,
messages: list[dict[str, str]],
stream: bool,
@@ -62,8 +63,7 @@ class Wewordle(BaseProvider):
},
}
- url = "https://wewordle.org/gptapi/v1/android/turbo"
- response = requests.post(url, headers=headers, data=json.dumps(data))
+ response = requests.post(f"{cls.url}gptapi/v1/android/turbo", headers=headers, data=json.dumps(data))
response.raise_for_status()
_json = response.json()
if "message" in _json:
diff --git a/testing/test_providers.py b/testing/test_providers.py
index fee79e20..6d3b62d8 100644
--- a/testing/test_providers.py
+++ b/testing/test_providers.py
@@ -1,5 +1,6 @@
import sys
from pathlib import Path
+from colorama import Fore
sys.path.append(str(Path(__file__).parent.parent))
@@ -20,9 +21,14 @@ def main():
if _provider.working and not result:
failed_providers.append([_provider, result])
- print("Failed providers:")
- for _provider, result in failed_providers:
- print(f"{_provider.__name__}: {result}")
+ print()
+
+ if failed_providers:
+ print(f"{Fore.RED}Failed providers:\n")
+ for _provider, result in failed_providers:
+ print(f"{Fore.RED}{_provider.__name__}")
+ else:
+ print(f"{Fore.GREEN}All providers are working")
def get_providers() -> list[type[BaseProvider]]:
@@ -36,18 +42,21 @@ def get_providers() -> list[type[BaseProvider]]:
for provider_name in provider_names
if not provider_name.startswith("__") and provider_name not in ignore_names
]
- return [getattr(Provider, provider_name) for provider_name in provider_names]
+ return [getattr(Provider, provider_name) for provider_name in sorted(provider_names)]
def create_response(_provider: type[BaseProvider]) -> str:
- model = (
- models.gpt_35_turbo.name
- if _provider.supports_gpt_35_turbo
- else _provider.model
- )
+ if _provider.supports_gpt_35_turbo:
+ model = models.gpt_35_turbo.name
+ elif _provider.supports_gpt_4:
+ model = models.gpt_4
+ elif hasattr(_provider, "model"):
+ model = _provider.model
+ else:
+ model = None
response = _provider.create_completion(
model=model,
- messages=[{"role": "user", "content": "Hello world!"}],
+ messages=[{"role": "user", "content": "Hello"}],
stream=False,
)
return "".join(response)
@@ -57,9 +66,13 @@ def judge(_provider: type[BaseProvider]) -> bool:
if _provider.needs_auth:
return _provider.working
+ return test(_provider)
+
+def test(_provider: type[BaseProvider]) -> bool:
try:
response = create_response(_provider)
assert type(response) is str
+ assert len(response) > 0
return response
except Exception as e:
if logging:
diff --git a/tool/readme_table.py b/tool/readme_table.py
index 10735ba0..b578b9ca 100644
--- a/tool/readme_table.py
+++ b/tool/readme_table.py
@@ -7,7 +7,7 @@ sys.path.append(str(Path(__file__).parent.parent))
from g4f import models, Provider
from g4f.Provider.base_provider import BaseProvider
-
+from testing.test_providers import test
def main():
print_providers()
@@ -21,25 +21,30 @@ def print_providers():
"| ------ | ------- | ------- | ----- | --------- | ------ | ---- |",
]
providers = get_providers()
- for _provider in providers:
- netloc = urlparse(_provider.url).netloc
- website = f"[{netloc}]({_provider.url})"
-
- provider_name = f"g4f.provider.{_provider.__name__}"
-
- has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else "❌"
- has_gpt_4 = "✔️" if _provider.supports_gpt_4 else "❌"
- stream = "✔️" if _provider.supports_stream else "❌"
- status = (
- "![Active](https://img.shields.io/badge/Active-brightgreen)"
- if _provider.working
- else "![Inactive](https://img.shields.io/badge/Inactive-red)"
- )
- auth = "✔️" if _provider.needs_auth else "❌"
-
- lines.append(
- f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {status} | {auth} |"
- )
+ for is_working in (True, False):
+ for _provider in providers:
+ if is_working != _provider.working:
+ continue
+ netloc = urlparse(_provider.url).netloc
+ website = f"[{netloc}]({_provider.url})"
+
+ provider_name = f"g4f.provider.{_provider.__name__}"
+
+ has_gpt_35 = "✔️" if _provider.supports_gpt_35_turbo else "❌"
+ has_gpt_4 = "✔️" if _provider.supports_gpt_4 else "❌"
+ stream = "✔️" if _provider.supports_stream else "❌"
+ if _provider.working:
+ if test(_provider):
+ status = '![Active](https://img.shields.io/badge/Active-brightgreen)'
+ else:
+ status = '![Unknown](https://img.shields.io/badge/Unknown-grey)'
+ else:
+ status = '![Inactive](https://img.shields.io/badge/Inactive-red)'
+ auth = "✔️" if _provider.needs_auth else "❌"
+
+ lines.append(
+ f"| {website} | {provider_name} | {has_gpt_35} | {has_gpt_4} | {stream} | {status} | {auth} |"
+ )
print("\n".join(lines))
@@ -79,6 +84,8 @@ def print_models():
_models = get_models()
for model in _models:
+ if model.best_provider.__name__ not in provider_urls:
+ continue
split_name = re.split(r":|/", model.name)
name = split_name[-1]