mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
add timeout
This commit is contained in:
@@ -1,23 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<odoo noupdate="1">
|
||||
<record id="chatgpt_robot" model="ai.robot">
|
||||
<field name="name">ChatGPT odoo</field>
|
||||
<field name="provider">openai</field>
|
||||
<field name="endpoint">https://api.openai.com/v1/chat/completions</field>
|
||||
<field name="sequence">1</field>
|
||||
</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>
|
||||
</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>
|
||||
</record>
|
||||
<record id="chatgpt_robot3" model="ai.robot">
|
||||
<field name="name">ChatGPT Azure</field>
|
||||
<field name="provider">azure</field>
|
||||
<field name="endpoint">https://my.openai.azure.com</field>
|
||||
<field name="engine">gpt35</field>
|
||||
<field name="sequence">8</field>
|
||||
</record>
|
||||
<record id="chatgpt4_azure" model="ai.robot">
|
||||
<field name="name">ChatGPT4 Azure</field>
|
||||
<field name="provider">azure</field>
|
||||
<field name="endpoint">https://my.openai.azure.com</field>
|
||||
<field name="engine">gpt4</field>
|
||||
<field name="sequence">9</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -62,5 +62,20 @@
|
||||
<field name="company_ids" eval="[Command.link(ref('base.main_company'))]"/>
|
||||
<field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/>
|
||||
</record>
|
||||
<record id="partner_chatgpt4_azure" model="res.partner">
|
||||
<field name="name">ChatGPT4 Azure</field>
|
||||
<field name="image_1920" type="base64" file="app_chatgpt/static/description/chatgpt.png"/>
|
||||
</record>
|
||||
|
||||
<record id="user_chatgpt4_azure" model="res.users">
|
||||
<field name="login">chatgpt4@sunpop.cn</field>
|
||||
<field name="email">chatgpt4@sunpop.cn</field>
|
||||
<field name="password">chatgpt</field>
|
||||
<field name="partner_id" ref="app_chatgpt.chatgpt4_azure"/>
|
||||
<field name="gpt_id" ref="app_chatgpt.chatgpt4_azure"/>
|
||||
<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>
|
||||
|
||||
@@ -42,6 +42,7 @@ GPT-3 A set of models that can understand and generate natural language
|
||||
endpoint = fields.Char('End Point', default='https://api.openai.com/v1/chat/completions')
|
||||
engine = fields.Char('Engine', help='If use Azure, Please input the Model deployment name.')
|
||||
api_version = fields.Char('API Version', default='2022-12-01')
|
||||
ai_timeout = fields.Integer('Timeout(seconds)', help="Connect timeout for Ai response", default=120)
|
||||
sequence = fields.Integer('Sequence', help="Determine the display order", default=10)
|
||||
sensitive_words = fields.Text('Sensitive Words Plus', help='Sensitive word filtering. Separate keywords with a carriage return.')
|
||||
is_filtering = fields.Boolean('Filter Sensitive Words', default=False, help='Use base Filter in dir models/lib/sensi_words.txt')
|
||||
@@ -77,7 +78,7 @@ GPT-3 A set of models that can understand and generate natural language
|
||||
def get_ai_model_info(self):
|
||||
self.ensure_one()
|
||||
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.openapi_api_key}"}
|
||||
R_TIMEOUT = 300
|
||||
R_TIMEOUT = self.ai_timeout or 120
|
||||
o_url = "https://api.openai.com/v1/models/%s" % self.ai_model
|
||||
if self.endpoint:
|
||||
o_url = self.endpoint.replace("/chat/completions", "") + "/models/%s" % self.ai_model
|
||||
@@ -94,7 +95,7 @@ GPT-3 A set of models that can understand and generate natural language
|
||||
def get_ai_list_model(self):
|
||||
self.ensure_one()
|
||||
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.openapi_api_key}"}
|
||||
R_TIMEOUT = 300
|
||||
R_TIMEOUT = self.ai_timeout or 120
|
||||
o_url = "https://api.openai.com/v1/models"
|
||||
if self.endpoint:
|
||||
o_url = self.endpoint.replace("/chat/completions", "") + "/models"
|
||||
@@ -110,7 +111,7 @@ GPT-3 A set of models that can understand and generate natural language
|
||||
def get_openai(self, data, partner_name='odoo', *args):
|
||||
self.ensure_one()
|
||||
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {self.openapi_api_key}"}
|
||||
R_TIMEOUT = 300
|
||||
R_TIMEOUT = self.ai_timeout or 120
|
||||
o_url = self.endpoint or "https://api.openai.com/v1/chat/completions"
|
||||
|
||||
# 以下处理 open ai
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
<field name="engine"/>
|
||||
<field name="endpoint"/>
|
||||
<field name="api_version"/>
|
||||
<field name="ai_timeout"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="is_filtering"/>
|
||||
|
||||
Reference in New Issue
Block a user