返回提交历史
Modified
g4f/Provider/EasyChat.py
+5
-3
XFEstudio/gpt4free
remove whitspace from data: and raise exception
e56f9b7c
代码差异
1 个文件
+5
-3
@@ -75,16 +75,18 @@ class EasyChat(BaseProvider):
75
75
if "choices" in json_data:
76
76
yield json_data["choices"][0]["message"]["content"]
77
77
else:
78
yield Exception("No response from server")
78
raise Exception("No response from server")
79
79
else:
80
80
81
81
for chunk in response.iter_lines():
82
82
if b"content" in chunk:
83
splitData = chunk.decode().split("data: ")
83
splitData = chunk.decode().split("data:")
84
84
if len(splitData) > 1:
85
85
yield json.loads(splitData[1])["choices"][0]["delta"]["content"]
86
else:
87
continue
86
88
else:
87
yield Exception(f"Error {response.status_code} from server")
89
raise Exception(f"Error {response.status_code} from server : {response.reason}")
88
90
89
91
90
92
@classmethod