yangtb24 commited on
Commit
b1e9de0
·
verified ·
1 Parent(s): 9da08a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -70
app.py CHANGED
@@ -435,76 +435,6 @@ def index():
435
  tpm = sum(token_counts)
436
 
437
  return jsonify({"rpm": rpm, "tpm": tpm})
438
-
439
- @app.route('/check_tokens', methods=['POST'])
440
- def check_tokens():
441
- tokens = request.json.get('tokens', [])
442
- test_model = os.environ.get(
443
- "TEST_MODEL",
444
- "Pro/google/gemma-2-9b-it"
445
- )
446
-
447
- with concurrent.futures.ThreadPoolExecutor(
448
- max_workers=10000
449
- ) as executor:
450
- future_to_token = {
451
- executor.submit(
452
- process_key, token, test_model
453
- ): token for token in tokens
454
- }
455
-
456
- results = []
457
- for future in concurrent.futures.as_completed(future_to_token):
458
- token = future_to_token[future]
459
- try:
460
- key_type = future.result()
461
- credit_summary = get_credit_summary(token)
462
- balance = (
463
- credit_summary.get("total_balance", 0)
464
- if credit_summary else 0
465
- )
466
- if key_type == "invalid":
467
- results.append(
468
- {
469
- "token": token,
470
- "type": "无效 KEY",
471
- "balance": balance,
472
- "message": "无法获取额度信息"
473
- }
474
- )
475
- elif key_type == "free":
476
- results.append(
477
- {
478
- "token": token,
479
- "type": "免费 KEY",
480
- "balance": balance,
481
- "message": "额度不足"
482
- }
483
- )
484
- elif key_type == "unverified":
485
- results.append(
486
- {
487
- "token": token,
488
- "type": "未实名 KEY",
489
- "balance": balance,
490
- "message": "无法使用指定模型"
491
- }
492
- )
493
- elif key_type == "valid":
494
- results.append(
495
- {
496
- "token": token,
497
- "type": "有效 KEY",
498
- "balance": balance,
499
- "message": "可以使用指定模型"
500
- }
501
- )
502
- except Exception as exc:
503
- logging.error(
504
- f"处理 Token {token} 生成异常: {exc}"
505
- )
506
-
507
- return jsonify(results)
508
 
509
  @app.route('/handsome/v1/models', methods=['GET'])
510
  def list_models():
 
435
  tpm = sum(token_counts)
436
 
437
  return jsonify({"rpm": rpm, "tpm": tpm})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
 
439
  @app.route('/handsome/v1/models', methods=['GET'])
440
  def list_models():