From 393be6be6b27cdfc9ae29da47c806361db72b683 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Sat, 6 Apr 2024 21:12:02 +0200 Subject: Update async.py --- g4f/client/async.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'g4f/client/async.py') diff --git a/g4f/client/async.py b/g4f/client/async.py index bcd1a502..96c715d4 100644 --- a/g4f/client/async.py +++ b/g4f/client/async.py @@ -6,6 +6,7 @@ import time import random import string +from .types import Client as BaseClient from .types import BaseProvider, ProviderType, FinishReason from .stubs import ChatCompletion, ChatCompletionChunk, Image, ImagesResponse from ..typing import Union, Iterator, Messages, ImageType, AsyncIerator @@ -61,30 +62,15 @@ async def iter_append_model_and_provider(response: AsyncIterResponse) -> IterRes chunk.provider = last_provider.get("name") yield chunk -class Client(): +class Client(BaseClient): def __init__( self, - api_key: str = None, - proxies: Proxies = None, - provider: ProviderType = None, - image_provider: ImageProvider = None, **kwargs - ) -> None: - self.api_key: str = api_key - self.proxies: Proxies = proxies + ): + super().__init__(**kwargs) self.chat: Chat = Chat(self, provider) self.images: Images = Images(self, image_provider) - 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"] - def filter_none(**kwargs): for key in list(kwargs.keys()): if kwargs[key] is None: -- cgit v1.2.3