From 053d7f9eaa8ecab6717895dc1f5bc68ab32e591d Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 27 Apr 2024 20:25:55 +0300 Subject: [PATCH] Remove the /inject when value is empty --- public/scripts/slash-commands.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index f02c086c6..3182dc424 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -146,7 +146,7 @@ class SlashCommandParser { return { commandName: command, command: { - callback: () => {}, + callback: () => { }, helpString: '', interruptsGeneration: false, purgeFromMessage: true, @@ -338,13 +338,12 @@ function injectCallback(args, value) { chat_metadata.script_injects = {}; } - chat_metadata.script_injects[id] = { - value, - position, - depth, - scan, - role, - }; + if (value) { + const inject = { value, position, depth, scan, role }; + chat_metadata.script_injects[id] = inject; + } else { + delete chat_metadata.script_injects[id]; + } setExtensionPrompt(prefixedId, value, position, depth, scan, role); saveMetadataDebounced();