summaryrefslogtreecommitdiffstats
path: root/g4f/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/__init__.py')
-rw-r--r--g4f/__init__.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/g4f/__init__.py b/g4f/__init__.py
index 441225f1..14405e92 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -51,7 +51,7 @@ def get_model_and_provider(model : Union[Model, str],
provider = IterProvider(provider_list)
elif provider in ProviderUtils.convert:
provider = ProviderUtils.convert[provider]
- else:
+ elif provider:
raise ProviderNotFoundError(f'Provider not found: {provider}')
if isinstance(model, str):
@@ -69,11 +69,14 @@ def get_model_and_provider(model : Union[Model, str],
if isinstance(model, Model):
model = model.name
- if ignored and isinstance(provider, BaseRetryProvider):
- provider.providers = [p for p in provider.providers if p.__name__ not in ignored]
-
if not ignore_working and not provider.working:
raise ProviderNotWorkingError(f'{provider.__name__} is not working')
+
+ if not ignore_working and isinstance(provider, BaseRetryProvider):
+ provider.providers = [p for p in provider.providers if p.working]
+
+ if ignored and isinstance(provider, BaseRetryProvider):
+ provider.providers = [p for p in provider.providers if p.__name__ not in ignored]
if not ignore_stream and not provider.supports_stream and stream:
raise StreamNotSupportedError(f'{provider.__name__} does not support "stream" argument')