diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2024-11-15 11:18:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 11:18:56 +0100 |
commit | f65ebd98518bc42bd83a9205f3eab9cb06de566a (patch) | |
tree | 82ceabb9503acd0e1301b6eb7e20493cc18f3672 /g4f/client | |
parent | FIX: fix the url in the markdown output (md compliance), and the chunk/ImageResponse to str ! (#2353) (diff) | |
parent | quick fix for Conflicts (diff) | |
download | gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.tar gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.tar.gz gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.tar.bz2 gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.tar.lz gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.tar.xz gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.tar.zst gpt4free-f65ebd98518bc42bd83a9205f3eab9cb06de566a.zip |
Diffstat (limited to 'g4f/client')
-rw-r--r-- | g4f/client/client.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/g4f/client/client.py b/g4f/client/client.py index 8e195213..73d8fea3 100644 --- a/g4f/client/client.py +++ b/g4f/client/client.py @@ -144,24 +144,32 @@ class Client(BaseClient): class AsyncClient(Client): """Legacy AsyncClient that redirects to the main Client class. This class exists for backwards compatibility.""" - + def __init__(self, *args, **kwargs): import warnings warnings.warn( - "AsyncClient is deprecated and will be removed in a future version. " + "AsyncClient is deprecated and will be removed in future versions." "Use Client instead, which now supports both sync and async operations.", DeprecationWarning, stacklevel=2 ) super().__init__(*args, **kwargs) - async def chat_complete(self, *args, **kwargs): - """Legacy method that redirects to async_create""" - return await self.chat.completions.async_create(*args, **kwargs) + async def async_create(self, *args, **kwargs): + """Asynchronous create method that calls the synchronous method.""" + return await super().async_create(*args, **kwargs) + + async def async_generate(self, *args, **kwargs): + """Asynchronous image generation method.""" + return await super().async_generate(*args, **kwargs) - async def create_image(self, *args, **kwargs): - """Legacy method that redirects to async_generate""" - return await self.images.async_generate(*args, **kwargs) + async def async_images(self) -> Images: + """Asynchronous access to images.""" + return await super().async_images() + + async def async_fetch_image(self, url: str) -> bytes: + """Asynchronous fetching of an image by URL.""" + return await self._fetch_image(url) class Completions: def __init__(self, client: Client, provider: ProviderType = None): @@ -531,4 +539,3 @@ class Images: async def create_variation(self, image: Union[str, bytes], model: str = None, response_format: str = "url", **kwargs): # Existing implementation, adjust if you want to support b64_json here as well pass - |