XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

feat(g4f/Provider/ChatGpt.py): enhance error handling and add debugging 2

cba121da
kqlio67 <kqlio67@users.noreply.github.com>
提交于

代码差异

1 个文件 +3 -5
Modified g4f/Provider/ChatGpt.py +3 -5
@@ -136,7 +136,6 @@ class ChatGpt(AbstractProvider, ProviderModelMixin):
136 136 response = session.post('https://chatgpt.com/backend-anon/sentinel/chat-requirements',
137 137 headers=headers, json={'p': pow_req})
138 138
139 # Додана перевірка на статус відповідей, якщо "незвична активність"
140 139 if response.status_code != 200:
141 140 print(f"Request failed with status: {response.status_code}")
142 141 print(f"Response content: {response.content}")
@@ -199,7 +198,6 @@ class ChatGpt(AbstractProvider, ProviderModelMixin):
199 198 },
200 199 }
201 200
202 # Додав паузу між запитами для уникнення блокувань через частоту
203 201 time.sleep(2)
204 202
205 203 response = session.post('https://chatgpt.com/backend-anon/conversation',
@@ -209,10 +207,10 @@ class ChatGpt(AbstractProvider, ProviderModelMixin):
209 207 for line in response.iter_lines():
210 208 if line:
211 209 decoded_line = line.decode()
212 print(f"Received line: {decoded_line}") # Debugging output
210 print(f"Received line: {decoded_line}")
213 211 if decoded_line.startswith('data:'):
214 json_string = decoded_line[6:] # Extract JSON part after 'data:'
215 if json_string.strip(): # Check if there's actual content
212 json_string = decoded_line[6:]
213 if json_string.strip():
216 214 try:
217 215 data = json.loads(json_string)
218 216 except json.JSONDecodeError as e: