Speedup poe generation for jailbroken chats

This commit is contained in:
SillyLossy
2023-04-01 17:41:47 +03:00
parent 885ef0c37c
commit 119309a778

View File

@@ -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,16 +82,22 @@ 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++) { await purgeConversation(count_to_delete);
const reply = await sendMessage(jailbreak_message);
if (reply.toLowerCase().includes(jailbreak_response.toLowerCase())) { if (!jailbroken) {
jailbroken = true; for (let retryNumber = 0; retryNumber < MAX_RETRIES_FOR_ACTIVATION; retryNumber++) {
break; const reply = await sendMessage(jailbreak_message);
if (reply.toLowerCase().includes(jailbreak_response.toLowerCase())) {
jailbroken = true;
break;
}
} }
} }
@@ -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);
context.saveReply(type, reply, false); const reply = await sendMessage(finalPrompt);
got_reply = true;
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());