From 8ce9e18656937db7a08593b8c05855b6c950ac71 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Fri, 19 May 2023 22:43:47 +0200 Subject: [PATCH] removing non needed code --- llamabot.js | 128 +++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 66 deletions(-) diff --git a/llamabot.js b/llamabot.js index f664933..a3dbbe7 100644 --- a/llamabot.js +++ b/llamabot.js @@ -290,79 +290,75 @@ 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 = { + 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 = { color: 0x0099ff, title: 'Please wait.. I am thinking...', - 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` + 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) { - (async () => { - botMessage = await message.channel.send({ embeds: [embedData] }); - })(); + botMessage = message.channel.send({ embeds: [embedData] }); } else { - botMessage.edit({ embeds: [embedData] }); // otherwise, update the message + botMessage.edit({ embeds: [embedData] }); // otherwise, update the message } - } + } }); };