From c9a83e53b7efe22ef1fbb6e4b80c8e6ff199ca1c Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Sat, 6 Apr 2024 21:15:07 +0200 Subject: [PATCH] Update types.py --- g4f/client/types.py | 15 ++++++++++++--- 1 file 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)