diff --git a/pkg/openai/session.py b/pkg/openai/session.py index 4a74e97..fc217ab 100644 --- a/pkg/openai/session.py +++ b/pkg/openai/session.py @@ -83,7 +83,7 @@ def load_sessions(): # 获取指定名称的session,如果不存在则创建一个新的 -def get_session(session_name: str): +def get_session(session_name: str) -> 'Session': global sessions if session_name not in sessions: sessions[session_name] = Session(session_name) diff --git a/pkg/qqbot/message.py b/pkg/qqbot/message.py index 4fb6b99..6871592 100644 --- a/pkg/qqbot/message.py +++ b/pkg/qqbot/message.py @@ -114,8 +114,12 @@ def process_normal_message(text_message: str, mgr, config, launcher_type: str, reply = handle_exception("{}会话调用API失败:{}".format(session_name, e), "[bot]err:RateLimitError,请重试或联系作者,或等待修复") except openai.error.InvalidRequestError as e: - reply = handle_exception("{}API调用参数错误:{}\n".format( - session_name, e), "[bot]err:API调用参数错误,请联系管理员,或等待修复") + if config.auto_reset: + session.reset() + reply = [tips_custom.session_auto_reset_message] + else: + reply = handle_exception("{}API调用参数错误:{}\n".format( + session_name, e), "[bot]err:API调用参数错误,请联系管理员,或等待修复") except openai.error.ServiceUnavailableError as e: reply = handle_exception("{}API调用服务不可用:{}".format(session_name, e), "[bot]err:API调用服务不可用,请重试或联系管理员,或等待修复") except Exception as e: diff --git a/pkg/qqbot/process.py b/pkg/qqbot/process.py index 5af3c08..3ae9543 100644 --- a/pkg/qqbot/process.py +++ b/pkg/qqbot/process.py @@ -74,7 +74,7 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes import config if config.income_msg_check: if mgr.reply_filter.is_illegal(text_message): - return MessageChain(Plain("[bot] 你的提问中有不合适的内容, 请更换措辞~")) + return MessageChain(Plain("[bot] 消息中存在不合适的内容, 请更换措辞")) pkg.openai.session.get_session(session_name).acquire_response_lock() diff --git a/tips-custom-template.py b/tips-custom-template.py index 4938084..639751d 100644 --- a/tips-custom-template.py +++ b/tips-custom-template.py @@ -34,4 +34,4 @@ command_reset_message = "[bot]会话已重置" command_reset_name_message = "[bot]会话已重置,使用场景预设:" # 会话自动重置时的提示 -session_auto_reset_message = "[bot]会话token超限,已自动重置" +session_auto_reset_message = "[bot]会话token超限,已自动重置,请重新发送消息"