diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 19:30:53 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 19:30:53 +0100 |
commit | 6b3be02d63b4c3592654a0059474c37465015e11 (patch) | |
tree | f19fcd829039435d1aae9ace02873770ca756dca /g4f | |
parent | Improve readme, add smartphone guide (diff) | |
download | gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.tar gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.tar.gz gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.tar.bz2 gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.tar.lz gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.tar.xz gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.tar.zst gpt4free-6b3be02d63b4c3592654a0059474c37465015e11.zip |
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/__init__.py | 8 | ||||
-rw-r--r-- | g4f/api/__init__.py | 10 |
2 files changed, 12 insertions, 6 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}') diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index 18268eec..abfe3b04 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -16,12 +16,12 @@ from g4f.typing import Messages class ChatCompletionsConfig(BaseModel): messages: Messages model: str - provider: Union[str, None] + provider: Union[str, None] = None stream: bool = False - temperature: Union[float, None] - max_tokens: int = None - stop: Union[list[str], str, None] - api_key: Union[str, None] + temperature: Union[float, None] = None + max_tokens: Union[int, None] = None + stop: Union[list[str], str, None] = None + api_key: Union[str, None] = None class Api: def __init__(self, engine: g4f, debug: bool = True, sentry: bool = False, |