Keldos commited on
Commit
bc82369
1 Parent(s): fb66964

fix: 修复openai usage

Browse files

1. 是否用legacy之前写反了
2. 重构html相关函数后未import

Files changed (2) hide show
  1. modules/config.py +3 -2
  2. modules/models/models.py +1 -0
modules/config.py CHANGED
@@ -91,10 +91,11 @@ os.environ["OPENAI_API_KEY"] = my_api_key
91
  os.environ["OPENAI_EMBEDDING_API_KEY"] = my_api_key
92
 
93
  if config.get("legacy_api_usage", False):
 
 
94
  sensitive_id = config.get("sensitive_id", "")
95
  sensitive_id = os.environ.get("SENSITIVE_ID", sensitive_id)
96
- else:
97
- sensitive_id = my_api_key
98
 
99
  google_palm_api_key = config.get("google_palm_api_key", "")
100
  google_palm_api_key = os.environ.get(
 
91
  os.environ["OPENAI_EMBEDDING_API_KEY"] = my_api_key
92
 
93
  if config.get("legacy_api_usage", False):
94
+ sensitive_id = my_api_key
95
+ else:
96
  sensitive_id = config.get("sensitive_id", "")
97
  sensitive_id = os.environ.get("SENSITIVE_ID", sensitive_id)
98
+
 
99
 
100
  google_palm_api_key = config.get("google_palm_api_key", "")
101
  google_palm_api_key = os.environ.get(
modules/models/models.py CHANGED
@@ -96,6 +96,7 @@ class OpenAIClient(BaseLLMModel):
96
  # rounded_usage = "{:.5f}".format(usage_data["total_usage"] / 100)
97
  rounded_usage = round(usage_data["total_usage"] / 100, 5)
98
  usage_percent = round(usage_data["total_usage"] / usage_limit, 2)
 
99
  # return i18n("**本月使用金额** ") + f"\u3000 ${rounded_usage}"
100
  return get_html("billing_info.html").format(
101
  label = i18n("本月使用金额"),
 
96
  # rounded_usage = "{:.5f}".format(usage_data["total_usage"] / 100)
97
  rounded_usage = round(usage_data["total_usage"] / 100, 5)
98
  usage_percent = round(usage_data["total_usage"] / usage_limit, 2)
99
+ from ..webui import get_html
100
  # return i18n("**本月使用金额** ") + f"\u3000 ${rounded_usage}"
101
  return get_html("billing_info.html").format(
102
  label = i18n("本月使用金额"),