Allowing users to select what model they are running

This commit is contained in:
Raven Scott 2023-04-03 00:33:59 +02:00
parent 5bbbcb7c08
commit 1f948cd001

View File

@ -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]){
if (!interaction.options._hoistedOptions[1]) {
console.log("-- No init-prompt provided, using default --")
} else [
initPrompt = interaction.options._hoistedOptions[0].value
]
} 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({