Skip to content

Commit 4cdcbcf

Browse files
committed
v1.8.6-beta2
1 parent 6820a42 commit 4cdcbcf

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

chatgpt/ChatService.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ async def get_chat_requirements(self):
211211
try:
212212
if turnstile_solver_url:
213213
res = await self.s.post(
214-
turnstile_solver_url, json={"url": "https://chatgpt.com", "p": p, "dx": turnstile_dx}
214+
turnstile_solver_url, json={"url": "https://chatgpt.com", "p": p, "dx": turnstile_dx, "ua": self.user_agent}
215215
)
216216
self.turnstile_token = res.json().get("t")
217217
except Exception as e:

gateway/backend.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ async def edge():
269269

270270
if no_sentinel:
271271
openai_sentinel_tokens_cache = {}
272+
openai_sentinel_cookies_cache = {}
272273

273274
@app.post("/backend-api/sentinel/chat-requirements")
274275
async def sentinel_chat_conversations(request: Request):
@@ -309,8 +310,12 @@ async def sentinel_chat_conversations(request: Request):
309310
config = get_config(user_agent, session_id)
310311
p = get_requirements_token(config)
311312
data = {'p': p}
312-
r = await clients.post(f'{host_url}/backend-api/sentinel/chat-requirements', headers=headers, json=data,
313-
timeout=10)
313+
for cookie in openai_sentinel_cookies_cache.get(req_token, []):
314+
clients.session.cookies.set(**cookie)
315+
r = await clients.post(f'{host_url}/backend-api/sentinel/chat-requirements', headers=headers, json=data, timeout=10)
316+
oai_sc = r.cookies.get("oai-sc")
317+
if oai_sc:
318+
openai_sentinel_cookies_cache[req_token] = [{"name": "oai-sc", "value": oai_sc}]
314319
if r.status_code != 200:
315320
raise HTTPException(status_code=r.status_code, detail="Failed to get chat requirements")
316321
resp = r.json()
@@ -321,7 +326,7 @@ async def sentinel_chat_conversations(request: Request):
321326
try:
322327
if turnstile_solver_url:
323328
res = await client.post(turnstile_solver_url,
324-
json={"url": "https://chatgpt.com", "p": p, "dx": turnstile_dx})
329+
json={"url": "https://chatgpt.com", "p": p, "dx": turnstile_dx, "ua": user_agent})
325330
turnstile_token = res.json().get("t")
326331
except Exception as e:
327332
logger.info(f"Turnstile ignored: {e}")
@@ -419,7 +424,7 @@ async def chat_conversations(request: Request):
419424
try:
420425
if turnstile_solver_url:
421426
res = await client.post(turnstile_solver_url,
422-
json={"url": "https://chatgpt.com", "p": p, "dx": turnstile_dx})
427+
json={"url": "https://chatgpt.com", "p": p, "dx": turnstile_dx, "ua": user_agent})
423428
turnstile_token = res.json().get("t")
424429
except Exception as e:
425430
logger.info(f"Turnstile ignored: {e}")

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8.6-beta1
1+
1.8.6-beta2

0 commit comments

Comments
 (0)