diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-10-22 18:08:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-22 18:08:03 +0200 |
commit | d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56 (patch) | |
tree | 9cc4e7401fdf42efdf6b42670acd3c2a72214ebf /g4f/Provider/retry_provider.py | |
parent | ~ | Merge pull request #1112 from lategege/main (diff) | |
parent | Fix ChatgptAi Provider (diff) | |
download | gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.gz gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.bz2 gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.lz gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.xz gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.zst gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.zip |
Diffstat (limited to 'g4f/Provider/retry_provider.py')
-rw-r--r-- | g4f/Provider/retry_provider.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/g4f/Provider/retry_provider.py b/g4f/Provider/retry_provider.py index ee342315..39d61c35 100644 --- a/g4f/Provider/retry_provider.py +++ b/g4f/Provider/retry_provider.py @@ -71,11 +71,10 @@ class RetryProvider(AsyncProvider): self.exceptions: Dict[str, Exception] = {} for provider in providers: try: - return await asyncio.wait_for(provider.create_async(model, messages, **kwargs), timeout=60) - except asyncio.TimeoutError as e: - self.exceptions[provider.__name__] = e - if self.logging: - print(f"{provider.__name__}: TimeoutError: {e}") + return await asyncio.wait_for( + provider.create_async(model, messages, **kwargs), + timeout=kwargs.get("timeout", 60) + ) except Exception as e: self.exceptions[provider.__name__] = e if self.logging: @@ -85,8 +84,8 @@ class RetryProvider(AsyncProvider): def raise_exceptions(self) -> None: if self.exceptions: - raise RuntimeError("\n".join(["All providers failed:"] + [ + raise RuntimeError("\n".join(["RetryProvider failed:"] + [ f"{p}: {self.exceptions[p].__class__.__name__}: {self.exceptions[p]}" for p in self.exceptions ])) - raise RuntimeError("No provider found")
\ No newline at end of file + raise RuntimeError("RetryProvider: No provider found")
\ No newline at end of file |