mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Speedup poe generation for jailbroken chats
This commit is contained in:
@@ -31,6 +31,8 @@ let bot;
|
|||||||
let jailbreak_response = DEFAULT_JAILBREAK_RESPONSE;
|
let jailbreak_response = DEFAULT_JAILBREAK_RESPONSE;
|
||||||
let jailbreak_message = DEFAULT_JAILBREAK_MESSAGE;
|
let jailbreak_message = DEFAULT_JAILBREAK_MESSAGE;
|
||||||
let max_context = DEFAULT_MAX_CONTEXT;
|
let max_context = DEFAULT_MAX_CONTEXT;
|
||||||
|
let jailbroken = false;
|
||||||
|
let got_reply = false;
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
token = localStorage.getItem(TOKEN_KEY);
|
token = localStorage.getItem(TOKEN_KEY);
|
||||||
@@ -80,19 +82,25 @@ async function generate(type, chat2, storyString, mesExamplesArray, promptBias,
|
|||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await purgeConversation();
|
let count_to_delete = -1;
|
||||||
|
|
||||||
let jailbroken = false;
|
if (jailbroken && got_reply) {
|
||||||
|
count_to_delete = 2;
|
||||||
for (let retryNumber = 0; retryNumber < MAX_RETRIES_FOR_ACTIVATION; retryNumber++) {
|
}
|
||||||
const reply = await sendMessage(jailbreak_message);
|
|
||||||
|
await purgeConversation(count_to_delete);
|
||||||
if (reply.toLowerCase().includes(jailbreak_response.toLowerCase())) {
|
|
||||||
jailbroken = true;
|
if (!jailbroken) {
|
||||||
break;
|
for (let retryNumber = 0; retryNumber < MAX_RETRIES_FOR_ACTIVATION; retryNumber++) {
|
||||||
|
const reply = await sendMessage(jailbreak_message);
|
||||||
|
|
||||||
|
if (reply.toLowerCase().includes(jailbreak_response.toLowerCase())) {
|
||||||
|
jailbroken = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jailbroken) {
|
if (!jailbroken) {
|
||||||
console.log('Could not jailbreak the bot');
|
console.log('Could not jailbreak the bot');
|
||||||
}
|
}
|
||||||
@@ -117,9 +125,10 @@ async function generate(type, chat2, storyString, mesExamplesArray, promptBias,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const finalPrompt = [prompt, messageSendString, activator].join('\n');
|
const finalPrompt = [prompt, messageSendString, activator].join('\n');
|
||||||
|
|
||||||
const reply = await sendMessage(finalPrompt);
|
const reply = await sendMessage(finalPrompt);
|
||||||
|
got_reply = true;
|
||||||
context.saveReply(type, reply, false);
|
context.saveReply(type, reply, true);
|
||||||
context.saveChat();
|
context.saveChat();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -132,10 +141,11 @@ async function generate(type, chat2, storyString, mesExamplesArray, promptBias,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function purgeConversation() {
|
async function purgeConversation(count = -1) {
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
bot,
|
bot,
|
||||||
token,
|
token,
|
||||||
|
count,
|
||||||
});
|
});
|
||||||
|
|
||||||
const apiUrl = new URL(getApiUrl());
|
const apiUrl = new URL(getApiUrl());
|
||||||
|
Reference in New Issue
Block a user