Add support for custom placeholders in prompt preparation. see #156

This commit is contained in:
mic 2025-06-16 21:13:48 +02:00
parent 1738a12481
commit f91e0e793f
2 changed files with 4 additions and 5 deletions

View file

@ -391,11 +391,6 @@ export const placeholdersUtils = {
},
async getPlaceholdersValues(prompt_text, curr_message, mail_subject, body_text, msg_text, only_typed_text, only_quoted_text, selection_text, selection_html, tags_full_list) {
// check if we have custom placeholders
if(placeholdersUtils.hasCustomPlaceholder(prompt_text)){
prompt_text = await placeholdersUtils.replaceCustomPlaceholders(prompt_text);
}
let currPHs = await placeholdersUtils.extractPlaceholders(prompt_text);
// console.log(">>>>>>>>>> currPHs: " + JSON.stringify(currPHs));
let finalSubs = {};

View file

@ -38,6 +38,10 @@ export const taPromptUtils = {
fullPrompt = curr_prompt.text + (String(curr_prompt.need_signature) == "1" ? " " + await taPromptUtils.getDefaultSignature():"") + " " + chatgpt_lang + " \"" + (selection_text=='' ? body_text : selection_text) + "\" ";
}else{
// we have at least a placeholder, do the magic!
// check if we have custom placeholders
if(placeholdersUtils.hasCustomPlaceholder(curr_prompt.text)){
curr_prompt.text = await placeholdersUtils.replaceCustomPlaceholders(curr_prompt.text);
}
let finalSubs = await placeholdersUtils.getPlaceholdersValues(curr_prompt.text, curr_message, subject_text, body_text, msg_text, only_typed_text, only_quoted_text, selection_text, selection_html, tags_full_list);
// console.log(">>>>>>>>>> finalSubs: " + JSON.stringify(finalSubs));
let prefs_ph = await browser.storage.sync.get({placeholders_use_default_value: false});