Skip to content

Commit

Permalink
Merge pull request #9 from zhayujie/master
Browse files Browse the repository at this point in the history
chore: strip content
  • Loading branch information
congxuma committed Apr 16, 2023
2 parents f4f57a3 + 720de9d commit b797ee4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bot/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def build_session(self, session_id, system_prompt=None):
如果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
Expand Down
4 changes: 2 additions & 2 deletions channel/chat_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ def _compose_context(self, ctype: ContextType, content, **kwargs):

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:
Expand Down

0 comments on commit b797ee4

Please sign in to comment.