diff options
author | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-05 05:13:37 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-05 05:13:37 +0200 |
commit | 88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9 (patch) | |
tree | 7e6e3b6c179cf1a695f9d80026d544a4fd3c5203 /g4f/Provider/Liaobots.py | |
parent | ~ | g4f v-0.1.4.8 - Fixed `g4f.Provider.Bing` (diff) | |
download | gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.tar gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.tar.gz gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.tar.bz2 gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.tar.lz gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.tar.xz gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.tar.zst gpt4free-88d2cbff099df00944ed6dfb6c73b1b5e8dfc7f9.zip |
Diffstat (limited to 'g4f/Provider/Liaobots.py')
-rw-r--r-- | g4f/Provider/Liaobots.py | 35 |
1 files changed, 27 insertions, 8 deletions
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: |