import { formatNumber } from '@/utils'; import { DownloadOutlined, FolderOutlined, HeartOutlined, WarningOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Tag, Tooltip } from 'antd'; import classNames from 'classnames'; import dayjs from 'dayjs'; import _ from 'lodash'; import { modelSourceMap } from '../config'; import '../style/hf-model-item.less'; interface HFModelItemProps { title: string; downloads: number; likes: number; task?: string; updatedAt: string; active: boolean; source?: string; tags?: string[]; } const warningTask = ['audio', 'video']; const SUPPORTEDSOURCE = [ modelSourceMap.huggingface_value, modelSourceMap.modelscope_value ]; const HFModelItem: React.FC = (props) => { const intl = useIntl(); const isExcludeTask = () => { if (!props.task) { return false; } return _.some(warningTask, (item: string) => { return props.task?.toLowerCase().includes(item); }); }; return (
{props.title} {isExcludeTask() && ( )}
{SUPPORTEDSOURCE.includes(props.source || '') ? (
{/* {props.task && ( {props.task} )} */} {dayjs().to( dayjs(dayjs(props.updatedAt).format('YYYY-MM-DD HH:mm:ss')) )} {props.likes} {formatNumber(props.downloads)}
) : (
{_.map(props.tags, (tag: string, index: string) => { return ( {tag} ); })}
)}
); }; export default HFModelItem;