fix #I6XRE8 【基本done,todo要变成服务】openai的vpn处理正常化

This commit is contained in:
ivan deng
2023-04-21 20:55:32 +08:00
parent 9c3b8f2575
commit 08981879a5

View File

@@ -143,8 +143,14 @@ GPT-3 A set of models that can understand and generate natural language
return res_post, is_ai
def get_ai_post(self, res, author_id=False, answer_id=False, param={}):
if res and author_id and isinstance(res, openai.openai_object.OpenAIObject) or isinstance(res, list):
if res and author_id and isinstance(res, openai.openai_object.OpenAIObject) or isinstance(res, list) or isinstance(res, dict):
# 返回是个对象那么就是ai
if isinstance(res, dict):
# openai 格式处理
usage = res['usage']
content = res['choices'][0]['message']['content']
else:
# azure 格式
usage = json.loads(json.dumps(res['usage']))
content = json.loads(json.dumps(res['choices'][0]['message']['content']))
data = content.replace(' .', '.').strip()