base init v17, 很多只改了版号,没验证

This commit is contained in:
Ivan Office
2023-11-06 15:37:16 +08:00
parent 62ea802b13
commit 587f5ad043
96 changed files with 53379 additions and 84 deletions

View File

@@ -0,0 +1,22 @@
<?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="//div[hasclass('o_Message_prettyBody')]//.." position="replace">
<t t-if="!messageView.composerViewInEditing">
<div class="o_Message_prettyBody" t-ref="prettyBody"/><!-- messageView.message.prettyBody is inserted here from _update() -->
<div name="bottom_operation" class="position-relative mt-8">
<div t-if="messageView.message.human_prompt_tokens &gt; 0 or messageView.message.ai_completion_tokens &gt;0"
class="o_Message_token text-muted" style="float:left;display:inline;font-size: 13px;">
<br/>
------------------
<br/>
<span title="提问/答复 消耗Token">
<t t-esc="messageView.message.human_prompt_tokens"/> / <t t-esc="messageView.message.ai_completion_tokens"/>
</span>
</div>
</div>
</t>
</xpath>
</t>
</templates>

View File

@@ -0,0 +1,48 @@
/** @odoo-module **/
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,
});
},
},
}
)

View File

@@ -0,0 +1,30 @@
/** @odoo-module **/
import { insert } from '@mail/model/model_field_command';
import { attr, many, one } from '@mail/model/model_field';
import { registerPatch } from '@mail/model/model_core';
registerPatch({
name: 'Message',
modelMethods: {
convertData(data) {
const data2 = this._super(data);
if ('human_prompt_tokens' in data) {
data2.human_prompt_tokens = data.human_prompt_tokens;
}
if ('ai_completion_tokens' in data) {
data2.ai_completion_tokens = data.ai_completion_tokens;
}
if ('is_ai' in data) {
data2.is_ai = data.is_ai;
}
return data2;
},
},
fields: {
human_prompt_tokens: attr(),
ai_completion_tokens: attr(),
is_ai: attr(),
}
})

File diff suppressed because it is too large Load Diff