[app_ai_bard] v17 to be validate

This commit is contained in:
Chill
2024-11-06 17:13:03 +08:00
parent 744e6f8247
commit 245f177dd2
43 changed files with 665 additions and 0 deletions

4
app_ai_bard/__init__.py Normal file
View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# from . import controllers
from . import models

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# Created on 2023-02-016
# author: 欧度智能https://www.odooai.cn
# email: 300883@qq.com
# resource of odooai
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Google Bard Ai for odoo ai center, 谷歌Ai支持',
'version': '24.11.06',
'author': 'odooai.cn',
'company': 'odooai.cn',
'maintainer': 'odooai.cn',
'category': 'Website/Website',
'website': 'https://www.odooai.cn',
'live_test_url': 'https://demo.odooapp.cn',
'license': 'LGPL-3',
'sequence': 10,
'images': ['static/description/banner.gif'],
'summary': '''
Google Bard Ai for Odoo AI Center. Ai Aigc Center including Google Bard Ai, Azure Ai, Baidu Ai.
Support chatgpt 4 image. DALLE, Integration All ChatGpt Api and Azure OpenAI Service.
Easy Chat channel with several ChatGPT Robots and train.
''',
'description': '''
Chat with google bard ai with odoo.
Allows the application to leverage the capabilities of the GPT language model to generate human-like responses,
providing a more natural and intuitive user experience.
odoo bard connector.
1. Multi ChatGpt openAI robot Connector. Chat and train.
2. Multi Ai support including Google Bard Ai, Azure Ai, Chatgpt 4, Chatgpt 3.5 Turbo, Chatgpt 3 Davinci, Chatgpt 2 Code Optimized, 'Dall-E Image.
3. Bind ChatGpt Api to user. So we can chat to robot user or use ChatGpt Channel for Group Chat.
4. White and black List for ChatGpt.
5. Setup Demo Chat time for every new user.
6. Easy Start and Stop ChatGpt.
7. Evaluation the ai robot to make better response. This training.
8. Add api support Connect the Microsoft Azure OpenAI Service.
9. Can set Synchronous or Asynchronous mode for Ai response.
10.Filter Sensitive Words Setup.
11. Multi-language Support. Multi-Company Support.
12. Support Odoo 18,17,16,15,14,13,12, Enterprise and Community and odoo.sh Edition.
13. Full Open Source.
''',
'depends': [
'app_chatgpt',
],
'data': [
'data/ai_robot_data.xml',
'data/user_partner_data.xml',
],
'assets': {
},
'external_dependencies': {'python': ['bardapi']},
'installable': True,
'application': True,
'auto_install': False,
}

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import main

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from odoo import http
class ChatgptController(http.Controller):
@http.route(['/chatgpt_form'], type='http', auth="public", csrf=False,
website=True)
def question_submit(self):
return http.request.render('app_chatgpt.connector')

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data noupdate="1">
<record id="robot_google_bard" model="ai.robot">
<field name="name">Google Bard</field>
<field name="provider">google</field>
<field name="ai_model">google-bard</field>
<field name="api_version" eval="False"/>
<field name="endpoint">https://api.bard.ai/v1/text/generate</field>
<field name="sequence">9</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="partner_google_bard" model="res.partner">
<field name="name">Google Bard</field>
<field name="image_1920" type="base64" file="app_ai_bard/static/src/img/bard.gif"/>
</record>
<record id="user_google_bard" model="res.users">
<field name="login">ai_bard@example.com</field>
<field name="email">ai_bard@example.com</field>
<field name="partner_id" ref="partner_google_bard"/>
<field name="gpt_id" ref="robot_google_bard"/>
<field name="company_id" ref="base.main_company"/>
<field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/>
<field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/>
</record>
</data>
</odoo>

View File

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import ai_robot

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
import os
import logging
import requests, json
from odoo import api, fields, models, _
from odoo.exceptions import UserError
# todo: 暂时直接 requests
# from bardapi import Bard
_logger = logging.getLogger(__name__)
class AiRobot(models.Model):
_inherit = 'ai.robot'
provider = fields.Selection(
selection_add=[('google', 'Google Ai')],
ondelete={'google': 'set default'}
)
set_ai_model = fields.Selection(
selection_add=[('google-bard', 'Google Bard')],
ondelete={'google-bard': 'set default'})
@api.onchange('provider')
def _onchange_provider(self):
if self.provider == 'google':
self.endpoint = 'https://api.bard.ai/v1/text/generate'
return super()._onchange_provider()
def get_google(self, data, author_id, answer_id, param={}):
self.ensure_one()
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.openapi_api_key}"}
R_TIMEOUT = self.ai_timeout or 120
o_url = self.endpoint or "https://api.bard.ai/v1/text/generate"
# todo: 更多参数如 prompt, max_length
max_tokens = param.get('max_tokens') if param.get('max_tokens') else self.max_tokens
temperature = param.get('temperature') if param.get('temperature') else self.temperature
pdata = {
"text": data,
"max_length": max_tokens,
"temperature": temperature,
}
response = requests.post(o_url, data=json.dumps(pdata), headers=headers, timeout=R_TIMEOUT)
response.raise_for_status()
try:
res = response.json()['text']
return res
except Exception as e:
_logger.warning("Get Response Json failed: %s", e)
else:
_logger.warning('=====================Openai output data: %s' % response.json())
def get_google_post(self, res, author_id=False, answer_id=False, param={}):
if self.provider == 'google':
content = res['text']
return content, False, True

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@@ -0,0 +1,263 @@
<section class="oe_container container">
<div class="oe_row oe_spaced" >
<div class="row">
<h2 class="oe_slogan"> Google Bard Ai for odoo ai center</h2>
<h3 class="oe_slogan"> Ai center addons. all aigc in one. </h3>
<div class="oe_row">
<h3>Latest update: v17.24.11.06</h3>
<div class="row">
<div class="row">
<img class="" src="bard.gif">
Add google bard support, update chatgpt api</div>
<img class="oe_demo oe_screenshot img img-fluid" src="demo02.jpg">
</div>
<div class="row">
<img class="oe_demo oe_screenshot img img-fluid" style="max-height: 100%;" src="banner.png">
</div>
<div class="oe_span12 oe_spaced">
<div class="alert alert-info" style="padding:8px;font-weight: 300; font-size: 20px;">
<i class="fa fa-hand-o-right"></i><b> Key features: </b>
<ul class="list-unstyled">
<li>
<i class="fa fa-check-square-o text-primary"></i>
1. Multi ChatGpt openAI robot Connector. Chat and train.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
2. Multi Ai support including Google Bard Ai, Azure Ai, Chatgpt 4, Chatgpt 3.5 Turbo, Chatgpt 3 Davinci, Chatgpt 2 Code Optimized, 'Dall-E Image.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
3. Bind ChatGpt Api to user. So we can chat to robot user or use ChatGpt Channel for Group Chat.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
4. White and black List for ChatGpt.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
5. Setup Demo Chat time for every new user.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
6. Easy Start and Stop ChatGpt.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
7. Evaluation the ai robot to make better response. This training.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
8. Add api support Connect the Microsoft Azure OpenAI Service.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
9. Can set Synchronous or Asynchronous mode for Ai response.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
10.Filter Sensitive Words Setup.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
11. Multi-language Support. Multi-Company Support.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
12. Support Odoo 18,17,16,15,14,13,12, Enterprise and Community and odoo.sh Edition.
</li>
<li>
<i class="fa fa-check-square-o text-primary"></i>
13. Full Open Source.
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">Add more Ai support like google bard, chatgpt 4, baidu china</h2>
<h4 class="oe_slogan"> Need to navigate to odoo app store to buy and install addons</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo01.jpg"/>
</div>
<h4 class="oe_slogan">Please apply for the bard api first from google</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo03.jpg"/>
</div>
<h4 class="oe_slogan">Setup for your own key</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo04.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">Easy to use Ai Robot with multi Provider. Easy chat, easy help</h2>
<h4 class="oe_slogan"> Open Ai for more smart. Microsoft Azure chatgpt for china user.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demob.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">1. Multi ChatGpt openAI robot Connector. Chat and train.</h2>
<h4 class="oe_slogan"> Goto Setting--> GPT Robot to setup your robot api. </h4>
<p> Input your api key, And Select the api model you need to use.</p>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo1.jpg"/>
</div>
<p> You can set the Temperature higer for more creative answer.</p>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo2.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">2. Multi Api support, Chatgpt 3.5 Turbo, Chatgpt 3 Davinci, Chatgpt 2 Code Optimized, 'Dall-E Image.</h2>
<h4 class="oe_slogan"> Choose the model you want to use</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo2.jpg"/>
</div>
<p> You can set the Temperature higer for more creative answer.</p>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo3.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">3. Bind ChatGpt Api to user. So we can chat to robot user or use ChatGpt Channel for Group Chat.</h2>
<h4 class="oe_slogan"> Go Settings ->users, bind chatgpt to some user.</h4>
<img src="demo4.jpg"/>
</div>
<h4 class="oe_slogan"> So you can have many user, and many chatgpt robot. This provide you an Ai pool.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo5.jpg"/>
</div>
<h4 class="oe_slogan"> You can set the blacklist to this chatgpt robot to limit request. Also you can setup Demo time for every normal user..</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo6.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">4. White and black List for ChatGpt.</h2>
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">5. Setup Demo Chat time for every new user.</h2>
<h4 class="oe_slogan"> You can set the blacklist to this chatgpt robot to limit request. Also you can setup Demo time for every normal user..</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo6.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">6. Easy Start and Stop ChatGpt..</h2>
<h4 class="oe_slogan"> You can easy chat with the apt robot with odoo IM</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo7.jpg"/>
</div>
<h4 class="oe_slogan"> You can chat with several robot in the same time</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo8.jpg"/>
</div>
<h4 class="oe_slogan"> If you have more than 1 robot in the group. you can @ the specify robot.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo9.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">7. Evaluation the ai robot to make better response. This training.</h2>
<h4 class="oe_slogan"> You can Evaluation chatgpt's answer. Mark as good for good answer. Mark as back for bad answer.</h4>
<p> With Evaluation, you can make your ai robot more smart.
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo71.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">8. Add api support Connect the Microsoft Azure OpenAI Service.</h2>
<h4 class="oe_slogan"> Azure openai add. It is for china and other country which no chatgpt service.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo81.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">9. Can set Synchronous or Asynchronous mode for Ai response.</h2>
<h4 class="oe_slogan"> Synchronous(default) mode can get response then ask question again. Asynchronous mode would make you do other thing when waiting for response.</h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="demo91.jpg"/>
</div>
</div>
</section>
<section class="oe_container container">
<div class="oe_row oe_spaced">
<h2 class="bg-warning text-center pt8 pb8 mt16 mb16">Multi-language Support..</h2>
<h4 class="oe_slogan"> </h4>
<div class="oe_demo oe_screenshot img img-fluid">
<img src="cnreadme.jpg"/>
</div>
</div>
</section>
<section class="container oe_dark">
<div class="oe_row oe_spaced text-center">
<div class="row">
<h2 class="oe_slogan">Technical Help & Support</h2>
</div>
<div class="col-md-12 pad0">
<div class="oe_mt16">
<p><h4>
For any type of technical help & support requests, Feel free to contact us</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:odoo@china.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> odoo@china.com</a>
<p><h4>
Via QQ: 300883 (App user would not get QQ or any other IM support. Only for odoo project customize.)</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="mailto:300883@qq.com"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-envelope"></i> 300883@qq.com</a>
</div>
<div class="oe_mt16">
<p><h4>
Visit our website for more support.</h4></p>
<a style="background: #002e5a none repeat scroll 0% 0%; color: rgb(255, 255, 255);position: relative; overflow: hidden;"
class="btn btn-warning btn-lg" rel="nofollow" href="https://www.odooai.cn" target="_blank"><span
style="height: 354px; width: 354px; top: -147.433px; left: -6.93335px;" class="o_ripple"></span>
<i class="fa fa-web"></i>https://www.odooai.cn</a>
</div>
</div>
</div>
<div class="oe_row oe_spaced text-center">
<h2>More Powerful addons, Make your odoo very easy to use, easy customize:
<a class="btn btn-primary mb16" href="http://www.odoo.com/apps/modules/browse?author=odooai.cn">odooai.cn Odoo Addons</a>
</h2>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

View File

@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ai_robot_tree_view" model="ir.ui.view">
<field name="name">ai.robot.tree</field>
<field name="model">ai.robot</field>
<field name="arch" type="xml">
<list>
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="provider" optional="hide"/>
<field name="ai_model" optional="show"/>
<field name="openapi_api_key" password="True"/>
<field name="max_tokens" optional="show"/>
<field name="temperature"/>
<field name="max_send_char"/>
</list>
</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>
<field name="arch" type="xml">
<form>
<header>
<button string="Get List Model" type="object" name="get_ai_list_model"/>
<button string="Get Model Info" type="object" name="get_ai_model_info"/>
</header>
<sheet>
<div class="oe_title">
<label for="name"/>
<h1>
<field name="name" placeholder="Robot Name" required="1"/>
</h1>
</div>
<group>
<group>
<field name="openapi_api_key" password="True" required="True"/>
<field name="temperature"/>
<field name="top_p"/>
<field name="frequency_penalty"/>
<field name="presence_penalty"/>
<field name="sys_content" placeholder="Role-playing and scene setting.Give the model instructions about how it should behave and any context it should reference when generating a response."/>
<field name="max_send_char"/>
</group>
<group>
<field name="ai_model"/>
<label class="o_form_label" for="provider">
OpenAI Document
</label>
<div>
<field name="provider"/>
<a href="https://platform.openai.com/docs/introduction" title="OpenAI Document" class="o_doc_link" target="_blank"></a>
</div>
<field name="max_tokens"/>
<field name="engine"/>
<field name="endpoint"/>
<field name="api_version"/>
<field name="ai_timeout"/>
<field name="sequence"/>
</group>
<group>
<field name="is_filtering"/>
<field name="sensitive_words" attrs="{'invisible': [('is_filtering', '=', False)]}"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_ai_robot" model="ir.actions.act_window">
<field name="name">GPT Robot</field>
<field name="res_model">ai.robot</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Let's create a GPT Robot.
</p>
</field>
</record>
<record id="model_ai_robot_action_disconnect" model="ir.actions.server">
<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="state">code</field>
<field name="code">action = records.action_disconnect()</field>
</record>
<menuitem
id="menu_ai_robot"
name="GPT Robot"
parent="base.menu_users"
sequence="2"
action="action_ai_robot"
groups="base.group_system"/>
</odoo>

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_partner_ai_use_tree_view" model="ir.ui.view">
<field name="name">res.partner.ai.use.tree</field>
<field name="model">res.partner.ai.use</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="ai_user_id" optional="show"/>
<field name="first_ask_time" optional="show"/>
<field name="latest_ask_time" optional="show"/>
<field name="service_start_date" optional="show"/>
<field name="service_end_date" optional="show"/>
<field name="used_number" sum="Total" optional="hide"/>
<field name="max_number" sum="Total" optional="hide"/>
<field name="human_prompt_tokens" sum="Total" optional="show"/>
<field name="ai_completion_tokens" sum="Total" optional="show"/>
<field name="tokens_total" sum="Total" optional="show"/>
<field name="token_balance" sum="Total" optional="show"/>
<field name="token_allow" sum="Total" optional="show"/>
</list>
</field>
</record>
<record id="res_partner_ai_use_form_view" model="ir.ui.view">
<field name="name">res.partner.ai.use.form</field>
<field name="model">res.partner.ai.use</field>
<field name="arch" type="xml">
<form>
<sheet>
<label for="name"/>
<h1>
<field name="name"/>
</h1>
<group>
<group>
<field name="ai_user_id"/>
<field name="first_ask_time"/>
<field name="latest_ask_time"/>
<field name="service_start_date"/>
<field name="service_end_date"/>
<field name="used_number" readonly="True"/>
<field name="max_number" readonly="True"/>
<field name="token_balance" readonly="True"/>
</group>
<group>
<field name="human_prompt_tokens" readonly="True"/>
<field name="ai_completion_tokens" readonly="True"/>
<field name="tokens_total" readonly="True"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="res_partner_ai_use_search_view" model="ir.ui.view">
<field name="name">res.partner.ai.use.search</field>
<field name="model">res.partner.ai.use</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
<field name="ai_user_id"/>
<searchpanel>
<field name="ai_user_id"/>
</searchpanel>
</search>
</field>
</record>
<record id="action_res_partner_ai_use" model="ir.actions.act_window">
<field name="name">Partner Ai Use</field>
<field name="res_model">res.partner.ai.use</field>
<field name="view_mode">list,form</field>
<field name="context">{'create': 0, 'delete': 0}</field>
</record>
<record id="action_res_users_2_partner_ai_use" model="ir.actions.act_window">
<field name="name">Partner Ai Use</field>
<field name="res_model">res.partner.ai.use</field>
<field name="view_mode">list,form</field>
<field name="domain">[('ai_user_id', 'in', active_ids)]</field>
<field name="context">{'default_ai_user_id':active_id,}</field>
</record>
<menuitem
id="menu_res_partner_ai_use"
name="Partner Ai Use"
parent="base.menu_users"
sequence="3"
action="action_res_partner_ai_use"
groups="base.group_system"/>
</odoo>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="app_chatgpt_res_users_form" model="ir.ui.view">
<field name="name">app.chatgpt.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button name="%(app_chatgpt.action_res_users_2_partner_ai_use)d" type="action" string="Partner Ai Use" icon="fa-comments">
</button>
</xpath>
<xpath expr="//page[@name='preferences']" position="after">
<page name="page_chatgpt" string="ChatGPT">
<group>
<group>
<field name="gpt_id"/>
<field name="gpt_policy"/>
<field name="gpt_wl_partners" widget="many2many_tags" attrs="{'invisible': [('gpt_policy', '=', 'all')]}"/>
<field name="gpt_demo_time"/>
</group>
</group>
</page>
</xpath>
</field>
</record>
<!-- search-->
<record id="app_view_users_search" model="ir.ui.view">
<field name="name">app.res.users.search</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_search"/>
<field name="arch" type="xml">
<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)]"/>
<separator/>
</xpath>
</field>
</record>
</odoo>