Move main and jailbreak override from manager into openai script.
Makes the code clearer and easier to understand
This commit is contained in:
parent
075c0c29f0
commit
9d6cf017d2
|
@ -472,23 +472,6 @@ PromptManagerModule.prototype.init = function (moduleConfiguration, serviceSetti
|
||||||
this.saveServiceSettings().then(() => this.render());
|
this.saveServiceSettings().then(() => this.render());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply character specific overrides for prompts
|
|
||||||
eventSource.on(event_types.OAI_BEFORE_CHATCOMPLETION, (prompts) => {
|
|
||||||
const systemPromptOverride = this.activeCharacter.data?.system_prompt ?? null;
|
|
||||||
const systemPrompt = prompts.get('main') ?? null;
|
|
||||||
if (systemPromptOverride) {
|
|
||||||
systemPrompt.content = systemPromptOverride;
|
|
||||||
prompts.set(systemPrompt, prompts.index('main'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const jailbreakPromptOverride = this.activeCharacter.data?.post_history_instructions ?? null;
|
|
||||||
const jailbreakPrompt = prompts.get('jailbreak') ?? null;
|
|
||||||
if (jailbreakPromptOverride && jailbreakPrompt) {
|
|
||||||
jailbreakPrompt.content = jailbreakPromptOverride;
|
|
||||||
prompts.set(jailbreakPrompt, prompts.index('jailbreak'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Trigger re-render when token settings are changed
|
// Trigger re-render when token settings are changed
|
||||||
document.getElementById('openai_max_context').addEventListener('change', (event) => {
|
document.getElementById('openai_max_context').addEventListener('change', (event) => {
|
||||||
this.serviceSettings.openai_max_context = event.target.value;
|
this.serviceSettings.openai_max_context = event.target.value;
|
||||||
|
|
|
@ -682,6 +682,22 @@ function preparePromptsForChatCompletion(Scenario, charPersonality, name2, world
|
||||||
else prompts.add(newPrompt);
|
else prompts.add(newPrompt);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Apply character-specific main prompt
|
||||||
|
const systemPromptOverride = promptManager.activeCharacter.data?.system_prompt ?? null;
|
||||||
|
const systemPrompt = prompts.get('main') ?? null;
|
||||||
|
if (systemPromptOverride) {
|
||||||
|
systemPrompt.content = systemPromptOverride;
|
||||||
|
prompts.set(systemPrompt, prompts.index('main'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply character-specific jailbreak
|
||||||
|
const jailbreakPromptOverride = promptManager.activeCharacter.data?.post_history_instructions ?? null;
|
||||||
|
const jailbreakPrompt = prompts.get('jailbreak') ?? null;
|
||||||
|
if (jailbreakPromptOverride && jailbreakPrompt) {
|
||||||
|
jailbreakPrompt.content = jailbreakPromptOverride;
|
||||||
|
prompts.set(jailbreakPrompt, prompts.index('jailbreak'));
|
||||||
|
}
|
||||||
|
|
||||||
// Replace {{original}} placeholder for supported prompts
|
// Replace {{original}} placeholder for supported prompts
|
||||||
const originalReplacements = {
|
const originalReplacements = {
|
||||||
main: default_main_prompt,
|
main: default_main_prompt,
|
||||||
|
|
Loading…
Reference in New Issue