From 1f948cd00147a4fd1d141bef122490f71c507955 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 3 Apr 2023 00:33:59 +0200 Subject: [PATCH] Allowing users to select what model they are running --- commands/system/new-chat.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/commands/system/new-chat.js b/commands/system/new-chat.js index 814ee6f..65e19a2 100644 --- a/commands/system/new-chat.js +++ b/commands/system/new-chat.js @@ -14,25 +14,42 @@ var repeatPenalty = 1.3; var initPrompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request. The response must be accurate, concise and evidence-based whenever possible. A complete answer is always ended by [end of text].'; var nThreads = 7; +let modelList = ["7B", "7B-native", "gpt4all"] module.exports = { name: "create-session", description: "create a new session chat", private: true, options: [{ + "name": "model", + "description": "The model you want to run, choose either: gpt4all, 7B, 7B-Native - Char case matters", + "required": false, + "type": 3 // 6 is type USER + }, + { "name": "init-prompt", "description": "A prompt you want to init the chat with, a default is used if not provided.", "required": false, "type": 3 // 6 is type USER -}], + }], run: async (client, interaction) => { const file = './cache/' + interaction.user.id - if (!interaction.options._hoistedOptions[0]){ - console.log("-- No init-prompt provided, using default --") - } else [ - initPrompt = interaction.options._hoistedOptions[0].value - ] + if (!interaction.options._hoistedOptions[1]) { + console.log("-- No init-prompt provided, using default --") + } else { + initPrompt = interaction.options._hoistedOptions[1].value + } + if (!interaction.options._hoistedOptions[0]) { + console.log("-- No model provided, using default --") + } else { + if (modelList.includes(interaction.options._hoistedOptions[0].value)) { + model = interaction.options._hoistedOptions[0].value + } else { + let modelListStr = modelList.join(", "); + return interaction.followUp(`You may only use one of the following: ${modelListStr}`); + } + } 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({