mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
prepare #I92TI8 app_chatgpt升级到17.默认不队列 置顶
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
{
|
||||
'name': 'ChatGPT4, China Ali,AiGC Center.Ai服务中心,聚合全网Ai',
|
||||
'version': '24.03.06',
|
||||
'version': '24.03.28',
|
||||
'author': 'odooai.cn',
|
||||
'company': 'odooai.cn',
|
||||
'maintainer': 'odooai.cn',
|
||||
@@ -63,13 +63,9 @@
|
||||
'views/discuss_channel_views.xml',
|
||||
],
|
||||
'assets': {
|
||||
'mail.assets_messaging': [
|
||||
'app_chatgpt/static/src/models/message.js',
|
||||
],
|
||||
'mail.assets_model_data': [
|
||||
'app_chatgpt/static/src/models_data/*.js',
|
||||
],
|
||||
'web.assets_backend': [
|
||||
'app_chatgpt/static/src/models/message_model.js',
|
||||
'app_chatgpt/static/src/components/message/message.js',
|
||||
'app_chatgpt/static/src/components/*/*.xml',
|
||||
],
|
||||
},
|
||||
|
||||
@@ -21,9 +21,8 @@ class Message(models.Model):
|
||||
# 处理反馈
|
||||
pass
|
||||
|
||||
def message_format(self, format_reply=True):
|
||||
message_values = super(Message, self).message_format(format_reply=format_reply)
|
||||
|
||||
def message_format(self, format_reply=True, msg_vals=None):
|
||||
message_values = super(Message, self).message_format(format_reply=format_reply, msg_vals=msg_vals)
|
||||
for message in message_values:
|
||||
message_sudo = self.browse(message['id']).sudo().with_prefetch(self.ids)
|
||||
message['human_prompt_tokens'] = message_sudo.human_prompt_tokens
|
||||
|
||||
25
app_chatgpt/static/src/components/message/message.js
Normal file
25
app_chatgpt/static/src/components/message/message.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/** @odoo-module */
|
||||
import {Message} from "@mail/core/common/message";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(Message.prototype, {
|
||||
async copy() {
|
||||
const parser = new DOMParser();
|
||||
const htmlDoc = parser.parseFromString(this.message.body.replaceAll('<br>', '\n').replaceAll('</br>', '\n'), "text/html");
|
||||
const textInputContent = htmlDoc.body.textContent;
|
||||
const tempInput = document.createElement("textarea");
|
||||
tempInput.value = textInputContent;
|
||||
document.body.appendChild(tempInput);
|
||||
tempInput.select();
|
||||
tempInput.setSelectionRange(0, tempInput.value.length);
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(tempInput);
|
||||
},
|
||||
async onClickMarkAsGood() {
|
||||
this.messageService.react(this.message, '👍');
|
||||
},
|
||||
|
||||
async onClickMarkAsBad() {
|
||||
this.messageService.react(this.message, '👎');
|
||||
},
|
||||
});
|
||||
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="app_chatgpt.Message" t-inherit="mail.Message" t-inherit-mode="extension">
|
||||
<xpath expr="//Composer[@composer='message.composer']" position="after">
|
||||
<div t-if="state.isEditing" name="bottom_operation" class="position-relative mt-8">
|
||||
<xpath expr="//t[@t-if='showSubtypeDescription']" position="after">
|
||||
<!-- <p>gpt xml测试:<t t-esc="message.ai_completion_tokens"/></p>-->
|
||||
<div t-if="!state.isEditing" name="bottom_operation" class="position-relative mt-8">
|
||||
<div t-if="message.human_prompt_tokens > 0 or message.ai_completion_tokens >0"
|
||||
class="o_Message_token text-muted" style="float:left;display:inline;font-size: 13px;">
|
||||
<br/>
|
||||
@@ -14,6 +15,24 @@
|
||||
<t t-esc="message.ai_completion_tokens"/>
|
||||
</span>
|
||||
</div>
|
||||
<!-- 直接将btn处理方法置于此-->
|
||||
<div name="action_btn" style="padding:40px 5px 0px 5px;float:right;">
|
||||
<div class="position-relative" style="padding:0px 5px;height:20px;display:inline-block;">
|
||||
<button t-on-click="copy" class="btn d-flex p-0 rounded-1">
|
||||
<i class="o_MessageView_btn fa fa-copy o_MessageActionView_actionCopy"/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="position-relative" style="padding:0px 5px;height:20px;display:inline-block;">
|
||||
<button t-on-click="onClickMarkAsGood" class="btn d-flex p-0 rounded-1">
|
||||
<i class="o_MessageView_btn fa fa-thumbs-up"/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="position-relative" style="padding:0px 0px 0px 5px;height:20px;display:inline-block;">
|
||||
<button t-on-click="onClickMarkAsBad" class="btn d-flex p-0 rounded-1">
|
||||
<i class="o_MessageView_btn fa fa-thumbs-down"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { EmojiPicker } from "@web/core/emoji_picker/emoji_picker";
|
||||
import { loader } from "@web/core/emoji_picker/emoji_picker";
|
||||
|
||||
|
||||
patch(EmojiPicker.prototype, {
|
||||
async loadEmoji() {
|
||||
try {
|
||||
await loader.loadEmoji();
|
||||
return odoo.loader.modules.get("@web/core/emoji_picker/emoji_data");
|
||||
} catch {
|
||||
// Could be intentional (tour ended successfully while emoji still loading)
|
||||
return {emojis: [], categories: []};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// import { insert } from '@mail/model/model_field_command';
|
||||
// import { getBundle, loadBundle} from '@web/core/assets';
|
||||
// import {registerPatch} from '@mail/model/model_core';
|
||||
//
|
||||
// registerPatch({
|
||||
// name: 'EmojiRegistry',
|
||||
// recordMethods: {
|
||||
// async loadEmojiData() {
|
||||
// this.update({isLoading: true});
|
||||
// await getBundle('mail.assets_model_data').then(loadBundle);
|
||||
// //优化 data 文件
|
||||
// const {emojiCategoriesData, emojisData} = await odoo.runtimeImport("@app_chatgpt/models_data/emoji_data");
|
||||
// if (!this.exists()) {
|
||||
// return;
|
||||
// }
|
||||
// this._populateFromEmojiData(emojiCategoriesData, emojisData);
|
||||
// },
|
||||
// async _populateFromEmojiData(dataCategories, dataEmojis) {
|
||||
// dataCategories.map(category => {
|
||||
// const emojiCount = dataEmojis.reduce((acc, emoji) => emoji.category === category.name ? acc + 1 : acc, 0);
|
||||
// this.update({
|
||||
// dataCategories: insert({
|
||||
// name: category.name,
|
||||
// displayName: category.displayName,
|
||||
// title: category.title,
|
||||
// sortId: category.sortId,
|
||||
// emojiCount,
|
||||
// }),
|
||||
// });
|
||||
// });
|
||||
// this.models['Emoji'].insert(dataEmojis.map(emojiData => ({
|
||||
// codepoints: emojiData.codepoints,
|
||||
// shortcodes: emojiData.shortcodes,
|
||||
// emoticons: emojiData.emoticons,
|
||||
// name: emojiData.name,
|
||||
// keywords: emojiData.keywords,
|
||||
// emojiDataCategory: {name: emojiData.category},
|
||||
// })));
|
||||
// this.update({
|
||||
// isLoaded: true,
|
||||
// isLoading: false,
|
||||
// });
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// )
|
||||
@@ -1,13 +1,15 @@
|
||||
/** @odoo-module **/
|
||||
import { Message } from "@mail/core/common/message_model";
|
||||
import { assignDefined } from "@mail/utils/common/misc";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(Message, {
|
||||
/** @type {number} */
|
||||
human_prompt_tokens,
|
||||
/** @type {number} */
|
||||
ai_completion_tokens,
|
||||
/** @type {boolean} */
|
||||
is_ai,
|
||||
// 参考模块 whatsapp
|
||||
|
||||
patch(Message.prototype, {
|
||||
update(data) {
|
||||
assignDefined(this, data, ["human_prompt_tokens", "ai_completion_tokens", "is_ai"]);
|
||||
super.update(data);
|
||||
},
|
||||
});
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user