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
Copy file name to clipboardExpand all lines: docs/apis/plugintypes/ai/provider.md
+183Lines changed: 183 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -285,6 +285,189 @@ class action_generate_text_form extends action_settings_form {
285
285
...
286
286
```
287
287
288
+
## Predefined models
289
+
290
+
Pre-defined models allow AI providers to define specific model configurations that can be selected by users.
291
+
This provides a better user experience by offering known model options with appropriate default parameters rather than requiring manual configuration.
292
+
293
+
### Creating Model Classes
294
+
295
+
To implement pre-defined models, you will need to create model classes in the `[your_plugin]/classes/aimodel` directory and extend the `core_ai\aimodel\base` class.
296
+
297
+
For example, `aiprovider_openai` plugin defines this:
298
+
299
+
```php
300
+
namespace aiprovider_openai\aimodel;
301
+
302
+
use core_ai\aimodel\base;
303
+
use MoodleQuickForm;
304
+
305
+
class gpt4o extends base implements openai_base {
306
+
#[\Override]
307
+
public function get_model_name(): string {
308
+
return 'gpt-4o';
309
+
}
310
+
311
+
#[\Override]
312
+
public function get_model_display_name(): string {
313
+
return 'GPT-4o';
314
+
}
315
+
316
+
// Add other model-specific methods or properties
317
+
}
318
+
```
319
+
320
+
### Implementing Per-Model Settings
321
+
322
+
To add configurable settings for individual models:
323
+
324
+
1. Override the `has_model_settings()` and `add_model_settings()` methods:
325
+
326
+
```php
327
+
#[\Override]
328
+
public function has_model_settings(): bool {
329
+
return true;
330
+
}
331
+
332
+
#[\Override]
333
+
public function add_model_settings(MoodleQuickForm $mform): void {
0 commit comments