diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2024-10-30 09:47:48 +0100 |
---|---|---|
committer | Tekky <98614666+xtekky@users.noreply.github.com> | 2024-10-30 09:47:48 +0100 |
commit | b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e (patch) | |
tree | 0be1c2b3359c2d32569c2d05dbd30771faf9b887 /g4f/client/client.py | |
parent | Merge pull request #2302 from foxfire52/copy-patch (diff) | |
download | gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.tar gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.tar.gz gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.tar.bz2 gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.tar.lz gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.tar.xz gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.tar.zst gpt4free-b1d5af85aec21dc1d0813ed8bf99f3081bdceb5e.zip |
Diffstat (limited to 'g4f/client/client.py')
-rw-r--r-- | g4f/client/client.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/g4f/client/client.py b/g4f/client/client.py index 41238df5..cb5427f9 100644 --- a/g4f/client/client.py +++ b/g4f/client/client.py @@ -140,6 +140,29 @@ class Client(BaseClient): async def async_images(self) -> Images: return self._images +# For backwards compatibility and legacy purposes, use Client instead +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. " + "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 create_image(self, *args, **kwargs): + """Legacy method that redirects to async_generate""" + return await self.images.async_generate(*args, **kwargs) + class Completions: def __init__(self, client: Client, provider: ProviderType = None): self.client: Client = client |