summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Yqcloud.py
diff options
context:
space:
mode:
authorLuneye <73485421+Luneye@users.noreply.github.com>2023-08-28 16:55:36 +0200
committerGitHub <noreply@github.com>2023-08-28 16:55:36 +0200
commit01294db6995511de37e9078e03ce32e54dbdad52 (patch)
treed6c4c14f4e6a3a81660ddb75272bc5da81cacecc /g4f/Provider/Yqcloud.py
parentUpdate Bing.py (diff)
parent~ | code styling (diff)
downloadgpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.gz
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.bz2
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.lz
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.xz
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.tar.zst
gpt4free-01294db6995511de37e9078e03ce32e54dbdad52.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/Yqcloud.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/g4f/Provider/Yqcloud.py b/g4f/Provider/Yqcloud.py
index 82ece2d5..44173525 100644
--- a/g4f/Provider/Yqcloud.py
+++ b/g4f/Provider/Yqcloud.py
@@ -1,26 +1,26 @@
import requests
-from ..typing import Any, CreateResult
+from ..typing import Any, CreateResult
from .base_provider import BaseProvider
class Yqcloud(BaseProvider):
- url = "https://chat9.yqcloud.top/"
- working = True
- supports_gpt_35_turbo = True
+ url = "https://chat9.yqcloud.top/"
+ working = True
+ supports_gpt_35_turbo = True
@staticmethod
def create_completion(
model: str,
messages: list[dict[str, str]],
- stream: bool,
- **kwargs: Any,
- ) -> CreateResult:
+ stream: bool, **kwargs: Any) -> CreateResult:
+
headers = _create_header()
payload = _create_payload(messages)
- url = "https://api.aichatos.cloud/api/generateStream"
- response = requests.post(url=url, headers=headers, json=payload)
+ response = requests.post("https://api.aichatos.cloud/api/generateStream",
+ headers=headers, json=payload)
+
response.raise_for_status()
response.encoding = 'utf-8'
yield response.text
@@ -28,9 +28,9 @@ class Yqcloud(BaseProvider):
def _create_header():
return {
- "accept": "application/json, text/plain, */*",
- "content-type": "application/json",
- "origin": "https://chat9.yqcloud.top",
+ "accept" : "application/json, text/plain, */*",
+ "content-type" : "application/json",
+ "origin" : "https://chat9.yqcloud.top",
}
@@ -39,10 +39,11 @@ def _create_payload(messages: list[dict[str, str]]):
for message in messages:
prompt += "%s: %s\n" % (message["role"], message["content"])
prompt += "assistant:"
+
return {
- "prompt": prompt,
- "network": True,
- "system": "",
+ "prompt" : prompt,
+ "network" : True,
+ "system" : "",
"withoutContext": False,
- "stream": False,
- }
+ "stream" : False,
+ } \ No newline at end of file