mzta-utils-core renamed to mzta-utils-prompt. see #237

This commit is contained in:
mic 2025-02-09 22:24:57 +01:00
parent 452fd4abf4
commit 310f5ec6e1
2 changed files with 6 additions and 6 deletions

View file

@ -20,7 +20,7 @@
import { getPrompts } from './mzta-prompts.js';
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet, getMailSubject, getTagsList } from './mzta-utils.js'
import { taCoreUtils } from './mzta-utils-core.js';
import { taPromptUtils } from './mzta-utils-prompt.js';
import { taLogger } from './mzta-logger.js';
import { placeholdersUtils } from './mzta-placeholders.js';
import { mzta_specialCommand } from './mzta-special-commands.js';
@ -138,7 +138,7 @@ export class mzta_Menus {
break;
}
fullPrompt = await taCoreUtils.preparePrompt(curr_prompt, curr_message, chatgpt_lang, selection_text, body_text, await getMailSubject(tabs[0]), msg_text, only_typed_text, tags_full_list);
fullPrompt = await taPromptUtils.preparePrompt(curr_prompt, curr_message, chatgpt_lang, selection_text, body_text, await getMailSubject(tabs[0]), msg_text, only_typed_text, tags_full_list);
switch(curr_prompt.id){
case 'prompt_translate_this':
@ -168,7 +168,7 @@ export class mzta_Menus {
console.error("[ThunderAI | AddTags] Invalid connection type: " + prefs_at.connection_type);
return {ok:'0'};
}
fullPrompt = taCoreUtils.finalizePrompt_add_tags(fullPrompt, prefs_at.add_tags_maxnum, prefs_at.add_tags_force_lang, prefs_at.default_chatgpt_lang);
fullPrompt = taPromptUtils.finalizePrompt_add_tags(fullPrompt, prefs_at.add_tags_maxnum, prefs_at.add_tags_force_lang, prefs_at.default_chatgpt_lang);
this.logger.log("fullPrompt: " + fullPrompt);
// TODO: use the current API, abort if using chatgpt web
// COMMENTED TO DO TESTS

View file

@ -18,7 +18,7 @@
import { placeholdersUtils } from './mzta-placeholders.js';
export const taCoreUtils = {
export const taPromptUtils = {
async getDefaultSignature(){
let prefs = await browser.storage.sync.get({default_sign_name: ''});
@ -34,13 +34,13 @@ export const taCoreUtils = {
if(!placeholdersUtils.hasPlaceholder(curr_prompt.text)){
// no placeholders, do as usual
fullPrompt = curr_prompt.text + (String(curr_prompt.need_signature) == "1" ? " " + await taCoreUtils.getDefaultSignature():"") + " " + chatgpt_lang + " \"" + (selection_text=='' ? body_text : selection_text) + "\" ";
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!
let finalSubs = placeholdersUtils.getPlaceholdersValues(curr_prompt.text, curr_message, subject_text, body_text, msg_text, only_typed_text, selection_text, tags_full_list);
// console.log(">>>>>>>>>> finalSubs: " + JSON.stringify(finalSubs));
let prefs_ph = await browser.storage.sync.get({placeholders_use_default_value: false});
fullPrompt = (placeholdersUtils.replacePlaceholders(curr_prompt.text, finalSubs, prefs_ph.placeholders_use_default_value, true) + (String(curr_prompt.need_signature) == "1" ? " " + await taCoreUtils.getDefaultSignature():"") + " " + chatgpt_lang).trim();
fullPrompt = (placeholdersUtils.replacePlaceholders(curr_prompt.text, finalSubs, prefs_ph.placeholders_use_default_value, true) + (String(curr_prompt.need_signature) == "1" ? " " + await taPromptUtils.getDefaultSignature():"") + " " + chatgpt_lang).trim();
}
return fullPrompt;