mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-15 22:11:36 +01:00
FIX Bad management of carriage return when requesting IA API.
This commit is contained in:
@@ -76,20 +76,19 @@ $ai = new Ai($db);
|
|||||||
|
|
||||||
// Get parameters
|
// Get parameters
|
||||||
$function = empty($jsonData['function']) ? 'textgeneration' : $jsonData['function']; // Default value. Can also be 'textgeneration', 'textgenerationemail', 'textgenerationwebpage', 'imagegeneration', 'videogeneration', ...
|
$function = empty($jsonData['function']) ? 'textgeneration' : $jsonData['function']; // Default value. Can also be 'textgeneration', 'textgenerationemail', 'textgenerationwebpage', 'imagegeneration', 'videogeneration', ...
|
||||||
$instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8');
|
|
||||||
$format = empty($jsonData['format']) ? '' : $jsonData['format']; // Can be '' for text, 'html', ...
|
$format = empty($jsonData['format']) ? '' : $jsonData['format']; // Can be '' for text, 'html', ...
|
||||||
|
|
||||||
if ($format == "html") {
|
if ($format == "html") {
|
||||||
$instructions = $jsonData['instructions'];
|
$instructions = $jsonData['instructions'];
|
||||||
} else {
|
} else {
|
||||||
$instructions = dol_string_nohtmltag($jsonData['instructions'], 1, 'UTF-8');
|
$instructions = dol_string_nohtmltag($jsonData['instructions'], 2, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note: The option AI_DEBUG will generate a log file dolibarr_ai.log when calling generateContent()
|
// Note: The option AI_DEBUG will generate a log file dolibarr_ai.log when calling generateContent()
|
||||||
dol_syslog("generate_content: function=".$function." format=".$format." instruction=".dol_substr($instructions, 0, 200));
|
dol_syslog("generate_content: function=".$function." format=".$format." instruction=".dol_substr($instructions, 0, 200));
|
||||||
|
|
||||||
|
|
||||||
$generatedContent = $ai->generateContent($instructions, 'auto', $function, $format);
|
$generatedContent = $ai->generateContent($instructions, 'auto', $function, $format);
|
||||||
|
|
||||||
if (empty($instructions)) {
|
if (empty($instructions)) {
|
||||||
|
|||||||
@@ -8955,7 +8955,7 @@ function picto_required()
|
|||||||
* - you can decide to convert line feed into a space
|
* - you can decide to convert line feed into a space
|
||||||
*
|
*
|
||||||
* @param string $stringtoclean String to clean
|
* @param string $stringtoclean String to clean
|
||||||
* @param integer $removelinefeed 1=Replace all new lines by 1 space, 0=Only ending new lines are removed others are replaced with \n, 2=The ending new line is removed but others are kept with the same number of \n than the nb of <br> when there is both "...<br>\n..."
|
* @param integer $removelinefeed 1=Replace all new lines strings ('<br>, "\n", "\r") by 1 space, 0=The last new line endings are removed and others '<br>' are replaced with "\n", 2=The last new line endings are removed and others '<br>\n' are replaced with "\n" with the same nb of "\n" than the nb of <br> when there is both "...<br>\n..."
|
||||||
* @param string $pagecodeto Encoding of input/output string
|
* @param string $pagecodeto Encoding of input/output string
|
||||||
* @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag or when tags is not closed like '<img onload=aaa')
|
* @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag or when tags is not closed like '<img onload=aaa')
|
||||||
* @param integer $removedoublespaces Replace double space into one space
|
* @param integer $removedoublespaces Replace double space into one space
|
||||||
|
|||||||
Reference in New Issue
Block a user