Keldos commited on
Commit
d2d74c3
·
1 Parent(s): cf3ed81

refactor: 分离用量账单进度条的html

Browse files
assets/html/billing_info.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <b>{label}</b>
2
+ <div class="progress-bar">
3
+ <div class="progress" style="width: {usage_percent}%;">
4
+ <span class="progress-text">{usage_percent}%</span>
5
+ </div>
6
+ </div>
7
+ <div style="display: flex; justify-content: space-between;">
8
+ <span>${rounded_usage}</span><span>${usage_limit}</span>
9
+ </div>
modules/models/models.py CHANGED
@@ -93,15 +93,12 @@ class OpenAIClient(BaseLLMModel):
93
  rounded_usage = round(usage_data["total_usage"] / 100, 5)
94
  usage_percent = round(usage_data["total_usage"] / usage_limit, 2)
95
  # return i18n("**本月使用金额** ") + f"\u3000 ${rounded_usage}"
96
- return """\
97
- <b>""" + i18n("本月使用金额") + f"""</b>
98
- <div class="progress-bar">
99
- <div class="progress" style="width: {usage_percent}%;">
100
- <span class="progress-text">{usage_percent}%</span>
101
- </div>
102
- </div>
103
- <div style="display: flex; justify-content: space-between;"><span>${rounded_usage}</span><span>${usage_limit}</span></div>
104
- """
105
  except requests.exceptions.ConnectTimeout:
106
  status_text = (
107
  STANDARD_ERROR_MSG + CONNECTION_TIMEOUT_MSG + ERROR_RETRIEVE_MSG
 
93
  rounded_usage = round(usage_data["total_usage"] / 100, 5)
94
  usage_percent = round(usage_data["total_usage"] / usage_limit, 2)
95
  # return i18n("**本月使用金额** ") + f"\u3000 ${rounded_usage}"
96
+ return get_html("billing_info.html").format(
97
+ label = i18n("本月使用金额"),
98
+ usage_percent = usage_percent,
99
+ rounded_usage = rounded_usage,
100
+ usage_limit = usage_limit
101
+ )
 
 
 
102
  except requests.exceptions.ConnectTimeout:
103
  status_text = (
104
  STANDARD_ERROR_MSG + CONNECTION_TIMEOUT_MSG + ERROR_RETRIEVE_MSG