Merge branch 'drop_dependencies' into 'main'
deleted import from iap and method generate_text See merge request productteam/talismanplatform/modules/odoo_17.0.1/web_editor!1
This commit is contained in:
commit
4f27a23395
|
@ -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
|
Loading…
Reference in New Issue
Block a user