chore: copy model-tag from user-view
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
import IconFont from '@/components/icon-font';
|
||||||
|
import {
|
||||||
|
AudioOutlined,
|
||||||
|
PictureOutlined,
|
||||||
|
WechatWorkOutlined
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import { Tag } from 'antd';
|
||||||
|
import { modelCategoriesMap } from '../config';
|
||||||
|
|
||||||
|
const categoryConfig = {
|
||||||
|
[modelCategoriesMap.reranker]: {
|
||||||
|
icon: <IconFont type="icon-rank1" />,
|
||||||
|
color: 'cyan',
|
||||||
|
label: 'Reranker'
|
||||||
|
},
|
||||||
|
[modelCategoriesMap.embedding]: {
|
||||||
|
icon: <IconFont type="icon-cube" />,
|
||||||
|
color: 'purple',
|
||||||
|
label: 'Embedding'
|
||||||
|
},
|
||||||
|
[modelCategoriesMap.text_to_speech]: {
|
||||||
|
icon: <IconFont type="icon-sound-wave" />,
|
||||||
|
color: 'geekblue',
|
||||||
|
label: 'Text-To-Speech'
|
||||||
|
},
|
||||||
|
[modelCategoriesMap.speech_to_text]: {
|
||||||
|
icon: <AudioOutlined />,
|
||||||
|
color: 'processing',
|
||||||
|
label: 'Speech-To-Text'
|
||||||
|
},
|
||||||
|
[modelCategoriesMap.image]: {
|
||||||
|
icon: <PictureOutlined />,
|
||||||
|
color: 'orange',
|
||||||
|
label: 'Image'
|
||||||
|
},
|
||||||
|
[modelCategoriesMap.llm]: {
|
||||||
|
icon: <WechatWorkOutlined />,
|
||||||
|
color: 'green',
|
||||||
|
label: 'LLM'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
interface ModelTagProps {
|
||||||
|
categoryKey: keyof typeof categoryConfig;
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ModelTag: React.FC<ModelTagProps> = ({ categoryKey, size }) => {
|
||||||
|
const config = categoryConfig[categoryKey];
|
||||||
|
|
||||||
|
if (!config) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
icon={config.icon}
|
||||||
|
style={{
|
||||||
|
height: size,
|
||||||
|
margin: 0,
|
||||||
|
opacity: 1,
|
||||||
|
paddingInline: 8,
|
||||||
|
borderRadius: 12,
|
||||||
|
transform: 'scale(0.9)'
|
||||||
|
}}
|
||||||
|
color={config.color}
|
||||||
|
>
|
||||||
|
{config.label}
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ModelTag;
|
||||||
@@ -19,28 +19,16 @@ import {
|
|||||||
} from '@/pages/resources/config/types';
|
} from '@/pages/resources/config/types';
|
||||||
import { handleBatchRequest } from '@/utils';
|
import { handleBatchRequest } from '@/utils';
|
||||||
import {
|
import {
|
||||||
AudioOutlined,
|
|
||||||
DeleteOutlined,
|
DeleteOutlined,
|
||||||
DownOutlined,
|
DownOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
ExperimentOutlined,
|
ExperimentOutlined,
|
||||||
PictureOutlined,
|
|
||||||
QuestionCircleOutlined,
|
QuestionCircleOutlined,
|
||||||
SyncOutlined,
|
SyncOutlined
|
||||||
WechatWorkOutlined
|
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { PageContainer } from '@ant-design/pro-components';
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
import { Access, useAccess, useIntl, useNavigate } from '@umijs/max';
|
import { Access, useAccess, useIntl, useNavigate } from '@umijs/max';
|
||||||
import {
|
import { Button, Dropdown, Input, Select, Space, Tooltip, message } from 'antd';
|
||||||
Button,
|
|
||||||
Dropdown,
|
|
||||||
Input,
|
|
||||||
Select,
|
|
||||||
Space,
|
|
||||||
Tag,
|
|
||||||
Tooltip,
|
|
||||||
message
|
|
||||||
} from 'antd';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -66,6 +54,7 @@ import { FormData, ListItem, ModelInstanceListItem } from '../config/types';
|
|||||||
import DeployDropdown from './deploy-dropdown';
|
import DeployDropdown from './deploy-dropdown';
|
||||||
import DeployModal from './deploy-modal';
|
import DeployModal from './deploy-modal';
|
||||||
import InstanceItem from './instance-item';
|
import InstanceItem from './instance-item';
|
||||||
|
import ModelTag from './model-tag';
|
||||||
import UpdateModel from './update-modal';
|
import UpdateModel from './update-modal';
|
||||||
import ViewLogsModal from './view-logs-modal';
|
import ViewLogsModal from './view-logs-modal';
|
||||||
|
|
||||||
@@ -584,116 +573,6 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
[handleViewLogs, handleDeleteInstace]
|
[handleViewLogs, handleDeleteInstace]
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderModelTags = useCallback(
|
|
||||||
(record: ListItem) => {
|
|
||||||
if (record.categories?.includes(modelCategoriesMap.reranker)) {
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
icon={<IconFont type="icon-rank1"></IconFont>}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 1,
|
|
||||||
paddingInline: 8,
|
|
||||||
borderRadius: 12,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="cyan"
|
|
||||||
>
|
|
||||||
Reranker
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (record.categories?.includes(modelCategoriesMap.embedding)) {
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
icon={<IconFont type="icon-cube"></IconFont>}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 1,
|
|
||||||
paddingInline: 8,
|
|
||||||
borderRadius: 12,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="purple"
|
|
||||||
>
|
|
||||||
Embedding
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (record.categories?.includes(modelCategoriesMap.text_to_speech)) {
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
icon={<IconFont type="icon-sound-wave"></IconFont>}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 1,
|
|
||||||
paddingInline: 8,
|
|
||||||
borderRadius: 12,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="geekblue"
|
|
||||||
>
|
|
||||||
Text-To-Speech
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (record.categories?.includes(modelCategoriesMap.speech_to_text)) {
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
icon={<AudioOutlined />}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 1,
|
|
||||||
paddingInline: 8,
|
|
||||||
borderRadius: 12,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="processing"
|
|
||||||
>
|
|
||||||
Speech-To-Text
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (record.categories?.includes(modelCategoriesMap.image)) {
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
icon={<PictureOutlined />}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 1,
|
|
||||||
paddingInline: 8,
|
|
||||||
borderRadius: 12,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="orange"
|
|
||||||
>
|
|
||||||
Image
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (record.categories?.includes(modelCategoriesMap.llm)) {
|
|
||||||
return (
|
|
||||||
<Tag
|
|
||||||
icon={<WechatWorkOutlined />}
|
|
||||||
style={{
|
|
||||||
margin: 0,
|
|
||||||
opacity: 1,
|
|
||||||
paddingInline: 8,
|
|
||||||
borderRadius: 12,
|
|
||||||
transform: 'scale(0.9)'
|
|
||||||
}}
|
|
||||||
color="green"
|
|
||||||
>
|
|
||||||
LLM
|
|
||||||
</Tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
[intl]
|
|
||||||
);
|
|
||||||
|
|
||||||
const renderChildren = useCallback(
|
const renderChildren = useCallback(
|
||||||
(list: any, parent?: any) => {
|
(list: any, parent?: any) => {
|
||||||
return (
|
return (
|
||||||
@@ -939,7 +818,9 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
<AutoTooltip ghost>
|
<AutoTooltip ghost>
|
||||||
<span className="m-r-5">{text}</span>
|
<span className="m-r-5">{text}</span>
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
{renderModelTags(record)}
|
<ModelTag
|
||||||
|
categoryKey={record.categories?.[0] || ''}
|
||||||
|
></ModelTag>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user