mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix ai_bard bug
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
{
|
||||
'name': 'Google Bard Ai for odoo ai center, 谷歌Ai支持',
|
||||
'version': '16.23.10.11',
|
||||
'version': '16.24.11.06',
|
||||
'author': 'odooai.cn',
|
||||
'company': 'odooai.cn',
|
||||
'maintainer': 'odooai.cn',
|
||||
|
||||
@@ -18,7 +18,7 @@ class AiRobot(models.Model):
|
||||
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'})
|
||||
@@ -28,13 +28,13 @@ class AiRobot(models.Model):
|
||||
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
|
||||
@@ -52,9 +52,9 @@ class AiRobot(models.Model):
|
||||
_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
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<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: v16.23.10.11</h3>
|
||||
<h3>Latest update: v16.24.11.06</h3>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<img class="" src="bard.gif">
|
||||
|
||||
Reference in New Issue
Block a user