Skip to content

Commit

Permalink
Quick fix to main prompt separation and a fallback to default behavio…
Browse files Browse the repository at this point in the history
…r in case we can't manage to separate it out
  • Loading branch information
PandarusAnon committed May 11, 2023
1 parent 22712cc commit a264833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This only needs to be changed if you have anything else running on the same port
The following settings aren't required for setup and can be left on their defaults.

### MAINPROMPT_LAST
If set to true Slaude will try to move the main prompt, which is usually the block of text before the character definitions, to the bottom of the prompt we send to Slack. Can be helpful when as the context grows because this prevents the main prompt from being the first thing that falls out of memory.
If set to true Slaude will try to move the main prompt, which is usually the block of text before the character definitions, to the bottom of the prompt we send to Slack. Can be helpful when as the context grows because this prevents the main prompt from being the first thing that falls out of memory. Both this setting and MAINPROMPT_AS_PING will break if you use double linebreaks anywhere in your main prompt or NSFW prompt as that's the only real way we have to determine where the main prompt stops and the character definition starts. That's a bit flimsier than I'd like but I'll look into other options. Single linebreaks are fine.

### MAINPROMPT_AS_PING
If set to true does the same as above, but uses the contents of the main prompt as the PING_MESSAGE instead (see below). This completely replaces the PING_MESSAGE set in the config. Using the main prompt we get from SillyTavern has the advantage that we have access to all placeholders, like `{{char}}` and `{{user}}`, and can use presets to change the PING_MESSAGE instead of having to edit the config every time. If you put an @Claude anywhere in your main prompt or NSFW prompt it will get replaced with the actual Claude ping, same as PING_MESSAGE. The jailbreak from SillyTavern is not included in this as it gets placed apart from the rest of the main prompt. If you want your jailbreak to be in the ping message too, try putting it in the main prompt or NSFW prompt instead.
Expand Down
20 changes: 14 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,20 @@ function buildSlackPromptMessages(messages) {
let currentPrompt = '';
let mainPrompt = '';
if (config.MAINPROMPT_LAST || config.MAINPROMPT_AS_PING) {
let firstMessage = convertToPrompt(messages.shift());
let index = firstMessage.indexOf('\n');
mainPrompt = firstMessage.slice(0, index);
currentPrompt = firstMessage.slice(index, firstMessage.length);
if (currentPrompt.length > maxMessageLength) {
currentPrompt = splitPrompt(currentPrompt, prompts);
let firstMessage = convertToPrompt(messages[0]);
let index = firstMessage.indexOf('\n\n');

if (index > 0) {
mainPrompt = firstMessage.slice(0, index);
currentPrompt = firstMessage.slice(index, firstMessage.length);
if (currentPrompt.length > maxMessageLength) {
currentPrompt = splitPrompt(currentPrompt, prompts);
}
messages.shift();
} else {
console.warn("Unable to determine cutoff point for main prompt, reverting to default behavior.");
config.MAINPROMPT_LAST = false;
config.MAINPROMPT_AS_PING = false;
}
}

Expand Down

0 comments on commit a264833

Please sign in to comment.