summaryrefslogtreecommitdiffstats
path: root/g4f/client
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/client')
-rw-r--r--g4f/client/__init__.py2
-rw-r--r--g4f/client/client.py23
2 files changed, 24 insertions, 1 deletions
diff --git a/g4f/client/__init__.py b/g4f/client/__init__.py
index 9fb3551e..d1e7e298 100644
--- a/g4f/client/__init__.py
+++ b/g4f/client/__init__.py
@@ -1,2 +1,2 @@
from .stubs import ChatCompletion, ChatCompletionChunk, ImagesResponse
-from .client import Client
+from .client import Client, AsyncClient
diff --git a/g4f/client/client.py b/g4f/client/client.py
index 44d99d60..8e195213 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