diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-09-07 19:45:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 19:45:04 +0200 |
commit | 7ca1a59d95b52f94f674e8f981eab910b2f03518 (patch) | |
tree | ca506c3c152f3906a5b727a4cc6ebba1fd59d335 /g4f/Provider/Liaobots.py | |
parent | ~ | Merge pull request #869 from ahobsonsayers/add-console-script (diff) | |
parent | Fix imports in Bing (diff) | |
download | gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.gz gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.bz2 gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.lz gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.xz gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.tar.zst gpt4free-7ca1a59d95b52f94f674e8f981eab910b2f03518.zip |
Diffstat (limited to 'g4f/Provider/Liaobots.py')
-rw-r--r-- | g4f/Provider/Liaobots.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/g4f/Provider/Liaobots.py b/g4f/Provider/Liaobots.py index 2360c8a5..2cc5ff99 100644 --- a/g4f/Provider/Liaobots.py +++ b/g4f/Provider/Liaobots.py @@ -32,7 +32,6 @@ models = { class Liaobots(AsyncGeneratorProvider): url = "https://liaobots.com" working = True - supports_stream = True supports_gpt_35_turbo = True supports_gpt_4 = True _auth_code = None @@ -46,24 +45,24 @@ class Liaobots(AsyncGeneratorProvider): proxy: str = None, **kwargs ) -> AsyncGenerator: + model = model if model in models else "gpt-3.5-turbo" if proxy and "://" not in proxy: proxy = f"http://{proxy}" headers = { "authority": "liaobots.com", "content-type": "application/json", - "origin": "https://liaobots.com", - "referer": "https://liaobots.com/", + "origin": cls.url, + "referer": cls.url + "/", "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 ) as session: - model = model if model in models else "gpt-3.5-turbo" auth_code = auth if isinstance(auth, str) else cls._auth_code if not auth_code: - async with session.post("https://liaobots.com/api/user", proxy=proxy, json={"authcode": ""}) as response: + async with session.post(cls.url + "/api/user", proxy=proxy, json={"authcode": ""}) as response: response.raise_for_status() - auth_code = cls._auth_code = json.loads((await response.text()))["authCode"] + auth_code = cls._auth_code = json.loads(await response.text())["authCode"] data = { "conversationId": str(uuid.uuid4()), "model": models[model], @@ -71,10 +70,11 @@ 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("https://liaobots.com/api/chat", proxy=proxy, json=data, headers={"x-auth-code": auth_code}) as response: + async with session.post(cls.url + "/api/chat", proxy=proxy, json=data, headers={"x-auth-code": auth_code}) as response: response.raise_for_status() - async for line in response.content: - yield line.decode("utf-8") + async for stream in response.content.iter_any(): + if stream: + yield stream.decode() @classmethod |