From cfa22309860441f02dbd8b20e578fdb5fad5a8f3 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sat, 8 Apr 2023 02:43:12 +0200 Subject: [PATCH 1/2] adding Docker Scripts and some fixes from fork: https://git.ssh.surf/MrTuxedo/rai-serge-discord-bot --- Dockerfile | 10 ++++++++++ commands/system/chat.js | 3 +++ commands/system/new-chat.js | 2 +- docker.compose.yml | 32 ++++++++++++++++++++++++++++++++ handler/index.js | 4 ++++ 5 files changed, 50 insertions(+), 1 deletion(-) 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/chat.js b/commands/system/chat.js index 128eb35..89360fe 100644 --- a/commands/system/chat.js +++ b/commands/system/chat.js @@ -53,6 +53,9 @@ module.exports = { console.log(`Prompt: ${prompt.replace("+", " ")}\nResponse: ${response.data.answer}`); + if (!response.data.answer) throw new Error("Did not receive a reply. API error?") + + interaction.editReply(response.data.answer); } catch (err) { console.error(err); diff --git a/commands/system/new-chat.js b/commands/system/new-chat.js index 26e9bb0..934f336 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 }, diff --git a/docker.compose.yml b/docker.compose.yml new file mode 100644 index 0000000..7ecb66b --- /dev/null +++ b/docker.compose.yml @@ -0,0 +1,32 @@ +version: '3' +services: + serge-discord-bot: + container_name: serge-discord-bot + build: + context: . + environment: + - NODE_ENV=production + ## Env Vars for rAi chatbot + - TOKEN # Pass the value from .env + - 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 + + \ No newline at end of file diff --git a/handler/index.js b/handler/index.js index 3cff50e..a48a5cf 100644 --- a/handler/index.js +++ b/handler/index.js @@ -30,6 +30,10 @@ 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); }); From 6435e059ad8a7d639da0aabc550bf94e3baef1e5 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sat, 8 Apr 2023 03:10:02 +0200 Subject: [PATCH 2/2] random update --- commands/system/new-chat.js | 3 +-- handler/index.js | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/commands/system/new-chat.js b/commands/system/new-chat.js index 934f336..12fc2af 100644 --- a/commands/system/new-chat.js +++ b/commands/system/new-chat.js @@ -51,8 +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].`; - + let 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 diff --git a/handler/index.js b/handler/index.js index a48a5cf..781d9eb 100644 --- a/handler/index.js +++ b/handler/index.js @@ -30,9 +30,8 @@ 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([]); - + // 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);