summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Liaobots.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider/Liaobots.py')
-rw-r--r--g4f/Provider/Liaobots.py33
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: