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_ollama\form;
|
|
|
18 |
|
|
|
19 |
use aiprovider_ollama\aimodel\ollama_base;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Base action settings form for Ollama provider.
|
|
|
23 |
*
|
|
|
24 |
* @package aiprovider_ollama
|
|
|
25 |
* @copyright 2025 Huong Nguyen <huongnv13@gmail.com>
|
|
|
26 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
27 |
*/
|
|
|
28 |
class action_generate_text_form extends action_form {
|
|
|
29 |
#[\Override]
|
|
|
30 |
protected function definition(): void {
|
|
|
31 |
parent::definition();
|
|
|
32 |
$mform = $this->_form;
|
|
|
33 |
|
|
|
34 |
$this->add_model_fields(ollama_base::MODEL_TYPE_TEXT);
|
|
|
35 |
|
|
|
36 |
// System Instructions.
|
|
|
37 |
$mform->addElement(
|
|
|
38 |
'textarea',
|
|
|
39 |
'systeminstruction',
|
|
|
40 |
get_string("action:{$this->actionname}:systeminstruction", 'aiprovider_ollama'),
|
|
|
41 |
'wrap="virtual" rows="5" cols="20"',
|
|
|
42 |
);
|
|
|
43 |
$mform->setType('systeminstruction', PARAM_TEXT);
|
|
|
44 |
$mform->setDefault('systeminstruction', $actionconfig['systeminstruction'] ?? $this->action::get_system_instruction());
|
|
|
45 |
$mform->addHelpButton('systeminstruction', "action:{$this->actionname}:systeminstruction", 'aiprovider_ollama');
|
|
|
46 |
|
|
|
47 |
if ($this->returnurl) {
|
|
|
48 |
$mform->addElement('hidden', 'returnurl', $this->returnurl);
|
|
|
49 |
$mform->setType('returnurl', PARAM_LOCALURL);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
// Add the action class as a hidden field.
|
|
|
53 |
$mform->addElement('hidden', 'action', $this->action);
|
|
|
54 |
$mform->setType('action', PARAM_TEXT);
|
|
|
55 |
|
|
|
56 |
// Add the provider class as a hidden field.
|
|
|
57 |
$mform->addElement('hidden', 'provider', $this->providername);
|
|
|
58 |
$mform->setType('provider', PARAM_TEXT);
|
|
|
59 |
|
|
|
60 |
// Add the provider id as a hidden field.
|
|
|
61 |
$mform->addElement('hidden', 'providerid', $this->providerid);
|
|
|
62 |
$mform->setType('providerid', PARAM_INT);
|
|
|
63 |
|
|
|
64 |
$this->set_data($this->actionconfig);
|
|
|
65 |
}
|
|
|
66 |
}
|