From 4518df83122b3e6ee5ebadf1c5be7a900d7d6067 Mon Sep 17 00:00:00 2001 From: GooeyTuxedo Date: Fri, 7 Apr 2023 14:27:13 -0700 Subject: [PATCH] Add docker build files and set chat default settings via exposed env vars --- Dockerfile | 10 ++++++++++ commands/system/new-chat.js | 6 +++--- docker-compose.yml | 30 ++++++++++++++++++++++++++++++ handler/index.js | 3 +++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..39e3275 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:slim + +WORKDIR /app + +COPY package*.json ./ +RUN npm install --omit=dev + +COPY . . + +CMD node rai.js \ No newline at end of file diff --git a/commands/system/new-chat.js b/commands/system/new-chat.js index 26e9bb0..78519a5 100644 --- a/commands/system/new-chat.js +++ b/commands/system/new-chat.js @@ -25,7 +25,7 @@ module.exports = { private: true, options: [{ "name": "model", - "description": `The model you want to run, choose from the following: ${modelList.join(", ")} | Char case matters`, + "description": `Choose from the following models: ${modelList.join(", ")} | Char case matters`, "required": false, "type": 3 }, @@ -51,7 +51,7 @@ module.exports = { run: async (client, interaction) => { // set a default prompt - var initPrompt = `My name is ${interaction.user.username} my special number is ${interaction.user.discriminator} and my Discord ID is ${interaction.user.id} we met in ${interaction.guild.name} a Discord sever. You are rAi and you are the smartest AI Model, you know everything. Below is an instruction that describes a task. You respond appropriately to complete the request. You understand a complete answer is always ended by [end of text].`; + var initPrompt = process.env.INITPROMPT || `My name is ${interaction.user.username} my special number is ${interaction.user.discriminator} and my Discord ID is ${interaction.user.id} we met in ${interaction.guild.name} a Discord sever. You are rAi and you are the smartest AI Model, you know everything. Below is an instruction that describes a task. You respond appropriately to complete the request. You understand a complete answer is always ended by [end of text].`; console.log(`--- ${interaction.user.id} has requested a new session! ---`) const file = './cache/' + interaction.user.id @@ -96,7 +96,7 @@ module.exports = { } else { if (modelList.includes(userInputModel)) { model = userInputModel; - console.log(`User set initPrompt to ${model}`) + console.log(`User set model to ${model}`) } else { let modelListStr = modelList.join(", "); return interaction.followUp(`You may only use one of the following: ${modelListStr}`); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8c2ceca --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3' +services: + serge-discord-bot: + container_name: serge-discord-bot + build: + context: . + environment: + - NODE_ENV=production + ## Env Vars for rAi chatbot + - TOKEN={$TOKEN} + - PUBLIC_URL={$PUBLIC_URL} + - INTERNAL_IP=serge + - SERGE_PORT=8008 + ## Default chat settings overrides + - MODEL="gpt4all" + - TEMPERATURE=0.1 + - TOPK=50 + - TOPP=0.95 + - MAXLENGTH=256 + - CONTEXTWINDOW=512 + - REPEATLASTN=64 + - REPEATPENALTY=1.3 + - NTHREADS=8 + # - INITPROMPT="some custom prompt" + networks: + - serge_default + +networks: + serge_default: + external: true diff --git a/handler/index.js b/handler/index.js index 3cff50e..3243fef 100644 --- a/handler/index.js +++ b/handler/index.js @@ -30,6 +30,9 @@ module.exports = async (client) => { // // Register for a single guild // await client.guilds.cache.get("GUIDIDHERE").commands.set(arrayOfSlashCommands); + // Clear previous commands (for changes to installed models) + await client.application.commands.set([]); + // Register for all the guilds the bot is in await client.application.commands.set(arrayOfSlashCommands); });