diff --git a/app_chatgpt/models/ai_robot.py b/app_chatgpt/models/ai_robot.py index 9be94c85..3b918728 100644 --- a/app_chatgpt/models/ai_robot.py +++ b/app_chatgpt/models/ai_robot.py @@ -387,11 +387,15 @@ GPT-3 A set of models that can understand and generate natural language "presence_penalty": 0.1, "stop": stop } - response = requests.post(o_url, data=json.dumps(pdata), headers=headers, timeout=R_TIMEOUT) - res = response.json() - if 'choices' in res: - res = '\n'.join([x['text'] for x in res['choices']]) - return res + response = openai.ChatCompletion.create( + model=self.ai_model, + messages=data + ) + # response = requests.post(o_url, data=json.dumps(pdata), headers=headers, timeout=R_TIMEOUT) + if 'choices' in response: + return response + else: + _logger.warning('=====================openai output data: %s' % response.json()) return _("Response Timeout, please speak again.") diff --git a/app_chatgpt/models/mail_channel.py b/app_chatgpt/models/mail_channel.py index 45f69028..ecb8abe6 100644 --- a/app_chatgpt/models/mail_channel.py +++ b/app_chatgpt/models/mail_channel.py @@ -241,7 +241,7 @@ class Channel(models.Model): # elif user_id.gpt_id and not is_allow: # # 暂时有限用户的Ai # raise UserError(_('此Ai暂时未开放,请联系管理员。')) - if hasattr(ai, 'is_translator') and ai.is_translator: + if hasattr(ai, 'is_translator') and ai.is_translator and ai.ai_model == 'translator': return rdata chatgpt_channel_id = self.env.ref('app_chatgpt.channel_chatgpt') diff --git a/app_chatgpt/views/res_users_views.xml b/app_chatgpt/views/res_users_views.xml index f1664e1e..e6c3a89d 100644 --- a/app_chatgpt/views/res_users_views.xml +++ b/app_chatgpt/views/res_users_views.xml @@ -17,6 +17,7 @@ +