You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[docs] AI: Update AI subsystem documentation (MDL-83403) [4.5]
This commit overall does the following:
- Adjust the function name with the latest changes
- Add a diagram in the design overview
- Content restructuring
Co-authored-by: David Woloszyn <[email protected]>
The AI Subsystem in Moodle LMS provides a consistent and user-friendly way for users to interact with AI
13
-
in Moodle's user interface, as they do their teaching and learning activities.
14
-
As well as providing a straightforward way to integrate with various AI providers on the backend.
13
+
in Moodle. It has been designed for easy integration with various AI providers and the development of [AI plugins](/apis/plugintypes/ai/index.md).
15
14
16
15
## What is AI in this context?
17
16
18
-
When we talk about AI in the context of this subsystem, AI is: anything that's plugged in via a Provider
19
-
Plugin and provides one or more Actions.
17
+
The term 'AI' is very broad and covers a range of concepts like Artificial Intelligence (AI), Machine Learning (ML),
18
+
Large Language Models (LLMs), Generative AI, etc.
20
19
21
-
Artificial Intelligence (AI), Machine Learning (ML), Large Language Models (LLMs), Generative AI, etc.
22
-
are all individual terms with discrete meanings. However, to keep things simple and in the context of
23
-
the subsystem everything is just called AI.
20
+
However, in the context of Moodle, we are simplifying the term 'AI' to mean the tools and actions AI technologies provide to the LMS learning experience.
21
+
These AI tools are supplied in the form of [plugins](/apis/plugintypes/ai/index.md) that feature a set of possible actions.
22
+
23
+
For example, the [Placement plugin](/apis/plugintypes/ai/placement.md) allows users to gain access to the Course Assistant. This AI tool enables
24
+
users to have information within their course summarised by the integrated AI.
25
+
26
+
This is the context of the term 'AI'.
24
27
25
28
## Design Overview
26
29
27
-
The AI subsystem consists of the following (main) components:
30
+
```mermaid
31
+
sequenceDiagram
32
+
User->>Placement: Input action
33
+
Placement->>Manager: Action data
34
+
Manager->>Provider: Formatted action data
35
+
Provider->>External AI: Send data
36
+
External AI-->>Provider: Receive response
37
+
Provider-->>Manager: Response data
38
+
Manager-->>Placement: Formatted response data
39
+
Placement-->>User: Action completed
40
+
```
41
+
42
+
The AI Subsystem consists of the following (main) components:
28
43
29
44
-**Placements**
30
45
- Are the UI components and associated workflows that allow users to interact with AI.
31
46
- They implement one or more AI actions.
32
-
- They provide a consistent experience for users regardless of which AI is providing the action
33
-
- They are LMS plugins
47
+
- They provide a consistent experience for users regardless of which AI is providing the action.
48
+
- They are LMS plugins.
34
49
-**Actions**
35
-
- These are the "things" users can do with AI.
50
+
- These are the 'things' users can do with AI.
36
51
- Examples of an action include: generating text, generating an image, providing a chat interface.
37
52
- Actions don't have a UI, they are classes that provide a predictable interface.
38
53
-**Providers**
39
54
- Providers are the interface between AI systems and the Moodle LMS.
40
55
- They implement support for one or more actions.
41
-
- Providers should not have an UI, apart from those required for settings,
42
-
to configure and manage the provider. For example an Administration UI to allow setting of API
43
-
keys; and/or to enable or disable the enabled actions.
44
-
- The aim of Providers is to make it "easy" to integrate AI systems with LMS,
45
-
without the need to implement a UI to use them.
46
-
- They are LMS plugins
56
+
- Providers should not have a UI, apart from those required to configure the provider.
57
+
- The aim of Providers is to make it easy to integrate AI systems with Moodle LMS.
58
+
- They are LMS plugins.
47
59
-**Subsystem Manager**
48
60
- This is implemented at code level and is a core part of the subsystem design.
49
-
- It is the "controller" that sits between Placements and Providers.
50
-
- It allows Placements to pass user requests to Providers and handles all the calls to
51
-
the providers including prioritisation and logging.
61
+
- It is the 'controller' that sits between Placement and Provider plugins.
62
+
- It allows Placements to pass user requests to Providers and handles all the calls to the Providers, including prioritisation and logging.
52
63
- It allows Providers to respond to action requests.
53
64
54
65
### Placements
55
66
56
-
The aim of Placements is to provide a consistent UX and UI for users when they use AI backed functionality.
67
+
Placements provide a consistent UX and UI for users when they use AI backed functionality (e.g. generating an image).
57
68
58
69
Placement plugins leverage the functionality of the other components of the AI subsystem.
59
70
This means plugin authors can focus on how users interact with the AI functionality, without needing to
60
71
implement the AI functionality itself.
61
72
62
-
Because Placements are LMS plugins in their own right and are not "other" types of LMS plugins,
63
-
it gives great flexibility in how AI functionality is presented to users.
73
+
Because Placements are plugins in their own right, it allows for greater flexibility in how AI functionality is presented to users.
64
74
65
75
See the [Placements](/apis/plugintypes/ai/placement.md) documentation for more information
66
76
on developing Placement plugins.
67
77
68
78
### Providers
69
79
70
-
Provider plugins are the interface between the LMS AI subsystem and external AI systems.
71
-
Their focus is on converting the data requested by an Action into the format needed by the
72
-
external AI services API, and then correctly providing the response back from the AI
73
-
in an Action Response object.
74
-
75
-
Because of this design the Providers that provide the AI Actions can be swapped out, mix and matched
76
-
or upgraded; both without the need to update the Placement code and without the need to change the
77
-
way users interact with the functionality.
80
+
Providers are the interface between the [AI subsystem](/apis/subsystems/ai/index.md) and external AI.
81
+
Their focus should be on converting the data requested into the format needed
82
+
by the external AI, and then correctly providing the response back.
78
83
79
84
See the [Providers](/apis/plugintypes/ai/provider.md) documentation for more information
80
85
on developing Provider plugins.
81
86
82
87
### Subsystem Manager
83
88
84
-
The Subsystem Manager is the "controller" that sits between Placements and Providers.
89
+
The Subsystem Manager is the 'controller' that sits between Placements and Providers.
90
+
In general it will be how most processes will interact with the AI subsystem.
85
91
86
92
:::warning The Golden Rule:
87
93
88
-
Placements DO NOT know about Providers, and Providers DO NOT know about Placements.
94
+
Placements **do not** know about Providers, and Providers **do not** know about Placements.
89
95
Everything should go via the Manager.
90
96
91
97
:::
92
98
93
-
The manager class `\core_ai\manager()` is the "controller" for the subsystem.
94
-
In general it will be how most processes will interact with the AI subsystem.
95
-
96
-
The main method in the class is `process_action(base $action): responses\response_base`
97
-
this is the entry point for Action processing. Every Placement that wants to process an AI action
98
-
calls this method.
99
-
The manager will determine what Providers support this action and then hand off the action object to
100
-
a Provider. The Provider **MUST** return an action response object. This method will also store the
99
+
The main method in the class is `process_action(base $action): responses\response_base`.
100
+
This is the entry point for Action processing. Every Placement that wants to process an AI action calls this method.
101
+
The Manager will determine which Providers support this action and then hand-off the action object to
102
+
a Provider. The Provider **must** return an action response object. This method will also store the
101
103
result of each action call.
102
104
103
-
The manager class also has various utility methods that can be accessed.
104
-
Such as getting the list of providers for specific actions, which is used to help render
105
-
administration settings.
106
-
107
-
### AI User Policy
108
-
109
-
Inline with Moodle's AI Principles and as guided by emerging legislation; users must accept an
110
-
AI policy before using AI in LMS. As the requirements are different to a site policy
111
-
(legislation, seems to indicate it acknowledgement of AI must be made at point of use),
112
-
separate policy functionality has been implemented for the subsystem.
113
-
114
-
All Placements must implement a check to see if a user has accepted the AI Policy.
115
-
Placements must also provide a way for users to accept the policy.
116
-
If a user has not previously accepted the AI Policy, the Placement must display the policy to the
117
-
user, and the user is not able to use the placement until they accept the policy.
118
-
Users only need to accept the policy once.
119
-
120
-
To assist Placements with policy display and acceptance the Manager provides the following functionality:
121
-
122
-
- The Manager makes the following methods available for Placements to call directly:
0 commit comments