From f72c6d13deec568eb515580a5911d942efcccea3 Mon Sep 17 00:00:00 2001 From: LanQian <5499636+LanQian528@users.noreply.github.com> Date: Sat, 15 Jun 2024 15:16:18 +0800 Subject: [PATCH] v1.2.6 update pow --- chatgpt/ChatService.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/chatgpt/ChatService.py b/chatgpt/ChatService.py index 21bf71f..ba57ff4 100644 --- a/chatgpt/ChatService.py +++ b/chatgpt/ChatService.py @@ -180,22 +180,12 @@ class ChatService: "code": "model_not_found" }) + # turnstile = resp.get('turnstile', {}) + # turnstile_required = turnstile.get('required') + # if turnstile_required: + # raise HTTPException(status_code=403, detail="Turnstile required") + arkose = resp.get('arkose', {}) - proofofwork = resp.get('proofofwork', {}) - turnstile = resp.get('turnstile', {}) - - proofofwork_required = proofofwork.get('required') - if proofofwork_required: - proofofwork_diff = proofofwork.get("difficulty") - if proofofwork_diff <= pow_difficulty: - raise HTTPException(status_code=403, - detail=f"Proof of work difficulty too high: {proofofwork_diff}") - proofofwork_seed = proofofwork.get("seed") - self.proof_token, solved = await run_in_threadpool(get_answer_token, proofofwork_seed, - proofofwork_diff, config) - if not solved: - raise HTTPException(status_code=403, detail="Failed to solve proof of work") - arkose_required = arkose.get('required') if arkose_required: if not self.arkose_token_url: @@ -218,9 +208,18 @@ class ChatService: finally: await arkose_client.close() - turnstile_required = turnstile.get('required') - if turnstile_required: - raise HTTPException(status_code=403, detail="Turnstile required") + proofofwork = resp.get('proofofwork', {}) + proofofwork_required = proofofwork.get('required') + if proofofwork_required: + proofofwork_diff = proofofwork.get("difficulty") + if proofofwork_diff <= pow_difficulty: + raise HTTPException(status_code=403, + detail=f"Proof of work difficulty too high: {proofofwork_diff}") + proofofwork_seed = proofofwork.get("seed") + self.proof_token, solved = await run_in_threadpool(get_answer_token, proofofwork_seed, + proofofwork_diff, config) + if not solved: + raise HTTPException(status_code=403, detail="Failed to solve proof of work") self.chat_token = resp.get('token') if not self.chat_token: