diff --git a/app_chatgpt/__manifest__.py b/app_chatgpt/__manifest__.py index adbd78a2..1a4bdfbf 100644 --- a/app_chatgpt/__manifest__.py +++ b/app_chatgpt/__manifest__.py @@ -45,6 +45,7 @@ ''', 'depends': [ 'base', + 'app_common', 'base_setup', 'mail', 'queue_job', diff --git a/app_chatgpt/models/mail_channel.py b/app_chatgpt/models/mail_channel.py index c8474c7b..108fa986 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.addons.app_common.models.base import get_ua_type import logging _logger = logging.getLogger(__name__) @@ -65,7 +66,7 @@ class Channel(models.Model): param = self.get_ai_config(ai) res, usage, is_ai = ai.get_ai(messages, author_id, answer_id, param) if res: - if self.get_ua_type() != 'wxweb': + if get_ua_type() != 'wxweb': # 处理当微信语音返回时,是直接回文本信息,不需要转换回车 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) diff --git a/app_common/controllers/main.py b/app_common/controllers/main.py index 2637f060..2e7e21f4 100644 --- a/app_common/controllers/main.py +++ b/app_common/controllers/main.py @@ -33,7 +33,7 @@ class AppController(http.Controller): # https://github.com/selwin/python-user-agents ua_string = request.httprequest.headers.get('User-Agent') user_agent = parse(ua_string) - ua_type = self.get_ua_type() + ua_type = get_ua_type() ustr = "Request UA:
%s
Parse UA:
%s
UA Type:
%s
" % (ua_string, str(user_agent), ua_type) return request.make_response(ustr, [('Content-Type', 'text/html')])