Skip to content

Commit 720de9d

Browse files
committed
chore: strip content
1 parent 78332d8 commit 720de9d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

bot/session_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def build_session(self, session_id, system_prompt=None):
5050
如果session_id不在sessions中,创建一个新的session并添加到sessions中
5151
如果system_prompt不会空,会更新session的system_prompt并重置session
5252
'''
53+
if session_id is None:
54+
return self.sessioncls(session_id, system_prompt, **self.session_args)
55+
5356
if session_id not in self.sessions:
5457
self.sessions[session_id] = self.sessioncls(session_id, system_prompt, **self.session_args)
5558
elif system_prompt is not None: # 如果有新的system_prompt,更新并重置session

channel/chat_channel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ def _compose_context(self, ctype: ContextType, content, **kwargs):
111111

112112
img_match_prefix = check_prefix(content, conf().get('image_create_prefix'))
113113
if img_match_prefix:
114-
content = content.replace(img_match_prefix, '', 1).strip()
114+
content = content.replace(img_match_prefix, '', 1)
115115
context.type = ContextType.IMAGE_CREATE
116116
else:
117117
context.type = ContextType.TEXT
118-
context.content = content
118+
context.content = content.strip()
119119
if 'desire_rtype' not in context and conf().get('always_reply_voice') and ReplyType.VOICE not in self.NOT_SUPPORT_REPLYTYPE:
120120
context['desire_rtype'] = ReplyType.VOICE
121121
elif context.type == ContextType.VOICE:

0 commit comments

Comments
 (0)