'use client'; import React from 'react'; import { Box, Typography, Paper, Alert } from '@mui/material'; import { useParams } from 'next/navigation'; import { useTheme } from '@mui/material/styles'; import ChatArea from '@/components/playground/ChatArea'; import MessageInput from '@/components/playground/MessageInput'; import PlaygroundHeader from '@/components/playground/PlaygroundHeader'; import useModelPlayground from '@/hooks/useModelPlayground'; import { playgroundStyles } from '@/styles/playground'; import { useTranslation } from 'react-i18next'; import { useAtomValue } from 'jotai/index'; import { modelConfigListAtom } from '@/lib/store'; export default function ModelPlayground({ searchParams }) { const theme = useTheme(); const params = useParams(); const { projectId } = params; const modelId = searchParams?.modelId || null; const styles = playgroundStyles(theme); const { t } = useTranslation(); const { selectedModels, loading, userInput, conversations, error, outputMode, uploadedImage, handleModelSelection, handleInputChange, handleImageUpload, handleRemoveImage, handleSendMessage, handleClearConversations, handleOutputModeChange } = useModelPlayground(projectId, modelId); const availableModels = useAtomValue(modelConfigListAtom); // 获取模型名称 const getModelName = modelId => { const model = availableModels.find(m => m.id === modelId); return model ? `${model.providerName}: ${model.modelName}` : modelId; }; return ( {t('playground.title')} {error && ( {error} )} ); }