'use client'; import { cn } from '@/lib/utils'; // 模型卡片配置 const MODEL_CARDS = [ { id: 'haiku', name: 'Haiku', description: 'Fast & efficient', modelIdPattern: 'haiku', }, { id: 'sonnet', name: 'Sonnet', description: 'Balanced', modelIdPattern: 'sonnet', }, { id: 'opus', name: 'Opus', description: 'Most capable', modelIdPattern: 'opus', }, ]; interface ModelCardSelectorProps { value: string; onChange: (modelId: string) => void; disabled?: boolean; models?: { modelId: string; displayName: string }[]; } export function ModelCardSelector({ value, onChange, disabled = false, models = [], }: ModelCardSelectorProps) { // 根据当前选中的模型ID判断选中的卡片 const getSelectedCard = (modelId: string): string => { const lowerModelId = modelId.toLowerCase(); if (lowerModelId.includes('haiku')) return 'haiku'; if (lowerModelId.includes('opus')) return 'opus'; return 'sonnet'; // 默认 sonnet }; // 根据卡片类型找到对应的实际模型ID const findModelIdByCard = (cardId: string): string => { const model = models.find((m) => m.modelId.toLowerCase().includes(cardId) ); return model?.modelId || value; }; const selectedCard = getSelectedCard(value); return (
{MODEL_CARDS.map((card) => { const isSelected = selectedCard === card.id; return ( ); })}
); }