diff options
author | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-02 02:04:22 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-02 02:04:22 +0200 |
commit | eb0e2c6a93c3f21937457d13220ce2b7fca1f04a (patch) | |
tree | e0139cd399052db29326d502f9d738d1943c7bce /g4f/Provider/AItianhuSpace.py | |
parent | Change event loop policy on windows (diff) | |
download | gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.tar gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.tar.gz gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.tar.bz2 gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.tar.lz gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.tar.xz gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.tar.zst gpt4free-eb0e2c6a93c3f21937457d13220ce2b7fca1f04a.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/AItianhuSpace.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/g4f/Provider/AItianhuSpace.py b/g4f/Provider/AItianhuSpace.py index eb072db5..8805b1c0 100644 --- a/g4f/Provider/AItianhuSpace.py +++ b/g4f/Provider/AItianhuSpace.py @@ -2,7 +2,7 @@ from __future__ import annotations import random, json -from g4f.requests import AsyncSession +from ..requests import StreamSession from .base_provider import AsyncGeneratorProvider, format_prompt domains = { @@ -33,7 +33,7 @@ class AItianhuSpace(AsyncGeneratorProvider): domain = domains[model] url = f'https://{rand}{domain}' - async with AsyncSession(impersonate="chrome110", verify=False) as session: + async with StreamSession(impersonate="chrome110", verify=False) as session: data = { "prompt": format_prompt(messages), "options": {}, @@ -50,10 +50,10 @@ class AItianhuSpace(AsyncGeneratorProvider): } async with session.post(f"{url}/api/chat-process", json=data, headers=headers) as response: response.raise_for_status() - async for line in response.content: + async for line in response.iter_lines(): if b"platform's risk control" in line: raise RuntimeError("Platform's Risk Control") - line = json.loads(line.rstrip()) + line = json.loads(line) if "detail" in line: content = line["detail"]["choices"][0]["delta"].get("content") if content: |