Update app.py
Browse files
app.py
CHANGED
|
@@ -264,18 +264,7 @@ def key_is_valid(key, request_type):
|
|
| 264 |
if request_type == "invalid":
|
| 265 |
return False
|
| 266 |
|
| 267 |
-
|
| 268 |
-
if credit_summary is None:
|
| 269 |
-
return False
|
| 270 |
-
|
| 271 |
-
total_balance = credit_summary.get("total_balance", 0)
|
| 272 |
-
|
| 273 |
-
if request_type == "free":
|
| 274 |
-
return True
|
| 275 |
-
elif request_type == "paid" or request_type == "unverified":
|
| 276 |
-
return total_balance > 0
|
| 277 |
-
else:
|
| 278 |
-
return False
|
| 279 |
|
| 280 |
def check_authorization(request):
|
| 281 |
"""
|
|
@@ -320,17 +309,13 @@ def index():
|
|
| 320 |
@app.route('/check_tokens', methods=['POST'])
|
| 321 |
def check_tokens():
|
| 322 |
tokens = request.json.get('tokens', [])
|
| 323 |
-
test_model = os.environ.get(
|
| 324 |
-
"TEST_MODEL",
|
| 325 |
-
"Pro/google/gemma-2-9b-it"
|
| 326 |
-
)
|
| 327 |
|
| 328 |
with concurrent.futures.ThreadPoolExecutor(
|
| 329 |
max_workers=1000
|
| 330 |
) as executor:
|
| 331 |
future_to_token = {
|
| 332 |
executor.submit(
|
| 333 |
-
process_key, token
|
| 334 |
): token for token in tokens
|
| 335 |
}
|
| 336 |
|
|
@@ -353,24 +338,6 @@ def check_tokens():
|
|
| 353 |
"message": "无法获取额度信息"
|
| 354 |
}
|
| 355 |
)
|
| 356 |
-
elif key_type == "free":
|
| 357 |
-
results.append(
|
| 358 |
-
{
|
| 359 |
-
"token": token,
|
| 360 |
-
"type": "免费 KEY",
|
| 361 |
-
"balance": balance,
|
| 362 |
-
"message": "额度不足"
|
| 363 |
-
}
|
| 364 |
-
)
|
| 365 |
-
elif key_type == "unverified":
|
| 366 |
-
results.append(
|
| 367 |
-
{
|
| 368 |
-
"token": token,
|
| 369 |
-
"type": "未实名 KEY",
|
| 370 |
-
"balance": balance,
|
| 371 |
-
"message": "无法使用指定模型"
|
| 372 |
-
}
|
| 373 |
-
)
|
| 374 |
elif key_type == "valid":
|
| 375 |
results.append(
|
| 376 |
{
|
|
|
|
| 264 |
if request_type == "invalid":
|
| 265 |
return False
|
| 266 |
|
| 267 |
+
return total_balance > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
def check_authorization(request):
|
| 270 |
"""
|
|
|
|
| 309 |
@app.route('/check_tokens', methods=['POST'])
|
| 310 |
def check_tokens():
|
| 311 |
tokens = request.json.get('tokens', [])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
with concurrent.futures.ThreadPoolExecutor(
|
| 314 |
max_workers=1000
|
| 315 |
) as executor:
|
| 316 |
future_to_token = {
|
| 317 |
executor.submit(
|
| 318 |
+
process_key, token
|
| 319 |
): token for token in tokens
|
| 320 |
}
|
| 321 |
|
|
|
|
| 338 |
"message": "无法获取额度信息"
|
| 339 |
}
|
| 340 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
elif key_type == "valid":
|
| 342 |
results.append(
|
| 343 |
{
|