mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-16 21:10:55 +08:00
v1.2.6 update pow
This commit is contained in:
parent
dda3c58dd0
commit
f72c6d13de
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user