diff options
author | Heiner Lohaus <heiner.lohaus@netformic.com> | 2023-09-05 17:27:24 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner.lohaus@netformic.com> | 2023-09-05 17:27:24 +0200 |
commit | 5ca47b44b2b42abb4f48163c17500b5ee67ab28f (patch) | |
tree | b8fba4bde73d59c05857459eac41b25347d65c8e /g4f/Provider/Yqcloud.py | |
parent | ~ | Merge pull request #869 from ahobsonsayers/add-console-script (diff) | |
download | gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.gz gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.bz2 gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.lz gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.xz gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.tar.zst gpt4free-5ca47b44b2b42abb4f48163c17500b5ee67ab28f.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Yqcloud.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/g4f/Provider/Yqcloud.py b/g4f/Provider/Yqcloud.py index 731e4ecb..ac93315c 100644 --- a/g4f/Provider/Yqcloud.py +++ b/g4f/Provider/Yqcloud.py @@ -2,28 +2,31 @@ from __future__ import annotations from aiohttp import ClientSession -from .base_provider import AsyncProvider, format_prompt +from ..typing import AsyncGenerator +from .base_provider import AsyncGeneratorProvider, format_prompt -class Yqcloud(AsyncProvider): +class Yqcloud(AsyncGeneratorProvider): url = "https://chat9.yqcloud.top/" working = True supports_gpt_35_turbo = True @staticmethod - async def create_async( + async def create_async_generator( model: str, messages: list[dict[str, str]], proxy: str = None, **kwargs, - ) -> str: + ) -> AsyncGenerator: async with ClientSession( headers=_create_header() ) as session: payload = _create_payload(messages) async with session.post("https://api.aichatos.cloud/api/generateStream", proxy=proxy, json=payload) as response: response.raise_for_status() - return await response.text() + async for stream in response.content.iter_any(): + if stream: + yield stream.decode() def _create_header(): @@ -40,6 +43,6 @@ def _create_payload(messages: list[dict[str, str]]): "network": True, "system": "", "withoutContext": False, - "stream": False, + "stream": True, "userId": "#/chat/1693025544336" } |