diff options
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Yqcloud.py | 35 |
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 |