// async function updateSystemLoad() {
// try {
// const response = await fetch("http://192.168.85.80:5000/full_status");
// if (!response.ok) {
// throw new Error(`HTTP error! Status: ${response.status}`);
// }
// const data = await response.json();
// console.log("API response:", data);
// // 计算所有 GPU 总使用率
// let totalGpuUsage = 0;
// let gpuDetails = {};
// data.gpu.forEach((gpu, index) => {
// totalGpuUsage += gpu.utilization_gpu;
// gpuDetails[`GPU${index + 1}`] = {
// name: gpu.name,
// utilization: gpu.utilization_gpu,
// temperature: gpu.temperature,
// memory_total: gpu.memory_total,
// memory_used: gpu.memory_used,
// memory_free: gpu.memory_free
// };
// });
// systemLoad = {
// cpuUsage: data.cpu.usage_percent, // CPU 使用率
// memoryUsage: data.memory.percent, // 内存使用率
// storageSpace: data.disk.percent, // 磁盘占用率
// cpuCores: data.cpu.cores, // CPU 核心数
// cpuThreads: data.cpu.threads, // CPU 线程数
// memoryTotal: data.memory.total, // 总内存
// memoryFree: data.memory.free, // 空闲内存
// diskTotal: data.disk.total, // 总磁盘空间
// diskFree: data.disk.free, // 剩余磁盘空间
// networkBytesSent: data.network.bytes_sent, // 网络发送字节
// networkBytesRecv: data.network.bytes_recv, // 网络接收字节
// totalGpuUsage: totalGpuUsage / data.gpu.length, // 计算所有 GPU 平均使用率
// gpus: gpuDetails // 详细的 GPU 信息
// };
// console.log("Updated System Load:", systemLoad);
// } catch (error) {
// console.error("Failed to fetch system status:", error);
// return null;
// }
// }
// // 每 5 秒更新一次系统状态
// setInterval(updateSystemLoad, 5000);
// updateSystemLoad(); // 页面加载时立即执行一次
// const systemLoad = {
// cpuUsage: 70,
// gpuUsage: 60,
// memoryUsage: 50,
// storageSpace: 500,
// };
//目前是写死的,后续要根据实际情况获取 done
// 需要对接曙光的接口 未完成
// 构建 Prompt 数据
// const prompt = `
// 用户需求:${message}
// 当前系统负载:CPU使用率=${systemLoad.cpuUsage}%,GPU使用率=${systemLoad.gpus}%,内存使用率=${systemLoad.memoryUsage}%,存储空间=${systemLoad.storageSpace}GB
// 首先在回复我对话的最开始列举出当前的系统负载情况,然后根据这些信息评估资源需求并给出建议使用的:CPU、GPU、内存、存储空间,所有回复默认使用中文
// `;
// 用户输入拼接到prompt-v1