diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-08-25 18:18:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 18:18:54 +0200 |
commit | 19a13c240a579a4fbdcf4ebb009732a19c80bf29 (patch) | |
tree | b8b7cd05ccdd614360b770aa519d488fee6f09d5 /g4f | |
parent | ~| Merge pull request #834 (diff) | |
parent | remove whitspace from data: and raise exception (diff) | |
download | gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.tar gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.tar.gz gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.tar.bz2 gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.tar.lz gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.tar.xz gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.tar.zst gpt4free-19a13c240a579a4fbdcf4ebb009732a19c80bf29.zip |
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/Provider/EasyChat.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/g4f/Provider/EasyChat.py b/g4f/Provider/EasyChat.py index 2a61346c..3c6562f0 100644 --- a/g4f/Provider/EasyChat.py +++ b/g4f/Provider/EasyChat.py @@ -75,16 +75,18 @@ class EasyChat(BaseProvider): if "choices" in json_data: yield json_data["choices"][0]["message"]["content"] else: - yield Exception("No response from server") + raise Exception("No response from server") else: for chunk in response.iter_lines(): if b"content" in chunk: - splitData = chunk.decode().split("data: ") + splitData = chunk.decode().split("data:") if len(splitData) > 1: yield json.loads(splitData[1])["choices"][0]["delta"]["content"] + else: + continue else: - yield Exception(f"Error {response.status_code} from server") + raise Exception(f"Error {response.status_code} from server : {response.reason}") @classmethod |