summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/retry_provider.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-19 09:53:37 +0200
committerGitHub <noreply@github.com>2023-10-19 09:53:37 +0200
commit4c72acca7b08d53cc19fe8478e9091ae26207635 (patch)
tree8ce5a5e3baabf035dd4840e30938dd4be659a40c /g4f/Provider/retry_provider.py
parent~ (diff)
parentFix: debug.logging not work in retry provider (diff)
downloadgpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.tar
gpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.tar.gz
gpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.tar.bz2
gpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.tar.lz
gpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.tar.xz
gpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.tar.zst
gpt4free-4c72acca7b08d53cc19fe8478e9091ae26207635.zip
Diffstat (limited to 'g4f/Provider/retry_provider.py')
-rw-r--r--g4f/Provider/retry_provider.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/g4f/Provider/retry_provider.py b/g4f/Provider/retry_provider.py
index 72170756..4ecfaffb 100644
--- a/g4f/Provider/retry_provider.py
+++ b/g4f/Provider/retry_provider.py
@@ -5,13 +5,13 @@ import random
from typing import List, Type, Dict
from ..typing import CreateResult, Messages
from .base_provider import BaseProvider, AsyncProvider
-from ..debug import logging
class RetryProvider(AsyncProvider):
__name__: str = "RetryProvider"
working: bool = True
supports_stream: bool = True
+ logging: bool = False
def __init__(
self,
@@ -21,7 +21,6 @@ class RetryProvider(AsyncProvider):
self.providers: List[Type[BaseProvider]] = providers
self.shuffle: bool = shuffle
-
def create_completion(
self,
model: str,
@@ -40,7 +39,7 @@ class RetryProvider(AsyncProvider):
started: bool = False
for provider in providers:
try:
- if logging:
+ if self.logging:
print(f"Using {provider.__name__} provider")
for token in provider.create_completion(model, messages, stream, **kwargs):
yield token
@@ -49,7 +48,7 @@ class RetryProvider(AsyncProvider):
return
except Exception as e:
self.exceptions[provider.__name__] = e
- if logging:
+ if self.logging:
print(f"{provider.__name__}: {e.__class__.__name__}: {e}")
if started:
raise e
@@ -72,11 +71,11 @@ class RetryProvider(AsyncProvider):
return await asyncio.wait_for(provider.create_async(model, messages, **kwargs), timeout=60)
except asyncio.TimeoutError as e:
self.exceptions[provider.__name__] = e
- if logging:
+ if self.logging:
print(f"{provider.__name__}: TimeoutError: {e}")
except Exception as e:
self.exceptions[provider.__name__] = e
- if logging:
+ if self.logging:
print(f"{provider.__name__}: {e.__class__.__name__}: {e}")
self.raise_exceptions()