From 3982f39424ea037aca1086d45c6f657b4bfc457c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=B2=98r=E1=B9=A8h=E0=B8=AA=E2=88=82ow?= <71973368+MrShadowDev@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:46:25 +0200 Subject: 'Refactored by Sourcery' (#1125) Co-authored-by: Sourcery AI <> --- g4f/Provider/AItianhu.py | 36 ++++++------- g4f/Provider/AItianhuSpace.py | 23 +++++---- g4f/Provider/Aichat.py | 18 ++++--- g4f/Provider/Ails.py | 24 ++++----- g4f/Provider/Bing.py | 90 ++++++++++++++++++--------------- g4f/Provider/ChatBase.py | 20 ++++---- g4f/Provider/Chatgpt4Online.py | 4 +- g4f/Provider/ChatgptAi.py | 13 +++-- g4f/Provider/ChatgptDemo.py | 12 +++-- g4f/Provider/ChatgptFree.py | 35 +++++++------ g4f/Provider/ChatgptLogin.py | 14 +++-- g4f/Provider/ChatgptX.py | 15 +++--- g4f/Provider/GPTalk.py | 6 +-- g4f/Provider/GptChatly.py | 10 ++-- g4f/Provider/GptForLove.py | 7 +-- g4f/Provider/GptGo.py | 35 +++++++------ g4f/Provider/GptGod.py | 7 ++- g4f/Provider/Liaobots.py | 2 +- g4f/Provider/Vercel.py | 66 +++++++++++------------- g4f/Provider/Ylokh.py | 18 +++---- g4f/Provider/deprecated/AiService.py | 9 ++-- g4f/Provider/deprecated/CodeLinkAva.py | 23 ++++----- g4f/Provider/deprecated/EasyChat.py | 40 +++++++-------- g4f/Provider/deprecated/Equing.py | 11 ++-- g4f/Provider/deprecated/FastGpt.py | 13 ++--- g4f/Provider/deprecated/H2o.py | 2 +- g4f/Provider/deprecated/Lockchat.py | 7 ++- g4f/Provider/deprecated/V50.py | 21 +++++--- g4f/Provider/deprecated/Vitalentum.py | 23 ++++----- g4f/Provider/deprecated/Wuguokai.py | 19 ++++--- g4f/Provider/helper.py | 22 ++++---- g4f/Provider/needs_auth/Bard.py | 14 ++--- g4f/Provider/needs_auth/Raycast.py | 10 ++-- g4f/Provider/needs_auth/Theb.py | 40 +++++++-------- g4f/Provider/unfinished/ChatAiGpt.py | 8 +-- g4f/Provider/unfinished/MikuChat.py | 3 +- g4f/Provider/unfinished/PerplexityAi.py | 2 +- 37 files changed, 364 insertions(+), 358 deletions(-) (limited to 'g4f/Provider') diff --git a/g4f/Provider/AItianhu.py b/g4f/Provider/AItianhu.py index 18ab08d8..2fdcfcde 100644 --- a/g4f/Provider/AItianhu.py +++ b/g4f/Provider/AItianhu.py @@ -24,9 +24,9 @@ class AItianhu(AsyncGeneratorProvider): if not cookies: cookies = get_cookies(domain_name='www.aitianhu.com') - if not cookies: - raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://www.aitianhu.com on chrome]") - + if not cookies: + raise RuntimeError(f"g4f.provider.{cls.__name__} requires cookies [refresh https://www.aitianhu.com on chrome]") + data = { "prompt": format_prompt(messages), "options": {}, @@ -35,7 +35,7 @@ class AItianhu(AsyncGeneratorProvider): "top_p": 1, **kwargs } - + headers = { 'authority': 'www.aitianhu.com', 'accept': 'application/json, text/plain, */*', @@ -51,31 +51,31 @@ class AItianhu(AsyncGeneratorProvider): 'sec-fetch-site': 'same-origin', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36', } - + async with StreamSession(headers=headers, - cookies=cookies, - timeout=timeout, - proxies={"https": proxy}, - impersonate="chrome107", verify=False) as session: + cookies=cookies, + timeout=timeout, + proxies={"https": proxy}, + impersonate="chrome107", verify=False) as session: async with session.post(f"{cls.url}/api/chat-process", json=data) as response: response.raise_for_status() - + async for line in response.iter_lines(): if line == b"