fix #I6WMVK [app_chatgpt] ChatGPT 使用情况,对话权限为所有用户时,也要保存数据

This commit is contained in:
Chill
2023-04-18 13:50:23 +08:00
parent 3072c7399b
commit c004ea5e82

View File

@@ -141,7 +141,7 @@ GPT-3 A set of models that can understand and generate natural language
content = json.loads(json.dumps(res['choices'][0]['message']['content']))
data = content.replace(' .', '.').strip()
answer_user = answer_id.mapped('user_ids')[:1]
if answer_user.gpt_policy == 'limit' and usage:
if usage:
prompt_tokens = usage['prompt_tokens']
completion_tokens = usage['completion_tokens']
total_tokens = usage['total_tokens']
@@ -151,6 +151,7 @@ GPT-3 A set of models that can understand and generate natural language
if not ai_use:
ai_use.create({
'name': author_id.id,
'ai_user_id': answer_user.id,
'human_prompt_tokens': prompt_tokens,
'ai_completion_tokens': completion_tokens,
'tokens_total': total_tokens,