Repository navigation
Expand file tree
/
Copy pathConfig.php
More file actions
137 lines (120 loc) · 4.15 KB
/
Copy pathConfig.php
File metadata and controls
137 lines (120 loc) · 4.15 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\ChatGPT;
/**
* Configuration constants and static data for ChatGPT plugin.
* This class has no dependencies to avoid circular loading issues.
*/
class Config
{
public const DEFAULT_HOST = 'https://api.openai.com/v1/chat/completions';
/**
* Whether a host is the API of the provider, which always needs a key. Any other host is a custom host
* (self-hosted or compatible endpoint), where the key is optional.
*/
public static function isDefaultHost(string $host): bool
{
return rtrim(strtolower(trim($host)), '/') === self::DEFAULT_HOST;
}
/**
* Model option resolved to RECOMMENDED_MODEL when a request is sent, so the installs using it follow the
* recommendation of each plugin release without changing their settings.
*/
public const LATEST_RECOMMENDED_MODEL = 'latest-recommended';
public const RECOMMENDED_MODEL = 'gpt-6-astra';
public const DEFAULT_MODEL = self::LATEST_RECOMMENDED_MODEL;
/**
* Returns the list of available preset models.
*
* Only conversational chat-completions models are listed: reasoning
* models (o-series), *-pro and *-codex variants are intentionally excluded
* because they are tuned for one-shot deep analysis or code rather than
* back-and-forth discussion of report data.
*/
public static function getAvailableModels(): array
{
return [
// GPT-6
'gpt-6-astra' => 'GPT 6 Astra',
'gpt-6.1-sol' => 'GPT 6.1 Sol',
'gpt-6-sol' => 'GPT 6 Sol',
'gpt-6-luna' => 'GPT 6 Luna',
// GPT-5.6
'gpt-5.6-sol' => 'GPT 5.6 Sol',
'gpt-5.6-terra' => 'GPT 5.6 Terra',
'gpt-5.6-luna' => 'GPT 5.6 Luna',
// GPT-5.5 / GPT-5.4
'gpt-5.5' => 'GPT 5.5',
'gpt-5.4' => 'GPT 5.4',
'gpt-5.4-mini' => 'GPT 5.4 mini',
'gpt-5.4-nano' => 'GPT 5.4 nano',
// GPT-5.2 / GPT-5.1 / GPT-5
'gpt-5.2' => 'GPT 5.2',
'gpt-5.1' => 'GPT 5.1',
'gpt-5' => 'GPT 5',
'gpt-5-mini' => 'GPT 5 mini',
'gpt-5-nano' => 'GPT 5 nano',
// GPT-4.1 / GPT-4o
'gpt-4.1' => 'GPT 4.1',
'gpt-4.1-mini' => 'GPT 4.1 mini',
'gpt-4o' => 'GPT 4o',
'gpt-4o-mini' => 'GPT 4o mini',
];
}
/**
* Models deprecated or shut down by OpenAI, or removed from the preset list of a previous plugin version.
*
* @return string[]
*/
public static function getDeprecatedModels(): array
{
return [
'gpt-5-chat-latest',
'gpt-5.1-chat-latest',
'gpt-5.2-chat-latest',
'gpt-5.3-chat-latest',
'gpt-5-2025-08-07',
'gpt-5-mini-2025-08-07',
'gpt-5-nano-2025-08-07',
'gpt-4.1-nano',
'chatgpt-4o-latest',
'gpt-4',
'gpt-4-0613',
'gpt-4-1106-preview',
'gpt-4-turbo',
'gpt-4-turbo-preview',
'gpt-4-32k',
'gpt-4.5-preview',
'gpt-3.5-turbo',
'o1',
'o1-mini',
'o1-preview',
'o3-mini',
];
}
public static function isAvailableModel(string $model): bool
{
return $model === self::LATEST_RECOMMENDED_MODEL || array_key_exists($model, self::getAvailableModels());
}
public static function isDeprecatedModel(string $model): bool
{
return in_array(strtolower(trim($model)), self::getDeprecatedModels(), true);
}
/**
* Model sent to the API for a configured value.
*/
public static function resolveModel(string $model): string
{
$model = trim($model);
return ($model === '' || $model === self::LATEST_RECOMMENDED_MODEL) ? self::RECOMMENDED_MODEL : $model;
}
public static function getModelLabel(string $model): string
{
return self::getAvailableModels()[$model] ?? $model;
}
}