yangtb24 commited on
Commit
72588b7
1 Parent(s): e5dce64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -27,13 +27,17 @@ def get_credit_summary(api_key):
27
  response.raise_for_status()
28
  data = response.json().get("data", {})
29
  total_balance = data.get("totalBalance", 0)
30
- return {"total_balance": total_balance}
 
31
  except requests.exceptions.RequestException as e:
32
  logging.error(f"获取额度信息失败,API Key:{api_key},错误信息:{e}")
33
  return None
34
  except (KeyError, TypeError) as e:
35
  logging.error(f"解析额度信息失败,API Key:{api_key},错误信息:{e}")
36
  return None
 
 
 
37
 
38
  def test_model_availability(api_key, model_name):
39
  """
 
27
  response.raise_for_status()
28
  data = response.json().get("data", {})
29
  total_balance = data.get("totalBalance", 0)
30
+ # total_balance 转换为浮点数
31
+ return {"total_balance": float(total_balance)}
32
  except requests.exceptions.RequestException as e:
33
  logging.error(f"获取额度信息失败,API Key:{api_key},错误信息:{e}")
34
  return None
35
  except (KeyError, TypeError) as e:
36
  logging.error(f"解析额度信息失败,API Key:{api_key},错误信息:{e}")
37
  return None
38
+ except ValueError as e:
39
+ logging.error(f"total_balance 无法转换为浮点数,API Key:{api_key},错误信息:{e}")
40
+ return None
41
 
42
  def test_model_availability(api_key, model_name):
43
  """