dolibarr 25.0.0-alpha
list_models.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Jose Martinez <jose.martinez@pichinov.com>
3 *
4 * This program 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 * This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
29if (!defined('NOTOKENRENEWAL')) {
30 define('NOTOKENRENEWAL', '1');
31}
32if (!defined('NOREQUIREMENU')) {
33 define('NOREQUIREMENU', '1');
34}
35if (!defined('NOREQUIREHTML')) {
36 define('NOREQUIREHTML', '1');
37}
38if (!defined('NOREQUIREAJAX')) {
39 define('NOREQUIREAJAX', '1');
40}
41if (!defined('NOREQUIRESOC')) {
42 define('NOREQUIRESOC', '1');
43}
44
45require '../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/ai/lib/ai.lib.php';
55top_httphead('application/json');
56
57if (!isModEnabled('ai')) {
58 http_response_code(403);
59 print json_encode(array('error' => 'Module not enabled'));
60 exit;
61}
62// Same gate as the assistant itself: the dedicated right, or admin.
63if (empty($user->admin) && !$user->hasRight('ai', 'assistant', 'use')) {
64 http_response_code(403);
65 print json_encode(array('error' => 'Permission denied'));
66 exit;
67}
68
69$list = getAiProviderModelList($db);
70
71print json_encode(array('service' => $list['service'], 'models' => $list['models']));
getAiProviderModelList($db, $forcerefresh=false)
Return the list of model ids offered by the configured AI provider, with a 1-hour cache in the consta...
Definition ai.lib.php:624
isModEnabled($module)
Is Dolibarr module enabled.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.