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 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'g4f/Provider/AItianhu.py') 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"