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/Liaobots.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'g4f/Provider/Liaobots.py') diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py index ea3e0d45..e65c3a0d 100644 --- a/g4f/Provider/Liaobots.py +++ b/g4f/Provider/Liaobots.py @@ -30,8 +30,8 @@ models = { } class Liaobots(AsyncGeneratorProvider): - url = "https://liaobots.com" - working = False + url = "https://liaobots.site" + working = True supports_gpt_35_turbo = True supports_gpt_4 = True _auth_code = None @@ -43,6 +43,7 @@ class Liaobots(AsyncGeneratorProvider): messages: list[dict[str, str]], auth: str = None, proxy: str = None, + timeout: int = 30, **kwargs ) -> AsyncGenerator: model = model if model in models else "gpt-3.5-turbo" @@ -54,13 +55,25 @@ class Liaobots(AsyncGeneratorProvider): "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36", } async with ClientSession( - headers=headers + headers=headers, timeout=timeout ) as session: - auth_code = auth if isinstance(auth, str) else cls._auth_code - if not auth_code: - async with session.post(cls.url + "/api/user", proxy=proxy, json={"authcode": ""}) as response: + cls._auth_code = auth if isinstance(auth, str) else cls._auth_code + if not cls._auth_code: + async with session.post( + "https://liaobots.work/recaptcha/api/login", + proxy=proxy, + data={"token": "abcdefghijklmnopqrst"}, + verify_ssl=False + ) as response: response.raise_for_status() - auth_code = cls._auth_code = json.loads(await response.text())["authCode"] + async with session.post( + "https://liaobots.work/api/user", + proxy=proxy, + json={"authcode": ""}, + verify_ssl=False + ) as response: + response.raise_for_status() + cls._auth_code = (await response.json(content_type=None))["authCode"] data = { "conversationId": str(uuid.uuid4()), "model": models[model], @@ -68,7 +81,13 @@ class Liaobots(AsyncGeneratorProvider): "key": "", "prompt": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully.", } - async with session.post(cls.url + "/api/chat", proxy=proxy, json=data, headers={"x-auth-code": auth_code}) as response: + async with session.post( + "https://liaobots.work/api/chat", + proxy=proxy, + json=data, + headers={"x-auth-code": cls._auth_code}, + verify_ssl=False + ) as response: response.raise_for_status() async for stream in response.content.iter_any(): if stream: -- cgit v1.2.3 From af9ed889c11f2ca5f1df96c40f072012a68b5713 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Fri, 6 Oct 2023 18:21:56 +0200 Subject: Fix timeout in create_async --- g4f/Provider/Liaobots.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'g4f/Provider/Liaobots.py') diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py index e65c3a0d..2e0154d5 100644 --- a/g4f/Provider/Liaobots.py +++ b/g4f/Provider/Liaobots.py @@ -1,9 +1,8 @@ from __future__ import annotations -import json import uuid -from aiohttp import ClientSession +from aiohttp import ClientSession, ClientTimeout from ..typing import AsyncGenerator from .base_provider import AsyncGeneratorProvider @@ -55,7 +54,7 @@ class Liaobots(AsyncGeneratorProvider): "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36", } async with ClientSession( - headers=headers, timeout=timeout + headers=headers, timeout=ClientTimeout(timeout) ) as session: cls._auth_code = auth if isinstance(auth, str) else cls._auth_code if not cls._auth_code: -- cgit v1.2.3 From 4fa6e9c0f597c07d2acf10732fe2aeda270c6ca6 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 7 Oct 2023 09:02:48 +0200 Subject: Add GptGod Provider Remove timeout from aiohttp providers Disable Opchatgpts and ChatgptLogin provider --- g4f/Provider/Liaobots.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'g4f/Provider/Liaobots.py') diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py index 2e0154d5..2ab96ce3 100644 --- a/g4f/Provider/Liaobots.py +++ b/g4f/Provider/Liaobots.py @@ -2,7 +2,7 @@ from __future__ import annotations import uuid -from aiohttp import ClientSession, ClientTimeout +from aiohttp import ClientSession from ..typing import AsyncGenerator from .base_provider import AsyncGeneratorProvider @@ -42,7 +42,6 @@ class Liaobots(AsyncGeneratorProvider): messages: list[dict[str, str]], auth: str = None, proxy: str = None, - timeout: int = 30, **kwargs ) -> AsyncGenerator: model = model if model in models else "gpt-3.5-turbo" @@ -54,7 +53,7 @@ class Liaobots(AsyncGeneratorProvider): "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36", } async with ClientSession( - headers=headers, timeout=ClientTimeout(timeout) + headers=headers ) as session: cls._auth_code = auth if isinstance(auth, str) else cls._auth_code if not cls._auth_code: -- cgit v1.2.3