From a7e19354a6754be94bd6b2db9d0e63d5290d9c2c Mon Sep 17 00:00:00 2001 From: Chill Date: Wed, 26 Apr 2023 17:53:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#I6Z4L9=20[app=5Fchatgpt]=20message=5Fpos?= =?UTF-8?q?t=5Fafter=5Fhook=E5=B0=B1=E8=A6=81=E5=B0=86is=5Fai=E5=86=99?= =?UTF-8?q?=E5=85=A5=EF=BC=8C=E6=89=8D=E8=83=BD=E5=8F=8A=E6=97=B6=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=88=B0=E8=81=8A=E5=A4=A9=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_chatgpt/models/mail_channel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app_chatgpt/models/mail_channel.py b/app_chatgpt/models/mail_channel.py index 21cb7745..e7bb1fa9 100644 --- a/app_chatgpt/models/mail_channel.py +++ b/app_chatgpt/models/mail_channel.py @@ -67,7 +67,6 @@ class Channel(models.Model): if res: res = res.replace('\n', '
') new_msg = channel.with_user(user_id).message_post(body=res, message_type='comment', subtype_xmlid='mail.mt_comment', parent_id=message.id) - new_msg.write({'is_ai': True}) if usage: prompt_tokens = usage['prompt_tokens'] completion_tokens = usage['completion_tokens'] @@ -210,3 +209,8 @@ class Channel(models.Model): return rdata + def _message_post_after_hook(self, message, msg_vals): + if message.author_id.gpt_id: + if msg_vals['body'] not in [_('Response Timeout, please speak again.'), _('温馨提示:您发送的内容含有敏感词,请修改内容后再向我发送。')]: + message.is_ai = True + return super(Channel, self)._message_post_after_hook(message, msg_vals)