diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-04-06 21:15:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-06 21:15:07 +0200 |
commit | c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c (patch) | |
tree | ba673d508e7dc1a761dcb6972cf3cec95f91e808 /g4f | |
parent | Update async.py (diff) | |
download | gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.tar gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.tar.gz gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.tar.bz2 gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.tar.lz gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.tar.xz gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.tar.zst gpt4free-c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/client/types.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/g4f/client/types.py b/g4f/client/types.py index 1c33e6c2..b21ff03a 100644 --- a/g4f/client/types.py +++ b/g4f/client/types.py @@ -5,7 +5,18 @@ ImageProvider = Union[BaseProvider, object] Proxies = Union[dict, str] IterResponse = Iterator[Union[ChatCompletion, ChatCompletionChunk]] -class Client(): +class ClientProxyMixin(): + def get_proxy(self) -> Union[str, None]: + if isinstance(self.proxies, str): + return self.proxies + elif self.proxies is None: + return os.environ.get("G4F_PROXY") + elif "all" in self.proxies: + return self.proxies["all"] + elif "https" in self.proxies: + return self.proxies["https"] + +class Client(ClientProxyMixin): def __init__( self, api_key: str = None, @@ -16,5 +27,3 @@ class Client(): ) -> None: self.api_key: str = api_key self.proxies: Proxies = proxies - self.chat: Chat = Chat(self, provider) - self.images: Images = Images(self, image_provider) |