mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update app_chatgpt: get_ai_post
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'ChatGPT4, China Ali,AiGC Center.Ai服务中心,聚合全网Ai',
|
'name': 'ChatGPT4, China Ali,AiGC Center.Ai服务中心,聚合全网Ai',
|
||||||
'version': '24.03.28',
|
'version': '24.03.29',
|
||||||
'author': 'odooai.cn',
|
'author': 'odooai.cn',
|
||||||
'company': 'odooai.cn',
|
'company': 'odooai.cn',
|
||||||
'maintainer': 'odooai.cn',
|
'maintainer': 'odooai.cn',
|
||||||
|
|||||||
@@ -171,12 +171,15 @@ GPT-3 A set of models that can understand and generate natural language
|
|||||||
res_post, usage, is_ai = self.get_ai_post(res, author_id, answer_id, param)
|
res_post, usage, is_ai = self.get_ai_post(res, author_id, answer_id, param)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_ai_post(self, res, author_id=False, answer_id=False, param={}):
|
def get_ai_post(self, res, author_id=False, answer_id=False, param=None):
|
||||||
# hook,高级版要替代
|
# hook,高级版要替代
|
||||||
if res and author_id or isinstance(res, list) or isinstance(res, dict):
|
if param is None:
|
||||||
# TODO: and type(res) == openai.Completion
|
param = {}
|
||||||
|
if not res or not author_id or (not isinstance(res, list) and not isinstance(res, dict)):
|
||||||
|
return res, False, False
|
||||||
# 返回是个对象,那么就是ai
|
# 返回是个对象,那么就是ai
|
||||||
# if isinstance(res, dict):
|
usage = content = data = None
|
||||||
|
try:
|
||||||
if self.provider == 'openai':
|
if self.provider == 'openai':
|
||||||
# openai 格式处理
|
# openai 格式处理
|
||||||
usage = res['usage']
|
usage = res['usage']
|
||||||
@@ -184,15 +187,15 @@ GPT-3 A set of models that can understand and generate natural language
|
|||||||
# _logger.warning('===========Ai响应:%s' % content)
|
# _logger.warning('===========Ai响应:%s' % content)
|
||||||
elif self.provider == 'azure':
|
elif self.provider == 'azure':
|
||||||
# azure 格式
|
# azure 格式
|
||||||
usage = json.loads(json.dumps(res['usage']))
|
usage = res['usage']
|
||||||
content = json.loads(json.dumps(res['choices'][0]['message']['content']))
|
content = res['choices'][0]['message']['content']
|
||||||
else:
|
else:
|
||||||
usage = False
|
usage = False
|
||||||
content = res
|
content = res
|
||||||
data = content.replace(' .', '.').strip()
|
data = content.replace(' .', '.').strip()
|
||||||
return data, usage, True
|
return data, usage, True
|
||||||
else:
|
except Exception as e:
|
||||||
# 直接返回错误语句,那么就是非ai
|
_logger.error('==========app_chatgpt get_ai_post Error: %s' % e)
|
||||||
return res, False, False
|
return res, False, False
|
||||||
|
|
||||||
def get_ai_system(self, content=None):
|
def get_ai_system(self, content=None):
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<img class="oe_demo oe_screenshot img img-fluid" src="demo02.jpg">
|
<img class="oe_demo oe_screenshot img img-fluid" src="demo02.jpg">
|
||||||
</div>
|
</div>
|
||||||
<h3>Lastest update: v17.24.03.28</h3>
|
<h3>Lastest update: v17.24.03.29</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<img class="oe_demo oe_screenshot img img-fluid" style="max-height: 100%;" src="banner.png">
|
<img class="oe_demo oe_screenshot img img-fluid" style="max-height: 100%;" src="banner.png">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user