返回提交历史
Modified
g4f/Provider/Yupp.py
+12
-1
XFEstudio/gpt4free
Update Yupp.py
fix 429 'Too Many Requests'
2ab3f8e3
代码差异
1 个文件
+12
-1
@@ -108,6 +108,8 @@ async def claim_yupp_reward(session: aiohttp.ClientSession, account: Dict[str, A
108
108
headers = {
109
109
"Content-Type": "application/json",
110
110
"Cookie": f"__Secure-yupp.session-token={account['token']}",
111
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0",
112
111
113
}
112
114
async with session.post(url, json=payload, headers=headers) as response:
113
115
response.raise_for_status()
@@ -135,6 +137,8 @@ async def make_chat_private(session: aiohttp.ClientSession, account: Dict[str, A
135
137
headers = {
136
138
"Content-Type": "application/json",
137
139
"Cookie": f"__Secure-yupp.session-token={account['token']}",
140
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0",
141
138
142
}
139
143
140
144
async with session.post(url, json=payload, headers=headers) as response:
@@ -248,7 +252,10 @@ class Yupp(AsyncGeneratorProvider, ProviderModelMixin):
248
252
json={
249
253
"0": {"json": {"fileName": name, "fileSize": len(data), "contentType": is_accepted_format(data)}}},
250
254
headers={"Content-Type": "application/json",
251
"Cookie": f"__Secure-yupp.session-token={account['token']}"}
255
"Cookie": f"__Secure-yupp.session-token={account['token']}",
256
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0",
257
258
}
252
259
)
253
260
presigned_resp.raise_for_status()
254
261
upload_info = (await presigned_resp.json())[0]["result"]["data"]["json"]
@@ -377,6 +384,7 @@ class Yupp(AsyncGeneratorProvider, ProviderModelMixin):
377
384
"content-type": "text/plain;charset=UTF-8",
378
385
"next-action": next_action,
379
386
"cookie": f"__Secure-yupp.session-token={account['token']}",
387
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0",
380
388
}
381
389
382
390
log_debug(f"Sending request to: {url}")
@@ -413,6 +421,9 @@ class Yupp(AsyncGeneratorProvider, ProviderModelMixin):
413
421
# No Available Yupp credits
414
422
if e.status == 500 and 'Internal Server Error' in e.message:
415
423
account["is_valid"] = False
424
# Need User-Agent
425
# elif e.status == 429 and 'Too Many Requests' in e.message:
426
# account["is_valid"] = False
416
427
else:
417
428
async with account_rotation_lock:
418
429
account["error_count"] += 1