diff --git a/app_chatgpt/__manifest__.py b/app_chatgpt/__manifest__.py index 21bea0f8..18ab3b37 100644 --- a/app_chatgpt/__manifest__.py +++ b/app_chatgpt/__manifest__.py @@ -10,7 +10,7 @@ { 'name': 'ChatGPT4, China Ali,AiGC Center.Ai服务中心,聚合全网Ai', - 'version': '23.10.19', + 'version': '24.03.06', 'author': 'odooai.cn', 'company': 'odooai.cn', 'maintainer': 'odooai.cn', @@ -48,19 +48,19 @@ 'app_odoo_customize', 'base_setup', 'mail', - 'queue_job', + # 'queue_job', ], 'data': [ 'security/ir.model.access.csv', 'security/ir_rules.xml', - 'data/mail_channel_data.xml', + 'data/discuss_channel_data.xml', 'data/ai_robot_data.xml', 'data/user_partner_data.xml', 'data/ir_config_parameter.xml', 'views/ai_robot_views.xml', 'views/res_partner_ai_use_views.xml', 'views/res_users_views.xml', - 'views/mail_channel_views.xml', + 'views/discuss_channel_views.xml', ], 'assets': { 'mail.assets_messaging': [ diff --git a/app_chatgpt/data/mail_channel_data.xml b/app_chatgpt/data/discuss_channel_data.xml similarity index 58% rename from app_chatgpt/data/mail_channel_data.xml rename to app_chatgpt/data/discuss_channel_data.xml index e4c8c70c..fa62a52d 100644 --- a/app_chatgpt/data/mail_channel_data.xml +++ b/app_chatgpt/data/discuss_channel_data.xml @@ -1,14 +1,14 @@ - + ChatGPT Group Chat ChatGPT话题 - mail.channel + discuss.channel email @@ -17,14 +17,7 @@

Please ask me any question.

]]>
- - - - - - - - +
diff --git a/app_chatgpt/i18n/zh_CN.po b/app_chatgpt/i18n/zh_CN.po index fd2ef90f..bfa31833 100644 --- a/app_chatgpt/i18n/zh_CN.po +++ b/app_chatgpt/i18n/zh_CN.po @@ -962,7 +962,7 @@ msgid "ChatGPT4 Azure" msgstr "" #. module: app_chatgpt -#: model:mail.channel,description:app_chatgpt.channel_chatgpt +#: model:discuss.channel,description:app_chatgpt.channel_chatgpt msgid "ChatGPT话题" msgstr "" diff --git a/app_chatgpt/models/__init__.py b/app_chatgpt/models/__init__.py index aadc6ff6..1eb4761c 100644 --- a/app_chatgpt/models/__init__.py +++ b/app_chatgpt/models/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from . import res_partner -from . import mail_channel +from . import discuss_channel from . import res_config_settings from . import ai_robot from . import res_partner_ai_use diff --git a/app_chatgpt/models/ai_robot.py b/app_chatgpt/models/ai_robot.py index 28cead77..156a25ff 100644 --- a/app_chatgpt/models/ai_robot.py +++ b/app_chatgpt/models/ai_robot.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -import openai.openai_object +# import openai.openai_object +import openai import requests, json import openai import base64 @@ -173,7 +174,7 @@ GPT-3 A set of models that can understand and generate natural language def get_ai_post(self, res, author_id=False, answer_id=False, param={}): # hook,高级版要替代 - if res and author_id and isinstance(res, openai.openai_object.OpenAIObject) or isinstance(res, list) or isinstance(res, dict): + if res and author_id and type(res) == openai.Completion or isinstance(res, list) or isinstance(res, dict): # 返回是个对象,那么就是ai # if isinstance(res, dict): if self.provider == 'openai': diff --git a/app_chatgpt/models/mail_channel.py b/app_chatgpt/models/discuss_channel.py similarity index 97% rename from app_chatgpt/models/mail_channel.py rename to app_chatgpt/models/discuss_channel.py index 0104d9d4..4f8aeaa6 100644 --- a/app_chatgpt/models/mail_channel.py +++ b/app_chatgpt/models/discuss_channel.py @@ -14,7 +14,7 @@ _logger = logging.getLogger(__name__) class Channel(models.Model): - _inherit = 'mail.channel' + _inherit = 'discuss.channel' is_private = fields.Boolean(string="Private", default=False, help="Check to set Private, Can only use by user, not Public") # 因为 channel_member_ids 不好处理,在此增加此字段 @@ -84,11 +84,8 @@ class Channel(models.Model): def name_get(self): result = [] for c in self: - if c.channel_type == 'channel' and c.is_private: - pre = '[私]' - else: - pre = '' - result.append((c.id, "%s%s" % (pre, c.name or ''))) + pre = '[私]' if c.channel_type == 'channel' and c.is_private else '' + result.append((c.id, f"{pre}{c.name or ''}")) return result def get_openai_context(self, channel_id, author_id, answer_id, minutes=60, chat_count=0): @@ -103,7 +100,7 @@ class Channel(models.Model): # todo: 更好的处理方式 domain = [('res_id', '=', channel_id), - ('model', '=', 'mail.channel'), + ('model', '=', 'discuss.channel'), ('message_type', '!=', 'user_notification'), ('parent_id', '!=', False), ('is_ai', '=', True), @@ -173,7 +170,7 @@ class Channel(models.Model): user_id = self.env['res.users'] author_id = msg_vals.get('author_id') ai = self.env['ai.robot'].sudo() - channel = self.env['mail.channel'] + channel = self.env['discuss.channel'] channel_type = self.channel_type messages = [] @@ -285,11 +282,11 @@ class Channel(models.Model): # 私聊 _logger.info(f'私聊:author_id:{author_id},partner_chatgpt.id:{answer_id.id}') channel = self.env[msg_vals.get('model')].browse(msg_vals.get('res_id')) - elif author_id != answer_id.id and msg_vals.get('model', '') == 'mail.channel' and msg_vals.get('res_id', 0) == chatgpt_channel_id.id: + elif author_id != answer_id.id and msg_vals.get('model', '') == 'discuss.channel' and msg_vals.get('res_id', 0) == chatgpt_channel_id.id: # todo: 公开的群聊,当前只开1个,后续更多 _logger.info(f'频道群聊:author_id:{author_id},partner_chatgpt.id:{answer_id.id}') channel = chatgpt_channel_id - elif author_id != answer_id.id and msg_vals.get('model', '') == 'mail.channel' and self.channel_type in ['group', 'channel']: + elif author_id != answer_id.id and msg_vals.get('model', '') == 'discuss.channel' and self.channel_type in ['group', 'channel']: # 高级用户自建的话题 channel = self.env[msg_vals.get('model')].browse(msg_vals.get('res_id')) if hasattr(channel, 'is_private') and channel.description: @@ -337,7 +334,7 @@ class Channel(models.Model): # todo: 优化,每次聊天进入时就 write user = self.env.user msgs = self.env['mail.message'].sudo().search([ - ('model', '=', 'mail.channel'), + ('model', '=', 'discuss.channel'), ('author_id', '=', user.partner_id.id), ], limit=3, order='id desc') c_id = 0 diff --git a/app_chatgpt/views/ai_robot_views.xml b/app_chatgpt/views/ai_robot_views.xml index fa28719d..03ddd0c7 100644 --- a/app_chatgpt/views/ai_robot_views.xml +++ b/app_chatgpt/views/ai_robot_views.xml @@ -68,8 +68,8 @@
-