mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add jailbreak as a system message option
This commit is contained in:
@ -664,6 +664,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="range-block">
|
||||||
|
<label title="Inserts jailbreak as a last system message" class="checkbox_label">
|
||||||
|
<input id="jailbreak_system" type="checkbox" />
|
||||||
|
Jailbreak as system message
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Currently broken -->
|
<!-- Currently broken -->
|
||||||
<div style="display: none" class="range-block">
|
<div style="display: none" class="range-block">
|
||||||
<label title="Enables OpenAI completion streaming" class="checkbox_label" for="stream_toggle">
|
<label title="Enables OpenAI completion streaming" class="checkbox_label" for="stream_toggle">
|
||||||
@ -702,10 +709,10 @@
|
|||||||
|
|
||||||
<div class="range-block">
|
<div class="range-block">
|
||||||
<div class="range-block-title">
|
<div class="range-block-title">
|
||||||
NSFW prompt
|
NSFW/Jailbreak prompt
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-counter">
|
<div class="range-block-counter">
|
||||||
Prompt that is used when the NSFW toggle is on
|
Prompt that is used when the NSFW/Jailbreak toggle is on
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-range">
|
<div class="range-block-range">
|
||||||
<textarea id="nsfw_prompt_textarea" class="custom_textarea" name="nsfw_prompt" rows="6" placeholder=""></textarea>
|
<textarea id="nsfw_prompt_textarea" class="custom_textarea" name="nsfw_prompt" rows="6" placeholder=""></textarea>
|
||||||
|
@ -66,6 +66,7 @@ const oai_settings = {
|
|||||||
main_prompt: default_main_prompt,
|
main_prompt: default_main_prompt,
|
||||||
nsfw_prompt: default_nsfw_prompt,
|
nsfw_prompt: default_nsfw_prompt,
|
||||||
openai_model: 'gpt-3.5-turbo-0301',
|
openai_model: 'gpt-3.5-turbo-0301',
|
||||||
|
jailbreak_system: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let openai_setting_names;
|
let openai_setting_names;
|
||||||
@ -220,6 +221,11 @@ async function prepareOpenAIMessages(name2, storyString, worldInfoBefore, worldI
|
|||||||
} else {
|
} else {
|
||||||
nsfw_toggle_prompt = "Avoid writing a NSFW/Smut reply. Creatively write around it NSFW/Smut scenarios in character.";
|
nsfw_toggle_prompt = "Avoid writing a NSFW/Smut reply. Creatively write around it NSFW/Smut scenarios in character.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oai_settings.jailbreak_system) {
|
||||||
|
nsfw_toggle_prompt = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Experimental but kinda works
|
// Experimental but kinda works
|
||||||
if (oai_settings.enhance_definitions) {
|
if (oai_settings.enhance_definitions) {
|
||||||
enhance_definitions_prompt = "If you have more knowledge of " + name2 + ", add to the character's lore and personality to enhance them but keep the Character Sheet's definitions absolute.";
|
enhance_definitions_prompt = "If you have more knowledge of " + name2 + ", add to the character's lore and personality to enhance them but keep the Character Sheet's definitions absolute.";
|
||||||
@ -270,6 +276,13 @@ async function prepareOpenAIMessages(name2, storyString, worldInfoBefore, worldI
|
|||||||
total_count += start_chat_count;
|
total_count += start_chat_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oai_settings.jailbreak_system) {
|
||||||
|
const jailbreakMessage = { "role": "system", "content": `[System note: ${oai_settings.nsfw_prompt}]`};
|
||||||
|
openai_msgs.push(jailbreakMessage);
|
||||||
|
|
||||||
|
total_count += await countTokens([jailbreakMessage], true);
|
||||||
|
}
|
||||||
|
|
||||||
// The user wants to always have all example messages in the context
|
// The user wants to always have all example messages in the context
|
||||||
if (pin_examples) {
|
if (pin_examples) {
|
||||||
// first we send *all* example messages
|
// first we send *all* example messages
|
||||||
@ -495,6 +508,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
|
if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
|
||||||
if (settings.nsfw_first !== undefined) oai_settings.nsfw_first = !!settings.nsfw_first;
|
if (settings.nsfw_first !== undefined) oai_settings.nsfw_first = !!settings.nsfw_first;
|
||||||
if (settings.openai_model !== undefined) oai_settings.openai_model = settings.openai_model;
|
if (settings.openai_model !== undefined) oai_settings.openai_model = settings.openai_model;
|
||||||
|
if (settings.jailbreak_system !== undefined) oai_settings.jailbreak_system = !!settings.jailbreak_system;
|
||||||
|
|
||||||
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
||||||
|
|
||||||
@ -509,6 +523,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
$('#enhance_definitions').prop('checked', oai_settings.enhance_definitions);
|
$('#enhance_definitions').prop('checked', oai_settings.enhance_definitions);
|
||||||
$('#wrap_in_quotes').prop('checked', oai_settings.wrap_in_quotes);
|
$('#wrap_in_quotes').prop('checked', oai_settings.wrap_in_quotes);
|
||||||
$('#nsfw_first').prop('checked', oai_settings.nsfw_first);
|
$('#nsfw_first').prop('checked', oai_settings.nsfw_first);
|
||||||
|
$('#jailbreak_system').prop('checked', oai_settings.jailbreak_system);
|
||||||
|
|
||||||
if (settings.main_prompt !== undefined) oai_settings.main_prompt = settings.main_prompt;
|
if (settings.main_prompt !== undefined) oai_settings.main_prompt = settings.main_prompt;
|
||||||
if (settings.nsfw_prompt !== undefined) oai_settings.nsfw_prompt = settings.nsfw_prompt;
|
if (settings.nsfw_prompt !== undefined) oai_settings.nsfw_prompt = settings.nsfw_prompt;
|
||||||
@ -671,4 +686,9 @@ $(document).ready(function () {
|
|||||||
oai_settings.nsfw_prompt = $('#nsfw_prompt_textarea').val();
|
oai_settings.nsfw_prompt = $('#nsfw_prompt_textarea').val();
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#jailbreak_system").change(function () {
|
||||||
|
oai_settings.jailbreak_system = !!$(this).prop("checked");
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
});
|
});
|
Reference in New Issue
Block a user