fix: 修复 API 密钥查看按钮和模型列表获取问题

- 修复 API 密钥输入框的查看密码按钮被 label 包裹导致重复显示的问题
- 修复硅基流动模型列表过滤过于严格,只显示包含 Instruct 的模型
- 优化 OpenAI 模型列表过滤逻辑,排除嵌入、音频、图像等非聊天模型
- 硅基流动现在会显示所有聊天模型,只排除嵌入和图像生成模型
This commit is contained in:
2026-01-27 11:01:14 +08:00
parent dca4680565
commit 81ab5871c1
2 changed files with 31 additions and 15 deletions

View File

@@ -9291,12 +9291,20 @@ function argon_get_openai_models($api_key, $custom_endpoint = '') {
$models = [];
foreach ($body['data'] as $model) {
// 只显示 GPT 聊天模型
if (strpos($model['id'], 'gpt') !== false && strpos($model['id'], 'instruct') === false) {
$models[] = [
'id' => $model['id'],
'name' => $model['id']
];
// 只显示 GPT 聊天模型,排除嵌入、音频、图像等模型
if (isset($model['id'])) {
$model_id = $model['id'];
// 只保留 gpt 开头的模型,排除其他类型
if (strpos($model_id, 'gpt') === 0 &&
strpos($model_id, 'embedding') === false &&
strpos($model_id, 'whisper') === false &&
strpos($model_id, 'tts') === false &&
strpos($model_id, 'dall-e') === false) {
$models[] = [
'id' => $model['id'],
'name' => $model['id']
];
}
}
}
@@ -9735,8 +9743,16 @@ function argon_get_siliconflow_models($api_key, $custom_endpoint = '') {
$models = [];
foreach ($body['data'] as $model) {
// 只显示聊天模型
if (isset($model['id']) && strpos($model['id'], 'Instruct') !== false) {
// 过滤掉嵌入模型和图像模型,只保留聊天模型
if (isset($model['id'])) {
$model_id = $model['id'];
// 排除嵌入模型和图像模型
if (strpos($model_id, 'embedding') !== false ||
strpos($model_id, 'FLUX') !== false ||
strpos($model_id, 'stable-diffusion') !== false ||
strpos($model_id, 'kolors') !== false) {
continue;
}
$name = isset($model['name']) ? $model['name'] : $model['id'];
$models[] = [
'id' => $model['id'],

View File

@@ -2162,13 +2162,13 @@ function themeoptions_page(){
</p>
<p>
<label>
<strong><?php _e('API 密钥:', 'argon'); ?></strong> *<br>
<input type="password" id="argon-unified-api-form-key" class="regular-text" placeholder="sk-..." />
<button type="button" class="button" id="argon-toggle-unified-password" style="margin-left: 5px;">
<span class="dashicons dashicons-visibility"></span>
</button>
</label>
<label for="argon-unified-api-form-key">
<strong><?php _e('API 密钥:', 'argon'); ?></strong> *
</label><br>
<input type="password" id="argon-unified-api-form-key" class="regular-text" placeholder="sk-..." />
<button type="button" class="button" id="argon-toggle-unified-password" style="margin-left: 5px;">
<span class="dashicons dashicons-visibility"></span>
</button>
</p>
<p>