perf: 调用OpenAI时的异常处理

This commit is contained in:
Rock Chin 2022-12-08 16:52:41 +08:00
parent 48171786e4
commit acf6110a85

View File

@ -118,7 +118,10 @@ class QQBotManager:
else: # 消息
session = pkg.openai.session.get_session(session_name)
reply = "[GPT]" + session.append(text_message)
try:
reply = "[GPT]" + session.append(text_message)
except Exception as e:
reply = "[bot]err:{}".format(e)
return reply
@ -147,7 +150,7 @@ class QQBotManager:
continue
if failed == self.retry:
reply = "err:请求超时"
reply = "[bot]err:请求超时"
processing.remove("person_{}".format(event.sender.id))