125 lines
4.1 KiB
JavaScript
125 lines
4.1 KiB
JavaScript
/*
|
|
* ThunderAI [https://micz.it/thunderbird-addon-thunderai/]
|
|
* Copyright (C) 2024 - 2025 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/>.
|
|
*/
|
|
|
|
const special_prompts_with_integration = ['add_tags', 'spamfilter'];
|
|
|
|
const integration_settings_template = {
|
|
use_specific_integration: false,
|
|
connection_type: 'chatgpt_api',
|
|
chatgpt_model: '',
|
|
ollama_model: '',
|
|
openai_comp_model: '',
|
|
google_gemini_model: '',
|
|
anthropic_model: '',
|
|
chatgpt_api_temperature: '',
|
|
ollama_temperature: '',
|
|
openai_comp_temperature: '',
|
|
google_gemini_temperature: '',
|
|
anthropic_temperature: '',
|
|
};
|
|
|
|
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 = {
|
|
do_debug: false,
|
|
chatgpt_win_height: 800,
|
|
chatgpt_win_width: 700,
|
|
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_api_key: '',
|
|
chatgpt_api_store: false,
|
|
chatgpt_model: '',
|
|
chatgpt_developer_messages: '',
|
|
chatgpt_api_temperature: '',
|
|
ollama_host: '',
|
|
ollama_model: '',
|
|
ollama_num_ctx: 0,
|
|
ollama_temperature: '',
|
|
ollama_think: false,
|
|
openai_comp_host: '', // For OpenAI Compatible API as LM-Studio
|
|
openai_comp_model: '',
|
|
openai_comp_api_key: '',
|
|
openai_comp_use_v1: true,
|
|
openai_comp_chat_name: 'OpenAI Comp',
|
|
openai_comp_temperature: '',
|
|
google_gemini_api_key: '',
|
|
google_gemini_model: '',
|
|
google_gemini_system_instruction: '',
|
|
google_gemini_thinking_budget: '',
|
|
google_gemini_temperature: '',
|
|
anthropic_api_key: '',
|
|
anthropic_model: '',
|
|
anthropic_version: '2023-06-01',
|
|
anthropic_max_tokens: 4096,
|
|
anthropic_system_prompt: '',
|
|
anthropic_temperature: '',
|
|
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_context_menu: true,
|
|
add_tags_enabled_accounts: [],
|
|
get_calendar_event: true,
|
|
get_task: true,
|
|
calendar_enforce_timezone: false,
|
|
calendar_timezone: '',
|
|
spamfilter: false,
|
|
spamfilter_threshold: 70,
|
|
spamfilter_context_menu: true,
|
|
spamfilter_enabled_accounts: [],
|
|
...generated_prefs
|
|
}
|