mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-27 16:04:21 +00:00
fix: 未经keymgr完整跟踪的key超额问题 #39
This commit is contained in:
+10
-2
@@ -194,8 +194,16 @@ class QQBotManager:
|
||||
self.notify_admin("{}会话调用API失败:{}".format(session_name, e))
|
||||
reply = "[bot]err:调用API失败,请重试或联系作者,或等待修复"
|
||||
except openai.error.RateLimitError as e:
|
||||
self.notify_admin("API调用额度超限,请向OpenAI账户充值或在config.py中更换api_key")
|
||||
reply = "[bot]err:API调用额度超额,请联系作者,或等待修复"
|
||||
# 尝试切换api-key
|
||||
pkg.openai.manager.get_inst().key_mgr.set_current_exceeded()
|
||||
switched, name = pkg.openai.manager.get_inst().key_mgr.auto_switch()
|
||||
|
||||
if not switched:
|
||||
self.notify_admin("API调用额度超限,请向OpenAI账户充值或在config.py中更换api_key")
|
||||
reply = "[bot]err:API调用额度超额,请联系作者,或等待修复"
|
||||
else:
|
||||
self.notify_admin("API调用额度超限,已切换到{}".format(name))
|
||||
reply = "[bot]err:API调用额度超额,已自动切换,请重新发送消息"
|
||||
except openai.error.InvalidRequestError as e:
|
||||
self.notify_admin("{}API调用参数错误:{}\n\n这可能是由于config.py中的prompt_submit_length参数或"
|
||||
"completion_api_params中的max_tokens参数数值过大导致的,请尝试将其降低".format(
|
||||
|
||||
Reference in New Issue
Block a user