the add tags response is now expcted as a JSON. see #365
This commit is contained in:
parent
071ee6acf2
commit
1f93f4d295
3 changed files with 10 additions and 10 deletions
|
|
@ -445,7 +445,7 @@ switch (message.command) {
|
|||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
async function createDialog(inputString, onSubmit) {
|
||||
async function createDialog(inputTags, onSubmit) {
|
||||
// Create the dialog
|
||||
const tags_dialog = document.createElement('dialog');
|
||||
tags_dialog.className = 'mzta_dialog';
|
||||
|
|
@ -461,8 +461,8 @@ switch (message.command) {
|
|||
|
||||
let no_submit = false;
|
||||
|
||||
// Parse the input string into labels
|
||||
const words = inputString.split(',').map(word => word.trim()).filter(word => word !== '');
|
||||
// Fix the input array
|
||||
const words = inputTags.map(word => word.trim()).filter(word => word !== '');
|
||||
|
||||
// console.log(">>>>>>>>>>>>> words: " + JSON.stringify(words));
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ export class mzta_Menus {
|
|||
if(curr_prompt.is_special == '1'){ // Special prompts
|
||||
switch(curr_prompt.id){
|
||||
case 'prompt_add_tags': { // Add tags to the email
|
||||
let tags_current_email = '';
|
||||
let tags_current_email = [];
|
||||
let prefs_at = await browser.storage.sync.get({add_tags_maxnum: 3, connection_type: '', add_tags_force_lang: true, default_chatgpt_lang: '', do_debug: false});
|
||||
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
||||
console.error("[ThunderAI | AddTags] Invalid connection type: " + prefs_at.connection_type);
|
||||
|
|
@ -183,7 +183,7 @@ export class mzta_Menus {
|
|||
let cmd_addTags = new mzta_specialCommand(fullPrompt,prefs_at.connection_type,prefs_at.do_debug);
|
||||
await cmd_addTags.initWorker();
|
||||
try{
|
||||
tags_current_email = (await cmd_addTags.sendPrompt()).trim();
|
||||
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt());
|
||||
// console.log(">>>>>>>>>>> tags_current_email: " + tags_current_email);
|
||||
}catch(err){
|
||||
console.error("[ThunderAI] Error getting tags: ", err);
|
||||
|
|
@ -191,7 +191,7 @@ export class mzta_Menus {
|
|||
taWorkingStatus.stopWorking();
|
||||
return {ok:'0'};
|
||||
}
|
||||
this.logger.log("tags_current_email: " + tags_current_email);
|
||||
this.logger.log("tags_current_email: " + JSON.stringify(tags_current_email));
|
||||
this.logger.log("tags_full_list: " + JSON.stringify(tags_full_list));
|
||||
browser.tabs.sendMessage(tabs[0].id, {command: "getTags", tags: tags_current_email, messageId: curr_message.id});
|
||||
taWorkingStatus.stopWorking();
|
||||
|
|
|
|||
|
|
@ -995,14 +995,14 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
|
|||
taLog.log("Special prompt: " + specialFullPrompt_add_tags);
|
||||
let cmd_addTags = new mzta_specialCommand(specialFullPrompt_add_tags, prefs_aats.connection_type, prefs_init.do_debug);
|
||||
await cmd_addTags.initWorker();
|
||||
let tags_current_email = '';
|
||||
let tags_current_email = [];
|
||||
try {
|
||||
tags_current_email = (await cmd_addTags.sendPrompt()).trim();
|
||||
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt());
|
||||
} catch (err) {
|
||||
console.error("[ThunderAI | Auto add_tags] Error getting tags: ", err);
|
||||
}
|
||||
taLog.log("tags_current_email: " + tags_current_email);
|
||||
let _data = { messageId: message.id, tags: tags_current_email.split(/,\s*/) };
|
||||
taLog.log("tags_current_email: " + JSON.stringify(tags_current_email));
|
||||
let _data = { messageId: message.id, tags: tags_current_email };
|
||||
_assign_tags(_data, !prefs_aats.add_tags_auto_force_existing, prefs_aats.add_tags_exclusions_exact_match);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue