diff options
author | Commenter123321 <36051603+Commenter123321@users.noreply.github.com> | 2023-10-09 18:02:06 +0200 |
---|---|---|
committer | Commenter123321 <36051603+Commenter123321@users.noreply.github.com> | 2023-10-09 18:02:06 +0200 |
commit | 119817c96349807efaf87ee432ce46446542b66a (patch) | |
tree | 1dbdf4d4dbf4f6c8a8247274ef500a2f1de765d1 /g4f/Provider/Liaobots.py | |
parent | aivvm's no life creator keeps patching it, but I'm just better 😉 (diff) | |
parent | Merge branch 'main' of https://github.com/xtekky/gpt4free (diff) | |
download | gpt4free-119817c96349807efaf87ee432ce46446542b66a.tar gpt4free-119817c96349807efaf87ee432ce46446542b66a.tar.gz gpt4free-119817c96349807efaf87ee432ce46446542b66a.tar.bz2 gpt4free-119817c96349807efaf87ee432ce46446542b66a.tar.lz gpt4free-119817c96349807efaf87ee432ce46446542b66a.tar.xz gpt4free-119817c96349807efaf87ee432ce46446542b66a.tar.zst gpt4free-119817c96349807efaf87ee432ce46446542b66a.zip |
Diffstat (limited to 'g4f/Provider/Liaobots.py')
-rw-r--r-- | g4f/Provider/Liaobots.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py index ea3e0d45..2ab96ce3 100644 --- a/g4f/Provider/Liaobots.py +++ b/g4f/Provider/Liaobots.py @@ -1,6 +1,5 @@ from __future__ import annotations -import json import uuid from aiohttp import ClientSession @@ -30,8 +29,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 @@ -56,11 +55,23 @@ class Liaobots(AsyncGeneratorProvider): async with ClientSession( headers=headers ) 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 +79,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: |