MDL-87267 aiplacement_courseassist: Improve response formatting

This commit is contained in:
raortegar
2025-12-03 11:15:44 +07:00
committed by Huong Nguyen
parent ac30e7e193
commit a3063dcaa4
2 changed files with 4 additions and 2 deletions
@@ -94,10 +94,11 @@ class explain_text extends external_api {
// Send the action to the AI manager.
$manager = \core\di::get(\core_ai\manager::class);
$response = $manager->process_action($action);
$generatedcontent = $response->get_response_data()['generatedcontent'] ?? '';
// Return the response.
return [
'success' => $response->get_success(),
'generatedcontent' => $response->get_response_data()['generatedcontent'] ?? '',
'generatedcontent' => \core_external\util::format_text($generatedcontent, FORMAT_PLAIN, $contextid)[0],
'finishreason' => $response->get_response_data()['finishreason'] ?? '',
'errorcode' => $response->get_errorcode(),
'error' => $response->get_error(),
@@ -94,10 +94,11 @@ class summarise_text extends external_api {
// Send the action to the AI manager.
$manager = \core\di::get(\core_ai\manager::class);
$response = $manager->process_action($action);
$generatedcontent = $response->get_response_data()['generatedcontent'] ?? '';
// Return the response.
return [
'success' => $response->get_success(),
'generatedcontent' => $response->get_response_data()['generatedcontent'] ?? '',
'generatedcontent' => \core_external\util::format_text($generatedcontent, FORMAT_PLAIN, $contextid)[0],
'finishreason' => $response->get_response_data()['finishreason'] ?? '',
'errorcode' => $response->get_errorcode(),
'error' => $response->get_error(),