mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 11:42:44 +08:00
feat: 上报使用量信息时的异常处理
This commit is contained in:
parent
013a9def25
commit
1015c6fa1f
|
@ -25,12 +25,15 @@ class DataGatherer:
|
|||
self.load_from_db()
|
||||
|
||||
def report_to_server(self, subservice_name: str, count: int):
|
||||
try:
|
||||
config = pkg.utils.context.get_config()
|
||||
if hasattr(config, "report_usage") and not config.report_usage:
|
||||
return
|
||||
res = requests.get("http://rockchin.top:18989/usage?service_name=qchatgpt.{}&version={}&count={}".format(subservice_name, version, count))
|
||||
if res.status_code != 200 or res.text != "ok":
|
||||
logging.warning("report to server failed, status_code: {}, text: {}".format(res.status_code, res.text))
|
||||
except:
|
||||
return
|
||||
|
||||
def report_text_model_usage(self, model, text):
|
||||
key_md5 = pkg.utils.context.get_openai_manager().key_mgr.get_using_key_md5()
|
||||
|
|
Loading…
Reference in New Issue
Block a user