From 5c66c3441422c6a9dda9b8b881b817282670803d Mon Sep 17 00:00:00 2001 From: Cohee Date: Wed, 26 Jul 2023 21:00:36 +0300 Subject: [PATCH] #778 Slash command to add a persona message without generation --- public/scripts/slash-commands.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index c48601a46..ebd801f0b 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -20,6 +20,7 @@ import { setCharacterId, generateQuietPrompt, reloadCurrentChat, + sendMessageAsUser, } from "../script.js"; import { humanizedDateTime } from "./RossAscends-mods.js"; import { resetSelectedGroup } from "./group-chats.js"; @@ -126,11 +127,23 @@ parser.addCommand('continue', continueChatCallback, ['cont'], ' – continues th parser.addCommand('go', goToCharacterCallback, ['char'], '(name) – opens up a chat with the character by its name', true, true); parser.addCommand('sysgen', generateSystemMessage, [], '(prompt) – generates a system message using a specified prompt', true, true); parser.addCommand('delname', deleteMessagesByNameCallback, ['cancel'], '(name) – deletes all messages attributed to a specified name', true, true); +parser.addCommand('send', sendUserMessageCallback, ['add'], '(text) – adds a user message to the chat log without triggering a generation', true, true); const NARRATOR_NAME_KEY = 'narrator_name'; const NARRATOR_NAME_DEFAULT = 'System'; const COMMENT_NAME_DEFAULT = 'Note'; +async function sendUserMessageCallback(_, text) { + if (!text) { + console.warn('WARN: No text provided for /send command'); + return; + } + + text = text.trim(); + const bias = extractMessageBias(text); + sendMessageAsUser(text, bias); +} + async function deleteMessagesByNameCallback(_, name) { if (!name) { console.warn('WARN: No name provided for /delname command');