forked from cosmocode/dokuwiki-plugin-aichat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelSetting.php
More file actions
28 lines (22 loc) · 764 Bytes
/
ModelSetting.php
File metadata and controls
28 lines (22 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace dokuwiki\plugin\aichat;
use dokuwiki\plugin\config\core\Setting\SettingMultichoice;
class ModelSetting extends SettingMultichoice
{
/** @inheritdoc */
public function __construct($key, $params = null)
{
parent::__construct($key, $params);
$type = $params['type'] ?? 'chat';
$jsons = glob(__DIR__ . '/Model/*/models.json');
foreach ($jsons as $json) {
$models = json_decode(file_get_contents($json), true);
if (!isset($models[$type])) continue;
$namespace = basename(dirname($json));
foreach (array_keys($models[$type]) as $model) {
$this->choices[] = "$namespace $model";
}
}
sort($this->choices);
}
}