move email separators to extra prompt field
This commit is contained in:
parent
3d2c2b9320
commit
66cc35746f
6 changed files with 85 additions and 8 deletions
|
|
@ -1012,11 +1012,15 @@
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"prompt_summarize_full_text": {
|
"prompt_summarize_full_text": {
|
||||||
"message": "Summarize the following email or emails into a bullet point list. If there are multiple emails, consider the entire thread for the summary.\n------------------\n\n",
|
"message": "Summarize the following email or emails into a bullet point list. If there are multiple emails, consider the entire thread for the summary.",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"prompt_summarize_email_template": {
|
"prompt_summarize_email_template": {
|
||||||
"message": "From: {%author%}\nTo: {%recipients%}\nCC: {%cc_list%}\nSubject: {%mail_subject%}\nDate: {%mail_datetime%}\nAttachments:\n{%mail_attachments_info%}\nBody:\n{%mail_text_body%}\n---------------\n\n",
|
"message": "From: {%author%}\nTo: {%recipients%}\nCC: {%cc_list%}\nSubject: {%mail_subject%}\nDate: {%mail_datetime%}\nAttachments:\n{%mail_attachments_info%}\nBody:\n{%mail_text_body%}",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"prompt_summarize_email_separator": {
|
||||||
|
"message": "\n\n---------- NEXT EMAIL ----------\n\n",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"prompt_get_task": {
|
"prompt_get_task": {
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,22 @@ const specialPrompts = [
|
||||||
api_model: '',
|
api_model: '',
|
||||||
is_default: "1",
|
is_default: "1",
|
||||||
is_special: "1",
|
is_special: "1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'prompt_summarize_email_separator',
|
||||||
|
name: "__MSG_prompt_summarize_email_separator__",
|
||||||
|
text: "prompt_summarize_email_separator_full_text",
|
||||||
|
type: "1",
|
||||||
|
action: "0",
|
||||||
|
need_selected: "0",
|
||||||
|
need_signature: "0",
|
||||||
|
need_custom_text: "0",
|
||||||
|
define_response_lang: "0",
|
||||||
|
use_diff_viewer: "0",
|
||||||
|
api_type: '',
|
||||||
|
api_model: '',
|
||||||
|
is_default: "1",
|
||||||
|
is_special: "1",
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -619,4 +635,4 @@ export async function clearPromptAPI(id){
|
||||||
}
|
}
|
||||||
// console.log(">>>>>>>>>>>>> clearPromptAPI _prompt AFTER: " + JSON.stringify(_prompt));
|
// console.log(">>>>>>>>>>>>> clearPromptAPI _prompt AFTER: " + JSON.stringify(_prompt));
|
||||||
await savePrompt(_prompt);
|
await savePrompt(_prompt);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1028,11 +1028,12 @@ browser.menus.onClicked.addListener( (info, tab) => {
|
||||||
async function summarizeEmails(messages) {
|
async function summarizeEmails(messages) {
|
||||||
taWorkingStatus.startWorking();
|
taWorkingStatus.startWorking();
|
||||||
|
|
||||||
// we have two prompts, the actual assignment for the LLM and the email
|
// we have three prompts, the actual assignment for the LLM, the email
|
||||||
// template prompt.
|
// template prompt, and the email separator prompt
|
||||||
const specialPrompts = await getSpecialPrompts();
|
const specialPrompts = await getSpecialPrompts();
|
||||||
const prompt = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize');
|
const prompt = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize');
|
||||||
const prompt_email = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize_email_template');
|
const prompt_email = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize_email_template');
|
||||||
|
const prompt_email_separator = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize_email_separator');
|
||||||
|
|
||||||
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
|
||||||
const chatgpt_lang = await taPromptUtils.getDefaultLang(prompt);
|
const chatgpt_lang = await taPromptUtils.getDefaultLang(prompt);
|
||||||
|
|
@ -1059,11 +1060,11 @@ async function summarizeEmails(messages) {
|
||||||
msg_text: curr_body_full_html,
|
msg_text: curr_body_full_html,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
let messages_string = messages_list.join("\n\n--- Next Email ---\n\n");
|
const messages_string = messages_list.join(prompt_email_separator_string);
|
||||||
|
|
||||||
let full_prompt = prompt.text + "\n\n\n" + messages_string;
|
const full_prompt = prompt_string + prompt_email_separator_string + messages_string;
|
||||||
|
|
||||||
console.log(full_prompt);
|
// console.log(full_prompt);
|
||||||
|
|
||||||
// send the prompt to the chat interface
|
// send the prompt to the chat interface
|
||||||
openChatGPT(
|
openChatGPT(
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#summarize_email_separator_text {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.infoline {
|
.infoline {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,22 @@
|
||||||
__MSG_save__
|
__MSG_save__
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- separator -->
|
||||||
|
<div class="autocomplete-container">
|
||||||
|
<textarea id="summarize_email_separator_text" rows="7"></textarea>
|
||||||
|
<ul class="autocomplete-list hidden"></ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="summarize_info_additional_statements"></div>
|
||||||
|
<div class="btn_div">
|
||||||
|
<button id="btn_reset_email_separator" disabled>
|
||||||
|
__MSG_reset_default__
|
||||||
|
</button>
|
||||||
|
<button id="btn_save_email_separator" disabled>
|
||||||
|
__MSG_save__
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script src="mzta-summarize.js" type="module"></script>
|
<script src="mzta-summarize.js" type="module"></script>
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||||
let specialPrompts = await getSpecialPrompts();
|
let specialPrompts = await getSpecialPrompts();
|
||||||
let summarize_prompt = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize');
|
let summarize_prompt = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize');
|
||||||
let summarize_email_template = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize_email_template');
|
let summarize_email_template = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize_email_template');
|
||||||
|
let summarize_email_separator = specialPrompts.find((prompt) => prompt.id === 'prompt_summarize_email_separator');
|
||||||
|
|
||||||
if (summarize_prompt && summarize_prompt.api_type && summarize_prompt.api_type !== '') {
|
if (summarize_prompt && summarize_prompt.api_type && summarize_prompt.api_type !== '') {
|
||||||
let update_prefs = {};
|
let update_prefs = {};
|
||||||
|
|
@ -80,8 +81,12 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||||
let summarize_textarea_email_template = document.getElementById("summarize_email_template_text");
|
let summarize_textarea_email_template = document.getElementById("summarize_email_template_text");
|
||||||
let summarize_reset_email_template_btn = document.getElementById("btn_reset_email_template");
|
let summarize_reset_email_template_btn = document.getElementById("btn_reset_email_template");
|
||||||
let summarize_save_email_template_btn = document.getElementById("btn_save_email_template");
|
let summarize_save_email_template_btn = document.getElementById("btn_save_email_template");
|
||||||
|
let summarize_email_separator_textarea = document.getElementById("summarize_email_separator_text");
|
||||||
|
let summarize_email_separator_save_btn = document.getElementById("btn_save_email_separator");
|
||||||
|
let summarize_email_separator_reset_btn = document.getElementById("btn_reset_email_separator");
|
||||||
|
|
||||||
|
|
||||||
|
// on changing textareas
|
||||||
summarize_textarea.addEventListener("input", (event) => {
|
summarize_textarea.addEventListener("input", (event) => {
|
||||||
summarize_reset_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_summarize_full_text'));
|
summarize_reset_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_summarize_full_text'));
|
||||||
summarize_save_btn.disabled = (event.target.value === summarize_prompt.text);
|
summarize_save_btn.disabled = (event.target.value === summarize_prompt.text);
|
||||||
|
|
@ -91,7 +96,14 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||||
summarize_reset_email_template_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_summarize_email_template'));
|
summarize_reset_email_template_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_summarize_email_template'));
|
||||||
summarize_save_email_template_btn.disabled = (event.target.value === summarize_email_template.text);
|
summarize_save_email_template_btn.disabled = (event.target.value === summarize_email_template.text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
summarize_email_separator_textarea.addEventListener("input", (event) => {
|
||||||
|
summarize_email_separator_reset_btn.disabled = (event.target.value === browser.i18n.getMessage('prompt_summarize_email_separator'));
|
||||||
|
summarize_email_separator_save_btn.disabled = (event.target.value === summarize_email_separator.text);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// on clicking buttons, reset
|
||||||
summarize_reset_email_template_btn.addEventListener("click", () => {
|
summarize_reset_email_template_btn.addEventListener("click", () => {
|
||||||
summarize_textarea_email_template.value = browser.i18n.getMessage("prompt_summarize_email_template");
|
summarize_textarea_email_template.value = browser.i18n.getMessage("prompt_summarize_email_template");
|
||||||
summarize_reset_email_template_btn.disabled = true;
|
summarize_reset_email_template_btn.disabled = true;
|
||||||
|
|
@ -105,7 +117,15 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||||
let event = new Event("input", { bubbles: true, cancelable: true });
|
let event = new Event("input", { bubbles: true, cancelable: true });
|
||||||
summarize_textarea.dispatchEvent(event);
|
summarize_textarea.dispatchEvent(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
summarize_email_separator_reset_btn.addEventListener("click", () => {
|
||||||
|
summarize_email_separator_textarea.value = browser.i18n.getMessage("prompt_summarize_email_separator");
|
||||||
|
summarize_email_separator_reset_btn.disabled = true;
|
||||||
|
let event = new Event("input", { bubbles: true, cancelable: true });
|
||||||
|
summarize_email_separator_textarea.dispatchEvent(event);
|
||||||
|
});
|
||||||
|
|
||||||
|
// on clicking buttons, save
|
||||||
summarize_save_email_template_btn.addEventListener("click", () => {
|
summarize_save_email_template_btn.addEventListener("click", () => {
|
||||||
specialPrompts.find(prompt => prompt.id === 'prompt_summarize_email_template').text = summarize_textarea_email_template.value;
|
specialPrompts.find(prompt => prompt.id === 'prompt_summarize_email_template').text = summarize_textarea_email_template.value;
|
||||||
setSpecialPrompts(specialPrompts);
|
setSpecialPrompts(specialPrompts);
|
||||||
|
|
@ -119,6 +139,14 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||||
summarize_save_btn.disabled = true;
|
summarize_save_btn.disabled = true;
|
||||||
browser.runtime.sendMessage({ command: "reload_menus" });
|
browser.runtime.sendMessage({ command: "reload_menus" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
summarize_email_separator_save_btn.addEventListener("click", () => {
|
||||||
|
specialPrompts.find(prompt => prompt.id === 'prompt_summarize_email_separator').text = summarize_email_separator_textarea.value;
|
||||||
|
setSpecialPrompts(specialPrompts);
|
||||||
|
summarize_email_separator_save_btn.disabled = true;
|
||||||
|
browser.runtime.sendMessage({ command: "reload_menus" });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if(summarize_prompt.text === 'prompt_summarize_full_text'){
|
if(summarize_prompt.text === 'prompt_summarize_full_text'){
|
||||||
summarize_prompt.text = browser.i18n.getMessage(summarize_prompt.text);
|
summarize_prompt.text = browser.i18n.getMessage(summarize_prompt.text);
|
||||||
|
|
@ -126,16 +154,24 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||||
if(summarize_email_template === 'prompt_summarize_email_template'){
|
if(summarize_email_template === 'prompt_summarize_email_template'){
|
||||||
summarize_email_template.text = browser.i18n.getMessage(summarize_email_template.text);
|
summarize_email_template.text = browser.i18n.getMessage(summarize_email_template.text);
|
||||||
}
|
}
|
||||||
|
if(summarize_email_separator.text === 'prompt_summarize_email_separator'){
|
||||||
|
summarize_email_separator.text = browser.i18n.getMessage(summarize_email_separator.text);
|
||||||
|
}
|
||||||
|
|
||||||
summarize_textarea_email_template.value = summarize_email_template.text;
|
summarize_textarea_email_template.value = summarize_email_template.text;
|
||||||
summarize_reset_email_template_btn.disabled = (summarize_email_template.value === browser.i18n.getMessage("prompt_summarize_email_template"));
|
summarize_reset_email_template_btn.disabled = (summarize_email_template.value === browser.i18n.getMessage("prompt_summarize_email_template"));
|
||||||
summarize_textarea.value = summarize_prompt.text;
|
summarize_textarea.value = summarize_prompt.text;
|
||||||
summarize_reset_btn.disabled = (summarize_textarea.value === browser.i18n.getMessage("prompt_summarize_full_text"));
|
summarize_reset_btn.disabled = (summarize_textarea.value === browser.i18n.getMessage("prompt_summarize_full_text"));
|
||||||
|
summarize_email_separator_textarea.value = summarize_email_separator.text;
|
||||||
|
summarize_email_separator_reset_btn.disabled = (summarize_email_separator.value === browser.i18n.getMessage("prompt_summarize_email_separator"));
|
||||||
|
|
||||||
autocompleteSuggestions = (await getPlaceholders(true))
|
autocompleteSuggestions = (await getPlaceholders(true))
|
||||||
.filter((p) => p.id !== "additional_text")
|
.filter((p) => p.id !== "additional_text")
|
||||||
.map(mapPlaceholderToSuggestion);
|
.map(mapPlaceholderToSuggestion);
|
||||||
|
|
||||||
textareaAutocomplete(summarize_textarea, autocompleteSuggestions, 1);
|
textareaAutocomplete(summarize_textarea, autocompleteSuggestions, 1);
|
||||||
textareaAutocomplete(summarize_textarea_email_template, autocompleteSuggestions, 1);
|
textareaAutocomplete(summarize_textarea_email_template, autocompleteSuggestions, 1);
|
||||||
|
textareaAutocomplete(summarize_email_separator_textarea, autocompleteSuggestions, 1);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue