From efd75a11b871d61ac31b0e274acdfb33daba361d Mon Sep 17 00:00:00 2001 From: abc <98614666+xtekky@users.noreply.github.com> Date: Sun, 27 Aug 2023 17:37:44 +0200 Subject: ~ | code styling --- g4f/Provider/Yqcloud.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'g4f/Provider/Yqcloud.py') 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 -- cgit v1.2.3