filtering tags in autotagging. see #289

This commit is contained in:
Mic 2025-09-01 23:40:00 +02:00
parent f3050d5277
commit b8cb3adfc6
2 changed files with 8 additions and 2 deletions

View file

@ -126,7 +126,7 @@ export const taPromptUtils = {
* For backwords compatibility, if the response text is not a valid JSON,
* it will try to split the text by commas and return the resulting array.
*/
getTagsFromResponse(response_text){
getTagsFromResponse(response_text, filter_tags = false, filter_tags_list = ''){
let tags = [];
if(response_text && response_text.length > 0){
try {
@ -143,6 +143,10 @@ export const taPromptUtils = {
tags = response_text.split(/,\s*/).map(tag => tag.trim());
}
}
if(filter_tags && filter_tags_list && filter_tags_list.length > 0){
const allowedTags = filter_tags_list.split(',').map(tag => tag.trim().toLowerCase()).filter(tag => tag.length > 0);
tags = tags.filter(tag => allowedTags.includes(tag.toLowerCase()));
}
return tags;
}
};

View file

@ -973,6 +973,8 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
add_tags_auto_force_existing: prefs_default.add_tags_auto_force_existing,
add_tags_enabled_accounts: prefs_default.add_tags_enabled_accounts,
add_tags_exclusions_exact_match: prefs_default.add_tags_exclusions_exact_match,
add_tags_auto_uselist: prefs_default.add_tags_auto_uselist,
add_tags_auto_uselist_list: prefs_default.add_tags_auto_uselist_list,
spamfilter_enabled_accounts: prefs_default.spamfilter_enabled_accounts,
});
@ -1020,7 +1022,7 @@ async function processEmails(messages, addTagsAuto, spamFilter) {
await cmd_addTags.initWorker();
let tags_current_email = [];
try {
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt());
tags_current_email = taPromptUtils.getTagsFromResponse(await cmd_addTags.sendPrompt(), prefs_aats.add_tags_auto_uselist, prefs_aats.add_tags_auto_uselist_list);
} catch (err) {
console.error("[ThunderAI | Auto add_tags] Error getting tags: ", err);
}