From 720de9d73f81ff8ad55732cfeec0416320a8915f Mon Sep 17 00:00:00 2001 From: lanvent Date: Sun, 16 Apr 2023 00:47:32 +0800 Subject: [PATCH] chore: strip content --- bot/session_manager.py | 3 +++ channel/chat_channel.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bot/session_manager.py b/bot/session_manager.py index cb05b68..ce189ed 100644 --- a/bot/session_manager.py +++ b/bot/session_manager.py @@ -50,6 +50,9 @@ class SessionManager(object): 如果session_id不在sessions中,创建一个新的session并添加到sessions中 如果system_prompt不会空,会更新session的system_prompt并重置session ''' + if session_id is None: + return self.sessioncls(session_id, system_prompt, **self.session_args) + if session_id not in self.sessions: self.sessions[session_id] = self.sessioncls(session_id, system_prompt, **self.session_args) elif system_prompt is not None: # 如果有新的system_prompt,更新并重置session diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 5ed0886..a89d0ad 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -111,11 +111,11 @@ class ChatChannel(Channel): img_match_prefix = check_prefix(content, conf().get('image_create_prefix')) if img_match_prefix: - content = content.replace(img_match_prefix, '', 1).strip() + content = content.replace(img_match_prefix, '', 1) context.type = ContextType.IMAGE_CREATE else: context.type = ContextType.TEXT - context.content = content + context.content = content.strip() if 'desire_rtype' not in context and conf().get('always_reply_voice') and ReplyType.VOICE not in self.NOT_SUPPORT_REPLYTYPE: context['desire_rtype'] = ReplyType.VOICE elif context.type == ContextType.VOICE: