diff --git a/app_chatgpt/data/ai_robot_data.xml b/app_chatgpt/data/ai_robot_data.xml
index 7bdc64a2..b02ea95f 100644
--- a/app_chatgpt/data/ai_robot_data.xml
+++ b/app_chatgpt/data/ai_robot_data.xml
@@ -18,7 +18,7 @@
https://api.openai.com/v1/chat/completions
7
-
+
ChatGPT Azure
azure
https://my.openai.azure.com
diff --git a/app_chatgpt/data/user_partner_data.xml b/app_chatgpt/data/user_partner_data.xml
index 682a32ad..00b800fe 100644
--- a/app_chatgpt/data/user_partner_data.xml
+++ b/app_chatgpt/data/user_partner_data.xml
@@ -47,31 +47,31 @@
-
- ChatGPT Azure
-
+
+ ChatGPT3 Azure
+
-
- chatgpt3@sunpop.cn
- chatgpt3@sunpop.cn
+
+ chatgpt3_azure@odooai.cn
+ chatgpt3_azure@odooai.cn
chatgpt
-
-
+
+
ChatGPT4 Azure
-
+
- chatgpt4@sunpop.cn
- chatgpt4@sunpop.cn
+ chatgpt4_azure@odooai.cn
+ chatgpt4_azure@odooai.cn
chatgpt
-
+
diff --git a/app_chatgpt/models/ai_robot.py b/app_chatgpt/models/ai_robot.py
index 545ae76d..b41a90c7 100644
--- a/app_chatgpt/models/ai_robot.py
+++ b/app_chatgpt/models/ai_robot.py
@@ -125,12 +125,13 @@ GPT-3 A set of models that can understand and generate natural language
return res_post
def get_ai_pre(self, data, author_id=False, answer_id=False, **kwargs):
- search = WordsSearch()
- search.SetKeywords([])
- content = data[0]['content']
- sensi = search.FindFirst(content)
- if sensi is not None:
- return _('温馨提示:您发送的内容含有敏感词,请修改内容后再向我发送。')
+ if self.is_filtering:
+ search = WordsSearch()
+ search.SetKeywords([])
+ content = data[0]['content']
+ sensi = search.FindFirst(content)
+ if sensi is not None:
+ return _('温馨提示:您发送的内容含有敏感词,请修改内容后再向我发送。')
else:
return False
@@ -231,10 +232,11 @@ GPT-3 A set of models that can understand and generate natural language
messages = data
else:
messages = [{"role": "user", "content": data}]
- # Ai角色设定
- sys_content = self.get_ai_system(kwargs.get('sys_content'))
- if sys_content:
- messages.insert(0, sys_content)
+ # Ai角色设定,如果没设定则再处理
+ if messages[0].get('role') != 'system':
+ sys_content = self.get_ai_system(kwargs.get('sys_content'))
+ if sys_content:
+ messages.insert(0, sys_content)
response = openai.ChatCompletion.create(
model=self.ai_model,
messages=messages,
@@ -300,9 +302,12 @@ GPT-3 A set of models that can understand and generate natural language
else:
messages = [{"role": "user", "content": data}]
# Ai角色设定
- sys_content = self.get_ai_system(kwargs.get('sys_content'))
- if sys_content:
- messages.insert(0, sys_content)
+
+ # Ai角色设定,如果没设定则再处理
+ if messages[0].role != 'system':
+ sys_content = self.get_ai_system(kwargs.get('sys_content'))
+ if sys_content:
+ messages.insert(0, sys_content)
response = openai.ChatCompletion.create(
engine=self.engine,
messages=messages,
diff --git a/app_chatgpt/models/lib/sensi_words.txt b/app_chatgpt/models/lib/sensi_words.txt
index 555bcd94..186acecd 100644
--- a/app_chatgpt/models/lib/sensi_words.txt
+++ b/app_chatgpt/models/lib/sensi_words.txt
@@ -1,5 +1,6 @@
回民吃猪肉
习近平
+李强
TMD
毛民进党
妹妹淫水 流
@@ -331,7 +332,6 @@ meimei的小阴户
毛佳静安定片
鸟gm
骚屄
-TeSt
激情电影免费下载裸体美女乳房图
日翻
美臀嫰穴
@@ -1638,7 +1638,6 @@ h站
淫穢
做爱电影
免费淫奸女A片段试看 强*十八岁meinv护士看完保证你打飞机
-Test
meinv 淫穴
peng peng bang
毛鸦片液
@@ -8993,7 +8992,6 @@ mo擦小肥穴
骚姐乱伦
無套自拍
白虎少婦
-test
毛麻醉药
wu jin de ren wu
粗大的阴茎与紧窄的阴道壁之间的剧烈磨擦
@@ -13692,7 +13690,6 @@ Tora Tora Gold Vol。14 星野みく
肉棒里插肉洞
亚甲二氧基甲基安非他明
人民
-TEsT
中国成人论坛
几巴
免费免注册在线淫电影
@@ -14071,7 +14068,6 @@ tibetalk
伱妈
(桃太郎)ファーストアナル生中出しSpecial 佐藤江梨花 特典
毛我妳老爸
-tEST
激情淫穴的嫂嫂
毛机巴
代挂
@@ -14187,7 +14183,6 @@ da qing di guo
王寶森
淫浆
高级淫口手淫口交
-tESt
金瓶梅免费电影院
毛李山
淫洞
@@ -14207,7 +14202,6 @@ BITCH
揚震
www。gpchina。com
怎样延迟射精24岁以下禁
-测试员
18dy桃色
xing fu hua yuan
穴
@@ -14394,7 +14388,6 @@ fuck生鸦片
丝袜写真
调理劳务系
激情淫穴小
-测试員
da tang hao xia
干死 狂插 操
我周容
diff --git a/app_chatgpt/models/mail_channel.py b/app_chatgpt/models/mail_channel.py
index 744b4a01..a5e2b153 100644
--- a/app_chatgpt/models/mail_channel.py
+++ b/app_chatgpt/models/mail_channel.py
@@ -23,13 +23,16 @@ class Channel(models.Model):
# 处理消息: 取最新问题 + 上 chat_count=1次的交互,将之前的交互按时间顺序拼接。
# 注意: ai 每一次回复都有 parent_id 来处理连续性
# 私聊处理
+
+ # todo: 更好的处理方式
domain = [('res_id', '=', channel_id),
('model', '=', 'mail.channel'),
('message_type', '!=', 'user_notification'),
('parent_id', '!=', False),
('author_id', '=', answer_id.id),
('body', '!=', '%s
' % _('Response Timeout, please speak again.')),
- ('body', '!=', '温馨提示:您发送的内容含有敏感词,请修改内容后再向我发送。')]
+ ('body', '!=', _('温馨提示:您发送的内容含有敏感词,请修改内容后再向我发送。'))]
+
if self.channel_type in ['group', 'channel']:
# 群聊增加时间限制,当前找所有人,不限制 author_id
domain += [('date', '>=', afterTime)]
@@ -64,7 +67,14 @@ class Channel(models.Model):
user_id = self.env['res.users']
author_id = msg_vals.get('author_id')
ai = self.env['ai.robot']
+ channel = self.env['mail.channel']
channel_type = self.channel_type
+ messages = []
+
+ # 不处理 一般notify,但处理欢迎
+ if 'joined the channel
'):
+ return rdata
+
if channel_type == 'chat':
channel_partner_ids = self.channel_partner_ids
answer_id = channel_partner_ids - message.author_id
@@ -80,22 +90,38 @@ class Channel(models.Model):
# partner_ids = @ ids
partner_ids = list(msg_vals.get('partner_ids'))
if partner_ids:
+ # 常规群聊 @
partners = self.env['res.partner'].search([('id', 'in', partner_ids)])
- # user_id = user has binded gpt robot
+ # user_id = user, who has binded gpt robot
user_id = partners.mapped('user_ids').filtered(lambda r: r.gpt_id)[:1]
- if user_id:
- gpt_policy = user_id.gpt_policy
- gpt_wl_partners = user_id.gpt_wl_partners
- is_allow = message.author_id.id in gpt_wl_partners.ids
- answer_id = user_id.partner_id
- if gpt_policy == 'all' or (gpt_policy == 'limit' and is_allow):
- ai = user_id.gpt_id
+ elif message.body == _('joined the channel
'):
+ # 欢迎的情况
+ partners = self.channel_partner_ids.filtered(lambda r: r.gpt_id)[:1]
+ user_id = partners.mapped('user_ids')[:1]
+ elif self.member_count == 2:
+ # 处理独聊频道
+ if hasattr(self, 'is_private') and not self.is_private:
+ # 2个人的非私有频道不处理
+ pass
+ else:
+ partners = self.channel_partner_ids.filtered(lambda r: r.gpt_id)[:1]
+ user_id = partners.mapped('user_ids')[:1]
+
+ if user_id:
+ gpt_policy = user_id.gpt_policy
+ gpt_wl_partners = user_id.gpt_wl_partners
+ is_allow = message.author_id.id in gpt_wl_partners.ids
+ answer_id = user_id.partner_id
+ if gpt_policy == 'all' or (gpt_policy == 'limit' and is_allow):
+ ai = user_id.gpt_id
chatgpt_channel_id = self.env.ref('app_chatgpt.channel_chatgpt')
- msg = message.preview.replace('@%s' % answer_id.name, '').lstrip()
- # print('prompt:', prompt)
- # print('-----')
+ if message.body == _('joined the channel
'):
+ msg = _("Please warmly welcome our new partner %s and send him the best wishes.") % message.author_id.name
+ else:
+ msg = message.preview.replace('@%s' % answer_id.name, '').lstrip()
+
if not msg:
return rdata
# api_key = self.env['ir.config_parameter'].sudo().get_param('app_chatgpt.openapi_api_key')
@@ -116,24 +142,27 @@ class Channel(models.Model):
# print('self.channel_type :',self.channel_type)
if ai:
# 非4版本,取0次。其它取3 次历史
+ # todo: channel中只有2个人,1个是ai,1个不是的时候,直接用ai回话,不用处理 @
chat_count = 0 if '4' in ai.ai_model else 3
if author_id != answer_id.id and self.channel_type == 'chat':
# 私聊
_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:
- # 公开的群聊
+ # 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']:
- # 其它群聊
- channel = self
+ # 高级用户自建的话题
+ channel = self.env[msg_vals.get('model')].browse(msg_vals.get('res_id'))
+ if hasattr(channel, 'is_private') and channel.description:
+ messages.append({"role": "system", "content": channel.description})
try:
- messages = [{"role": "user", "content": msg}]
c_history = self.get_openai_context(channel.id, author_id, answer_id, openapi_context_timeout, chat_count)
if c_history:
- messages += c_history
+ messages = messages + c_history
+ messages.append({"role": "user", "content": msg})
if sync_config == 'sync':
self.get_ai_response(ai, messages, channel, user_id, message)
else:
diff --git a/app_chatgpt/static/description/chatgpt_blue.png b/app_chatgpt/static/description/chatgpt_blue.png
new file mode 100644
index 00000000..1e94178f
Binary files /dev/null and b/app_chatgpt/static/description/chatgpt_blue.png differ
diff --git a/app_chatgpt/views/ai_robot_views.xml b/app_chatgpt/views/ai_robot_views.xml
index 1ea0a57e..8c224aef 100644
--- a/app_chatgpt/views/ai_robot_views.xml
+++ b/app_chatgpt/views/ai_robot_views.xml
@@ -39,6 +39,7 @@
+