Merge branch 'MDL-84819-main' of https://github.com/HuongNV13/moodle
This commit is contained in:
@@ -43,7 +43,7 @@ class dalle3 extends base implements openai_base {
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function model_type(): int {
|
||||
return self::MODEL_TYPE_IMAGE;
|
||||
public function model_type(): array {
|
||||
return [self::MODEL_TYPE_IMAGE];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class gpt4o extends base implements openai_base {
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function model_type(): int {
|
||||
return self::MODEL_TYPE_TEXT;
|
||||
public function model_type(): array {
|
||||
return [self::MODEL_TYPE_TEXT];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class o1 extends gpt4o {
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function model_type(): int {
|
||||
return self::MODEL_TYPE_TEXT;
|
||||
public function model_type(): array {
|
||||
return [self::MODEL_TYPE_TEXT];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ interface openai_base {
|
||||
public const MODEL_TYPE_IMAGE = 2;
|
||||
|
||||
/**
|
||||
* Get model type.
|
||||
* Get model types.
|
||||
*
|
||||
* @return int Model type.
|
||||
* @return array List of model types.
|
||||
*/
|
||||
public function model_type(): int;
|
||||
public function model_type(): array;
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ class action_form extends action_settings_form {
|
||||
global $PAGE;
|
||||
$PAGE->requires->js_call_amd('aiprovider_openai/modelchooser', 'init');
|
||||
$mform = $this->_form;
|
||||
$actionname = $this->actionname;
|
||||
|
||||
// Action model to use.
|
||||
$mform->addElement(
|
||||
@@ -155,13 +156,15 @@ class action_form extends action_settings_form {
|
||||
(!array_key_exists($this->actionconfig['model'], $this->get_model_list($modeltype)) ||
|
||||
!empty($this->actionconfig['modelextraparams']))) {
|
||||
$defaultmodel = 'custom';
|
||||
} else if (empty($this->actionconfig['model'])) {
|
||||
$defaultmodel = ($actionname === 'generate_image') ? 'dall-e-3' : 'gpt-4o';
|
||||
} else {
|
||||
$defaultmodel = $this->actionconfig['model'] ?? 'gpt-4o';
|
||||
$defaultmodel = $this->actionconfig['model'];
|
||||
}
|
||||
$mform->setDefault('modeltemplate', $defaultmodel);
|
||||
$mform->addHelpButton('modeltemplate', "action:{$this->actionname}:model", 'aiprovider_openai');
|
||||
|
||||
$mform->addElement('hidden', 'model', $this->actionconfig['model'] ?? 'gpt-4o');
|
||||
$mform->addElement('hidden', 'model', $defaultmodel);
|
||||
$mform->setType('model', PARAM_TEXT);
|
||||
|
||||
$mform->addElement('text', 'custommodel', get_string('custom_model_name', 'aiprovider_openai'));
|
||||
@@ -189,7 +192,7 @@ class action_form extends action_settings_form {
|
||||
$models['custom'] = get_string('custom', 'core_form');
|
||||
foreach (helper::get_model_classes() as $class) {
|
||||
$model = new $class();
|
||||
if ($model->model_type() == $modeltype) {
|
||||
if (in_array($modeltype, $model->model_type())) {
|
||||
$models[$model->get_model_name()] = $model->get_model_display_name();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user