From 1ffe68bd415f2b29d6d7d1c857392003a8e7328a Mon Sep 17 00:00:00 2001 From: Chill Date: Wed, 19 Jul 2023 18:45:40 +0800 Subject: [PATCH] fix gpt history context domain --- app_chatgpt/models/mail_channel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app_chatgpt/models/mail_channel.py b/app_chatgpt/models/mail_channel.py index 108fa986..e9031663 100644 --- a/app_chatgpt/models/mail_channel.py +++ b/app_chatgpt/models/mail_channel.py @@ -6,6 +6,7 @@ import datetime # from transformers import TextDavinciTokenizer, TextDavinciModel from odoo import api, fields, models, tools, _ from odoo.exceptions import UserError +from odoo.osv import expression from odoo.addons.app_common.models.base import get_ua_type import logging @@ -30,13 +31,14 @@ class Channel(models.Model): ('model', '=', 'mail.channel'), ('message_type', '!=', 'user_notification'), ('parent_id', '!=', False), - ('author_id', '=', answer_id.id), ('body', '!=', '

%s

' % _('Response Timeout, please speak again.')), ('body', '!=', _('温馨提示:您发送的内容含有敏感词,请修改内容后再向我发送。'))] if self.channel_type in ['group', 'channel']: # 群聊增加时间限制,当前找所有人,不限制 author_id - domain += [('date', '>=', afterTime)] + domain = expression.AND([domain, [('date', '>=', afterTime)]]) + else: + domain = expression.AND([domain, [('author_id', '=', answer_id.id)]]) ai_msg_list = message_model.with_context(tz='UTC').search(domain, order="id desc", limit=chat_count) for ai_msg in ai_msg_list: # 判断这个 ai_msg 是不是ai发,有才 insert。 判断 user_msg 是不是 user发的,有才 insert