diff --git a/htdocs/ai/ajax/generate_content.php b/htdocs/ai/ajax/generate_content.php index 2eab4c88f73..4ffd318b484 100644 --- a/htdocs/ai/ajax/generate_content.php +++ b/htdocs/ai/ajax/generate_content.php @@ -123,9 +123,11 @@ if (empty($instructions)) { } else { // Default case 'textgeneration', 'texttranslation', 'textsummarize' if ($format == "html") { - print dolPrintHTML($generatedContent); // Note that common HTML tags are NOT escaped (but a sanitization is done) + print dolPrintHTML($generatedContent); } else { - print dolPrintText($generatedContent); // Note that common HTML tags are NOT escaped (but a sanitization is done) + // We must not use dolPrintText because dolPrintText format data including accent in htmlentities for a HTML output. We need a non formatted output. + //print dol_string_onlythesehtmltags('"Ça va" est une expression française et ceci une balise html', 1, 1, 1); + print dol_string_onlythesehtmltags($generatedContent, 1, 1, 1); } } } diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index bc4704f6a01..9074f5509e5 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -277,7 +277,7 @@ class Ai } else { $generatedContent = $decodedResponse['choices'][0]['message']['content']; } - dol_syslog("generatedContent=".dol_trunc($generatedContent, 50)); + dol_syslog("ai->generatedContent returned: ".dol_trunc($generatedContent, 50)); // If content is not HTML, we convert it into HTML if ($format == 'html') { diff --git a/htdocs/core/class/html.formai.class.php b/htdocs/core/class/html.formai.class.php index 5de0a36fe84..e6fa8f68376 100644 --- a/htdocs/core/class/html.formai.class.php +++ b/htdocs/core/class/html.formai.class.php @@ -356,6 +356,7 @@ class FormAI extends Form CKEDITOR.instances[htmlname].setReadOnly(1); } + console.log('Call generate_content.php'); $.ajax({ url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."', type: 'POST', diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c5451c088eb..ffd0042bd83 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2247,7 +2247,7 @@ function dolPrintPassword($s) * @param int $keepb 1=Replace b tags with escaped value (except if in $noescapetags), 0=Remove them completely * @param int $keepn 1=Preserve \r\n strings, 0=Replace them with escaped value, -1=Remove them. Set to 1 when escaping for a