feat: add OpenRouter pricing support to upstream ratio sync (#2925)
This commit is contained in:
@@ -117,6 +117,7 @@ const ChannelSelectorModal = forwardRef(
|
||||
const getEndpointType = (ep) => {
|
||||
if (ep === '/api/ratio_config') return 'ratio_config';
|
||||
if (ep === '/api/pricing') return 'pricing';
|
||||
if (ep === 'openrouter') return 'openrouter';
|
||||
return 'custom';
|
||||
};
|
||||
|
||||
@@ -127,6 +128,8 @@ const ChannelSelectorModal = forwardRef(
|
||||
updateEndpoint(channelId, '/api/ratio_config');
|
||||
} else if (val === 'pricing') {
|
||||
updateEndpoint(channelId, '/api/pricing');
|
||||
} else if (val === 'openrouter') {
|
||||
updateEndpoint(channelId, 'openrouter');
|
||||
} else {
|
||||
if (currentType !== 'custom') {
|
||||
updateEndpoint(channelId, '');
|
||||
@@ -144,6 +147,7 @@ const ChannelSelectorModal = forwardRef(
|
||||
optionList={[
|
||||
{ label: 'ratio_config', value: 'ratio_config' },
|
||||
{ label: 'pricing', value: 'pricing' },
|
||||
{ label: 'OpenRouter', value: 'openrouter' },
|
||||
{ label: 'custom', value: 'custom' },
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -154,14 +154,20 @@ export default function UpstreamRatioSync(props) {
|
||||
const id = channel.key;
|
||||
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 isOpenRouter = channelType === 20;
|
||||
if (!merged[id]) {
|
||||
merged[id] = isOfficial
|
||||
? '/llm-metadata/api/newapi/ratio_config-v1-base.json'
|
||||
: DEFAULT_ENDPOINT;
|
||||
if (isOfficial) {
|
||||
merged[id] = '/llm-metadata/api/newapi/ratio_config-v1-base.json';
|
||||
} else if (isOpenRouter) {
|
||||
merged[id] = 'openrouter';
|
||||
} else {
|
||||
merged[id] = DEFAULT_ENDPOINT;
|
||||
}
|
||||
}
|
||||
});
|
||||
return merged;
|
||||
@@ -652,7 +658,7 @@ export default function UpstreamRatioSync(props) {
|
||||
color={text !== null && text !== undefined ? 'blue' : 'default'}
|
||||
shape='circle'
|
||||
>
|
||||
{text !== null && text !== undefined ? text : t('未设置')}
|
||||
{text !== null && text !== undefined ? String(text) : t('未设置')}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
@@ -774,7 +780,7 @@ export default function UpstreamRatioSync(props) {
|
||||
}
|
||||
}}
|
||||
>
|
||||
{upstreamVal}
|
||||
{String(upstreamVal)}
|
||||
</Checkbox>
|
||||
{!isConfident && (
|
||||
<Tooltip
|
||||
|
||||
Reference in New Issue
Block a user