返回提交历史
Modified
g4f/client/__init__.py
+1
-1
Modified
g4f/client/client.py
+23
-0
XFEstudio/gpt4free
re-include`AsyncClient` for backwards compatibility, with deprecationwarning. Use `Client` instead
b1d5af85
代码差异
2 个文件
+24
-1
@@ -1,2 +1,2 @@
1
1
from .stubs import ChatCompletion, ChatCompletionChunk, ImagesResponse
2
from .client import Client
2
from .client import Client, AsyncClient
@@ -140,6 +140,29 @@ class Client(BaseClient):
140
140
async def async_images(self) -> Images:
141
141
return self._images
142
142
143
# For backwards compatibility and legacy purposes, use Client instead
144
class AsyncClient(Client):
145
"""Legacy AsyncClient that redirects to the main Client class.
146
This class exists for backwards compatibility."""
147
148
def __init__(self, *args, **kwargs):
149
import warnings
150
warnings.warn(
151
"AsyncClient is deprecated and will be removed in a future version. "
152
"Use Client instead, which now supports both sync and async operations.",
153
DeprecationWarning,
154
stacklevel=2
155
)
156
super().__init__(*args, **kwargs)
157
158
async def chat_complete(self, *args, **kwargs):
159
"""Legacy method that redirects to async_create"""
160
return await self.chat.completions.async_create(*args, **kwargs)
161
162
async def create_image(self, *args, **kwargs):
163
"""Legacy method that redirects to async_generate"""
164
return await self.images.async_generate(*args, **kwargs)
165
143
166
class Completions:
144
167
def __init__(self, client: Client, provider: ProviderType = None):
145
168
self.client: Client = client