mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 05:02:17 +00:00
fix: refine upstream update ignore UX and detect behavior
This commit is contained in:
@@ -730,14 +730,6 @@ func DetectChannelUpstreamModelUpdates(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
settings := channel.GetOtherSettings()
|
settings := channel.GetOtherSettings()
|
||||||
if !settings.UpstreamModelUpdateCheckEnabled {
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"success": false,
|
|
||||||
"message": "该渠道未开启上游模型更新检测",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
modelsChanged, autoAdded, err := checkAndPersistChannelUpstreamModelUpdates(channel, &settings, true, false)
|
modelsChanged, autoAdded, err := checkAndPersistChannelUpstreamModelUpdates(channel, &settings, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ApiError(c, err)
|
common.ApiError(c, err)
|
||||||
|
|||||||
@@ -723,10 +723,6 @@ export const getChannelsColumns = ({
|
|||||||
name: t('仅检测上游模型更新'),
|
name: t('仅检测上游模型更新'),
|
||||||
type: 'tertiary',
|
type: 'tertiary',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if (!upstreamUpdateMeta.enabled) {
|
|
||||||
showInfo(t('该渠道未开启上游模型更新检测'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
detectChannelUpstreamUpdates(record);
|
detectChannelUpstreamUpdates(record);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3291,6 +3291,18 @@ const EditChannelModal = (props) => {
|
|||||||
inputs.upstream_model_update_last_check_time,
|
inputs.upstream_model_update_last_check_time,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<Form.Input
|
||||||
|
field='upstream_model_update_ignored_models'
|
||||||
|
label={t('已忽略模型')}
|
||||||
|
placeholder={t('例如:gpt-4.1-nano,gpt-4o-mini')}
|
||||||
|
onChange={(value) =>
|
||||||
|
handleInputChange(
|
||||||
|
'upstream_model_update_ignored_models',
|
||||||
|
value,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
showClear
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -3460,19 +3472,6 @@ const EditChannelModal = (props) => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Form.Input
|
|
||||||
field='upstream_model_update_ignored_models'
|
|
||||||
label={t('手动忽略模型(逗号分隔)')}
|
|
||||||
placeholder={t('例如:gpt-4.1-nano,gpt-4o-mini')}
|
|
||||||
onChange={(value) =>
|
|
||||||
handleInputChange(
|
|
||||||
'upstream_model_update_ignored_models',
|
|
||||||
value,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
showClear
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className='text-xs text-gray-500 mb-3'>
|
<div className='text-xs text-gray-500 mb-3'>
|
||||||
{t('上次检测到可加入模型')}:
|
{t('上次检测到可加入模型')}:
|
||||||
{upstreamDetectedModels.length === 0 ? (
|
{upstreamDetectedModels.length === 0 ? (
|
||||||
|
|||||||
@@ -21,6 +21,23 @@ import { useRef, useState } from 'react';
|
|||||||
import { API, showError, showInfo, showSuccess } from '../../helpers';
|
import { API, showError, showInfo, showSuccess } from '../../helpers';
|
||||||
import { normalizeModelList } from './upstreamUpdateUtils';
|
import { normalizeModelList } from './upstreamUpdateUtils';
|
||||||
|
|
||||||
|
const getManualIgnoredModelCountFromSettings = (settings) => {
|
||||||
|
let parsed = null;
|
||||||
|
if (settings && typeof settings === 'object') {
|
||||||
|
parsed = settings;
|
||||||
|
} else if (typeof settings === 'string') {
|
||||||
|
try {
|
||||||
|
parsed = JSON.parse(settings);
|
||||||
|
} catch (error) {
|
||||||
|
parsed = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!parsed || typeof parsed !== 'object') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return normalizeModelList(parsed.upstream_model_update_ignored_models).length;
|
||||||
|
};
|
||||||
|
|
||||||
export const useChannelUpstreamUpdates = ({ t, refresh }) => {
|
export const useChannelUpstreamUpdates = ({ t, refresh }) => {
|
||||||
const [showUpstreamUpdateModal, setShowUpstreamUpdateModal] = useState(false);
|
const [showUpstreamUpdateModal, setShowUpstreamUpdateModal] = useState(false);
|
||||||
const [upstreamUpdateChannel, setUpstreamUpdateChannel] = useState(null);
|
const [upstreamUpdateChannel, setUpstreamUpdateChannel] = useState(null);
|
||||||
@@ -115,13 +132,17 @@ export const useChannelUpstreamUpdates = ({ t, refresh }) => {
|
|||||||
const addedCount = data?.added_models?.length || 0;
|
const addedCount = data?.added_models?.length || 0;
|
||||||
const removedCount = data?.removed_models?.length || 0;
|
const removedCount = data?.removed_models?.length || 0;
|
||||||
const ignoredCount = data?.ignored_models?.length || 0;
|
const ignoredCount = data?.ignored_models?.length || 0;
|
||||||
|
const totalIgnoredCount = getManualIgnoredModelCountFromSettings(
|
||||||
|
data?.settings,
|
||||||
|
);
|
||||||
showSuccess(
|
showSuccess(
|
||||||
t(
|
t(
|
||||||
'已处理上游模型更新:加入 {{added}} 个,删除 {{removed}} 个,忽略 {{ignored}} 个',
|
'已处理上游模型更新:加入 {{added}} 个,删除 {{removed}} 个,本次忽略 {{ignored}} 个,当前已忽略模型 {{totalIgnored}} 个',
|
||||||
{
|
{
|
||||||
added: addedCount,
|
added: addedCount,
|
||||||
removed: removedCount,
|
removed: removedCount,
|
||||||
ignored: ignoredCount,
|
ignored: ignoredCount,
|
||||||
|
totalIgnored: totalIgnoredCount,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user