mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix deepseek
This commit is contained in:
@@ -69,3 +69,27 @@ class AiRobot(models.Model):
|
||||
return content, usage, True
|
||||
else:
|
||||
return super().get_ai_post(res, author_id, answer_id, param)
|
||||
|
||||
def get_ai_list_model(self):
|
||||
self.ensure_one()
|
||||
if self.provider == 'deepseek':
|
||||
api_key = self.openapi_api_key
|
||||
if not api_key:
|
||||
raise UserError(_("Please provide Ai Robot [%s] API Key." % self.name))
|
||||
payload = {}
|
||||
headers = {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': f'Bearer {self.openapi_api_key}'
|
||||
}
|
||||
R_TIMEOUT = self.ai_timeout or 120
|
||||
o_url = "https://api.deepseek.com/models"
|
||||
response = requests.get(o_url, headers=headers, data=payload, timeout=R_TIMEOUT)
|
||||
response.close()
|
||||
if response:
|
||||
res = response.json()
|
||||
r_text = json.dumps(res, indent=2)
|
||||
else:
|
||||
r_text = 'No response.'
|
||||
raise UserError(r_text)
|
||||
else:
|
||||
return super().get_ai_list_model()
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- <record id="baidu_ai_robot_form_view" model="ir.ui.view">
|
||||
<field name="name">baidu.ai.robot.form</field>
|
||||
<record id="app_ai_robot_deepseek_form_view" model="ir.ui.view">
|
||||
<field name="name">app.ai.robot.deepseek.form</field>
|
||||
<field name="model">ai.robot</field>
|
||||
<field name="inherit_id" ref="app_chatgpt.ai_robot_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='openapi_api_key']" position="after">
|
||||
<field name="client_secret" password="True"/>
|
||||
<xpath expr="//button[@name='get_ai_list_model']" position="attributes">
|
||||
<attribute name="invisible">False</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record> -->
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user