Update app.py
Browse files
app.py
CHANGED
@@ -59,14 +59,17 @@ def get_credit_summary(api_key):
|
|
59 |
response.raise_for_status()
|
60 |
data = response.json().get("data", {})
|
61 |
total_balance = data.get("totalBalance", 0)
|
62 |
-
logging.info(f"API Key:{api_key},当前额度: {total_balance}")
|
63 |
return {"total_balance": float(total_balance)}
|
64 |
-
except
|
65 |
-
logging.error(f"获取额度信息失败,API Key:{api_key},尝试次数:{attempt+1}/{max_retries},错误信息:{e}")
|
66 |
if attempt < max_retries - 1:
|
67 |
time.sleep(retry_delay)
|
68 |
else:
|
69 |
-
logging.error(f"获取额度信息失败,API Key:{api_key},所有重试次数均已失败")
|
|
|
|
|
|
|
70 |
return None
|
71 |
|
72 |
FREE_MODEL_TEST_KEY = (
|
|
|
59 |
response.raise_for_status()
|
60 |
data = response.json().get("data", {})
|
61 |
total_balance = data.get("totalBalance", 0)
|
62 |
+
logging.info(f"获取额度,API Key:{api_key},当前额度: {total_balance}")
|
63 |
return {"total_balance": float(total_balance)}
|
64 |
+
except Timeout as e:
|
65 |
+
logging.error(f"获取额度信息失败,API Key:{api_key},尝试次数:{attempt+1}/{max_retries},错误信息:{e} (Timeout)")
|
66 |
if attempt < max_retries - 1:
|
67 |
time.sleep(retry_delay)
|
68 |
else:
|
69 |
+
logging.error(f"获取额度信息失败,API Key:{api_key},所有重试次数均已失败 (Timeout)")
|
70 |
+
except requests.exceptions.RequestException as e:
|
71 |
+
logging.error(f"获取额度信息失败,API Key:{api_key},错误信息:{e}")
|
72 |
+
return None
|
73 |
return None
|
74 |
|
75 |
FREE_MODEL_TEST_KEY = (
|