summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner.lohaus@netformic.com>2023-09-01 23:39:57 +0200
committerHeiner Lohaus <heiner.lohaus@netformic.com>2023-09-01 23:39:57 +0200
commit3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471 (patch)
treecc45ace1412c64677eba834ba60d73b03973d195 /tool
parent~ (diff)
downloadgpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.tar
gpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.tar.gz
gpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.tar.bz2
gpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.tar.lz
gpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.tar.xz
gpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.tar.zst
gpt4free-3e6b1d6bef04881d8f46ab06331b5e3c5e2e3471.zip
Diffstat (limited to 'tool')
-rw-r--r--tool/readme_table.py48
1 files changed, 39 insertions, 9 deletions
diff --git a/tool/readme_table.py b/tool/readme_table.py
index b578b9ca..522c66a7 100644
--- a/tool/readme_table.py
+++ b/tool/readme_table.py
@@ -6,14 +6,35 @@ from urllib.parse import urlparse
sys.path.append(str(Path(__file__).parent.parent))
from g4f import models, Provider
-from g4f.Provider.base_provider import BaseProvider
+from g4f.Provider.base_provider import BaseProvider, AsyncProvider
from testing.test_providers import test
-def main():
- print_providers()
- print("\n", "-" * 50, "\n")
- print_models()
+def print_imports():
+ print("##### Providers:")
+ print("```py")
+ print("from g4f.Provider import (")
+ for _provider in get_providers():
+ if _provider.working:
+ print(f" {_provider.__name__},")
+ print(")")
+ print("# Usage:")
+ print("response = g4f.ChatCompletion.create(..., provider=ProviderName)")
+ print("```")
+ print()
+ print()
+
+def print_async():
+ print("##### Async support:")
+ print("```py")
+ print("from g4f.Provider import (")
+ for _provider in get_providers():
+ if issubclass(_provider, AsyncProvider):
+ print(f" {_provider.__name__},")
+ print(")")
+ print("```")
+ print()
+ print()
def print_providers():
lines = [
@@ -48,18 +69,23 @@ def print_providers():
print("\n".join(lines))
-def get_providers() -> list[type[BaseProvider]]:
+def get_provider_names() -> list[str]:
provider_names = dir(Provider)
ignore_names = [
"base_provider",
"BaseProvider",
+ "AsyncProvider",
+ "AsyncGeneratorProvider"
]
- provider_names = [
+ return [
provider_name
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]
+
+
+def get_providers() -> list[type[BaseProvider]]:
+ return [getattr(Provider, provider_name) for provider_name in get_provider_names()]
def print_models():
@@ -107,4 +133,8 @@ def get_models():
if __name__ == "__main__":
- main()
+ print_imports()
+ print_async()
+ print_providers()
+ print("\n", "-" * 50, "\n")
+ print_models() \ No newline at end of file