summaryrefslogtreecommitdiffstats
path: root/g4f/__init__.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-02-23 20:57:22 +0100
committerGitHub <noreply@github.com>2024-02-23 20:57:22 +0100
commitf1ba06e062c35ddf2f86ee09e1b162cf178ebb47 (patch)
treef19fcd829039435d1aae9ace02873770ca756dca /g4f/__init__.py
parentMerge pull request #1616 from hlohaus/gem (diff)
parentSet default values for generation config (diff)
downloadgpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.tar
gpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.tar.gz
gpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.tar.bz2
gpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.tar.lz
gpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.tar.xz
gpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.tar.zst
gpt4free-f1ba06e062c35ddf2f86ee09e1b162cf178ebb47.zip
Diffstat (limited to 'g4f/__init__.py')
-rw-r--r--g4f/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/g4f/__init__.py b/g4f/__init__.py
index 6c8e100e..6716c727 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -10,6 +10,7 @@ from .cookies import get_cookies, set_cookies
from . import debug, version
from .providers.types import BaseRetryProvider, ProviderType
from .providers.base_provider import ProviderModelMixin
+from .providers.retry_provider import RetryProvider
def get_model_and_provider(model : Union[Model, str],
provider : Union[ProviderType, str, None],
@@ -43,7 +44,12 @@ def get_model_and_provider(model : Union[Model, str],
version.utils.check_version()
if isinstance(provider, str):
- if provider in ProviderUtils.convert:
+ if " " in provider:
+ provider_list = [ProviderUtils.convert[p] for p in provider.split() if p in ProviderUtils.convert]
+ if not provider_list:
+ raise ProviderNotFoundError(f'Providers not found: {provider}')
+ provider = RetryProvider(provider_list, False)
+ elif provider in ProviderUtils.convert:
provider = ProviderUtils.convert[provider]
else:
raise ProviderNotFoundError(f'Provider not found: {provider}')