Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace aiprovider_openai\aimodel;
18
 
19
use core_ai\aimodel\base;
20
use MoodleQuickForm;
21
 
22
/**
23
 * GPT-4o AI model.
24
 *
25
 * @package    aiprovider_openai
26
 * @copyright  2025 Huong Nguyen <huongnv13@gmail.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
class gpt4o extends base implements openai_base {
30
 
31
    #[\Override]
32
    public function get_model_name(): string {
33
        return 'gpt-4o';
34
    }
35
 
36
    #[\Override]
37
    public function get_model_display_name(): string {
38
        return 'GPT-4o';
39
    }
40
 
41
    #[\Override]
42
    public function has_model_settings(): bool {
43
        return true;
44
    }
45
 
46
    #[\Override]
47
    public function add_model_settings(MoodleQuickForm $mform): void {
48
        $mform->addElement(
49
            'text',
50
            'top_p',
51
            get_string('settings_top_p', 'aiprovider_openai'),
52
        );
53
        $mform->setType('top_p', PARAM_FLOAT);
54
        $mform->addHelpButton('top_p', 'settings_top_p', 'aiprovider_openai');
55
 
56
        $mform->addElement(
57
            'text',
58
            'max_completion_tokens',
59
            get_string('settings_max_completion_tokens', 'aiprovider_openai'),
60
        );
61
        $mform->setType('max_completion_tokens', PARAM_INT);
62
        $mform->addHelpButton('max_completion_tokens', 'settings_max_completion_tokens', 'aiprovider_openai');
63
 
64
        $mform->addElement(
65
            'text',
66
            'frequency_penalty',
67
            get_string('settings_frequency_penalty', 'aiprovider_openai'),
68
        );
69
        // This is a raw value because it can be a float from -2.0 to 2.0.
70
        $mform->setType('frequency_penalty', PARAM_RAW);
71
        $mform->addHelpButton('frequency_penalty', 'settings_frequency_penalty', 'aiprovider_openai');
72
 
73
        $mform->addElement(
74
            'text',
75
            'presence_penalty',
76
            get_string('settings_presence_penalty', 'aiprovider_openai'),
77
        );
78
        // This is a raw value because it can be a float from -2.0 to 2.0.
79
        $mform->setType('presence_penalty', PARAM_RAW);
80
        $mform->addHelpButton('presence_penalty', 'settings_presence_penalty', 'aiprovider_openai');
81
    }
82
 
83
    #[\Override]
84
    public function model_type(): array {
85
        return [self::MODEL_TYPE_TEXT];
86
    }
87
}