summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Yqcloud.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-22 18:08:03 +0200
committerGitHub <noreply@github.com>2023-10-22 18:08:03 +0200
commitd1eaa46360b7fe30d6f9c60f5a4af6246c24dc56 (patch)
tree9cc4e7401fdf42efdf6b42670acd3c2a72214ebf /g4f/Provider/Yqcloud.py
parent~ | Merge pull request #1112 from lategege/main (diff)
parentFix ChatgptAi Provider (diff)
downloadgpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar
gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.gz
gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.bz2
gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.lz
gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.xz
gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.tar.zst
gpt4free-d1eaa46360b7fe30d6f9c60f5a4af6246c24dc56.zip
Diffstat (limited to 'g4f/Provider/Yqcloud.py')
-rw-r--r--g4f/Provider/Yqcloud.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/g4f/Provider/Yqcloud.py b/g4f/Provider/Yqcloud.py
index d6ce21a9..2829c5bf 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
@@ -9,7 +9,7 @@ from .base_provider import AsyncGeneratorProvider, format_prompt
class Yqcloud(AsyncGeneratorProvider):
url = "https://chat9.yqcloud.top/"
- working = False
+ working = True
supports_gpt_35_turbo = True
@staticmethod
@@ -17,15 +17,16 @@ class Yqcloud(AsyncGeneratorProvider):
model: str,
messages: Messages,
proxy: str = None,
+ timeout: int = 120,
**kwargs,
) -> AsyncResult:
- async with ClientSession(
- headers=_create_header()
+ async with StreamSession(
+ headers=_create_header(), proxies={"https": proxy}, timeout=timeout
) 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 +39,7 @@ def _create_header():
"accept" : "application/json, text/plain, */*",
"content-type" : "application/json",
"origin" : "https://chat9.yqcloud.top",
+ "referer" : "https://chat9.yqcloud.top/"
}