mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-03 01:12:15 +00:00
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: 谨欣 <echo.cmy@antgroup.com> Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com> Co-authored-by: yanzhiyong <932374019@qq.com>
35 lines
965 B
TypeScript
35 lines
965 B
TypeScript
import { MODEL_ICON_DICT } 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;
|
|
}, [model]);
|
|
|
|
if (!model) return null;
|
|
|
|
return (
|
|
<Image
|
|
className='rounded-full border border-gray-200 object-contain bg-white inline-block'
|
|
width={width || 24}
|
|
height={height || 24}
|
|
src={iconSrc}
|
|
alt='llm'
|
|
priority
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default memo(ModelIcon);
|