From 8a7e985b5935d897bd850e1df73732332d201889 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 3 Apr 2023 02:50:13 +0200 Subject: [PATCH] clean up code to make it easier to read --- commands/system/new-chat.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/commands/system/new-chat.js b/commands/system/new-chat.js index 9a56554..90a16aa 100644 --- a/commands/system/new-chat.js +++ b/commands/system/new-chat.js @@ -51,12 +51,11 @@ module.exports = { } ], - - run: async (client, interaction) => { const file = './cache/' + interaction.user.id let options = interaction.options._hoistedOptions; + let varsToCheck = [ { name: "model", value: null }, { name: "temperature", value: null }, @@ -74,6 +73,7 @@ module.exports = { } } } + // Now you can access the values of each variable you are interested in: let userInputModel = varsToCheck.find(v => v.name === "model")?.value; let userInputTemperature = varsToCheck.find(v => v.name === "temperature")?.value; @@ -127,9 +127,8 @@ module.exports = { } } - - var req = unirest('POST', apiUrl + '?model=' + model + '&temperature=' + temperature + '&top_k=' + topK + '&top_p=' + topP + '&max_length=' + maxLength + '&context_window=' + contextWindow + '&repeat_last_n=' + repeatLastN + '&repeat_penalty=' + repeatPenalty + '&init_prompt=' + initPrompt + '&n_threads=' + nThreads) - .headers({ + const req = unirest('POST',`${apiUrl}?model=${model}&temperature=${temperature}&top_k=${topK}&top_p=${topP}&max_length=${maxLength}&context_window=${contextWindow}&repeat_last_n=${repeatLastN}&repeat_penalty=${repeatPenalty}&init_prompt=${initPrompt}&n_threads=${nThreads}`) + .headers({ 'accept': 'application/json' }) .send('')