model-card.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { IModelData } from '@/types/model';
  2. import { MODEL_ICON_MAP } from '@/utils';
  3. import moment from 'moment';
  4. import GptCard from '../common/gpt-card';
  5. interface Props {
  6. info: IModelData;
  7. }
  8. function ModelCard({ info }: Props) {
  9. // const { t } = useTranslation();
  10. // const [loading, setLoading] = useState<boolean>(false);
  11. // TODO:unused function
  12. // async function stopTheModel(info: IModelData) {
  13. // if (loading) {
  14. // return;
  15. // }
  16. // setLoading(true);
  17. // const [, res] = await apiInterceptors(
  18. // stopModel({
  19. // host: info.host,
  20. // port: info.port,
  21. // model: info.model_name,
  22. // worker_type: info.model_type,
  23. // params: {},
  24. // }),
  25. // );
  26. // setLoading(false);
  27. // if (res === true) {
  28. // message.success(t('stop_model_success'));
  29. // }
  30. // }
  31. return (
  32. <GptCard
  33. className='w-96'
  34. title={info.model_name}
  35. tags={[
  36. {
  37. text: info.healthy ? 'Healthy' : 'Unhealthy',
  38. color: info.healthy ? 'green' : 'red',
  39. border: true,
  40. },
  41. info.model_type,
  42. ]}
  43. icon={MODEL_ICON_MAP[info.model_name]?.icon || '/models/huggingface.svg'}
  44. // operations={[
  45. // {
  46. // children: (
  47. // <div>
  48. // <PauseCircleOutlined className="mr-2" />
  49. // <span className="text-sm">Stop Model</span>
  50. // </div>
  51. // ),
  52. // onClick: () => {
  53. // stopTheModel(info);
  54. // },
  55. // },
  56. // ]}
  57. >
  58. <div className='flex flex-col gap-1 px-4 pb-4 text-xs'>
  59. <div className='flex overflow-hidden'>
  60. <p className='w-28 text-gray-500 mr-2'>Host:</p>
  61. <p className='flex-1 text-ellipsis'>{info.host}</p>
  62. </div>
  63. <div className='flex overflow-hidden'>
  64. <p className='w-28 text-gray-500 mr-2'>Manage Host:</p>
  65. <p className='flex-1 text-ellipsis'>
  66. {info.manager_host}:{info.manager_port}
  67. </p>
  68. </div>
  69. <div className='flex overflow-hidden'>
  70. <p className='w-28 text-gray-500 mr-2'>Last Heart Beat:</p>
  71. <p className='flex-1 text-ellipsis'>{moment(info.last_heartbeat).format('YYYY-MM-DD')}</p>
  72. </div>
  73. </div>
  74. </GptCard>
  75. );
  76. }
  77. export default ModelCard;