// src/components/ModelProviderCard.tsx import { LlmIcon } from '@/components/svg-icon'; import { Button } from '@/components/ui/button'; import { Switch } from '@/components/ui/switch'; import { useSetModalState, useTranslate } from '@/hooks/common-hooks'; import { LlmItem } from '@/hooks/llm-hooks'; import { getRealModelName } from '@/utils/llm-util'; import { EditOutlined, SettingOutlined } from '@ant-design/icons'; import { ChevronsDown, ChevronsUp, Trash2 } from 'lucide-react'; import { FC } from 'react'; import { isLocalLlmFactory } from '../../utils'; import { useHandleDeleteFactory, useHandleEnableLlm } from '../hooks'; interface IModelCardProps { item: LlmItem; clickApiKey: (llmFactory: string) => void; handleEditModel: (model: any, factory: LlmItem) => void; } type TagType = | 'LLM' | 'TEXT EMBEDDING' | 'TEXT RE-RANK' | 'TTS' | 'SPEECH2TEXT' | 'IMAGE2TEXT' | 'MODERATION'; const sortTags = (tags: string) => { const orderMap: Record = { LLM: 1, 'TEXT EMBEDDING': 2, 'TEXT RE-RANK': 3, TTS: 4, SPEECH2TEXT: 5, IMAGE2TEXT: 6, MODERATION: 7, }; return tags .split(',') .map((tag) => tag.trim()) .sort( (a, b) => (orderMap[a as TagType] || 999) - (orderMap[b as TagType] || 999), ); }; export const ModelProviderCard: FC = ({ item, clickApiKey, handleEditModel, }) => { const { visible, switchVisible } = useSetModalState(); const { t } = useTranslate('setting'); const { handleEnableLlm } = useHandleEnableLlm(item.name); const { handleDeleteFactory } = useHandleDeleteFactory(item.name); const handleApiKeyClick = () => { clickApiKey(item.name); }; const handleShowMoreClick = () => { switchVisible(); }; return (
{/* Header */}

{item.name}

{/* Content */} {visible && (
{sortTags(item.tags).map((tag, index) => ( {tag} ))}
{item.llm.map((model) => (
{getRealModelName(model.name)} {model.type}
{isLocalLlmFactory(item.name) && ( )} { handleEnableLlm(model.name, value); }} />
))}
)}
); };