This commit is contained in:
Raven Scott 2023-05-19 22:55:25 +02:00
parent 8ce9e18656
commit 1fe0f20e6f

View File

@ -290,75 +290,79 @@ async function generateResponse(conversation, message) {
if (process.env.GPU == 1) {
smi(function (err, data) {
if (err) {
// Handle error if smi function fails
console.error(err);
return;
}
let utilization = data.nvidia_smi_log.gpu.utilization;
let gpuUtilization = utilization.gpu_util;
let memoryUtilization = utilization.memory_util;
let gpuTemp = data.nvidia_smi_log.gpu.temperature.gpu_temp;
// These are not used until nvidia-docker fixes their support
let gpuTarget = data.nvidia_smi_log.gpu.temperature.gpu_target_temperature;
let gpuFanSpeed = data.nvidia_smi_log.gpu.fan_speed;
let filedsData = [
{
name: 'System Load',
value: `${systemLoad.toFixed(2)}%`,
},
{
name: 'Memory Usage',
value: `${usedMemory.toFixed(2)} GB / ${totalMemory.toFixed(2)} GB`,
},
{
name: 'GPU Utilization',
value: `${gpuUtilization}`,
},
{
name: 'Memory Utilization',
value: `${memoryUtilization}`,
},
{
name: 'GPU Temperature',
value: `${gpuTemp}`,
},
{
name: 'Time',
value: `~${time} seconds.`,
},
];
const embedData = {
color: 0x0099ff,
title: 'Please wait.. I am thinking...',
fields: filedsData,
};
// if the message object doesn't exist, create it
if (!botMessage) {
botMessage = message.channel.send({ embeds: [embedData] });
} else {
botMessage.edit({ embeds: [embedData] }); // otherwise, update the message
}
});
} else {
const embedData = {
if (err) {
// Handle error if smi function fails
console.error(err);
return;
}
let utilization = data.nvidia_smi_log.gpu.utilization;
let gpuUtilization = utilization.gpu_util;
let memoryUtilization = utilization.memory_util;
let gpuTemp = data.nvidia_smi_log.gpu.temperature.gpu_temp;
// These are not used until nvidia-docker fixes their support
let gpuTarget = data.nvidia_smi_log.gpu.temperature.gpu_target_temperature;
let gpuFanSpeed = data.nvidia_smi_log.gpu.fan_speed;
let filedsData = [
{
name: 'System Load',
value: `${systemLoad.toFixed(2)}%`,
},
{
name: 'Memory Usage',
value: `${usedMemory.toFixed(2)} GB / ${totalMemory.toFixed(2)} GB`,
},
{
name: 'GPU Utilization',
value: `${gpuUtilization}`,
},
{
name: 'Memory Utilization',
value: `${memoryUtilization}`,
},
{
name: 'GPU Temperature',
value: `${gpuTemp}`,
},
{
name: 'Time',
value: `~${time} seconds.`,
},
];
const embedData = {
color: 0x0099ff,
title: 'Please wait.. I am thinking...',
fields: filedsData, // It seems like a typo, it should be `filedsData` instead of `filedsData`
fields: filedsData,
};
// if the message object doesn't exist, create it
if (!botMessage) {
(async () => {
botMessage = await message.channel.send({ embeds: [embedData] });
})();
} else {
botMessage.edit({ embeds: [embedData] }); // otherwise, update the message
}
});
} else {
const embedData = {
color: 0x0099ff,
title: 'Please wait.. I am thinking...',
fields: filedsData, // It seems like a typo, it should be `filedsData` instead of `filedsData`
};
// if the message object doesn't exist, create it
if (!botMessage) {
botMessage = message.channel.send({ embeds: [embedData] });
(async () => {
botMessage = await message.channel.send({ embeds: [embedData] });
})();
} else {
botMessage.edit({ embeds: [embedData] }); // otherwise, update the message
botMessage.edit({ embeds: [embedData] }); // otherwise, update the message
}
}
}
});
};