diff options
author | ⲘrṨhส∂ow <71973368+MrShadowDev@users.noreply.github.com> | 2023-10-23 09:46:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-23 09:46:25 +0200 |
commit | 3982f39424ea037aca1086d45c6f657b4bfc457c (patch) | |
tree | 987290c5dc5822cb0197e789df68488536b1637c /g4f/Provider/Ylokh.py | |
parent | ~ | g4f `v-0.1.7.5` (diff) | |
download | gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.gz gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.bz2 gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.lz gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.xz gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.zst gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.zip |
Diffstat (limited to 'g4f/Provider/Ylokh.py')
-rw-r--r-- | g4f/Provider/Ylokh.py | 18 |
1 files changed, 8 insertions, 10 deletions
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() |