From bb481a03ab1a64e47731eb28e461e1dc1d655383 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sun, 1 Oct 2023 10:36:09 +0200 Subject: Disable Wewordle Provider Update Ylokh Provider Improve StreamRequest --- g4f/Provider/Ylokh.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'g4f/Provider/Ylokh.py') diff --git a/g4f/Provider/Ylokh.py b/g4f/Provider/Ylokh.py index c7b92089..2187eb78 100644 --- a/g4f/Provider/Ylokh.py +++ b/g4f/Provider/Ylokh.py @@ -1,8 +1,8 @@ from __future__ import annotations import json -from aiohttp import ClientSession +from ..requests import AsyncSession from .base_provider import AsyncGeneratorProvider from ..typing import AsyncGenerator @@ -23,14 +23,8 @@ class Ylokh(AsyncGeneratorProvider): ) -> AsyncGenerator: model = model if model else "gpt-3.5-turbo" headers = { - "User-Agent" : "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0", - "Accept" : "*/*", - "Accept-language" : "de,en-US;q=0.7,en;q=0.3", "Origin" : cls.url, "Referer" : cls.url + "/", - "Sec-Fetch-Dest" : "empty", - "Sec-Fetch-Mode" : "cors", - "Sec-Fetch-Site" : "same-origin", } data = { "messages": messages, @@ -43,7 +37,7 @@ class Ylokh(AsyncGeneratorProvider): "stream": stream, **kwargs } - async with ClientSession( + async with AsyncSession( headers=headers ) as session: async with session.post("https://chatapi.ylokh.xyz/v1/chat/completions", json=data, proxy=proxy) as response: -- cgit v1.2.3 From eb0e2c6a93c3f21937457d13220ce2b7fca1f04a Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 2 Oct 2023 02:04:22 +0200 Subject: +Curl +Async +Stream Requests Update Model List --- g4f/Provider/Ylokh.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'g4f/Provider/Ylokh.py') diff --git a/g4f/Provider/Ylokh.py b/g4f/Provider/Ylokh.py index 2187eb78..3c8b32dd 100644 --- a/g4f/Provider/Ylokh.py +++ b/g4f/Provider/Ylokh.py @@ -2,7 +2,7 @@ from __future__ import annotations import json -from ..requests import AsyncSession +from ..requests import StreamSession from .base_provider import AsyncGeneratorProvider from ..typing import AsyncGenerator @@ -37,18 +37,19 @@ class Ylokh(AsyncGeneratorProvider): "stream": stream, **kwargs } - async with AsyncSession( - headers=headers + async with StreamSession( + headers=headers, + proxies={"https": proxy} ) as session: - async with session.post("https://chatapi.ylokh.xyz/v1/chat/completions", json=data, proxy=proxy) as response: + async with session.post("https://chatapi.ylokh.xyz/v1/chat/completions", json=data) as response: response.raise_for_status() if stream: - async for line in response.content: + async for line in response.iter_lines(): line = line.decode() if line.startswith("data: "): if line.startswith("data: [DONE]"): break - line = json.loads(line[6:-1]) + line = json.loads(line[6:]) content = line["choices"][0]["delta"].get("content") if content: yield content -- cgit v1.2.3 From 88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Thu, 5 Oct 2023 05:13:37 +0200 Subject: Add AiAsk, Chatgpt4Online, ChatgptDemo and ChatgptX Provider Fix Bing, Liaobots and ChatgptAi Provider Add "gpt_35_long" model and custom timeout --- g4f/Provider/Ylokh.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'g4f/Provider/Ylokh.py') diff --git a/g4f/Provider/Ylokh.py b/g4f/Provider/Ylokh.py index 3c8b32dd..a15f7894 100644 --- a/g4f/Provider/Ylokh.py +++ b/g4f/Provider/Ylokh.py @@ -19,6 +19,7 @@ class Ylokh(AsyncGeneratorProvider): messages: list[dict[str, str]], stream: bool = True, proxy: str = None, + timeout: int = 30, **kwargs ) -> AsyncGenerator: model = model if model else "gpt-3.5-turbo" @@ -39,7 +40,8 @@ class Ylokh(AsyncGeneratorProvider): } async with StreamSession( headers=headers, - proxies={"https": proxy} + 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() -- cgit v1.2.3 From 6401084fd0d23b75a883888f70cd705e4cacd202 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sun, 8 Oct 2023 13:59:56 +0200 Subject: Add Messages and AsyncResult typing Add system_message in Yqcloud --- g4f/Provider/Ylokh.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'g4f/Provider/Ylokh.py') diff --git a/g4f/Provider/Ylokh.py b/g4f/Provider/Ylokh.py index a15f7894..59da0fa4 100644 --- a/g4f/Provider/Ylokh.py +++ b/g4f/Provider/Ylokh.py @@ -4,7 +4,7 @@ import json from ..requests import StreamSession from .base_provider import AsyncGeneratorProvider -from ..typing import AsyncGenerator +from ..typing import AsyncResult, Messages class Ylokh(AsyncGeneratorProvider): url = "https://chat.ylokh.xyz" @@ -16,16 +16,16 @@ class Ylokh(AsyncGeneratorProvider): async def create_async_generator( cls, model: str, - messages: list[dict[str, str]], + messages: Messages, stream: bool = True, proxy: str = None, - timeout: int = 30, + timeout: int = 120, **kwargs - ) -> AsyncGenerator: + ) -> AsyncResult: model = model if model else "gpt-3.5-turbo" headers = { - "Origin" : cls.url, - "Referer" : cls.url + "/", + "Origin" : cls.url, + "Referer": cls.url + "/", } data = { "messages": messages, @@ -69,6 +69,7 @@ class Ylokh(AsyncGeneratorProvider): ("messages", "list[dict[str, str]]"), ("stream", "bool"), ("proxy", "str"), + ("timeout", "int"), ("temperature", "float"), ("top_p", "float"), ] -- cgit v1.2.3