From 696387f4669ba7c5b33195eb14e89bacd2691112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BE=D1=80=D0=BE=D0=B1=D1=8C=D0=B5=D0=B2=20=D0=94?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=20=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B5?= =?UTF-8?q?=D0=B2=D0=B8=D1=87?= Date: Fri, 17 May 2024 18:18:14 +0300 Subject: [PATCH] deleted import from iap and method generate_text --- controllers/main.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/controllers/main.py b/controllers/main.py index cda5c5c..6208732 100644 --- a/controllers/main.py +++ b/controllers/main.py @@ -24,7 +24,7 @@ from odoo.exceptions import UserError, MissingError, AccessError from odoo.tools.misc import file_open from odoo.tools.mimetypes import guess_mimetype from odoo.tools.image import image_data_uri, binary_to_image -from odoo.addons.iap.tools import iap_tools + from odoo.addons.base.models.assetsbundle import AssetsBundle from ..models.ir_attachment import SUPPORTED_IMAGE_MIMETYPES @@ -799,22 +799,4 @@ class Web_Editor(http.Controller): @http.route("/web_editor/generate_text", type="json", auth="user") def generate_text(self, prompt, conversation_history): - try: - IrConfigParameter = request.env['ir.config_parameter'].sudo() - olg_api_endpoint = IrConfigParameter.get_param('web_editor.olg_api_endpoint', DEFAULT_OLG_ENDPOINT) - database_id = IrConfigParameter.get_param('database.uuid') - response = iap_tools.iap_jsonrpc(olg_api_endpoint + "/api/olg/1/chat", params={ - 'prompt': prompt, - 'conversation_history': conversation_history or [], - 'database_id': database_id, - }, timeout=30) - if response['status'] == 'success': - return response['content'] - elif response['status'] == 'error_prompt_too_long': - raise UserError(_("Sorry, your prompt is too long. Try to say it in fewer words.")) - elif response['status'] == 'limit_call_reached': - raise UserError(_("You have reached the maximum number of requests for this service. Try again later.")) - else: - raise UserError(_("Sorry, we could not generate a response. Please try again later.")) - except AccessError: - raise AccessError(_("Oops, it looks like our AI is unreachable!")) + return \ No newline at end of file