Files
hubian f249f28eb7 新增后台管理系统
功能模块:
- 仪表盘: 模型/GPU/CPU统计、开源/闭源分布、快速操作
- 模型管理: 查看模型列表、筛选搜索、添加新模型
- GPU管理: 查看GPU列表、厂商筛选、添加新GPU
- CPU管理: 查看CPU列表
- 数据导出: 导出模型/GPU数据为JSON

技术:
- Flask + Tailwind CSS
- 解析TypeScript数据文件
- 端口: 19006
2026-04-08 14:13:06 +08:00

247 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>模型管理 - 参数百科后台</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
</head>
<body class="bg-gray-50 min-h-screen">
<div class="flex">
<aside class="w-64 bg-slate-800 min-h-screen fixed left-0 top-0">
<div class="p-6">
<h1 class="text-white text-xl font-bold flex items-center gap-2">
<i class="ri-database-2-line text-2xl text-blue-400"></i>
参数百科后台
</h1>
</div>
<nav class="mt-6">
<a href="/" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-dashboard-line"></i><span>仪表盘</span>
</a>
<a href="/models" class="flex items-center gap-3 px-6 py-3 bg-slate-700 text-white">
<i class="ri-cpu-line"></i><span>模型管理</span>
</a>
<a href="/gpus" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-dashboard-3-line"></i><span>GPU管理</span>
</a>
<a href="/cpus" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
<i class="ri-cpu-line"></i><span>CPU管理</span>
</a>
</nav>
</aside>
<main class="ml-64 flex-1 p-8">
<div class="flex items-center justify-between mb-6">
<h1 class="text-2xl font-bold text-gray-800">模型管理</h1>
<button onclick="showAddModal()" class="px-4 py-2 gradient-bg text-white rounded-lg flex items-center gap-2">
<i class="ri-add-line"></i> 添加模型
</button>
</div>
<!-- 筛选 -->
<div class="bg-white rounded-lg p-4 mb-6 border border-gray-100">
<div class="flex gap-4 items-center">
<input type="text" id="searchInput" placeholder="搜索模型名称..."
class="flex-1 px-4 py-2 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500"
onkeyup="filterModels()">
<select id="filterSource" onchange="filterModels()" class="px-4 py-2 border border-gray-200 rounded-lg">
<option value="all">全部</option>
<option value="open">开源</option>
<option value="closed">闭源</option>
</select>
</div>
</div>
<!-- 模型列表 -->
<div class="bg-white rounded-xl border border-gray-100 overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-100">
<tr>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">模型名称</th>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">组织</th>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">参数量</th>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">上下文</th>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">类型</th>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">MMLU</th>
<th class="px-6 py-3 text-left text-sm font-medium text-gray-500">操作</th>
</tr>
</thead>
<tbody id="modelTable">
<tr><td colspan="7" class="px-6 py-8 text-center text-gray-500">加载中...</td></tr>
</tbody>
</table>
</div>
</main>
</div>
<!-- 添加模型弹窗 -->
<div id="addModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
<div class="bg-white rounded-xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col">
<div class="p-4 border-b flex justify-between items-center">
<h3 class="font-bold text-lg">添加新模型</h3>
<button onclick="closeAddModal()" class="text-gray-400"><i class="ri-close-line text-2xl"></i></button>
</div>
<div class="p-4 overflow-auto flex-1">
<form id="addForm" class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm text-gray-600 mb-1">模型名称 *</label>
<input type="text" name="name" required class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">组织</label>
<input type="text" name="organization" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">参数量 (B)</label>
<input type="number" name="parametersCount" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">上下文长度</label>
<input type="number" name="contextLength" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">架构</label>
<input type="text" name="architecture" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">开源</label>
<select name="isOpenSource" class="w-full px-3 py-2 border rounded-lg">
<option value="false"></option>
<option value="true"></option>
</select>
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">许可证</label>
<input type="text" name="license" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">MMLU分数</label>
<input type="number" step="0.1" name="benchmarkMmlu" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">HumanEval分数</label>
<input type="number" step="0.1" name="benchmarkHumaneval" class="w-full px-3 py-2 border rounded-lg">
</div>
<div>
<label class="block text-sm text-gray-600 mb-1">FP16显存(GB)</label>
<input type="number" name="minVramFp16" class="w-full px-3 py-2 border rounded-lg">
</div>
</form>
</div>
<div class="p-4 border-t flex justify-end gap-3">
<button onclick="closeAddModal()" class="px-4 py-2 border rounded-lg">取消</button>
<button onclick="submitModel()" class="px-4 py-2 gradient-bg text-white rounded-lg">添加</button>
</div>
</div>
</div>
<script>
let allModels = [];
async function loadModels() {
const res = await fetch('/api/models');
allModels = await res.json();
renderModels(allModels);
}
function renderModels(models) {
const tbody = document.getElementById('modelTable');
if (models.length === 0) {
tbody.innerHTML = '<tr><td colspan="7" class="px-6 py-8 text-center text-gray-500">暂无模型数据</td></tr>';
return;
}
tbody.innerHTML = models.map(m => `
<tr class="border-b border-gray-50 hover:bg-gray-50">
<td class="px-6 py-4 font-medium text-gray-800">${m.name}</td>
<td class="px-6 py-4 text-gray-600">${m.organization || '-'}</td>
<td class="px-6 py-4">${m.parametersCount ? m.parametersCount + 'B' : '-'}</td>
<td class="px-6 py-4">${m.contextLength ? (m.contextLength >= 1000 ? m.contextLength/1000 + 'K' : m.contextLength) : '-'}</td>
<td class="px-6 py-4">
${m.isOpenSource
? '<span class="px-2 py-1 bg-green-100 text-green-600 rounded text-xs">开源</span>'
: '<span class="px-2 py-1 bg-gray-100 text-gray-600 rounded text-xs">闭源</span>'}
</td>
<td class="px-6 py-4 text-blue-600">${m.benchmarkMmlu || '-'}</td>
<td class="px-6 py-4">
<button class="text-blue-500 hover:text-blue-700 mr-2"><i class="ri-edit-line"></i></button>
<button class="text-red-500 hover:text-red-700"><i class="ri-delete-bin-line"></i></button>
</td>
</tr>
`).join('');
}
function filterModels() {
const search = document.getElementById('searchInput').value.toLowerCase();
const source = document.getElementById('filterSource').value;
let filtered = allModels;
if (search) {
filtered = filtered.filter(m =>
m.name.toLowerCase().includes(search) ||
(m.organization && m.organization.toLowerCase().includes(search))
);
}
if (source === 'open') {
filtered = filtered.filter(m => m.isOpenSource);
} else if (source === 'closed') {
filtered = filtered.filter(m => !m.isOpenSource);
}
renderModels(filtered);
}
function showAddModal() {
document.getElementById('addModal').classList.remove('hidden');
document.getElementById('addModal').classList.add('flex');
}
function closeAddModal() {
document.getElementById('addModal').classList.add('hidden');
document.getElementById('addModal').classList.remove('flex');
}
async function submitModel() {
const form = document.getElementById('addForm');
const formData = new FormData(form);
const data = {};
formData.forEach((value, key) => {
if (value) {
if (key === 'isOpenSource') {
data[key] = value === 'true';
} else if (!isNaN(value) && value !== '') {
data[key] = parseFloat(value);
} else {
data[key] = value;
}
}
});
try {
const res = await fetch('/api/models', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
const result = await res.json();
if (result.success) {
closeAddModal();
loadModels();
alert('模型添加成功!');
}
} catch (err) {
alert('添加失败,请重试');
}
}
loadModels();
</script>
</body>
</html>