Skip to content

Commit 7362047

Browse files
author
Apple\Apple
committed
✨ feat(ui): Enhance model tag rendering in logs table with icons
Improve the logs table by implementing brand-specific model icons and better redirection visualization: - Replace standard tags with `renderModelTag` to display appropriate brand icons for each model (OpenAI, Claude, Gemini, etc.) - Fix background colors by explicitly passing color parameters - Restore descriptive text for model redirection in popover - Replace refresh icon with forward icon for better representation of model redirection - Clean up unused imports This change provides a more intuitive visual representation of models and their relationships, making the logs table easier to understand at a glance.
1 parent f9ddec3 commit 7362047

File tree

5 files changed

+359
-338
lines changed

5 files changed

+359
-338
lines changed

web/src/components/table/LogsTable.js

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import {
44
API,
@@ -19,7 +19,8 @@ import {
1919
renderNumber,
2020
renderQuota,
2121
stringToColor,
22-
getLogOther
22+
getLogOther,
23+
renderModelTag
2324
} from '../../helpers';
2425

2526
import {
@@ -39,18 +40,14 @@ import {
3940
Typography,
4041
Divider,
4142
Input,
42-
DatePicker,
43+
DatePicker
4344
} from '@douyinfe/semi-ui';
4445
import { ITEMS_PER_PAGE } from '../../constants';
4546
import Paragraph from '@douyinfe/semi-ui/lib/es/typography/paragraph';
4647
import {
47-
IconRefresh,
4848
IconSetting,
49-
IconEyeOpened,
5049
IconSearch,
51-
IconCoinMoneyStroked,
52-
IconPulse,
53-
IconTypograph,
50+
IconForward
5451
} from '@douyinfe/semi-icons';
5552

5653
const { Text } = Typography;
@@ -202,19 +199,12 @@ const LogsTable = () => {
202199
other?.upstream_model_name &&
203200
other?.upstream_model_name !== '';
204201
if (!modelMapped) {
205-
return (
206-
<Tag
207-
color={stringToColor(record.model_name)}
208-
size='large'
209-
shape='circle'
210-
onClick={(event) => {
211-
copyText(event, record.model_name).then((r) => { });
212-
}}
213-
>
214-
{' '}
215-
{record.model_name}{' '}
216-
</Tag>
217-
);
202+
return renderModelTag(record.model_name, {
203+
color: stringToColor(record.model_name),
204+
onClick: (event) => {
205+
copyText(event, record.model_name).then((r) => { });
206+
}
207+
});
218208
} else {
219209
return (
220210
<>
@@ -223,48 +213,35 @@ const LogsTable = () => {
223213
content={
224214
<div style={{ padding: 10 }}>
225215
<Space vertical align={'start'}>
226-
<Tag
227-
color={stringToColor(record.model_name)}
228-
size='large'
229-
shape='circle'
230-
onClick={(event) => {
231-
copyText(event, record.model_name).then((r) => { });
232-
}}
233-
>
234-
{t('请求并计费模型')} {record.model_name}{' '}
235-
</Tag>
236-
<Tag
237-
color={stringToColor(other.upstream_model_name)}
238-
size='large'
239-
shape='circle'
240-
onClick={(event) => {
241-
copyText(event, other.upstream_model_name).then(
242-
(r) => { },
243-
);
244-
}}
245-
>
246-
{t('实际模型')} {other.upstream_model_name}{' '}
247-
</Tag>
216+
<div className="flex items-center">
217+
<Text strong style={{ marginRight: 8 }}>{t('请求并计费模型')}:</Text>
218+
{renderModelTag(record.model_name, {
219+
color: stringToColor(record.model_name),
220+
onClick: (event) => {
221+
copyText(event, record.model_name).then((r) => { });
222+
}
223+
})}
224+
</div>
225+
<div className="flex items-center">
226+
<Text strong style={{ marginRight: 8 }}>{t('实际模型')}:</Text>
227+
{renderModelTag(other.upstream_model_name, {
228+
color: stringToColor(other.upstream_model_name),
229+
onClick: (event) => {
230+
copyText(event, other.upstream_model_name).then((r) => { });
231+
}
232+
})}
233+
</div>
248234
</Space>
249235
</div>
250236
}
251237
>
252-
<Tag
253-
color={stringToColor(record.model_name)}
254-
size='large'
255-
shape='circle'
256-
onClick={(event) => {
238+
{renderModelTag(record.model_name, {
239+
color: stringToColor(record.model_name),
240+
onClick: (event) => {
257241
copyText(event, record.model_name).then((r) => { });
258-
}}
259-
suffixIcon={
260-
<IconRefresh
261-
style={{ width: '0.8em', height: '0.8em', opacity: 0.6 }}
262-
/>
263-
}
264-
>
265-
{' '}
266-
{record.model_name}{' '}
267-
</Tag>
242+
},
243+
suffixIcon: <IconForward style={{ width: '0.9em', height: '0.9em', opacity: 0.75 }} />
244+
})}
268245
</Popover>
269246
</Space>
270247
</>

web/src/components/table/ModelPricing.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext, useEffect, useRef, useMemo, useState } from 'react';
2-
import { API, copy, showError, showInfo, showSuccess } from '../../helpers/index.js';
2+
import { API, copy, showError, showInfo, showSuccess, getModelCategories } from '../../helpers/index.js';
33
import { useTranslation } from 'react-i18next';
44

55
import {
@@ -28,7 +28,6 @@ import {
2828
} from '@douyinfe/semi-icons';
2929
import { UserContext } from '../../context/User/index.js';
3030
import { AlertCircle } from 'lucide-react';
31-
import { MODEL_CATEGORIES } from '../../constants/index.js';
3231

3332
const ModelPricing = () => {
3433
const { t } = useTranslation();
@@ -321,7 +320,7 @@ const ModelPricing = () => {
321320
refresh().then();
322321
}, []);
323322

324-
const modelCategories = MODEL_CATEGORIES(t);
323+
const modelCategories = getModelCategories(t);
325324

326325
const renderArrow = (items, pos, handleArrowClick) => {
327326
const style = {

web/src/constants/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ export * from './channel.constants';
22
export * from './user.constants';
33
export * from './toast.constants';
44
export * from './common.constant';
5-
export * from './model.constants';
65
export * from './playground.constants';

web/src/constants/model.constants.js

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)