From 7ad2473f99120409a384cd069bc681d274db4d0f Mon Sep 17 00:00:00 2001
From: Cohee <18619528+Cohee1207@users.noreply.github.com>
Date: Tue, 12 Mar 2024 23:22:29 +0200
Subject: [PATCH] Add char.card Jailbreak support for Text Completion APIs
---
public/index.html | 4 ++++
public/script.js | 7 +++++++
public/scripts/power-user.js | 2 ++
3 files changed, 13 insertions(+)
diff --git a/public/index.html b/public/index.html
index a06b539f3..86c192ac0 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2665,6 +2665,10 @@
Use as Stop Strings
+
diff --git a/public/script.js b/public/script.js
index d8a242c73..da7f07910 100644
--- a/public/script.js
+++ b/public/script.js
@@ -3182,6 +3182,13 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
//////////////////////////////////
+ // Insert character jailbreak as a last user message (if exists, allowed, preferred, and not using Chat Completion)
+ if (power_user.context.allow_jailbreak && power_user.prefer_character_jailbreak && main_api !== 'openai' && jailbreak) {
+ // Set "original" explicity to empty string since there's no original
+ jailbreak = substituteParams(jailbreak, name1, name2, '');
+ coreChat.push({ mes: jailbreak, is_user: true });
+ }
+
let chat2 = [];
let continue_mag = '';
for (let i = coreChat.length - 1, j = 0; i >= 0; i--, j++) {
diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js
index 863f59d19..db872788a 100644
--- a/public/scripts/power-user.js
+++ b/public/scripts/power-user.js
@@ -217,6 +217,7 @@ let power_user = {
chat_start: defaultChatStart,
example_separator: defaultExampleSeparator,
use_stop_strings: true,
+ allow_jailbreak: false,
},
personas: {},
@@ -294,6 +295,7 @@ const contextControls = [
{ id: 'context_example_separator', property: 'example_separator', isCheckbox: false, isGlobalSetting: false },
{ id: 'context_chat_start', property: 'chat_start', isCheckbox: false, isGlobalSetting: false },
{ id: 'context_use_stop_strings', property: 'use_stop_strings', isCheckbox: true, isGlobalSetting: false, defaultValue: false },
+ { id: 'context_allow_jailbreak', property: 'allow_jailbreak', isCheckbox: true, isGlobalSetting: false, defaultValue: false },
// Existing power user settings
{ id: 'always-force-name2-checkbox', property: 'always_force_name2', isCheckbox: true, isGlobalSetting: true, defaultValue: true },