summaryrefslogtreecommitdiffstats
path: root/etc/testing
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--etc/testing/log_time.py (renamed from testing/log_time.py)0
-rw-r--r--etc/testing/test_async.py31
-rw-r--r--etc/testing/test_chat_completion.py (renamed from testing/test_chat_completion.py)8
-rw-r--r--etc/testing/test_interference.py (renamed from testing/test_interference.py)0
-rw-r--r--etc/testing/test_needs_auth.py (renamed from testing/test_needs_auth.py)0
-rw-r--r--etc/testing/test_providers.py (renamed from testing/test_providers.py)22
6 files changed, 41 insertions, 20 deletions
diff --git a/testing/log_time.py b/etc/testing/log_time.py
index 376ab86d..376ab86d 100644
--- a/testing/log_time.py
+++ b/etc/testing/log_time.py
diff --git a/etc/testing/test_async.py b/etc/testing/test_async.py
new file mode 100644
index 00000000..2c15f6b0
--- /dev/null
+++ b/etc/testing/test_async.py
@@ -0,0 +1,31 @@
+import sys
+from pathlib import Path
+import asyncio
+
+sys.path.append(str(Path(__file__).parent.parent))
+sys.path.append(str(Path(__file__).parent.parent.parent))
+
+import g4f
+from testing.test_providers import get_providers
+from testing.log_time import log_time_async
+
+async def create_async(provider):
+ try:
+ response = await log_time_async(
+ provider.create_async,
+ model=g4f.models.default.name,
+ messages=[{"role": "user", "content": "Hello, are you GPT 3.5?"}]
+ )
+ print(f"{provider.__name__}:", response)
+ except Exception as e:
+ print(f"{provider.__name__}: {e.__class__.__name__}: {e}")
+
+async def run_async():
+ responses: list = [
+ create_async(provider)
+ for provider in get_providers()
+ if provider.working
+ ]
+ await asyncio.gather(*responses)
+
+print("Total:", asyncio.run(log_time_async(run_async))) \ No newline at end of file
diff --git a/testing/test_chat_completion.py b/etc/testing/test_chat_completion.py
index 7600e46b..ee523b86 100644
--- a/testing/test_chat_completion.py
+++ b/etc/testing/test_chat_completion.py
@@ -1,14 +1,14 @@
import sys
from pathlib import Path
-sys.path.append(str(Path(__file__).parent.parent))
+sys.path.append(str(Path(__file__).parent.parent.parent))
import g4f, asyncio
print("create:", end=" ", flush=True)
for response in g4f.ChatCompletion.create(
- model=g4f.models.gpt_4_32k_0613,
- provider=g4f.Provider.Aivvm,
+ model=g4f.models.default,
+ provider=g4f.Provider.GptForLove,
messages=[{"role": "user", "content": "send a bunch of emojis. i want to test something"}],
temperature=0.0,
stream=True
@@ -19,7 +19,7 @@ print()
async def run_async():
response = await g4f.ChatCompletion.create_async(
model=g4f.models.gpt_35_turbo_16k_0613,
- provider=g4f.Provider.Aivvm,
+ provider=g4f.Provider.GptGod,
messages=[{"role": "user", "content": "hello!"}],
)
print("create_async:", response)
diff --git a/testing/test_interference.py b/etc/testing/test_interference.py
index d8e85a6c..d8e85a6c 100644
--- a/testing/test_interference.py
+++ b/etc/testing/test_interference.py
diff --git a/testing/test_needs_auth.py b/etc/testing/test_needs_auth.py
index 26630e23..26630e23 100644
--- a/testing/test_needs_auth.py
+++ b/etc/testing/test_needs_auth.py
diff --git a/testing/test_providers.py b/etc/testing/test_providers.py
index cd82fe7c..ec0e0271 100644
--- a/testing/test_providers.py
+++ b/etc/testing/test_providers.py
@@ -33,21 +33,10 @@ def main():
def get_providers() -> list[type[BaseProvider]]:
- provider_names = dir(Provider)
- ignore_names = [
- "annotations",
- "base_provider",
- "retry_provider",
- "BaseProvider",
- "AsyncProvider",
- "AsyncGeneratorProvider",
- "RetryProvider",
- ]
- return [
- getattr(Provider, provider_name)
- for provider_name in provider_names
- if not provider_name.startswith("__") and provider_name not in ignore_names
- ]
+ providers = dir(Provider)
+ providers = [getattr(Provider, provider) for provider in providers if provider != "RetryProvider"]
+ providers = [provider for provider in providers if isinstance(provider, type)]
+ return [provider for provider in providers if issubclass(provider, BaseProvider)]
def create_response(_provider: type[BaseProvider]) -> str:
@@ -73,4 +62,5 @@ def test(_provider: type[BaseProvider]) -> bool:
if __name__ == "__main__":
- main() \ No newline at end of file
+ main()
+ \ No newline at end of file