Commit fa4465c4 by RedwindA

feat: add models.dev preset support to upstream ratio sync

parent d45cd9af
...@@ -35,6 +35,13 @@ import { ...@@ -35,6 +35,13 @@ import {
} from '@douyinfe/semi-ui'; } from '@douyinfe/semi-ui';
import { IconSearch } from '@douyinfe/semi-icons'; 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( const ChannelSelectorModal = forwardRef(
( (
{ {
...@@ -70,9 +77,12 @@ const ChannelSelectorModal = forwardRef( ...@@ -70,9 +77,12 @@ const ChannelSelectorModal = forwardRef(
const base = record?._originalData?.base_url || ''; const base = record?._originalData?.base_url || '';
const name = record?.label || ''; const name = record?.label || '';
return ( return (
id === -100 || id === OFFICIAL_RATIO_PRESET_ID ||
base === 'https://basellm.github.io' || id === MODELS_DEV_PRESET_ID ||
name === '官方倍率预设' base === OFFICIAL_RATIO_PRESET_BASE_URL ||
base === MODELS_DEV_PRESET_BASE_URL ||
name === OFFICIAL_RATIO_PRESET_NAME ||
name === MODELS_DEV_PRESET_NAME
); );
}; };
......
...@@ -53,6 +53,16 @@ import { ...@@ -53,6 +53,16 @@ import {
} from '@douyinfe/semi-illustrations'; } from '@douyinfe/semi-illustrations';
import ChannelSelectorModal from '../../../components/settings/ChannelSelectorModal'; 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 }) { function ConflictConfirmModal({ t, visible, items, onOk, onCancel }) {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const columns = [ const columns = [
...@@ -155,14 +165,20 @@ export default function UpstreamRatioSync(props) { ...@@ -155,14 +165,20 @@ export default function UpstreamRatioSync(props) {
const base = channel._originalData?.base_url || ''; const base = channel._originalData?.base_url || '';
const name = channel.label || ''; const name = channel.label || '';
const channelType = channel._originalData?.type; const channelType = channel._originalData?.type;
const isOfficial = const isOfficialRatioPreset =
id === -100 || id === OFFICIAL_RATIO_PRESET_ID ||
base === 'https://basellm.github.io' || base === OFFICIAL_RATIO_PRESET_BASE_URL ||
name === '官方倍率预设'; 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; const isOpenRouter = channelType === 20;
if (!merged[id]) { if (!merged[id]) {
if (isOfficial) { if (isModelsDevPreset) {
merged[id] = '/llm-metadata/api/newapi/ratio_config-v1-base.json'; merged[id] = MODELS_DEV_PRESET_ENDPOINT;
} else if (isOfficialRatioPreset) {
merged[id] = OFFICIAL_RATIO_PRESET_ENDPOINT;
} else if (isOpenRouter) { } else if (isOpenRouter) {
merged[id] = 'openrouter'; merged[id] = 'openrouter';
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment