mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix misc for ai
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
{
|
||||
'name': 'ChatGPT4,Google Bard, AiGC Center.Ai服务中心,聚合全网Ai',
|
||||
'version': '16.23.08.15',
|
||||
'version': '16.23.09.08',
|
||||
'author': 'odooai.cn',
|
||||
'company': 'odooai.cn',
|
||||
'maintainer': 'odooai.cn',
|
||||
|
||||
@@ -5,18 +5,21 @@
|
||||
<field name="provider">openai</field>
|
||||
<field name="endpoint">https://api.openai.com/v1/chat/completions</field>
|
||||
<field name="sequence">1</field>
|
||||
<field name="image_avatar" type="base64" file="app_chatgpt/static/description/src/openai.png"/>
|
||||
</record>
|
||||
<record id="chatgpt_robot1" model="ai.robot">
|
||||
<field name="name">ChatGPT Coding</field>
|
||||
<field name="provider">openai</field>
|
||||
<field name="endpoint">https://api.openai.com/v1/chat/completions</field>
|
||||
<field name="sequence">6</field>
|
||||
<field name="image_avatar" type="base64" file="app_chatgpt/static/description/src/openai.png"/>
|
||||
</record>
|
||||
<record id="chatgpt_robot2" model="ai.robot">
|
||||
<field name="name">ChatGPT Finance</field>
|
||||
<field name="provider">openai</field>
|
||||
<field name="endpoint">https://api.openai.com/v1/chat/completions</field>
|
||||
<field name="sequence">7</field>
|
||||
<field name="image_avatar" type="base64" file="app_chatgpt/static/description/src/openai.png"/>
|
||||
</record>
|
||||
<record id="chatgpt3_azure" model="ai.robot">
|
||||
<field name="name">ChatGPT Azure</field>
|
||||
@@ -25,6 +28,7 @@
|
||||
<field name="engine">gpt35</field>
|
||||
<field name="api_version">2023-03-15-preview</field>
|
||||
<field name="sequence">8</field>
|
||||
<field name="image_avatar" type="base64" file="app_chatgpt/static/description/src/azure.png"/>
|
||||
</record>
|
||||
<record id="chatgpt4_azure" model="ai.robot">
|
||||
<field name="name">ChatGPT4 Azure</field>
|
||||
@@ -33,5 +37,6 @@
|
||||
<field name="engine">gpt4</field>
|
||||
<field name="api_version">2023-03-15-preview</field>
|
||||
<field name="sequence">9</field>
|
||||
<field name="image_avatar" type="base64" file="app_chatgpt/static/description/src/azure.png"/>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0+e-20230721\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-08-29 10:37+0000\n"
|
||||
"PO-Revision-Date: 2023-08-29 10:37+0000\n"
|
||||
"POT-Creation-Date: 2023-09-08 15:42+0000\n"
|
||||
"PO-Revision-Date: 2023-09-08 15:42+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -125,6 +125,11 @@ msgstr ""
|
||||
"Moderation: A fine-tuned model that can detect whether text may be sensitive or unsafe\n"
|
||||
"GPT-3\tA set of models that can understand and generate natural language\n"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_ai_robot__partner_count
|
||||
msgid "#Partner"
|
||||
msgstr "用户绑定"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,help:app_chatgpt.field_mail_channel__frequency_penalty
|
||||
#: model:ir.model.fields,help:app_chatgpt.field_mail_channel__set_frequency_penalty
|
||||
@@ -689,11 +694,6 @@ msgstr "上下文连接超时(秒)"
|
||||
msgid "Ai Center Setup"
|
||||
msgstr "Ai智能服务中心设置"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_mail_channel__description
|
||||
msgid "Ai Character"
|
||||
msgstr "Ai角色设定"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_mail_channel_view_form
|
||||
msgid "Ai Character Set"
|
||||
@@ -717,11 +717,6 @@ msgstr "GPT机器人"
|
||||
msgid "Ai User"
|
||||
msgstr "Ai用户"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,help:app_chatgpt.field_mail_channel__description
|
||||
msgid "Ai would help you act as the Character set."
|
||||
msgstr "Ai将按你设置的角色来对你的问题进行反馈"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_mail_channel_view_form
|
||||
msgid "Ai常规设定"
|
||||
@@ -820,6 +815,11 @@ msgstr "异步响应"
|
||||
msgid "Australia"
|
||||
msgstr ""
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_ai_robot__image_avatar
|
||||
msgid "Avatar"
|
||||
msgstr "头像"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields.selection,name:app_chatgpt.selection__ai_robot__provider__azure
|
||||
msgid "Azure"
|
||||
@@ -859,11 +859,16 @@ msgstr ""
|
||||
msgid "Baidu Ai China"
|
||||
msgstr "百度Ai"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_robot_kanban_view
|
||||
msgid "Bind Partner"
|
||||
msgstr "用户绑定"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_res_partner__gpt_id
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_res_users__gpt_id
|
||||
msgid "Bind to ChatGpt"
|
||||
msgstr "绑定至ChatGpt"
|
||||
msgid "Bind to Ai"
|
||||
msgstr "绑定至Ai"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#. odoo-javascript
|
||||
@@ -1171,7 +1176,7 @@ msgstr ""
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model,name:app_chatgpt.model_mail_thread
|
||||
msgid "Email Thread"
|
||||
msgstr "邮件会话"
|
||||
msgstr "EMail线程"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_ai_robot__endpoint
|
||||
@@ -1782,6 +1787,11 @@ msgstr ""
|
||||
msgid "Milky Way"
|
||||
msgstr ""
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_robot_kanban_view
|
||||
msgid "Model:"
|
||||
msgstr "模型:"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#. odoo-javascript
|
||||
#: code:addons/app_chatgpt/static/src/models_data/emoji_data.js:0
|
||||
@@ -2006,6 +2016,7 @@ msgid "PC"
|
||||
msgstr ""
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_ai_robot__partner_ids
|
||||
#: model:ir.model.fields,field_description:app_chatgpt.field_res_partner_ai_use__name
|
||||
msgid "Partner"
|
||||
msgstr "用户"
|
||||
@@ -2091,7 +2102,12 @@ msgstr ""
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_robot_form_view
|
||||
msgid "Robot Name"
|
||||
msgstr ""
|
||||
msgstr "Ai名称"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_robot_kanban_view
|
||||
msgid "Robot Provider"
|
||||
msgstr "Ai服务商"
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model_terms:ir.ui.view,arch_db:app_chatgpt.ai_robot_form_view
|
||||
@@ -27674,6 +27690,12 @@ msgstr ""
|
||||
msgid "中等"
|
||||
msgstr ""
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:mail.channel,description:app_chatgpt.channel_chatgpt
|
||||
msgid ""
|
||||
"你是一个智能语音对话系统\"odooAi欧度智能\",用户关注微信公众号或者打开微信小程序\"odooAi欧度智能\"即可使用,如果用户疑问,请告诉他们以上使用说明。"
|
||||
msgstr ""
|
||||
|
||||
#. module: app_chatgpt
|
||||
#: model:ir.model.fields.selection,name:app_chatgpt.selection__mail_channel__set_temperature__0_1
|
||||
msgid "保守"
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import openai.openai_object
|
||||
import requests, json
|
||||
import openai
|
||||
from odoo import api, fields, models, _
|
||||
import base64
|
||||
|
||||
from odoo import api, fields, models, modules, tools, _
|
||||
from odoo.exceptions import UserError
|
||||
from .lib.WordsSearch import WordsSearch
|
||||
|
||||
@@ -16,7 +19,8 @@ class AiRobot(models.Model):
|
||||
_order = 'sequence, name'
|
||||
|
||||
name = fields.Char(string='Name', translate=True, required=True)
|
||||
provider = fields.Selection(string="AI Provider", selection=[('openai', 'OpenAI'), ('azure', 'Azure')], required=True, default='openai')
|
||||
provider = fields.Selection(string="AI Provider", selection=[('openai', 'OpenAI'), ('azure', 'Azure')],
|
||||
required=True, default='openai', change_default=True)
|
||||
ai_model = fields.Selection(string="AI Model", selection=[
|
||||
('gpt-3.5-turbo-0613', 'gpt-3.5-turbo-0613(Default and Latest)'),
|
||||
('gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-16k-0613(Big text)'),
|
||||
@@ -106,8 +110,15 @@ GPT-3 A set of models that can understand and generate natural language
|
||||
is_filtering = fields.Boolean('Filter Sensitive Words', default=False, help='Use base Filter in dir models/lib/sensi_words.txt')
|
||||
|
||||
max_send_char = fields.Integer('Max Send Char', help='Max Send Prompt Length', default=8000)
|
||||
image_avatar = fields.Image('Avatar')
|
||||
partner_ids = fields.One2many('res.partner', 'gpt_id', string='Partner')
|
||||
partner_count = fields.Integer('#Partner', compute='_compute_partner_count', store=False)
|
||||
active = fields.Boolean('Active', default=True)
|
||||
|
||||
|
||||
def _compute_partner_count(self):
|
||||
for rec in self:
|
||||
rec.partner_count = len(rec.partner_ids)
|
||||
|
||||
def action_disconnect(self):
|
||||
requests.delete('https://chatgpt.com/v1/disconnect')
|
||||
|
||||
@@ -429,6 +440,15 @@ GPT-3 A set of models that can understand and generate natural language
|
||||
elif self.provider == 'azure':
|
||||
self.endpoint = 'https://odoo.openai.azure.com'
|
||||
|
||||
if self.provider:
|
||||
# 取头像
|
||||
module_path = modules.get_module_path('app_chatgpt', display_warning=False)
|
||||
if module_path:
|
||||
path = modules.check_resource_path(module_path, ('static/description/src/%s.png' % self.provider))
|
||||
if path:
|
||||
image_file = tools.file_open(path, 'rb')
|
||||
self.image_avatar = base64.b64encode(image_file.read())
|
||||
|
||||
def filter_sensitive_words(self, data):
|
||||
if self.is_filtering:
|
||||
search = WordsSearch()
|
||||
|
||||
@@ -6,7 +6,7 @@ from odoo import fields, models, api
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
gpt_id = fields.Many2one('ai.robot', string='Bind to ChatGpt')
|
||||
gpt_id = fields.Many2one('ai.robot', string='Bind to Ai', ondelete='set null')
|
||||
|
||||
is_chat_private = fields.Boolean('Allow Chat Private', default=False)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
# 改为在 partner中设置,用户处绑定
|
||||
gpt_id = fields.Many2one('ai.robot', string='Bind to ChatGpt', related='partner_id.gpt_id', inherited=True, readonly=False)
|
||||
gpt_id = fields.Many2one('ai.robot', string='Bind to Ai', related='partner_id.gpt_id', inherited=True, readonly=False)
|
||||
gpt_policy = fields.Selection([
|
||||
('all', 'All Users'),
|
||||
('limit', 'Selected Users')
|
||||
|
||||
BIN
app_chatgpt/static/description/src/azure.png
Normal file
BIN
app_chatgpt/static/description/src/azure.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB |
BIN
app_chatgpt/static/description/src/google.png
Normal file
BIN
app_chatgpt/static/description/src/google.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
BIN
app_chatgpt/static/description/src/openai.png
Normal file
BIN
app_chatgpt/static/description/src/openai.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -16,7 +16,51 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="ai_robot_kanban_view" model="ir.ui.view">
|
||||
<field name="name">ai.robot.kanban</field>
|
||||
<field name="model">ai.robot</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="o_ai_robot_kanban">
|
||||
<field name="id"/>
|
||||
<field name="name"/>
|
||||
<field name="provider"/>
|
||||
<field name="ai_model"/>
|
||||
<field name="partner_count"/>
|
||||
<field name="image_avatar"/>
|
||||
<field name="active"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_card oe_kanban_global_click">
|
||||
<div class="o_kanban_image me-1">
|
||||
<img t-att-src="kanban_image('ai.robot', 'image_avatar', record.id.raw_value)" alt="Robot Provider" class="o_image_64_contain"/>
|
||||
</div>
|
||||
<div class="oe_kanban_details">
|
||||
<div class="o_kanban_record_top mb-0">
|
||||
<div class="o_kanban_record_headings">
|
||||
<strong class="o_kanban_record_title">
|
||||
<field name="name"/>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
Model:
|
||||
<field name="ai_model"/>
|
||||
</div>
|
||||
<div class="mt-1">
|
||||
<strong>
|
||||
<t t-esc="record.partner_count.value"/>
|
||||
</strong>
|
||||
Bind Partner
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ai_robot_form_view" model="ir.ui.view">
|
||||
<field name="name">ai.robot.form</field>
|
||||
<field name="model">ai.robot</field>
|
||||
@@ -27,6 +71,13 @@
|
||||
<button string="Get Model Info" type="object" name="get_ai_model_info" attrs="{'invisible': [('provider', '!=', 'openai')]}"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button class="oe_stat_button" name="%(base.action_res_users)d" icon="fa-users" type="action"
|
||||
context="{'search_default_gpt_id': id}">
|
||||
<field name="partner_count" widget="statinfo"/>
|
||||
</button>
|
||||
</div>
|
||||
<field name="image_avatar" widget='image' class="oe_avatar"/>
|
||||
<div class="oe_title">
|
||||
<label for="name"/>
|
||||
<h1>
|
||||
@@ -35,6 +86,7 @@
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
<field name="id" invisible="1"/>
|
||||
<field name="openapi_api_key" password="True" required="True"/>
|
||||
<field name="temperature"/>
|
||||
<field name="top_p"/>
|
||||
@@ -69,26 +121,25 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="ai_robot_search_view" model="ir.ui.view">
|
||||
<field name="name">ai.robot.search</field>
|
||||
<field name="model">ai.robot</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name"/>
|
||||
<field name="ai_model"/>
|
||||
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
|
||||
<group expand="0" name="group_by" string="Group By">
|
||||
<filter name="groupby_provider" string="Ai Provider" domain="[]" context="{'group_by' : 'provider'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="ai_robot_search_view" model="ir.ui.view">
|
||||
<field name="name">ai.robot.search</field>
|
||||
<field name="model">ai.robot</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name"/>
|
||||
<field name="ai_model"/>
|
||||
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
|
||||
<group expand="0" name="group_by" string="Group By">
|
||||
<filter name="groupby_provider" string="Ai Provider" domain="[]" context="{'group_by' : 'provider'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_ai_robot" model="ir.actions.act_window">
|
||||
<field name="name">Ai Robot</field>
|
||||
<field name="res_model">ai.robot</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
Let's create a Ai Robot.
|
||||
@@ -100,7 +151,7 @@
|
||||
<field name="name">Disconnect</field>
|
||||
<field name="model_id" ref="app_chatgpt.model_ai_robot"/>
|
||||
<field name="binding_model_id" ref="app_chatgpt.model_ai_robot"/>
|
||||
<field name="binding_view_types">list,form</field>
|
||||
<field name="binding_view_types">kanban,list,form</field>
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = records.action_disconnect()</field>
|
||||
</record>
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="gpt_id"/>
|
||||
</xpath>
|
||||
<xpath expr="//filter[@name='filter_no_share']" position="before">
|
||||
<filter name="is_robot" string="Ai User" domain="[('gpt_id','!=',False)]"/>
|
||||
<filter name="not_robot" string="Not Ai" domain="[('gpt_id','=',False)]"/>
|
||||
|
||||
@@ -16,3 +16,15 @@ class BlogBlog(models.Model):
|
||||
action = self.env.ref('website_blog.action_blog_post').read()[0]
|
||||
action['domain'] = [('blog_id', '=', self.id)]
|
||||
return action
|
||||
|
||||
# def unlink(self):
|
||||
# # active的先不删除,设置为 deactive
|
||||
# to_deactive = self.filtered(lambda r: r.active)
|
||||
# self = self - to_deactive
|
||||
# to_deactive.write({
|
||||
# 'active': False,
|
||||
# })
|
||||
# if self:
|
||||
# return super(BlogBlog, self).unlink()
|
||||
# else:
|
||||
# return False
|
||||
|
||||
@@ -7,7 +7,10 @@ from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
class BlogPost(models.Model):
|
||||
_inherit = 'blog.post'
|
||||
|
||||
|
||||
# 不允许暴力删除
|
||||
blog_id = fields.Many2one('blog.blog', ondelete='restrict')
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get('website_meta_og_img'):
|
||||
sync_blog_meta_background_img = self.env['ir.config_parameter'].sudo().get_param('app_website_blog_editor.sync_blog_meta_background_img')
|
||||
|
||||
Reference in New Issue
Block a user