summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Ylokh.py
diff options
context:
space:
mode:
authorAndPim4912 <52836885+AndPim4912@users.noreply.github.com>2023-10-23 14:10:28 +0200
committerGitHub <noreply@github.com>2023-10-23 14:10:28 +0200
commit8d7ad98fcb314453c01f6dcd4bfe59016efd78ce (patch)
tree4d39804e1aa1724560e1688f0b6d4c124b9771c7 /g4f/Provider/Ylokh.py
parentRefactor API initialization to accept a list of ignored providers. (diff)
parentDebug config in api (diff)
downloadgpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.gz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.bz2
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.lz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.xz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.zst
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.zip
Diffstat (limited to 'g4f/Provider/Ylokh.py')
-rw-r--r--g4f/Provider/Ylokh.py18
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()