From 4ecf7334e53b66a9fa7c5e29ed36cc40968c9b12 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Tue, 11 Feb 2025 14:30:48 +0100 Subject: [PATCH 1/3] Added substitutions in AI response --- htdocs/core/class/html.formmail.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a9b87e75da69e..2ad80549cfc56 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1554,6 +1554,16 @@ public function getSectionForAIPrompt($function = 'textgeneration', $format = '' }), success: function(response) { console.log('Received image URL: '+response); + + // make substitutions + let substit = ". json_encode($this->substit)."; + for (let key in substit) { + if (substit.hasOwnProperty(key)) { + // Replace the placeholder with its corresponding value + response = response.replace(key, substit[key]); + } + } + // Assuming response is the URL of the generated image var imageUrl = response; $('#ai_image_result').html('\"Generated'); From 898beaa75021a167aae7162b37647efa610ddc0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2025 22:52:42 +0100 Subject: [PATCH 2/3] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 2ad80549cfc56..e5319cbf30e60 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1554,7 +1554,7 @@ public function getSectionForAIPrompt($function = 'textgeneration', $format = '' }), success: function(response) { console.log('Received image URL: '+response); - + // make substitutions let substit = ". json_encode($this->substit)."; for (let key in substit) { @@ -1563,7 +1563,7 @@ public function getSectionForAIPrompt($function = 'textgeneration', $format = '' response = response.replace(key, substit[key]); } } - + // Assuming response is the URL of the generated image var imageUrl = response; $('#ai_image_result').html('\"Generated'); From 6ab6f02241cc728d3074c28244687f2f5a82f398 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2025 23:02:04 +0100 Subject: [PATCH 3/3] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index e5319cbf30e60..1fdd72ab37158 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1562,7 +1562,7 @@ public function getSectionForAIPrompt($function = 'textgeneration', $format = '' // Replace the placeholder with its corresponding value response = response.replace(key, substit[key]); } - } + } // Assuming response is the URL of the generated image var imageUrl = response;