MDL-87267 aiplacement_courseassist: Improve response formatting

This commit is contained in:
raortegar
2025-12-03 11:17:21 +07:00
committed by Huong Nguyen
parent f5a401c0a5
commit 0df615a945
@@ -92,10 +92,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_errormessage(),