155 lines
5.3 KiB
JavaScript
155 lines
5.3 KiB
JavaScript
/*
|
|
* ThunderAI [https://micz.it/thunderbird-addon-thunderai/]
|
|
* Copyright (C) 2024 - 2026 Mic (m@micz.it)
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
export const special_prompts_with_integration = ['add_tags', 'spamfilter', 'summarize', 'get_calendar_event', 'get_task', 'translate'];
|
|
|
|
export const integration_options_config = {
|
|
chatgpt: {
|
|
api_key: '',
|
|
model: '',
|
|
developer_messages: '',
|
|
temperature: '',
|
|
store: false
|
|
},
|
|
ollama: {
|
|
host: '',
|
|
model: '',
|
|
num_ctx: 0,
|
|
temperature: '',
|
|
think: false,
|
|
format_json: false
|
|
},
|
|
openai_comp: {
|
|
host: '',
|
|
model: '',
|
|
api_key: '',
|
|
use_v1: true,
|
|
chat_name: 'OpenAI Comp',
|
|
temperature: ''
|
|
},
|
|
google_gemini: {
|
|
api_key: '',
|
|
model: '',
|
|
system_instruction: '',
|
|
thinking_budget: '',
|
|
temperature: ''
|
|
},
|
|
anthropic: {
|
|
api_key: '',
|
|
model: '',
|
|
version: '2023-06-01',
|
|
max_tokens: 4096,
|
|
system_prompt: '',
|
|
temperature: ''
|
|
}
|
|
};
|
|
|
|
const integration_settings_template = {
|
|
use_specific_integration: false,
|
|
connection_type: 'chatgpt_api',
|
|
};
|
|
|
|
const global_integration_settings = { ...integration_settings_template };
|
|
|
|
for (const [integration, options] of Object.entries(integration_options_config)) {
|
|
for (const [key, value] of Object.entries(options)) {
|
|
global_integration_settings[`${integration}_${key}`] = value;
|
|
}
|
|
}
|
|
|
|
let generated_prefs = {};
|
|
|
|
special_prompts_with_integration.forEach(prompt_prefix => {
|
|
for (const [key, value] of Object.entries(integration_settings_template)) {
|
|
generated_prefs[`${prompt_prefix}_${key}`] = value;
|
|
}
|
|
});
|
|
|
|
export function getDynamicSettingsDefaults(keysFilter = []) {
|
|
let defaults = {};
|
|
special_prompts_with_integration.forEach(prefix => {
|
|
const keys = keysFilter.length > 0 ? keysFilter : Object.keys(integration_settings_template);
|
|
keys.forEach(key => {
|
|
defaults[`${prefix}_${key}`] = prefs_default[`${prefix}_${key}`];
|
|
});
|
|
});
|
|
return defaults;
|
|
}
|
|
|
|
export function getDynamicSettingValue(prefs, prefix, settingName) {
|
|
return prefs[`${prefix}_${settingName}`];
|
|
}
|
|
|
|
export const prefs_default = {
|
|
...global_integration_settings,
|
|
do_debug: false,
|
|
chatgpt_win_height: 800,
|
|
chatgpt_win_width: 700,
|
|
chatgpt_win_top: '',
|
|
chatgpt_win_left: '',
|
|
chatgpt_win_save_position: false,
|
|
default_chatgpt_lang: '',
|
|
default_sign_name: '',
|
|
reply_type: 'reply_all',
|
|
composing_plain_text: false,
|
|
connection_type: 'chatgpt_web', //Other values: 'chatgpt_api', 'ollama_api', 'openai_comp_api', 'google_gemini_api'
|
|
chatgpt_web_model: '',
|
|
chatgpt_web_tempchat: false,
|
|
chatgpt_web_project: '',
|
|
chatgpt_web_custom_gpt: '',
|
|
chatgpt_web_load_wait_time: 1000,
|
|
dynamic_menu_force_enter: false,
|
|
dynamic_menu_order_alphabet: true,
|
|
placeholders_use_default_value: false,
|
|
max_prompt_length: 30000, // max string length for prompt
|
|
add_tags: false,
|
|
add_tags_maxnum: 3,
|
|
add_tags_hide_exclusions: false,
|
|
add_tags_exclusions_exact_match: false,
|
|
add_tags_first_uppercase: true,
|
|
add_tags_force_lang: true,
|
|
add_tags_auto: false,
|
|
add_tags_auto_force_existing: false,
|
|
add_tags_auto_only_inbox: true,
|
|
add_tags_auto_uselist: false,
|
|
add_tags_auto_uselist_list: '',
|
|
add_tags_enabled_accounts: [],
|
|
get_calendar_event: true,
|
|
get_calendar_event_from_clipboard: false, // Enable calendar event from clipboard menu item
|
|
get_task: true,
|
|
calendar_enforce_timezone: false,
|
|
calendar_timezone: '',
|
|
calendar_no_selection: false, // If true do not ask for selection, but use the full prompt
|
|
spamfilter: false,
|
|
spamfilter_threshold: 70,
|
|
spamfilter_enabled_accounts: [],
|
|
spamfilter_skip_addresses: [],
|
|
spamfilter_skip_addressbook: false,
|
|
summarize: false,
|
|
summarize_auto: 1, // 0: disabled, 1: manual button, 2: automatic on message open, 3: generate on email receive
|
|
summarize_display_mode: 'inline', // 'inline' or 'webchat'
|
|
summarize_max_display_length: 0, // 0 = no limit, otherwise max chars shown inline
|
|
summarize_strip_formatting: false, // strip HTML/markdown formatting from AI summary
|
|
translate: true,
|
|
translate_auto: 0, // 0: disabled, 1: manual button, 2: automatic on message open, 3: generate on email receive
|
|
translate_max_display_length: 0, // 0 = no limit, otherwise max chars shown inline
|
|
translate_lang: '', // target language, fallback on default_chatgpt_lang
|
|
translate_exclude_lang: '', // languages to do not translate
|
|
spamfilter_show_msg_panel: true,
|
|
...generated_prefs
|
|
}
|