diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-11-08 11:03:33 +0100 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-11-08 11:03:33 +0100 |
commit | b5c432f73e845c57899a706ccdf440fabccac42e (patch) | |
tree | 9250bca65e641e3788cd82183b8a5f542f320d2c /g4f/client/AsyncClient.py | |
parent | Update (docs/providers-and-models.md) (diff) | |
download | gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.tar gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.tar.gz gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.tar.bz2 gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.tar.lz gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.tar.xz gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.tar.zst gpt4free-b5c432f73e845c57899a706ccdf440fabccac42e.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/client/AsyncClient.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/g4f/client/AsyncClient.py b/g4f/client/AsyncClient.py deleted file mode 100644 index fd2cc353..00000000 --- a/g4f/client/AsyncClient.py +++ /dev/null @@ -1,38 +0,0 @@ -from __future__ import annotations - -from .Client import Client, Chat, Images, Completions -from .Client import async_iter_response, async_iter_append_model_and_provider -from aiohttp import ClientSession -from typing import Union, AsyncIterator - -class AsyncClient(Client): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.chat = AsyncChat(self) - self._images = AsyncImages(self) - - @property - def images(self) -> 'AsyncImages': - return self._images - -class AsyncCompletions(Completions): - async def async_create(self, *args, **kwargs) -> Union['ChatCompletion', AsyncIterator['ChatCompletionChunk']]: - response = await super().async_create(*args, **kwargs) - async for result in response: - return result - -class AsyncChat(Chat): - def __init__(self, client: AsyncClient): - self.completions = AsyncCompletions(client) - -class AsyncImages(Images): - async def async_generate(self, *args, **kwargs) -> 'ImagesResponse': - return await super().async_generate(*args, **kwargs) - - async def _fetch_image(self, url: str) -> bytes: - async with ClientSession() as session: - async with session.get(url) as resp: - if resp.status == 200: - return await resp.read() - else: - raise Exception(f"Failed to fetch image from {url}, status code {resp.status}") |