clean up code to make it easier to read

This commit is contained in:
Raven Scott 2023-04-03 02:50:13 +02:00
parent 9797096b84
commit 8a7e985b59

View File

@ -51,12 +51,11 @@ module.exports = {
} }
], ],
run: async (client, interaction) => { run: async (client, interaction) => {
const file = './cache/' + interaction.user.id const file = './cache/' + interaction.user.id
let options = interaction.options._hoistedOptions; let options = interaction.options._hoistedOptions;
let varsToCheck = [ let varsToCheck = [
{ name: "model", value: null }, { name: "model", value: null },
{ name: "temperature", 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: // Now you can access the values of each variable you are interested in:
let userInputModel = varsToCheck.find(v => v.name === "model")?.value; let userInputModel = varsToCheck.find(v => v.name === "model")?.value;
let userInputTemperature = varsToCheck.find(v => v.name === "temperature")?.value; let userInputTemperature = varsToCheck.find(v => v.name === "temperature")?.value;
@ -127,8 +127,7 @@ module.exports = {
} }
} }
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}`)
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({ .headers({
'accept': 'application/json' 'accept': 'application/json'
}) })