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/deprecated/V50.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'g4f/Provider/deprecated/V50.py') diff --git a/g4f/Provider/deprecated/V50.py b/g4f/Provider/deprecated/V50.py index 9a8b032c..f4f4d823 100644 --- a/g4f/Provider/deprecated/V50.py +++ b/g4f/Provider/deprecated/V50.py @@ -21,9 +21,12 @@ class V50(BaseProvider): messages: list[dict[str, str]], stream: bool, **kwargs: Any) -> CreateResult: - conversation = "\n".join(f"{message['role']}: {message['content']}" for message in messages) - conversation += "\nassistant: " - + conversation = ( + "\n".join( + f"{message['role']}: {message['content']}" for message in messages + ) + + "\nassistant: " + ) payload = { "prompt" : conversation, "options" : {}, @@ -33,7 +36,7 @@ class V50(BaseProvider): "model" : model, "user" : str(uuid.uuid4()) } - + headers = { 'authority' : 'p5.v50.ltd', 'accept' : 'application/json, text/plain, */*', @@ -47,9 +50,13 @@ class V50(BaseProvider): 'sec-fetch-site' : 'same-origin', 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36' } - response = requests.post("https://p5.v50.ltd/api/chat-process", - json=payload, headers=headers, proxies=kwargs['proxy'] if 'proxy' in kwargs else {}) - + response = requests.post( + "https://p5.v50.ltd/api/chat-process", + json=payload, + headers=headers, + proxies=kwargs.get('proxy', {}), + ) + if "https://fk1.v50.ltd" not in response.text: yield response.text -- cgit v1.2.3