From efc9bae678efc12f089ad39ce7f06aac6df52875 Mon Sep 17 00:00:00 2001 From: Chill Date: Mon, 6 Jan 2025 17:50:59 +0800 Subject: [PATCH] [18] app_chatgpt --- app_chatgpt/models/discuss_channel.py | 6 +++-- app_chatgpt/views/ai_robot_views.xml | 38 +++++++++++---------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/app_chatgpt/models/discuss_channel.py b/app_chatgpt/models/discuss_channel.py index 4357ead7..698c2ebf 100644 --- a/app_chatgpt/models/discuss_channel.py +++ b/app_chatgpt/models/discuss_channel.py @@ -3,6 +3,7 @@ import openai import requests, json import datetime +from markupsafe import Markup # from transformers import TextDavinciTokenizer, TextDavinciModel from odoo import api, fields, models, tools, _ from odoo.exceptions import UserError @@ -126,7 +127,7 @@ class Channel(models.Model): 'content': ai_content, }) if not user_msg.author_id.gpt_id: - user_content = user_msg.description.replace("

", "").replace("

", "").replace('@%s' % answer_id.name, '').lstrip() + user_content = user_msg.body.replace("

", "").replace("

", "").replace('@%s' % answer_id.name, '').lstrip() context_history.insert(0, { 'role': 'user', 'content': user_content, @@ -147,6 +148,7 @@ class Channel(models.Model): if get_ua_type() != 'wxweb': # 处理当微信语音返回时,是直接回文本信息,不需要转换回车 res = res.replace('\n', '
') + res = Markup(res) new_msg = channel.with_user(user_id).message_post(body=res, message_type='comment', subtype_xmlid='mail.mt_comment', parent_id=message.id) if usage: if ai.provider == 'ali': @@ -318,7 +320,7 @@ class Channel(models.Model): # else: # self.with_delay().get_ai_response(ai, messages, channel, user_id, message) except Exception as e: - raise UserError(_(e)) + raise UserError(e) return rdata diff --git a/app_chatgpt/views/ai_robot_views.xml b/app_chatgpt/views/ai_robot_views.xml index 9a6643c6..7efe764f 100644 --- a/app_chatgpt/views/ai_robot_views.xml +++ b/app_chatgpt/views/ai_robot_views.xml @@ -31,31 +31,23 @@ - -
-
- Robot Provider + + +
+ +
+ Model: +
-
-
-
- - - -
-
-
- Model: - -
-
- - - - Bind Partner -
+
+ + + + Bind Partner
-
+