added methods to get and set specialprompts. see #183
This commit is contained in:
parent
073655f1e2
commit
a4bdebabbd
1 changed files with 19 additions and 3 deletions
|
|
@ -166,6 +166,9 @@ const defaultPrompts = [
|
||||||
is_default: "1",
|
is_default: "1",
|
||||||
is_special: "0",
|
is_special: "0",
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const specialPrompts = [
|
||||||
{
|
{
|
||||||
id: 'prompt_add_tags',
|
id: 'prompt_add_tags',
|
||||||
name: "__MSG_prompt_add_tags__",
|
name: "__MSG_prompt_add_tags__",
|
||||||
|
|
@ -178,7 +181,7 @@ const defaultPrompts = [
|
||||||
define_response_lang: "0",
|
define_response_lang: "0",
|
||||||
is_default: "1",
|
is_default: "1",
|
||||||
is_special: "1",
|
is_special: "1",
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -187,7 +190,8 @@ export async function getPrompts(onlyEnabled = false, includeSpecial = false){
|
||||||
// console.log('>>>>>>>>>>>> getPrompts _defaultPrompts: ' + JSON.stringify(_defaultPrompts));
|
// console.log('>>>>>>>>>>>> getPrompts _defaultPrompts: ' + JSON.stringify(_defaultPrompts));
|
||||||
const customPrompts = await getCustomPrompts();
|
const customPrompts = await getCustomPrompts();
|
||||||
// console.log('>>>>>>>>>>>> getPrompts customPrompts: ' + JSON.stringify(customPrompts));
|
// console.log('>>>>>>>>>>>> getPrompts customPrompts: ' + JSON.stringify(customPrompts));
|
||||||
let output = _defaultPrompts.concat(customPrompts);
|
const specialPrompts = await getSpecialPrompts();
|
||||||
|
let output = _defaultPrompts.concat(customPrompts).concat(specialPrompts);
|
||||||
if(!includeSpecial){
|
if(!includeSpecial){
|
||||||
output = output.filter(obj => obj.is_special != 1); // we do not want special prompts
|
output = output.filter(obj => obj.is_special != 1); // we do not want special prompts
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +298,19 @@ export async function setDefaultPromptsProperties(prompts) {
|
||||||
await browser.storage.local.set({_default_prompts_properties: default_prompts_properties});
|
await browser.storage.local.set({_default_prompts_properties: default_prompts_properties});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function setCustomPrompts(prompts) {
|
export async function setCustomPrompts(prompts) {
|
||||||
await browser.storage.local.set({_custom_prompt: prompts});
|
await browser.storage.local.set({_custom_prompt: prompts});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getSpecialPrompts(){
|
||||||
|
let prefs = await browser.storage.local.get({_special_prompts: null});
|
||||||
|
if(prefs._special_prompts === null){
|
||||||
|
return specialPrompts;
|
||||||
|
} else {
|
||||||
|
return prefs._special_prompts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setSpecialPrompts(prompts) {
|
||||||
|
await browser.storage.local.set({_special_prompts: prompts});
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue