mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Add per-character override of JB prompts.
This commit is contained in:
		| @@ -1900,6 +1900,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, | ||||
|         let Scenario = baseChatReplace(scenarioText.trim(), name1, name2); | ||||
|         let mesExamples = baseChatReplace(characters[this_chid].mes_example.trim(), name1, name2); | ||||
|         let systemPrompt = baseChatReplace(characters[this_chid].data?.system_prompt?.trim(), name1, name2); | ||||
|         let jailbreakPrompt = baseChatReplace(characters[this_chid].data?.post_history_instructions?.trim(), name1, name2); | ||||
|  | ||||
|         // Parse example messages | ||||
|         if (!mesExamples.startsWith('<START>')) { | ||||
| @@ -2280,7 +2281,18 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, | ||||
|                 generate_data = getNovelGenerationData(finalPromt, this_settings, this_amount_gen); | ||||
|             } | ||||
|             else if (main_api == 'openai') { | ||||
|                 let [prompt, counts] = await prepareOpenAIMessages(systemPrompt, name2, storyString, worldInfoBefore, worldInfoAfter, afterScenarioAnchor, promptBias, type, quiet_prompt); | ||||
|                 let [prompt, counts] = await prepareOpenAIMessages({ | ||||
|                     systemPrompt: systemPrompt, | ||||
|                     name2: name2, | ||||
|                     storyString: storyString, | ||||
|                     worldInfoBefore: worldInfoBefore, | ||||
|                     worldInfoAfter: worldInfoAfter, | ||||
|                     extensionPrompt: afterScenarioAnchor, | ||||
|                     bias: promptBias, | ||||
|                     type: type, | ||||
|                     quietPrompt: quiet_prompt, | ||||
|                     jailbreakPrompt: jailbreakPrompt, | ||||
|                 }); | ||||
|                 generate_data = { prompt: prompt }; | ||||
|  | ||||
|                 // counts will return false if the user has not enabled the token breakdown feature | ||||
|   | ||||
| @@ -310,7 +310,7 @@ function formatWorldInfo(value) { | ||||
|     return stringFormat(oai_settings.wi_format, value); | ||||
| } | ||||
|  | ||||
| async function prepareOpenAIMessages(systemPrompt, name2, storyString, worldInfoBefore, worldInfoAfter, extensionPrompt, bias, type, quietPrompt) { | ||||
| async function prepareOpenAIMessages({ systemPrompt, name2, storyString, worldInfoBefore, worldInfoAfter, extensionPrompt, bias, type, quietPrompt, jailbreakPrompt } = {}) { | ||||
|     const isImpersonate = type == "impersonate"; | ||||
|     let this_max_context = oai_settings.openai_max_context; | ||||
|     let enhance_definitions_prompt = ""; | ||||
| @@ -374,8 +374,9 @@ async function prepareOpenAIMessages(systemPrompt, name2, storyString, worldInfo | ||||
|         total_count += start_chat_count; | ||||
|     } | ||||
|  | ||||
|     if (oai_settings.jailbreak_system && oai_settings.jailbreak_prompt) { | ||||
|         const jailbreakMessage = { "role": "system", "content": substituteParams(oai_settings.jailbreak_prompt) }; | ||||
|     const jailbreak = power_user.prefer_character_jailbreak && jailbreakPrompt ? jailbreakPrompt : oai_settings.jailbreak_prompt; | ||||
|     if (oai_settings.jailbreak_system && jailbreak) { | ||||
|         const jailbreakMessage = { "role": "system", "content": substituteParams(jailbreak) }; | ||||
|         openai_msgs.push(jailbreakMessage); | ||||
|  | ||||
|         total_count += handler_instance.count([jailbreakMessage], true, 'jailbreak'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user