Skip to content

Commit dc83c4a

Browse files
committed
refactor(settings): update RatioSetting component to use ModelPricingCombined and adjust tab structure
- Replaced ModelRatioSettings with ModelPricingCombined in the RatioSetting component. - Updated tab structure to prioritize pricing settings over model settings. - Removed unused imports for ModelRatioSettings and ModelSettingsVisualEditor.
1 parent 960bf9c commit dc83c4a

17 files changed

Lines changed: 4378 additions & 2240 deletions

File tree

web/src/components/settings/RatioSetting.jsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import React, { useEffect, useState } from 'react';
2121
import { Card, Spin, Tabs } from '@douyinfe/semi-ui';
2222
import { useTranslation } from 'react-i18next';
2323

24+
import ModelPricingCombined from '../../pages/Setting/Ratio/ModelPricingCombined';
2425
import GroupRatioSettings from '../../pages/Setting/Ratio/GroupRatioSettings';
25-
import ModelRatioSettings from '../../pages/Setting/Ratio/ModelRatioSettings';
26-
import ModelSettingsVisualEditor from '../../pages/Setting/Ratio/ModelSettingsVisualEditor';
2726
import ModelRatioNotSetEditor from '../../pages/Setting/Ratio/ModelRationNotSetEditor';
2827
import UpstreamRatioSync from '../../pages/Setting/Ratio/UpstreamRatioSync';
2928

@@ -95,18 +94,14 @@ const RatioSetting = () => {
9594

9695
return (
9796
<Spin spinning={loading} size='large'>
98-
{/* 模型倍率设置以及价格编辑器 */}
9997
<Card style={{ marginTop: '10px' }}>
100-
<Tabs type='card' defaultActiveKey='visual'>
101-
<Tabs.TabPane tab={t('模型倍率设置')} itemKey='model'>
102-
<ModelRatioSettings options={inputs} refresh={onRefresh} />
98+
<Tabs type='card' defaultActiveKey='pricing'>
99+
<Tabs.TabPane tab={t('模型定价设置')} itemKey='pricing'>
100+
<ModelPricingCombined options={inputs} refresh={onRefresh} />
103101
</Tabs.TabPane>
104102
<Tabs.TabPane tab={t('分组相关设置')} itemKey='group'>
105103
<GroupRatioSettings options={inputs} refresh={onRefresh} />
106104
</Tabs.TabPane>
107-
<Tabs.TabPane tab={t('价格设置')} itemKey='visual'>
108-
<ModelSettingsVisualEditor options={inputs} refresh={onRefresh} />
109-
</Tabs.TabPane>
110105
<Tabs.TabPane tab={t('未设置价格模型')} itemKey='unset_models'>
111106
<ModelRatioNotSetEditor options={inputs} refresh={onRefresh} />
112107
</Tabs.TabPane>

web/src/components/table/tokens/TokensColumnDefs.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const renderStatus = (text, record, t) => {
8888
};
8989

9090
// Render group column
91-
const renderGroupColumn = (text, record, t) => {
91+
const renderGroupColumn = (text, record, t, groupRatios = {}) => {
9292
if (text === 'auto') {
9393
return (
9494
<Tooltip
@@ -104,7 +104,17 @@ const renderGroupColumn = (text, record, t) => {
104104
</Tooltip>
105105
);
106106
}
107-
return renderGroup(text);
107+
const ratio = groupRatios[text];
108+
return (
109+
<span className='flex items-center gap-1'>
110+
{renderGroup(text)}
111+
{ratio !== undefined && (
112+
<Tag size='small' color='green' shape='circle'>
113+
{ratio}x
114+
</Tag>
115+
)}
116+
</span>
117+
);
108118
};
109119

110120
// Render token key column with show/hide and copy functionality
@@ -469,6 +479,7 @@ export const getTokensColumns = ({
469479
setEditingToken,
470480
setShowEdit,
471481
refresh,
482+
groupRatios = {},
472483
}) => {
473484
return [
474485
{
@@ -490,7 +501,7 @@ export const getTokensColumns = ({
490501
title: t('分组'),
491502
dataIndex: 'group',
492503
key: 'group',
493-
render: (text, record) => renderGroupColumn(text, record, t),
504+
render: (text, record) => renderGroupColumn(text, record, t, groupRatios),
494505
},
495506
{
496507
title: t('密钥'),

web/src/components/table/tokens/TokensTable.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const TokensTable = (tokensData) => {
4949
setEditingToken,
5050
setShowEdit,
5151
refresh,
52+
groupRatios,
5253
t,
5354
} = tokensData;
5455

@@ -67,6 +68,7 @@ const TokensTable = (tokensData) => {
6768
setEditingToken,
6869
setShowEdit,
6970
refresh,
71+
groupRatios,
7072
});
7173
}, [
7274
t,
@@ -81,6 +83,7 @@ const TokensTable = (tokensData) => {
8183
setEditingToken,
8284
setShowEdit,
8385
refresh,
86+
groupRatios,
8487
]);
8588

8689
// Handle compact mode by removing fixed positioning

web/src/components/table/tokens/modals/EditTokenModal.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ const EditTokenModal = (props) => {
366366
placeholder={t('令牌分组,默认为用户的分组')}
367367
optionList={groups}
368368
renderOptionItem={renderGroupOption}
369+
filter={(input, option) => {
370+
const q = input.toLowerCase();
371+
return (
372+
option.value?.toLowerCase().includes(q) ||
373+
(typeof option.label === 'string' &&
374+
option.label.toLowerCase().includes(q))
375+
);
376+
}}
369377
showClear
370378
style={{ width: '100%' }}
371379
/>

web/src/hooks/tokens/useTokensData.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const useTokensData = (openFluentNotification, openCCSwitchModal) => {
4242
// Basic state
4343
const [tokens, setTokens] = useState([]);
4444
const [loading, setLoading] = useState(true);
45+
const [groupRatios, setGroupRatios] = useState({});
4546
const [activePage, setActivePage] = useState(1);
4647
const [tokenCount, setTokenCount] = useState(0);
4748
const [pageSize, setPageSize] = useState(ITEMS_PER_PAGE);
@@ -437,6 +438,17 @@ export const useTokensData = (openFluentNotification, openCCSwitchModal) => {
437438
.catch((reason) => {
438439
showError(reason);
439440
});
441+
API.get('/api/user/self/groups')
442+
.then((res) => {
443+
if (res.data.success && res.data.data) {
444+
const ratios = {};
445+
for (const [name, info] of Object.entries(res.data.data)) {
446+
ratios[name] = info.ratio;
447+
}
448+
setGroupRatios(ratios);
449+
}
450+
})
451+
.catch(() => {});
440452
}, [pageSize]);
441453

442454
return {
@@ -447,6 +459,7 @@ export const useTokensData = (openFluentNotification, openCCSwitchModal) => {
447459
tokenCount,
448460
pageSize,
449461
searching,
462+
groupRatios,
450463

451464
// Selection state
452465
selectedKeys,

0 commit comments

Comments
 (0)