'use client'; import React, { useState } from 'react'; import { Box, TextField, Button, IconButton, Badge, Tooltip } from '@mui/material'; import SendIcon from '@mui/icons-material/Send'; import ImageIcon from '@mui/icons-material/Image'; import CancelIcon from '@mui/icons-material/Cancel'; import { useTheme } from '@mui/material/styles'; import { playgroundStyles } from '@/styles/playground'; import { useTranslation } from 'react-i18next'; const MessageInput = ({ userInput, handleInputChange, handleSendMessage, loading, selectedModels, uploadedImage, handleImageUpload, handleRemoveImage, availableModels }) => { const theme = useTheme(); const styles = playgroundStyles(theme); const { t } = useTranslation(); const isDisabled = Object.values(loading).some(value => value) || selectedModels.length === 0; const isSendDisabled = isDisabled || (!userInput.trim() && !uploadedImage); // 检查是否有视觉模型被选中 const hasVisionModel = selectedModels.some(modelId => { const model = availableModels.find(m => m.id === modelId); return model && model.type === 'vision'; }); return ( {uploadedImage && ( } sx={{ width: '100%' }} overlap="rectangular" anchorOrigin={{ vertical: 'top', horizontal: 'right' }} > 上传图片 )} { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSendMessage(); } }} multiline maxRows={4} /> {hasVisionModel && ( )} ); }; export default MessageInput;