From 7f9ee613ab2dfcd92d59e34e19a20cb3b78fd556 Mon Sep 17 00:00:00 2001 From: Mic Date: Thu, 4 Sep 2025 22:41:00 +0200 Subject: [PATCH] code formatted for clarity --- js/mzta-special-commands.js | 79 ++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/js/mzta-special-commands.js b/js/mzta-special-commands.js index 2ac7ac38..fdd4ac59 100644 --- a/js/mzta-special-commands.js +++ b/js/mzta-special-commands.js @@ -60,28 +60,87 @@ async initWorker() { switch (this.llm) { case "chatgpt_api": { - let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', chatgpt_developer_messages: ''}); - this.worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model, chatgpt_developer_messages: prefs_api.chatgpt_developer_messages, do_debug: this.do_debug, i18nStrings: ''}); + let prefs_api = await browser.storage.sync.get({ + chatgpt_api_key: '', + chatgpt_model: '', + chatgpt_developer_messages: '' + }); + this.worker.postMessage({ + type: 'init', + chatgpt_api_key: prefs_api.chatgpt_api_key, + chatgpt_model: prefs_api.chatgpt_model, + chatgpt_developer_messages: prefs_api.chatgpt_developer_messages, + do_debug: this.do_debug, + i18nStrings: '' + }); break; } case "google_gemini_api": { - let prefs_api = await browser.storage.sync.get({google_gemini_api_key: '', google_gemini_model: '', google_gemini_system_instruction: ''}); - this.worker.postMessage({ type: 'init', google_gemini_api_key: prefs_api.google_gemini_api_key, google_gemini_model: prefs_api.google_gemini_model, google_gemini_system_instruction: prefs_api.google_gemini_system_instruction, do_debug: this.do_debug, i18nStrings: ''}); + let prefs_api = await browser.storage.sync.get({ + google_gemini_api_key: '', + google_gemini_model: '', + google_gemini_system_instruction: '' + }); + this.worker.postMessage({ + type: 'init', + google_gemini_api_key: prefs_api.google_gemini_api_key, + google_gemini_model: prefs_api.google_gemini_model, + google_gemini_system_instruction: prefs_api.google_gemini_system_instruction, + do_debug: this.do_debug, + i18nStrings: '' + }); break; } case "ollama_api": { - let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: ''}); - this.worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, do_debug: this.do_debug, i18nStrings: ''}); + let prefs_api = await browser.storage.sync.get({ + ollama_host: '', + ollama_model: '', + }); + this.worker.postMessage({ + type: 'init', + ollama_host: prefs_api.ollama_host, + ollama_model: prefs_api.ollama_model, + do_debug: this.do_debug, + i18nStrings: '' + }); break; } case "openai_comp_api": { - let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_comp_api_key: '', openai_comp_use_v1: true, openai_comp_chat_name: '', do_debug: false}); - this.worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, openai_comp_use_v1: prefs_api.openai_comp_use_v1, do_debug: this.do_debug, i18nStrings: ''}); + let prefs_api = await browser.storage.sync.get({ + openai_comp_host: '', + openai_comp_model: '', + openai_comp_api_key: '', + openai_comp_use_v1: true, + openai_comp_chat_name: '', + do_debug: false, + }); + this.worker.postMessage({ + type: 'init', + openai_comp_host: prefs_api.openai_comp_host, + openai_comp_model: prefs_api.openai_comp_model, + openai_comp_api_key: prefs_api.openai_comp_api_key, + openai_comp_use_v1: prefs_api.openai_comp_use_v1, + do_debug: this.do_debug, + i18nStrings: '' + }); break; } case "anthropic_api": { - let prefs_api = await browser.storage.sync.get({anthropic_api_key: '', anthropic_model: '', anthropic_version: '2023-06-01', anthropic_max_tokens: 4096}); - this.worker.postMessage({ type: 'init', anthropic_api_key: prefs_api.anthropic_api_key, anthropic_model: prefs_api.anthropic_model, anthropic_version: prefs_api.anthropic_version, anthropic_max_tokens: prefs_api.anthropic_max_tokens, do_debug: this.do_debug, i18nStrings: ''}); + let prefs_api = await browser.storage.sync.get({ + anthropic_api_key: '', + anthropic_model: '', + anthropic_version: '2023-06-01', + anthropic_max_tokens: 4096, + }); + this.worker.postMessage({ + type: 'init', + anthropic_api_key: prefs_api.anthropic_api_key, + anthropic_model: prefs_api.anthropic_model, + anthropic_version: prefs_api.anthropic_version, + anthropic_max_tokens: prefs_api.anthropic_max_tokens, + do_debug: this.do_debug, + i18nStrings: '' + }); break; } }