2025-07-19 03:30:44 +08:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-06-23 16:34:00 +08:00
|
|
|
|
import React, { useState, useCallback, useMemo, useEffect } from 'react';
|
2025-06-19 08:57:34 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Table,
|
|
|
|
|
|
Tag,
|
|
|
|
|
|
Empty,
|
|
|
|
|
|
Checkbox,
|
|
|
|
|
|
Form,
|
2025-06-19 18:54:46 +08:00
|
|
|
|
Input,
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
Tooltip,
|
|
|
|
|
|
Select,
|
2025-06-23 17:35:39 +08:00
|
|
|
|
Modal,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
} from '@douyinfe/semi-ui';
|
2025-06-19 18:54:46 +08:00
|
|
|
|
import { IconSearch } from '@douyinfe/semi-icons';
|
2025-06-19 08:57:34 +08:00
|
|
|
|
import {
|
|
|
|
|
|
RefreshCcw,
|
|
|
|
|
|
CheckSquare,
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
AlertTriangle,
|
|
|
|
|
|
CheckCircle,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
} from 'lucide-react';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
import {
|
|
|
|
|
|
API,
|
|
|
|
|
|
showError,
|
|
|
|
|
|
showSuccess,
|
|
|
|
|
|
showWarning,
|
|
|
|
|
|
stringToColor,
|
|
|
|
|
|
} from '../../../helpers';
|
2025-08-18 04:14:35 +08:00
|
|
|
|
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
2025-06-19 15:17:05 +08:00
|
|
|
|
import { DEFAULT_ENDPOINT } from '../../../constants';
|
2025-06-19 08:57:34 +08:00
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import {
|
|
|
|
|
|
IllustrationNoResult,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
IllustrationNoResultDark,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
} from '@douyinfe/semi-illustrations';
|
|
|
|
|
|
import ChannelSelectorModal from '../../../components/settings/ChannelSelectorModal';
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
function ConflictConfirmModal({ t, visible, items, onOk, onCancel }) {
|
š± refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
⢠Removed isMobile import.
⢠Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
⢠Layout: HeaderBar, PageLayout, SiderBar
⢠Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
⢠Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
⢠Unifies mobile detection with a React-friendly hook.
⢠Eliminates duplicated logic and improves maintainability.
⢠Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
const isMobile = useIsMobile();
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const columns = [
|
|
|
|
|
|
{ title: t('ęø é'), dataIndex: 'channel' },
|
|
|
|
|
|
{ title: t('樔å'), dataIndex: 'model' },
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('å½å讔蓹'),
|
|
|
|
|
|
dataIndex: 'current',
|
|
|
|
|
|
render: (text) => <div style={{ whiteSpace: 'pre-wrap' }}>{text}</div>,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('äæ®ę¹äøŗ'),
|
|
|
|
|
|
dataIndex: 'newVal',
|
|
|
|
|
|
render: (text) => <div style={{ whiteSpace: 'pre-wrap' }}>{text}</div>,
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title={t('甮认å²ēŖé”¹äæ®ę¹')}
|
|
|
|
|
|
visible={visible}
|
|
|
|
|
|
onCancel={onCancel}
|
|
|
|
|
|
onOk={onOk}
|
š± refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
⢠Removed isMobile import.
⢠Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
⢠Layout: HeaderBar, PageLayout, SiderBar
⢠Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
⢠Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
⢠Unifies mobile detection with a React-friendly hook.
⢠Eliminates duplicated logic and improves maintainability.
⢠Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
size={isMobile ? 'full-width' : 'large'}
|
2025-06-23 17:35:39 +08:00
|
|
|
|
>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Table
|
|
|
|
|
|
columns={columns}
|
|
|
|
|
|
dataSource={items}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
/>
|
2025-06-23 17:35:39 +08:00
|
|
|
|
</Modal>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
export default function UpstreamRatioSync(props) {
|
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
const [modalVisible, setModalVisible] = useState(false);
|
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
|
const [syncLoading, setSyncLoading] = useState(false);
|
š± refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
⢠Removed isMobile import.
⢠Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
⢠Layout: HeaderBar, PageLayout, SiderBar
⢠Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
⢠Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
⢠Unifies mobile detection with a React-friendly hook.
⢠Eliminates duplicated logic and improves maintainability.
⢠Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
const isMobile = useIsMobile();
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
// ęø ééę©ēøå
³
|
|
|
|
|
|
const [allChannels, setAllChannels] = useState([]);
|
|
|
|
|
|
const [selectedChannelIds, setSelectedChannelIds] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
// ęø é端ē¹é
ē½®
|
|
|
|
|
|
const [channelEndpoints, setChannelEndpoints] = useState({}); // { channelId: endpoint }
|
|
|
|
|
|
|
|
|
|
|
|
// å·®å¼ę°ę®åęµčÆē»ę
|
|
|
|
|
|
const [differences, setDifferences] = useState({});
|
|
|
|
|
|
const [resolutions, setResolutions] = useState({});
|
|
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
// ęÆå¦å·²ē»ę§č”čæåę„
|
|
|
|
|
|
const [hasSynced, setHasSynced] = useState(false);
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
// å锵ēøå
³ē¶ę
|
|
|
|
|
|
const [currentPage, setCurrentPage] = useState(1);
|
|
|
|
|
|
const [pageSize, setPageSize] = useState(10);
|
|
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
// ęē“¢ēøå
³ē¶ę
|
|
|
|
|
|
const [searchKeyword, setSearchKeyword] = useState('');
|
|
|
|
|
|
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
// åēē±»åčæę»¤
|
|
|
|
|
|
const [ratioTypeFilter, setRatioTypeFilter] = useState('');
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
// å²ēŖē”®č®¤å¼¹ēŖēøå
³
|
|
|
|
|
|
const [confirmVisible, setConfirmVisible] = useState(false);
|
|
|
|
|
|
const [conflictItems, setConflictItems] = useState([]); // {channel, model, current, newVal, ratioType}
|
|
|
|
|
|
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const channelSelectorRef = React.useRef(null);
|
|
|
|
|
|
|
2025-06-23 16:34:00 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
|
}, [ratioTypeFilter, searchKeyword]);
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const fetchAllChannels = async () => {
|
|
|
|
|
|
setLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await API.get('/api/ratio_sync/channels');
|
|
|
|
|
|
|
|
|
|
|
|
if (res.data.success) {
|
|
|
|
|
|
const channels = res.data.data || [];
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const transferData = channels.map((channel) => ({
|
2025-06-19 08:57:34 +08:00
|
|
|
|
key: channel.id,
|
|
|
|
|
|
label: channel.name,
|
|
|
|
|
|
value: channel.id,
|
2025-06-19 18:38:43 +08:00
|
|
|
|
disabled: false,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
_originalData: channel,
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
setAllChannels(transferData);
|
|
|
|
|
|
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
// åå¹¶å·²ę endpointsļ¼éæå
ęÆę¬”ęå¼å¼¹ēŖé½éē½®
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setChannelEndpoints((prev) => {
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const merged = { ...prev };
|
2025-08-30 21:15:10 +08:00
|
|
|
|
transferData.forEach((channel) => {
|
2025-09-01 23:43:39 +08:00
|
|
|
|
const id = channel.key;
|
|
|
|
|
|
const base = channel._originalData?.base_url || '';
|
|
|
|
|
|
const name = channel.label || '';
|
|
|
|
|
|
const isOfficial =
|
|
|
|
|
|
id === -100 ||
|
|
|
|
|
|
base === 'https://basellm.github.io' ||
|
|
|
|
|
|
name === 'å®ę¹åēé¢č®¾';
|
|
|
|
|
|
if (!merged[id]) {
|
|
|
|
|
|
merged[id] = isOfficial
|
|
|
|
|
|
? '/llm-metadata/api/newapi/ratio_config-v1-base.json'
|
|
|
|
|
|
: DEFAULT_ENDPOINT;
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return merged;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(res.data.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(t('č·åęø é失蓄ļ¼') + error.message);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const confirmChannelSelection = () => {
|
|
|
|
|
|
const selected = allChannels
|
2025-08-30 21:15:10 +08:00
|
|
|
|
.filter((ch) => selectedChannelIds.includes(ch.value))
|
|
|
|
|
|
.map((ch) => ch._originalData);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
if (selected.length === 0) {
|
|
|
|
|
|
showWarning(t('请č³å°éę©äøäøŖęø é'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setModalVisible(false);
|
|
|
|
|
|
fetchRatiosFromChannels(selected);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchRatiosFromChannels = async (channelList) => {
|
|
|
|
|
|
setSyncLoading(true);
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const upstreams = channelList.map((ch) => ({
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
id: ch.id,
|
|
|
|
|
|
name: ch.name,
|
|
|
|
|
|
base_url: ch.base_url,
|
|
|
|
|
|
endpoint: channelEndpoints[ch.id] || DEFAULT_ENDPOINT,
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const payload = {
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
upstreams: upstreams,
|
2025-06-19 15:17:05 +08:00
|
|
|
|
timeout: 10,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await API.post('/api/ratio_sync/fetch', payload);
|
|
|
|
|
|
|
|
|
|
|
|
if (!res.data.success) {
|
|
|
|
|
|
showError(res.data.message || t('å端请ę±å¤±č“„'));
|
|
|
|
|
|
setSyncLoading(false);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { differences = {}, test_results = [] } = res.data.data;
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const errorResults = test_results.filter((r) => r.status === 'error');
|
2025-06-19 08:57:34 +08:00
|
|
|
|
if (errorResults.length > 0) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
showWarning(
|
|
|
|
|
|
t('éØåęø éęµčÆå¤±č“„ļ¼') +
|
|
|
|
|
|
errorResults.map((r) => `${r.name}: ${r.error}`).join(', '),
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setDifferences(differences);
|
|
|
|
|
|
setResolutions({});
|
2025-06-19 18:54:46 +08:00
|
|
|
|
setHasSynced(true);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
if (Object.keys(differences).length === 0) {
|
2025-06-21 02:09:08 +08:00
|
|
|
|
showSuccess(t('ęŖę¾å°å·®å¼ååēļ¼ę éåę„'));
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
showError(t('请ę±å端ę„å£å¤±č“„ļ¼') + e.message);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setSyncLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
function getBillingCategory(ratioType) {
|
|
|
|
|
|
return ratioType === 'model_price' ? 'price' : 'ratio';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const selectValue = useCallback(
|
|
|
|
|
|
(model, ratioType, value) => {
|
|
|
|
|
|
const category = getBillingCategory(ratioType);
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setResolutions((prev) => {
|
|
|
|
|
|
const newModelRes = { ...(prev[model] || {}) };
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
Object.keys(newModelRes).forEach((rt) => {
|
|
|
|
|
|
if (getBillingCategory(rt) !== category) {
|
|
|
|
|
|
delete newModelRes[rt];
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
newModelRes[ratioType] = value;
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...prev,
|
|
|
|
|
|
[model]: newModelRes,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
[setResolutions],
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
const applySync = async () => {
|
|
|
|
|
|
const currentRatios = {
|
|
|
|
|
|
ModelRatio: JSON.parse(props.options.ModelRatio || '{}'),
|
|
|
|
|
|
CompletionRatio: JSON.parse(props.options.CompletionRatio || '{}'),
|
|
|
|
|
|
CacheRatio: JSON.parse(props.options.CacheRatio || '{}'),
|
|
|
|
|
|
ModelPrice: JSON.parse(props.options.ModelPrice || '{}'),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const conflicts = [];
|
|
|
|
|
|
|
|
|
|
|
|
const getLocalBillingCategory = (model) => {
|
|
|
|
|
|
if (currentRatios.ModelPrice[model] !== undefined) return 'price';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (
|
|
|
|
|
|
currentRatios.ModelRatio[model] !== undefined ||
|
2025-06-23 17:35:39 +08:00
|
|
|
|
currentRatios.CompletionRatio[model] !== undefined ||
|
2025-08-30 21:15:10 +08:00
|
|
|
|
currentRatios.CacheRatio[model] !== undefined
|
|
|
|
|
|
)
|
|
|
|
|
|
return 'ratio';
|
2025-06-23 17:35:39 +08:00
|
|
|
|
return null;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const findSourceChannel = (model, ratioType, value) => {
|
|
|
|
|
|
if (differences[model] && differences[model][ratioType]) {
|
|
|
|
|
|
const upMap = differences[model][ratioType].upstreams || {};
|
|
|
|
|
|
const entry = Object.entries(upMap).find(([_, v]) => v === value);
|
|
|
|
|
|
if (entry) return entry[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
return t('ęŖē„');
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(resolutions).forEach(([model, ratios]) => {
|
|
|
|
|
|
const localCat = getLocalBillingCategory(model);
|
|
|
|
|
|
const newCat = 'model_price' in ratios ? 'price' : 'ratio';
|
|
|
|
|
|
|
|
|
|
|
|
if (localCat && localCat !== newCat) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const currentDesc =
|
|
|
|
|
|
localCat === 'price'
|
|
|
|
|
|
? `${t('åŗå®ä»·ę ¼')} : ${currentRatios.ModelPrice[model]}`
|
|
|
|
|
|
: `${t('樔ååē')} : ${currentRatios.ModelRatio[model] ?? '-'}\n${t('蔄å
Øåē')} : ${currentRatios.CompletionRatio[model] ?? '-'}`;
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
|
|
|
|
|
let newDesc = '';
|
|
|
|
|
|
if (newCat === 'price') {
|
|
|
|
|
|
newDesc = `${t('åŗå®ä»·ę ¼')} : ${ratios['model_price']}`;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const newModelRatio = ratios['model_ratio'] ?? '-';
|
|
|
|
|
|
const newCompRatio = ratios['completion_ratio'] ?? '-';
|
|
|
|
|
|
newDesc = `${t('樔ååē')} : ${newModelRatio}\n${t('蔄å
Øåē')} : ${newCompRatio}`;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const channels = Object.entries(ratios)
|
|
|
|
|
|
.map(([rt, val]) => findSourceChannel(model, rt, val))
|
|
|
|
|
|
.filter((v, idx, arr) => arr.indexOf(v) === idx)
|
|
|
|
|
|
.join(', ');
|
|
|
|
|
|
|
|
|
|
|
|
conflicts.push({
|
|
|
|
|
|
channel: channels,
|
|
|
|
|
|
model,
|
|
|
|
|
|
current: currentDesc,
|
|
|
|
|
|
newVal: newDesc,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (conflicts.length > 0) {
|
|
|
|
|
|
setConflictItems(conflicts);
|
|
|
|
|
|
setConfirmVisible(true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await performSync(currentRatios);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const performSync = useCallback(
|
|
|
|
|
|
async (currentRatios) => {
|
|
|
|
|
|
const finalRatios = {
|
|
|
|
|
|
ModelRatio: { ...currentRatios.ModelRatio },
|
|
|
|
|
|
CompletionRatio: { ...currentRatios.CompletionRatio },
|
|
|
|
|
|
CacheRatio: { ...currentRatios.CacheRatio },
|
|
|
|
|
|
ModelPrice: { ...currentRatios.ModelPrice },
|
|
|
|
|
|
};
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
Object.entries(resolutions).forEach(([model, ratios]) => {
|
|
|
|
|
|
const selectedTypes = Object.keys(ratios);
|
|
|
|
|
|
const hasPrice = selectedTypes.includes('model_price');
|
|
|
|
|
|
const hasRatio = selectedTypes.some((rt) => rt !== 'model_price');
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (hasPrice) {
|
|
|
|
|
|
delete finalRatios.ModelRatio[model];
|
|
|
|
|
|
delete finalRatios.CompletionRatio[model];
|
|
|
|
|
|
delete finalRatios.CacheRatio[model];
|
|
|
|
|
|
}
|
|
|
|
|
|
if (hasRatio) {
|
|
|
|
|
|
delete finalRatios.ModelPrice[model];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(ratios).forEach(([ratioType, value]) => {
|
|
|
|
|
|
const optionKey = ratioType
|
|
|
|
|
|
.split('_')
|
|
|
|
|
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
|
|
|
|
.join('');
|
|
|
|
|
|
finalRatios[optionKey][model] = parseFloat(value);
|
|
|
|
|
|
});
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const updates = Object.entries(finalRatios).map(([key, value]) =>
|
|
|
|
|
|
API.put('/api/option/', {
|
|
|
|
|
|
key,
|
|
|
|
|
|
value: JSON.stringify(value, null, 2),
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const results = await Promise.all(updates);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (results.every((res) => res.data.success)) {
|
|
|
|
|
|
showSuccess(t('åę„ęå'));
|
|
|
|
|
|
props.refresh();
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setDifferences((prevDifferences) => {
|
|
|
|
|
|
const newDifferences = { ...prevDifferences };
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
Object.entries(resolutions).forEach(([model, ratios]) => {
|
|
|
|
|
|
Object.keys(ratios).forEach((ratioType) => {
|
|
|
|
|
|
if (newDifferences[model] && newDifferences[model][ratioType]) {
|
|
|
|
|
|
delete newDifferences[model][ratioType];
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (Object.keys(newDifferences[model]).length === 0) {
|
|
|
|
|
|
delete newDifferences[model];
|
|
|
|
|
|
}
|
2025-06-19 18:38:43 +08:00
|
|
|
|
}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
});
|
2025-06-19 18:38:43 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return newDifferences;
|
|
|
|
|
|
});
|
2025-06-19 18:38:43 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setResolutions({});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(t('éØåäæå失蓄'));
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(t('äæå失蓄'));
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
[resolutions, props.options, props.refresh],
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
const getCurrentPageData = (dataSource) => {
|
|
|
|
|
|
const startIndex = (currentPage - 1) * pageSize;
|
|
|
|
|
|
const endIndex = startIndex + pageSize;
|
|
|
|
|
|
return dataSource.slice(startIndex, endIndex);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const renderHeader = () => (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex flex-col w-full'>
|
|
|
|
|
|
<div className='flex flex-col md:flex-row justify-between items-center gap-4 w-full'>
|
|
|
|
|
|
<div className='flex flex-col md:flex-row gap-2 w-full md:w-auto order-2 md:order-1'>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
icon={<RefreshCcw size={14} />}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full md:w-auto mt-2'
|
2025-06-19 08:57:34 +08:00
|
|
|
|
onClick={() => {
|
|
|
|
|
|
setModalVisible(true);
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
if (allChannels.length === 0) {
|
|
|
|
|
|
fetchAllChannels();
|
|
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('éę©åę„ęø é')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
{(() => {
|
|
|
|
|
|
const hasSelections = Object.keys(resolutions).length > 0;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
icon={<CheckSquare size={14} />}
|
|
|
|
|
|
type='secondary'
|
|
|
|
|
|
onClick={applySync}
|
|
|
|
|
|
disabled={!hasSelections}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full md:w-auto mt-2'
|
2025-06-19 08:57:34 +08:00
|
|
|
|
>
|
|
|
|
|
|
{t('åŗēØåę„')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
);
|
|
|
|
|
|
})()}
|
2025-06-19 18:54:46 +08:00
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex flex-col sm:flex-row gap-2 w-full md:w-auto mt-2'>
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
<Input
|
|
|
|
|
|
prefix={<IconSearch size={14} />}
|
|
|
|
|
|
placeholder={t('ę瓢樔ååē§°')}
|
|
|
|
|
|
value={searchKeyword}
|
|
|
|
|
|
onChange={setSearchKeyword}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full sm:w-64'
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Select
|
|
|
|
|
|
placeholder={t('ęåēē±»åēé')}
|
|
|
|
|
|
value={ratioTypeFilter}
|
|
|
|
|
|
onChange={setRatioTypeFilter}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='w-full sm:w-48'
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
onClear={() => setRatioTypeFilter('')}
|
|
|
|
|
|
>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Select.Option value='model_ratio'>{t('樔ååē')}</Select.Option>
|
|
|
|
|
|
<Select.Option value='completion_ratio'>
|
|
|
|
|
|
{t('蔄å
Øåē')}
|
|
|
|
|
|
</Select.Option>
|
|
|
|
|
|
<Select.Option value='cache_ratio'>{t('ē¼ååē')}</Select.Option>
|
|
|
|
|
|
<Select.Option value='model_price'>{t('åŗå®ä»·ę ¼')}</Select.Option>
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
</Select>
|
|
|
|
|
|
</div>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const renderDifferenceTable = () => {
|
|
|
|
|
|
const dataSource = useMemo(() => {
|
|
|
|
|
|
const tmp = [];
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(differences).forEach(([model, ratioTypes]) => {
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const hasPrice = 'model_price' in ratioTypes;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const hasOtherRatio = [
|
|
|
|
|
|
'model_ratio',
|
|
|
|
|
|
'completion_ratio',
|
|
|
|
|
|
'cache_ratio',
|
|
|
|
|
|
].some((rt) => rt in ratioTypes);
|
2025-06-23 17:35:39 +08:00
|
|
|
|
const billingConflict = hasPrice && hasOtherRatio;
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
Object.entries(ratioTypes).forEach(([ratioType, diff]) => {
|
|
|
|
|
|
tmp.push({
|
|
|
|
|
|
key: `${model}_${ratioType}`,
|
|
|
|
|
|
model,
|
|
|
|
|
|
ratioType,
|
|
|
|
|
|
current: diff.current,
|
|
|
|
|
|
upstreams: diff.upstreams,
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
confidence: diff.confidence || {},
|
2025-06-23 17:35:39 +08:00
|
|
|
|
billingConflict,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
|
|
}, [differences]);
|
|
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
const filteredDataSource = useMemo(() => {
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
if (!searchKeyword.trim() && !ratioTypeFilter) {
|
2025-06-19 18:54:46 +08:00
|
|
|
|
return dataSource;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return dataSource.filter((item) => {
|
|
|
|
|
|
const matchesKeyword =
|
|
|
|
|
|
!searchKeyword.trim() ||
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
item.model.toLowerCase().includes(searchKeyword.toLowerCase().trim());
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const matchesRatioType =
|
|
|
|
|
|
!ratioTypeFilter || item.ratioType === ratioTypeFilter;
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
|
|
|
|
|
|
return matchesKeyword && matchesRatioType;
|
|
|
|
|
|
});
|
|
|
|
|
|
}, [dataSource, searchKeyword, ratioTypeFilter]);
|
2025-06-19 18:54:46 +08:00
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const upstreamNames = useMemo(() => {
|
|
|
|
|
|
const set = new Set();
|
2025-06-19 18:54:46 +08:00
|
|
|
|
filteredDataSource.forEach((row) => {
|
2025-06-19 08:57:34 +08:00
|
|
|
|
Object.keys(row.upstreams || {}).forEach((name) => set.add(name));
|
|
|
|
|
|
});
|
|
|
|
|
|
return Array.from(set);
|
2025-06-19 18:54:46 +08:00
|
|
|
|
}, [filteredDataSource]);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
if (filteredDataSource.length === 0) {
|
2025-06-19 08:57:34 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Empty
|
|
|
|
|
|
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
darkModeImage={
|
|
|
|
|
|
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
|
|
|
|
|
}
|
2025-06-19 18:54:46 +08:00
|
|
|
|
description={
|
|
|
|
|
|
searchKeyword.trim()
|
|
|
|
|
|
? t('ęŖę¾å°å¹é
ē樔å')
|
2025-08-30 21:15:10 +08:00
|
|
|
|
: Object.keys(differences).length === 0
|
|
|
|
|
|
? hasSynced
|
|
|
|
|
|
? t('ęę å·®å¼ååēę¾ē¤ŗ')
|
|
|
|
|
|
: t('请å
éę©åę„ęø é')
|
|
|
|
|
|
: t('请å
éę©åę„ęø é')
|
2025-06-19 18:54:46 +08:00
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
style={{ padding: 30 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('樔å'),
|
|
|
|
|
|
dataIndex: 'model',
|
|
|
|
|
|
fixed: 'left',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('åēē±»å'),
|
|
|
|
|
|
dataIndex: 'ratioType',
|
2025-06-23 17:35:39 +08:00
|
|
|
|
render: (text, record) => {
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const typeMap = {
|
|
|
|
|
|
model_ratio: t('樔ååē'),
|
|
|
|
|
|
completion_ratio: t('蔄å
Øåē'),
|
|
|
|
|
|
cache_ratio: t('ē¼ååē'),
|
|
|
|
|
|
model_price: t('åŗå®ä»·ę ¼'),
|
|
|
|
|
|
};
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const baseTag = (
|
|
|
|
|
|
<Tag color={stringToColor(text)} shape='circle'>
|
|
|
|
|
|
{typeMap[text] || text}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
);
|
2025-06-23 17:35:39 +08:00
|
|
|
|
if (record?.billingConflict) {
|
|
|
|
|
|
return (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center gap-1'>
|
2025-06-23 17:35:39 +08:00
|
|
|
|
{baseTag}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tooltip
|
|
|
|
|
|
position='top'
|
|
|
|
|
|
content={t(
|
|
|
|
|
|
'评樔åååØåŗå®ä»·ę ¼äøåē讔蓹ę¹å¼å²ēŖļ¼čÆ·ē”®č®¤éę©',
|
|
|
|
|
|
)}
|
|
|
|
|
|
>
|
|
|
|
|
|
<AlertTriangle size={14} className='text-yellow-500' />
|
2025-06-23 17:35:39 +08:00
|
|
|
|
</Tooltip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return baseTag;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: t('置俔度'),
|
|
|
|
|
|
dataIndex: 'confidence',
|
|
|
|
|
|
render: (_, record) => {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const allConfident = Object.values(record.confidence || {}).every(
|
|
|
|
|
|
(v) => v !== false,
|
|
|
|
|
|
);
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
|
|
|
|
|
|
if (allConfident) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Tooltip content={t('ęęäøęøøę°ę®ååÆäæ”')}>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tag
|
|
|
|
|
|
color='green'
|
|
|
|
|
|
shape='circle'
|
|
|
|
|
|
type='light'
|
|
|
|
|
|
prefixIcon={<CheckCircle size={14} />}
|
|
|
|
|
|
>
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
{t('åÆäæ”')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const untrustedSources = Object.entries(record.confidence || {})
|
|
|
|
|
|
.filter(([_, isConfident]) => isConfident === false)
|
|
|
|
|
|
.map(([name]) => name)
|
|
|
|
|
|
.join(', ');
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tooltip
|
|
|
|
|
|
content={t('仄äøäøęøøę°ę®åÆč½äøåÆäæ”ļ¼') + untrustedSources}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Tag
|
|
|
|
|
|
color='yellow'
|
|
|
|
|
|
shape='circle'
|
|
|
|
|
|
type='light'
|
|
|
|
|
|
prefixIcon={<AlertTriangle size={14} />}
|
|
|
|
|
|
>
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
{t('č°Øę
')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-06-19 08:57:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: t('å½åå¼'),
|
|
|
|
|
|
dataIndex: 'current',
|
|
|
|
|
|
render: (text) => (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tag
|
|
|
|
|
|
color={text !== null && text !== undefined ? 'blue' : 'default'}
|
|
|
|
|
|
shape='circle'
|
|
|
|
|
|
>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
{text !== null && text !== undefined ? text : t('ęŖč®¾ē½®')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
...upstreamNames.map((upName) => {
|
|
|
|
|
|
const channelStats = (() => {
|
2025-06-19 18:38:43 +08:00
|
|
|
|
let selectableCount = 0;
|
|
|
|
|
|
let selectedCount = 0;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
2025-06-19 18:54:46 +08:00
|
|
|
|
filteredDataSource.forEach((row) => {
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const upstreamVal = row.upstreams?.[upName];
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (
|
|
|
|
|
|
upstreamVal !== null &&
|
|
|
|
|
|
upstreamVal !== undefined &&
|
|
|
|
|
|
upstreamVal !== 'same'
|
|
|
|
|
|
) {
|
2025-06-19 08:57:34 +08:00
|
|
|
|
selectableCount++;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const isSelected =
|
|
|
|
|
|
resolutions[row.model]?.[row.ratioType] === upstreamVal;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
if (isSelected) {
|
|
|
|
|
|
selectedCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
selectableCount,
|
|
|
|
|
|
selectedCount,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
allSelected:
|
|
|
|
|
|
selectableCount > 0 && selectedCount === selectableCount,
|
|
|
|
|
|
partiallySelected:
|
|
|
|
|
|
selectedCount > 0 && selectedCount < selectableCount,
|
|
|
|
|
|
hasSelectableItems: selectableCount > 0,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
const handleBulkSelect = (checked) => {
|
2025-06-23 17:35:39 +08:00
|
|
|
|
if (checked) {
|
2025-06-19 18:54:46 +08:00
|
|
|
|
filteredDataSource.forEach((row) => {
|
2025-06-19 08:57:34 +08:00
|
|
|
|
const upstreamVal = row.upstreams?.[upName];
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (
|
|
|
|
|
|
upstreamVal !== null &&
|
|
|
|
|
|
upstreamVal !== undefined &&
|
|
|
|
|
|
upstreamVal !== 'same'
|
|
|
|
|
|
) {
|
2025-06-23 17:35:39 +08:00
|
|
|
|
selectValue(row.model, row.ratioType, upstreamVal);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setResolutions((prev) => {
|
|
|
|
|
|
const newRes = { ...prev };
|
|
|
|
|
|
filteredDataSource.forEach((row) => {
|
|
|
|
|
|
if (newRes[row.model]) {
|
|
|
|
|
|
delete newRes[row.model][row.ratioType];
|
|
|
|
|
|
if (Object.keys(newRes[row.model]).length === 0) {
|
|
|
|
|
|
delete newRes[row.model];
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-06-23 17:35:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
return newRes;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
});
|
2025-06-23 17:35:39 +08:00
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
title: channelStats.hasSelectableItems ? (
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
checked={channelStats.allSelected}
|
|
|
|
|
|
indeterminate={channelStats.partiallySelected}
|
|
|
|
|
|
onChange={(e) => handleBulkSelect(e.target.checked)}
|
|
|
|
|
|
>
|
|
|
|
|
|
{upName}
|
|
|
|
|
|
</Checkbox>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<span>{upName}</span>
|
|
|
|
|
|
),
|
|
|
|
|
|
dataIndex: upName,
|
|
|
|
|
|
render: (_, record) => {
|
|
|
|
|
|
const upstreamVal = record.upstreams?.[upName];
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const isConfident = record.confidence?.[upName] !== false;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
if (upstreamVal === null || upstreamVal === undefined) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Tag color='default' shape='circle'>
|
|
|
|
|
|
{t('ęŖč®¾ē½®')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (upstreamVal === 'same') {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Tag color='blue' shape='circle'>
|
|
|
|
|
|
{t('äøę¬å°ēøå')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
);
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const isSelected =
|
|
|
|
|
|
resolutions[record.model]?.[record.ratioType] === upstreamVal;
|
2025-06-19 08:57:34 +08:00
|
|
|
|
|
|
|
|
|
|
return (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center gap-2'>
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
<Checkbox
|
|
|
|
|
|
checked={isSelected}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
const isChecked = e.target.checked;
|
|
|
|
|
|
if (isChecked) {
|
|
|
|
|
|
selectValue(record.model, record.ratioType, upstreamVal);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setResolutions((prev) => {
|
|
|
|
|
|
const newRes = { ...prev };
|
|
|
|
|
|
if (newRes[record.model]) {
|
|
|
|
|
|
delete newRes[record.model][record.ratioType];
|
|
|
|
|
|
if (Object.keys(newRes[record.model]).length === 0) {
|
|
|
|
|
|
delete newRes[record.model];
|
|
|
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
return newRes;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{upstreamVal}
|
|
|
|
|
|
</Checkbox>
|
|
|
|
|
|
{!isConfident && (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tooltip
|
|
|
|
|
|
position='left'
|
|
|
|
|
|
content={t('评ę°ę®åÆč½äøåÆäæ”ļ¼čÆ·č°Øę
使ēØ')}
|
|
|
|
|
|
>
|
|
|
|
|
|
<AlertTriangle size={16} className='text-yellow-500' />
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
</Tooltip>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
}),
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Table
|
|
|
|
|
|
columns={columns}
|
2025-06-19 18:54:46 +08:00
|
|
|
|
dataSource={getCurrentPageData(filteredDataSource)}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
pagination={{
|
|
|
|
|
|
currentPage: currentPage,
|
|
|
|
|
|
pageSize: pageSize,
|
2025-06-19 18:54:46 +08:00
|
|
|
|
total: filteredDataSource.length,
|
2025-06-19 08:57:34 +08:00
|
|
|
|
showSizeChanger: true,
|
|
|
|
|
|
showQuickJumper: true,
|
|
|
|
|
|
pageSizeOptions: ['5', '10', '20', '50'],
|
|
|
|
|
|
onChange: (page, size) => {
|
|
|
|
|
|
setCurrentPage(page);
|
|
|
|
|
|
setPageSize(size);
|
|
|
|
|
|
},
|
|
|
|
|
|
onShowSizeChange: (current, size) => {
|
|
|
|
|
|
setCurrentPage(1);
|
|
|
|
|
|
setPageSize(size);
|
2025-08-30 21:15:10 +08:00
|
|
|
|
},
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}}
|
|
|
|
|
|
scroll={{ x: 'max-content' }}
|
|
|
|
|
|
size='middle'
|
|
|
|
|
|
loading={loading || syncLoading}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const updateChannelEndpoint = useCallback((channelId, endpoint) => {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setChannelEndpoints((prev) => ({ ...prev, [channelId]: endpoint }));
|
2025-06-19 08:57:34 +08:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
const handleModalClose = () => {
|
|
|
|
|
|
setModalVisible(false);
|
|
|
|
|
|
if (channelSelectorRef.current) {
|
|
|
|
|
|
channelSelectorRef.current.resetPagination();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-19 08:57:34 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Form.Section text={renderHeader()}>
|
|
|
|
|
|
{renderDifferenceTable()}
|
|
|
|
|
|
</Form.Section>
|
|
|
|
|
|
|
|
|
|
|
|
<ChannelSelectorModal
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
ref={channelSelectorRef}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
t={t}
|
|
|
|
|
|
visible={modalVisible}
|
⨠feat(ratio-sync): support /api/pricing parsing, confidence verification & UI enhancements
Backend
- controller/ratio_sync.go
⢠Parse /api/pricing response and convert to ratio / price maps.
⢠Introduce confidence heuristic (model_ratio = 37.5 && completion_ratio = 1) to flag unreliable data.
⢠Include confidence map when building differences and filter āsameā/empty entries.
- dto/ratio_sync.go
⢠Add `ID` to UpstreamDTO, `upstreams` to UpstreamRequest, and `Confidence` to DifferenceItem.
Frontend
- ChannelSelectorModal.js
⢠Re-implement with table layout, pagination, search, endpoint-type selector and mobile support.
- UpstreamRatioSync.js
⢠Send full upstream objects, add ratio-type filter, confidence badges/tooltips, retain endpoints.
⢠Leverage ChannelSelectorModalās pagination reset.
- ChannelsTable.js ā fix tag color for disabled status.
- en.json ā add translations for new UI labels.
Motivation
These changes let users sync model ratiosā/āprices from different upstream endpoints and visually identify potentially unreliable data, improving operational safety and flexibility.
2025-06-21 20:24:52 +08:00
|
|
|
|
onCancel={handleModalClose}
|
2025-06-19 08:57:34 +08:00
|
|
|
|
onOk={confirmChannelSelection}
|
|
|
|
|
|
allChannels={allChannels}
|
|
|
|
|
|
selectedChannelIds={selectedChannelIds}
|
|
|
|
|
|
setSelectedChannelIds={setSelectedChannelIds}
|
|
|
|
|
|
channelEndpoints={channelEndpoints}
|
|
|
|
|
|
updateChannelEndpoint={updateChannelEndpoint}
|
|
|
|
|
|
/>
|
2025-06-23 17:35:39 +08:00
|
|
|
|
|
|
|
|
|
|
<ConflictConfirmModal
|
|
|
|
|
|
t={t}
|
|
|
|
|
|
visible={confirmVisible}
|
|
|
|
|
|
items={conflictItems}
|
|
|
|
|
|
onOk={async () => {
|
|
|
|
|
|
setConfirmVisible(false);
|
|
|
|
|
|
const curRatios = {
|
|
|
|
|
|
ModelRatio: JSON.parse(props.options.ModelRatio || '{}'),
|
|
|
|
|
|
CompletionRatio: JSON.parse(props.options.CompletionRatio || '{}'),
|
|
|
|
|
|
CacheRatio: JSON.parse(props.options.CacheRatio || '{}'),
|
|
|
|
|
|
ModelPrice: JSON.parse(props.options.ModelPrice || '{}'),
|
|
|
|
|
|
};
|
|
|
|
|
|
await performSync(curRatios);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onCancel={() => setConfirmVisible(false)}
|
|
|
|
|
|
/>
|
2025-06-19 08:57:34 +08:00
|
|
|
|
</>
|
|
|
|
|
|
);
|
2025-08-30 21:15:10 +08:00
|
|
|
|
}
|