summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Yqcloud.py
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner@lohaus.eu>2023-10-22 08:57:31 +0200
committerHeiner Lohaus <heiner@lohaus.eu>2023-10-22 08:57:31 +0200
commit13e89d6ab9e3016741fdcbd03cc4996faec54f9a (patch)
treeff4b350e57dd8a77d8e7b41f85431bdb85118a4f /g4f/Provider/Yqcloud.py
parentAdd FakeGpt Provider (diff)
downloadgpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.tar
gpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.tar.gz
gpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.tar.bz2
gpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.tar.lz
gpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.tar.xz
gpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.tar.zst
gpt4free-13e89d6ab9e3016741fdcbd03cc4996faec54f9a.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/Yqcloud.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/g4f/Provider/Yqcloud.py b/g4f/Provider/Yqcloud.py
index d6ce21a9..b567f3a0 100644
--- a/g4f/Provider/Yqcloud.py
+++ b/g4f/Provider/Yqcloud.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import random
-from aiohttp import ClientSession
+from ..requests import StreamSession
from ..typing import AsyncResult, Messages
from .base_provider import AsyncGeneratorProvider, format_prompt
@@ -19,13 +19,13 @@ class Yqcloud(AsyncGeneratorProvider):
proxy: str = None,
**kwargs,
) -> AsyncResult:
- async with ClientSession(
- headers=_create_header()
+ async with StreamSession(
+ headers=_create_header(), proxies={"https": proxy}
) as session:
payload = _create_payload(messages, **kwargs)
- async with session.post("https://api.aichatos.cloud/api/generateStream", proxy=proxy, json=payload) as response:
+ async with session.post("https://api.aichatos.cloud/api/generateStream", json=payload) as response:
response.raise_for_status()
- async for chunk in response.content.iter_any():
+ async for chunk in response.iter_content():
if chunk:
chunk = chunk.decode()
if "sorry, 您的ip已由于触发防滥用检测而被封禁" in chunk:
@@ -38,6 +38,7 @@ def _create_header():
"accept" : "application/json, text/plain, */*",
"content-type" : "application/json",
"origin" : "https://chat9.yqcloud.top",
+ "referer" : "https://chat9.yqcloud.top/"
}