dify/web/app/components/header/account-setting/model-provider-page/model-icon/index.tsx

56 lines
1.8 KiB
TypeScript
Raw Normal View History

import type { FC } from 'react'
import type {
Model,
ModelProvider,
} from '../declarations'
import { useLanguage } from '../hooks'
import { Group } from '@/app/components/base/icons/src/vender/other'
import { OpenaiBlue, OpenaiViolet } from '@/app/components/base/icons/src/public/llm'
2024-12-13 13:10:13 +08:00
import cn from '@/utils/classnames'
type ModelIconProps = {
provider?: Model | ModelProvider
modelName?: string
className?: string
isDeprecated?: boolean
2025-01-08 14:45:03 +08:00
isInModelList?: boolean
}
const ModelIcon: FC<ModelIconProps> = ({
provider,
className,
modelName,
isDeprecated = false,
2025-01-08 14:45:03 +08:00
isInModelList = false,
}) => {
const language = useLanguage()
if (provider?.provider.includes('openai') && modelName?.includes('gpt-4o'))
2024-12-31 14:35:11 +08:00
return <div className='flex items-center justify-center'><OpenaiBlue className={cn('w-5 h-5', className)}/></div>
if (provider?.provider.includes('openai') && modelName?.startsWith('gpt-4'))
2024-12-31 14:35:11 +08:00
return <div className='flex items-center justify-center'><OpenaiViolet className={cn('w-5 h-5', className)}/></div>
2025-01-08 14:45:03 +08:00
if (provider?.icon_small && isInModelList) {
return (
2025-01-07 16:31:15 +08:00
<div className={`flex items-center justify-center w-5 h-5 ${isDeprecated ? 'opacity-50' : ''}`}>
<img
alt='model-icon'
src={`${provider.icon_small[language] || provider.icon_small.en_US}`}
2025-01-07 16:31:15 +08:00
className={cn('w-4.5 h-4.5', className)}
/>
</div>
)
}
return (
2024-12-13 13:10:13 +08:00
<div className={cn(
2025-01-08 14:45:03 +08:00
'flex items-center justify-center rounded-md border-[0.5px] w-5 h-5 border-components-panel-border-subtle bg-background-default-subtle',
2024-12-13 13:10:13 +08:00
className,
)}>
2025-01-07 11:18:01 +08:00
<div className='flex w-5 h-5 items-center justify-center opacity-35'>
<Group className='text-text-tertiary w-3 h-3' />
</div>
</div>
)
}
export default ModelIcon