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/Ylokh.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'g4f/Provider/Ylokh.py') diff --git a/g4f/Provider/Ylokh.py b/g4f/Provider/Ylokh.py index b13f846e..dce76f22 100644 --- a/g4f/Provider/Ylokh.py +++ b/g4f/Provider/Ylokh.py @@ -23,10 +23,7 @@ class Ylokh(AsyncGeneratorProvider): **kwargs ) -> AsyncResult: model = model if model else "gpt-3.5-turbo" - headers = { - "Origin" : cls.url, - "Referer": cls.url + "/", - } + headers = {"Origin": cls.url, "Referer": f"{cls.url}/"} data = { "messages": messages, "model": model, @@ -39,10 +36,10 @@ class Ylokh(AsyncGeneratorProvider): **kwargs } async with StreamSession( - headers=headers, - proxies={"https": proxy}, - timeout=timeout - ) as session: + headers=headers, + proxies={"https": proxy}, + timeout=timeout + ) as session: async with session.post("https://chatapi.ylokh.xyz/v1/chat/completions", json=data) as response: response.raise_for_status() if stream: @@ -52,8 +49,9 @@ class Ylokh(AsyncGeneratorProvider): if line.startswith("data: [DONE]"): break line = json.loads(line[6:]) - content = line["choices"][0]["delta"].get("content") - if content: + if content := line["choices"][0]["delta"].get( + "content" + ): yield content else: chat = await response.json() -- cgit v1.2.3