fix gpt and 优化外观

This commit is contained in:
ivan deng
2023-04-16 00:19:09 +08:00
parent a5f3ba360a
commit 02cea839d3
2 changed files with 40 additions and 17 deletions

View File

@@ -52,10 +52,16 @@ class Channel(models.Model):
})
return context_history
def get_ai_config(self, ai):
# 勾子用于取ai 配置
return {}
def get_ai_response(self, ai, messages, channel, user_id, message):
author_id = message.create_uid.partner_id
answer_id = user_id.partner_id
res = ai.get_ai(messages, author_id, answer_id)
# todo: 只有个人配置的群聊才给配置
param = self.get_ai_config(ai)
res = ai.get_ai(messages, author_id, answer_id, param)
if res:
res = res.replace('\n', '<br/>')
channel.with_user(user_id).message_post(body=res, message_type='comment', subtype_xmlid='mail.mt_comment', parent_id=message.id)
@@ -120,7 +126,8 @@ class Channel(models.Model):
if message.body == _('<div class="o_mail_notification">joined the channel</div>'):
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()
# 不能用 preview 如果用 : 提示词则 preview信息丢失
msg = message.description.replace('@%s' % answer_id.name, '').lstrip()
if not msg:
return rdata
@@ -142,7 +149,6 @@ class Channel(models.Model):
# print('self.channel_type :',self.channel_type)
if ai:
# 非4版本取0次。其它取3 次历史
# todo: channel中只有2个人1个是ai1个不是的时候直接用ai回话不用处理 @
chat_count = 0 if '4' in ai.ai_model else 3
if author_id != answer_id.id and self.channel_type == 'chat':
# 私聊