mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-82977 AI: Provider instances
Create provider instances for AI povider plugins. Each provider plugin can now have multiple instances, allowing for different configurations and models using the same base provider.
This commit is contained in:
parent
eabd31c5d3
commit
368114c7cd
56 changed files with 2987 additions and 477 deletions
|
@ -90,7 +90,7 @@ class summarise_text extends external_api {
|
|||
);
|
||||
|
||||
// Send the action to the AI manager.
|
||||
$manager = new \core_ai\manager();
|
||||
$manager = \core\di::get(\core_ai\manager::class);
|
||||
$response = $manager->process_action($action);
|
||||
// Return the response.
|
||||
return [
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace aiplacement_courseassist;
|
|||
class placement extends \core_ai\placement {
|
||||
|
||||
#[\Override]
|
||||
public function get_action_list(): array {
|
||||
public static function get_action_list(): array {
|
||||
return [
|
||||
\core_ai\aiactions\summarise_text::class,
|
||||
];
|
||||
|
|
|
@ -35,15 +35,16 @@ class utils {
|
|||
*/
|
||||
public static function is_course_assist_available(\context $context): bool {
|
||||
[$plugintype, $pluginname] = explode('_', \core_component::normalize_componentname('aiplacement_courseassist'), 2);
|
||||
$manager = \core_plugin_manager::resolve_plugininfo_class($plugintype);
|
||||
if (!$manager::is_plugin_enabled($pluginname)) {
|
||||
$pluginmanager = \core_plugin_manager::resolve_plugininfo_class($plugintype);
|
||||
if (!$pluginmanager::is_plugin_enabled($pluginname)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$providers = manager::get_providers_for_actions([summarise_text::class], true);
|
||||
$aimanager = \core\di::get(manager::class);
|
||||
$providers = $aimanager->get_providers_for_actions([summarise_text::class], true);
|
||||
if (!has_capability('aiplacement/courseassist:summarise_text', $context)
|
||||
|| !manager::is_action_available(summarise_text::class)
|
||||
|| !manager::is_action_enabled('aiplacement_courseassist', summarise_text::class)
|
||||
|| !$aimanager->is_action_available(summarise_text::class)
|
||||
|| !$aimanager->is_action_enabled('aiplacement_courseassist', summarise_text::class)
|
||||
|| empty($providers[summarise_text::class])
|
||||
) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue