diff --git a/llamabot.js b/llamabot.js index d148fc5..709d6fe 100644 --- a/llamabot.js +++ b/llamabot.js @@ -4,7 +4,7 @@ import { emptyResponses } from './assets/emptyMessages.js'; import { resetResponses, userResetMessages } from './assets/resetMessages.js'; import { errorMessages, busyResponses } from './assets/errorMessages.js'; import cpuStat from 'cpu-stat'; -import os from 'os'; +import os, { tmpdir } from 'os'; import { Client, @@ -180,10 +180,10 @@ async function generateResponse(conversation, message) { const messagesCopy = [...conversation.messages]; // create a copy of the messages array let botMessage; // define a variable to hold the message object - + let time = 0 // define a function that shows the system load percentage and updates the message const showSystemLoad = async () => { - + time = time + 7 cpuStat.usagePercent(function(err, percent, seconds) { if (err) { return console.log(err); @@ -193,7 +193,7 @@ async function generateResponse(conversation, message) { const freeMemory = os.freemem() / 1024 / 1024 / 1024; const totalMemory = os.totalmem() / 1024 / 1024 / 1024; const usedMemory = totalMemory - freeMemory; - const messageData = `Please wait, I am thinking...\nSystem Load Average: ${systemLoad.toFixed(2)}%\nMemory Usage: ${usedMemory.toFixed(2)} GB / ${totalMemory.toFixed(2)} GB`; + const messageData = `Please wait, I am thinking...\nSystem Load: ${systemLoad.toFixed(2)}%\nMemory Usage: ${usedMemory.toFixed(2)} GB / ${totalMemory.toFixed(2)} GB | Time: ${time} seconds.`; // if the message object doesn't exist, create it if (!botMessage) { @@ -243,6 +243,7 @@ async function generateResponse(conversation, message) { throw err; } finally { clearTimeout(timeout); + time = 0 } }