feat(model): Support model icon

This commit is contained in:
Fangyin Cheng
2025-03-19 11:51:26 +08:00
parent 88bbd695d0
commit 4489f74e8d
474 changed files with 15535 additions and 7832 deletions

View File

@@ -1,20 +1,10 @@
import { MODEL_ICON_DICT } from '@/utils/constants';
import { getModelIcon } from '@/utils/constants';
import Image from 'next/image';
import React, { memo, useMemo } from 'react';
const DEFAULT_ICON_URL = '/models/huggingface.svg';
const ModelIcon: React.FC<{ width?: number; height?: number; model?: string }> = ({ width, height, model }) => {
const iconSrc = useMemo(() => {
const formatterModal = model?.replaceAll('-', '_').split('_')[0];
const dict = Object.keys(MODEL_ICON_DICT);
for (let i = 0; i < dict.length; i++) {
const element = dict[i];
if (formatterModal?.includes(element)) {
return MODEL_ICON_DICT[element];
}
}
return DEFAULT_ICON_URL;
return getModelIcon(model || 'huggingface');
}, [model]);
if (!model) return null;