mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-07 07:06:05 +01:00
Simplify new character handling
This commit is contained in:
parent
a627f684d2
commit
0e3e57269c
@ -313,11 +313,13 @@ PromptManagerModule.prototype.isPromptDeletionAllowed = function (prompt) {
|
|||||||
|
|
||||||
PromptManagerModule.prototype.handleCharacterSelected = function (event) {
|
PromptManagerModule.prototype.handleCharacterSelected = function (event) {
|
||||||
this.activeCharacter = {id: event.detail.id, ...event.detail.character};
|
this.activeCharacter = {id: event.detail.id, ...event.detail.character};
|
||||||
|
|
||||||
const promptList = this.getPromptListByCharacter(this.activeCharacter);
|
const promptList = this.getPromptListByCharacter(this.activeCharacter);
|
||||||
if (0 === promptList.length) {
|
|
||||||
this.setPromptListForCharacter(this.activeCharacter, this.getDefaultPromptList())
|
// ToDo: These should be passed as parameter or attached to the manager as a set of default options.
|
||||||
}
|
// Set default prompts and order for character.
|
||||||
|
if (0 === promptList.length) this.setPromptListForCharacter(this.activeCharacter, openAiDefaultPromptList)
|
||||||
|
// Check whether the referenced prompts are present.
|
||||||
|
if (0 === this.serviceSettings.prompts.length) this.setPrompts(openAiDefaultPrompts);
|
||||||
}
|
}
|
||||||
|
|
||||||
PromptManagerModule.prototype.getPromptsForCharacter = function (character, onlyEnabled = false) {
|
PromptManagerModule.prototype.getPromptsForCharacter = function (character, onlyEnabled = false) {
|
||||||
@ -328,7 +330,11 @@ PromptManagerModule.prototype.getPromptsForCharacter = function (character, only
|
|||||||
|
|
||||||
// Get the prompt order for a given character, otherwise an empty array is returned.
|
// Get the prompt order for a given character, otherwise an empty array is returned.
|
||||||
PromptManagerModule.prototype.getPromptListByCharacter = function (character) {
|
PromptManagerModule.prototype.getPromptListByCharacter = function (character) {
|
||||||
return character === null ? [] : (this.serviceSettings.prompt_lists.find(list => String(list.character_id) === String(character.id))?.list ?? []);
|
return !character ? [] : (this.serviceSettings.prompt_lists.find(list => String(list.character_id) === String(character.id))?.list ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
PromptManagerModule.prototype.setPrompts = function(prompts) {
|
||||||
|
this.serviceSettings.prompts = prompts;
|
||||||
}
|
}
|
||||||
|
|
||||||
PromptManagerModule.prototype.setPromptListForCharacter = function (character, promptList) {
|
PromptManagerModule.prototype.setPromptListForCharacter = function (character, promptList) {
|
||||||
@ -748,59 +754,56 @@ const openAiDefaultPrompts = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openAiDefaultPromptLists = {
|
const openAiDefaultPromptLists = {
|
||||||
"prompt_lists": [
|
"prompt_lists": []
|
||||||
{
|
|
||||||
"character_id": "default",
|
|
||||||
"list": [
|
|
||||||
{
|
|
||||||
"identifier": "worldInfoBefore",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "characterInfo",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "nsfw",
|
|
||||||
"enabled": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "main",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "enhanceDefinitions",
|
|
||||||
"enabled": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "worldInfoAfter",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "newExampleChat",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "dialogueExamples",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "newMainChat",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "chatHistory",
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"identifier": "jailbreak",
|
|
||||||
"enabled": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openAiDefaultPromptList = [
|
||||||
|
{
|
||||||
|
"identifier": "worldInfoBefore",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "characterInfo",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "nsfw",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "main",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "enhanceDefinitions",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "worldInfoAfter",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "newExampleChat",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "dialogueExamples",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "newMainChat",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "chatHistory",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "jailbreak",
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const defaultPromptManagerSettings = {
|
const defaultPromptManagerSettings = {
|
||||||
"prompt_manager_settings": {
|
"prompt_manager_settings": {
|
||||||
"showAdvancedSettings": false
|
"showAdvancedSettings": false
|
||||||
|
Loading…
Reference in New Issue
Block a user