summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Yqcloud.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-09-07 19:45:04 +0200
committerGitHub <noreply@github.com>2023-09-07 19:45:04 +0200
commit7ca1a59d95b52f94f674e8f981eab910b2f03518 (patch)
treeca506c3c152f3906a5b727a4cc6ebba1fd59d335 /g4f/Provider/Yqcloud.py
parent~ | Merge pull request #869 from ahobsonsayers/add-console-script (diff)
parentFix imports in Bing (diff)
downloadgpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar
gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.gz
gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.bz2
gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.lz
gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.xz
gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.zst
gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.zip
Diffstat (limited to 'g4f/Provider/Yqcloud.py')
-rw-r--r--g4f/Provider/Yqcloud.py15
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"
}