Merge pull request #2973 from RedwindA/feat/modelsdotdev

feat(ratio-sync): support models.dev ratio sync and fix Gemini cache ratios
This commit is contained in:
Seefs
2026-02-21 14:28:18 +08:00
committed by GitHub
4 changed files with 292 additions and 26 deletions

View File

@@ -35,6 +35,13 @@ import {
} from '@douyinfe/semi-ui';
import { IconSearch } from '@douyinfe/semi-icons';
const OFFICIAL_RATIO_PRESET_ID = -100;
const MODELS_DEV_PRESET_ID = -101;
const OFFICIAL_RATIO_PRESET_NAME = '官方倍率预设';
const MODELS_DEV_PRESET_NAME = 'models.dev 价格预设';
const OFFICIAL_RATIO_PRESET_BASE_URL = 'https://basellm.github.io';
const MODELS_DEV_PRESET_BASE_URL = 'https://models.dev';
const ChannelSelectorModal = forwardRef(
(
{
@@ -70,9 +77,12 @@ const ChannelSelectorModal = forwardRef(
const base = record?._originalData?.base_url || '';
const name = record?.label || '';
return (
id === -100 ||
base === 'https://basellm.github.io' ||
name === '官方倍率预设'
id === OFFICIAL_RATIO_PRESET_ID ||
id === MODELS_DEV_PRESET_ID ||
base === OFFICIAL_RATIO_PRESET_BASE_URL ||
base === MODELS_DEV_PRESET_BASE_URL ||
name === OFFICIAL_RATIO_PRESET_NAME ||
name === MODELS_DEV_PRESET_NAME
);
};

View File

@@ -53,6 +53,16 @@ import {
} from '@douyinfe/semi-illustrations';
import ChannelSelectorModal from '../../../components/settings/ChannelSelectorModal';
const OFFICIAL_RATIO_PRESET_ID = -100;
const OFFICIAL_RATIO_PRESET_NAME = '官方倍率预设';
const OFFICIAL_RATIO_PRESET_BASE_URL = 'https://basellm.github.io';
const OFFICIAL_RATIO_PRESET_ENDPOINT =
'/llm-metadata/api/newapi/ratio_config-v1-base.json';
const MODELS_DEV_PRESET_ID = -101;
const MODELS_DEV_PRESET_NAME = 'models.dev 价格预设';
const MODELS_DEV_PRESET_BASE_URL = 'https://models.dev';
const MODELS_DEV_PRESET_ENDPOINT = 'https://models.dev/api.json';
function ConflictConfirmModal({ t, visible, items, onOk, onCancel }) {
const isMobile = useIsMobile();
const columns = [
@@ -155,14 +165,20 @@ export default function UpstreamRatioSync(props) {
const base = channel._originalData?.base_url || '';
const name = channel.label || '';
const channelType = channel._originalData?.type;
const isOfficial =
id === -100 ||
base === 'https://basellm.github.io' ||
name === '官方倍率预设';
const isOfficialRatioPreset =
id === OFFICIAL_RATIO_PRESET_ID ||
base === OFFICIAL_RATIO_PRESET_BASE_URL ||
name === OFFICIAL_RATIO_PRESET_NAME;
const isModelsDevPreset =
id === MODELS_DEV_PRESET_ID ||
base === MODELS_DEV_PRESET_BASE_URL ||
name === MODELS_DEV_PRESET_NAME;
const isOpenRouter = channelType === 20;
if (!merged[id]) {
if (isOfficial) {
merged[id] = '/llm-metadata/api/newapi/ratio_config-v1-base.json';
if (isModelsDevPreset) {
merged[id] = MODELS_DEV_PRESET_ENDPOINT;
} else if (isOfficialRatioPreset) {
merged[id] = OFFICIAL_RATIO_PRESET_ENDPOINT;
} else if (isOpenRouter) {
merged[id] = 'openrouter';
} else {