diff --git a/app_ai_bard/__init__.py b/app_ai_bard/__init__.py new file mode 100644 index 00000000..d6948c82 --- /dev/null +++ b/app_ai_bard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +# from . import controllers +from . import models diff --git a/app_ai_bard/__manifest__.py b/app_ai_bard/__manifest__.py new file mode 100644 index 00000000..7ca2f3e4 --- /dev/null +++ b/app_ai_bard/__manifest__.py @@ -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, +} diff --git a/app_ai_bard/controllers/__init__.py b/app_ai_bard/controllers/__init__.py new file mode 100644 index 00000000..65a8c120 --- /dev/null +++ b/app_ai_bard/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import main diff --git a/app_ai_bard/controllers/main.py b/app_ai_bard/controllers/main.py new file mode 100644 index 00000000..217c4d8b --- /dev/null +++ b/app_ai_bard/controllers/main.py @@ -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') diff --git a/app_ai_bard/data/ai_robot_data.xml b/app_ai_bard/data/ai_robot_data.xml new file mode 100644 index 00000000..ad4ac00b --- /dev/null +++ b/app_ai_bard/data/ai_robot_data.xml @@ -0,0 +1,13 @@ + + + + + Google Bard + google + google-bard + + https://api.bard.ai/v1/text/generate + 9 + + + diff --git a/app_ai_bard/data/user_partner_data.xml b/app_ai_bard/data/user_partner_data.xml new file mode 100644 index 00000000..4e3f2910 --- /dev/null +++ b/app_ai_bard/data/user_partner_data.xml @@ -0,0 +1,19 @@ + + + + + Google Bard + + + + + ai_bard@example.com + ai_bard@example.com + + + + + + + + diff --git a/app_ai_bard/i18n/zh_CN.po b/app_ai_bard/i18n/zh_CN.po new file mode 100644 index 00000000..e69de29b diff --git a/app_ai_bard/models/__init__.py b/app_ai_bard/models/__init__.py new file mode 100644 index 00000000..a1e55a68 --- /dev/null +++ b/app_ai_bard/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import ai_robot diff --git a/app_ai_bard/models/ai_robot.py b/app_ai_bard/models/ai_robot.py new file mode 100644 index 00000000..d1622b77 --- /dev/null +++ b/app_ai_bard/models/ai_robot.py @@ -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 diff --git a/app_ai_bard/security/odooai.cn b/app_ai_bard/security/odooai.cn new file mode 100644 index 00000000..e69de29b diff --git a/app_ai_bard/static/description/banner.gif b/app_ai_bard/static/description/banner.gif new file mode 100644 index 00000000..93134017 Binary files /dev/null and b/app_ai_bard/static/description/banner.gif differ diff --git a/app_ai_bard/static/description/banner.png b/app_ai_bard/static/description/banner.png new file mode 100644 index 00000000..958454d3 Binary files /dev/null and b/app_ai_bard/static/description/banner.png differ diff --git a/app_ai_bard/static/description/bard.gif b/app_ai_bard/static/description/bard.gif new file mode 100644 index 00000000..78de3734 Binary files /dev/null and b/app_ai_bard/static/description/bard.gif differ diff --git a/app_ai_bard/static/description/chatgpt.png b/app_ai_bard/static/description/chatgpt.png new file mode 100644 index 00000000..20a03f9d Binary files /dev/null and b/app_ai_bard/static/description/chatgpt.png differ diff --git a/app_ai_bard/static/description/chatgpt4_azure.png b/app_ai_bard/static/description/chatgpt4_azure.png new file mode 100644 index 00000000..8f24124c Binary files /dev/null and b/app_ai_bard/static/description/chatgpt4_azure.png differ diff --git a/app_ai_bard/static/description/chatgpt_blue.png b/app_ai_bard/static/description/chatgpt_blue.png new file mode 100644 index 00000000..1e94178f Binary files /dev/null and b/app_ai_bard/static/description/chatgpt_blue.png differ diff --git a/app_ai_bard/static/description/chatgpt_green.jpg b/app_ai_bard/static/description/chatgpt_green.jpg new file mode 100644 index 00000000..f3350c62 Binary files /dev/null and b/app_ai_bard/static/description/chatgpt_green.jpg differ diff --git a/app_ai_bard/static/description/demo01.jpg b/app_ai_bard/static/description/demo01.jpg new file mode 100644 index 00000000..dd014ea8 Binary files /dev/null and b/app_ai_bard/static/description/demo01.jpg differ diff --git a/app_ai_bard/static/description/demo02.jpg b/app_ai_bard/static/description/demo02.jpg new file mode 100644 index 00000000..7e0c8c39 Binary files /dev/null and b/app_ai_bard/static/description/demo02.jpg differ diff --git a/app_ai_bard/static/description/demo03.jpg b/app_ai_bard/static/description/demo03.jpg new file mode 100644 index 00000000..f8f05ac6 Binary files /dev/null and b/app_ai_bard/static/description/demo03.jpg differ diff --git a/app_ai_bard/static/description/demo04.jpg b/app_ai_bard/static/description/demo04.jpg new file mode 100644 index 00000000..0051ee1d Binary files /dev/null and b/app_ai_bard/static/description/demo04.jpg differ diff --git a/app_ai_bard/static/description/demo1.jpg b/app_ai_bard/static/description/demo1.jpg new file mode 100644 index 00000000..ff7e66d4 Binary files /dev/null and b/app_ai_bard/static/description/demo1.jpg differ diff --git a/app_ai_bard/static/description/demo2.jpg b/app_ai_bard/static/description/demo2.jpg new file mode 100644 index 00000000..c1fad2d0 Binary files /dev/null and b/app_ai_bard/static/description/demo2.jpg differ diff --git a/app_ai_bard/static/description/demo3.jpg b/app_ai_bard/static/description/demo3.jpg new file mode 100644 index 00000000..427f8b90 Binary files /dev/null and b/app_ai_bard/static/description/demo3.jpg differ diff --git a/app_ai_bard/static/description/demo4.jpg b/app_ai_bard/static/description/demo4.jpg new file mode 100644 index 00000000..b83102fa Binary files /dev/null and b/app_ai_bard/static/description/demo4.jpg differ diff --git a/app_ai_bard/static/description/demo5.jpg b/app_ai_bard/static/description/demo5.jpg new file mode 100644 index 00000000..c8f3ffd6 Binary files /dev/null and b/app_ai_bard/static/description/demo5.jpg differ diff --git a/app_ai_bard/static/description/demo6.jpg b/app_ai_bard/static/description/demo6.jpg new file mode 100644 index 00000000..af62be26 Binary files /dev/null and b/app_ai_bard/static/description/demo6.jpg differ diff --git a/app_ai_bard/static/description/demo7.jpg b/app_ai_bard/static/description/demo7.jpg new file mode 100644 index 00000000..d65a8b2a Binary files /dev/null and b/app_ai_bard/static/description/demo7.jpg differ diff --git a/app_ai_bard/static/description/demo71.jpg b/app_ai_bard/static/description/demo71.jpg new file mode 100644 index 00000000..a5c83ab2 Binary files /dev/null and b/app_ai_bard/static/description/demo71.jpg differ diff --git a/app_ai_bard/static/description/demo8.jpg b/app_ai_bard/static/description/demo8.jpg new file mode 100644 index 00000000..e17bab42 Binary files /dev/null and b/app_ai_bard/static/description/demo8.jpg differ diff --git a/app_ai_bard/static/description/demo81.jpg b/app_ai_bard/static/description/demo81.jpg new file mode 100644 index 00000000..cf73a540 Binary files /dev/null and b/app_ai_bard/static/description/demo81.jpg differ diff --git a/app_ai_bard/static/description/demo9.jpg b/app_ai_bard/static/description/demo9.jpg new file mode 100644 index 00000000..e8760f93 Binary files /dev/null and b/app_ai_bard/static/description/demo9.jpg differ diff --git a/app_ai_bard/static/description/demo91.jpg b/app_ai_bard/static/description/demo91.jpg new file mode 100644 index 00000000..ccad6d14 Binary files /dev/null and b/app_ai_bard/static/description/demo91.jpg differ diff --git a/app_ai_bard/static/description/demoa.jpg b/app_ai_bard/static/description/demoa.jpg new file mode 100644 index 00000000..02e4e950 Binary files /dev/null and b/app_ai_bard/static/description/demoa.jpg differ diff --git a/app_ai_bard/static/description/demob.jpg b/app_ai_bard/static/description/demob.jpg new file mode 100644 index 00000000..9d845f51 Binary files /dev/null and b/app_ai_bard/static/description/demob.jpg differ diff --git a/app_ai_bard/static/description/icon.png b/app_ai_bard/static/description/icon.png new file mode 100644 index 00000000..5392d797 Binary files /dev/null and b/app_ai_bard/static/description/icon.png differ diff --git a/app_ai_bard/static/description/index.html b/app_ai_bard/static/description/index.html new file mode 100644 index 00000000..a9ebd64f --- /dev/null +++ b/app_ai_bard/static/description/index.html @@ -0,0 +1,263 @@ +
+
+
+

Google Bard Ai for odoo ai center

+

Ai center addons. all aigc in one.

+
+

Latest update: v17.24.11.06

+
+
+ + Add google bard support, update chatgpt api
+ +
+
+ +
+
+
+ Key features: +
    +
  • + + 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. +
  • +
+
+
+
+
+
+
+ +
+
+

Add more Ai support like google bard, chatgpt 4, baidu china

+

Need to navigate to odoo app store to buy and install addons

+
+ +
+

Please apply for the bard api first from google

+
+ +
+

Setup for your own key

+
+ +
+
+
+ +
+
+

Easy to use Ai Robot with multi Provider. Easy chat, easy help

+

Open Ai for more smart. Microsoft Azure chatgpt for china user.

+
+ +
+
+
+ +
+
+

1. Multi ChatGpt openAI robot Connector. Chat and train.

+

Goto Setting--> GPT Robot to setup your robot api.

+

Input your api key, And Select the api model you need to use.

+
+ +
+

You can set the Temperature higer for more creative answer.

+
+ +
+
+
+ + +
+
+

2. Multi Api support, Chatgpt 3.5 Turbo, Chatgpt 3 Davinci, Chatgpt 2 Code Optimized, 'Dall-E Image.

+

Choose the model you want to use

+
+ +
+

You can set the Temperature higer for more creative answer.

+
+ +
+
+
+ +
+
+

3. Bind ChatGpt Api to user. So we can chat to robot user or use ChatGpt Channel for Group Chat.

+

Go Settings ->users, bind chatgpt to some user.

+ +
+

So you can have many user, and many chatgpt robot. This provide you an Ai pool.

+
+ +
+

You can set the blacklist to this chatgpt robot to limit request. Also you can setup Demo time for every normal user..

+
+ +
+ +
+ +
+
+

4. White and black List for ChatGpt.

+

5. Setup Demo Chat time for every new user.

+

You can set the blacklist to this chatgpt robot to limit request. Also you can setup Demo time for every normal user..

+
+ +
+
+
+ +
+
+

6. Easy Start and Stop ChatGpt..

+

You can easy chat with the apt robot with odoo IM

+
+ +
+

You can chat with several robot in the same time

+
+ +
+

If you have more than 1 robot in the group. you can @ the specify robot.

+
+ +
+
+
+ + +
+
+

7. Evaluation the ai robot to make better response. This training.

+

You can Evaluation chatgpt's answer. Mark as good for good answer. Mark as back for bad answer.

+

With Evaluation, you can make your ai robot more smart. +

+ +
+
+
+ +
+
+

8. Add api support Connect the Microsoft Azure OpenAI Service.

+

Azure openai add. It is for china and other country which no chatgpt service.

+
+ +
+
+
+ +
+
+

9. Can set Synchronous or Asynchronous mode for Ai response.

+

Synchronous(default) mode can get response then ask question again. Asynchronous mode would make you do other thing when waiting for response.

+
+ +
+
+
+ +
+
+

Multi-language Support..

+

+
+ +
+
+
+ +
+
+
+

Technical Help & Support

+
+
+
+

+ For any type of technical help & support requests, Feel free to contact us

+ + odoo@china.com +

+ Via QQ: 300883 (App user would not get QQ or any other IM support. Only for odoo project customize.)

+ + 300883@qq.com +
+
+

+ Visit our website for more support.

+ + https://www.odooai.cn +
+
+
+
+

More Powerful addons, Make your odoo very easy to use, easy customize: + odooai.cn Odoo Addons +

+
+
+ diff --git a/app_ai_bard/static/src/img/bard.gif b/app_ai_bard/static/src/img/bard.gif new file mode 100644 index 00000000..78de3734 Binary files /dev/null and b/app_ai_bard/static/src/img/bard.gif differ diff --git a/app_ai_bard/static/src/img/google.png b/app_ai_bard/static/src/img/google.png new file mode 100644 index 00000000..ed8841bd Binary files /dev/null and b/app_ai_bard/static/src/img/google.png differ diff --git a/app_ai_bard/static/src/odooai.cn b/app_ai_bard/static/src/odooai.cn new file mode 100644 index 00000000..e69de29b diff --git a/app_ai_bard/views/ai_robot_views.xml b/app_ai_bard/views/ai_robot_views.xml new file mode 100644 index 00000000..05a6f03f --- /dev/null +++ b/app_ai_bard/views/ai_robot_views.xml @@ -0,0 +1,100 @@ + + + + ai.robot.tree + ai.robot + + + + + + + + + + + + + + + + ai.robot.form + ai.robot + +
+
+
+ +
+
+ + + + + + + + + + + + + +
+ + +
+ + + + + + +
+ + + + +
+
+
+
+
+ + + GPT Robot + ai.robot + list,form + +

+ Let's create a GPT Robot. +

+
+
+ + + Disconnect + + + list,form + code + action = records.action_disconnect() + + + + +
diff --git a/app_ai_bard/views/res_partner_ai_use_views.xml b/app_ai_bard/views/res_partner_ai_use_views.xml new file mode 100644 index 00000000..716a8acb --- /dev/null +++ b/app_ai_bard/views/res_partner_ai_use_views.xml @@ -0,0 +1,94 @@ + + + + res.partner.ai.use.tree + res.partner.ai.use + + + + + + + + + + + + + + + + + + + + + res.partner.ai.use.form + res.partner.ai.use + +
+ + +
+
+
+ + + res.partner.ai.use.search + res.partner.ai.use + + + + + + + + + + + + + Partner Ai Use + res.partner.ai.use + list,form + {'create': 0, 'delete': 0} + + + + + Partner Ai Use + res.partner.ai.use + list,form + [('ai_user_id', 'in', active_ids)] + {'default_ai_user_id':active_id,} + + + +
diff --git a/app_ai_bard/views/res_users_views.xml b/app_ai_bard/views/res_users_views.xml new file mode 100644 index 00000000..ad87f8b8 --- /dev/null +++ b/app_ai_bard/views/res_users_views.xml @@ -0,0 +1,39 @@ + + + + app.chatgpt.res.users.form + res.users + + + + + + + + + + + + + + + + + + + + + + app.res.users.search + res.users + + + + + + + + + +