import { TooltipOverlayScroller } from '@/components/overlay-scroller'; import ThemeTag from '@/components/tags-wrapper/theme-tag'; import { convertFileSize } from '@/utils'; import { InfoCircleOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import classNames from 'classnames'; import _ from 'lodash'; import React from 'react'; import 'simplebar-react/dist/simplebar.min.css'; import { getFileType } from '../config/file-type'; import '../style/hf-model-file.less'; import FileParts from './file-parts'; import IncompatiableInfo from './incompatiable-info'; interface ModelFileItemProps { data: Record; isEvaluating: boolean; active: boolean; handleSelectModelFile: (item: any) => void; handleOnEnter: (e: any, item: any) => void; } const FilePartsTag = (props: { parts: any[] }) => { const { parts } = props; const intl = useIntl(); if (!props.parts || !props.parts.length) { return null; } return ( }> {intl.formatMessage( { id: 'models.search.parts' }, { n: parts.length } )} ); }; const ModelFileItem: React.FC = (props) => { const { data: item, isEvaluating, active, handleSelectModelFile, handleOnEnter } = props; const getModelQuantizationType = (item: any) => { let path = item.path; if (item?.parts?.length) { path = `${item.path}.gguf`; } const quanType = getFileType(path); if (quanType) { return ( {_.toUpper(quanType)} ); } return null; }; return (
handleSelectModelFile(item)} onKeyDown={(e) => handleOnEnter(e, item)} >
{item.path}
{convertFileSize(item.size)} {getModelQuantizationType(item)}
); }; export default ModelFileItem;