From f47b12946a676cd91aef932207dba1752b32ee65 Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 29 Dec 2025 22:03:45 +0100 Subject: [PATCH] workers updated to use the new dynamic settings --- js/workers/model-worker-anthropic.js | 18 +++++++++--------- js/workers/model-worker-google_gemini.js | 17 +++++++++-------- js/workers/model-worker-ollama.js | 16 ++++++++-------- js/workers/model-worker-openai_comp.js | 17 +++++++++-------- js/workers/model-worker-openai_responses.js | 18 ++++++++++-------- 5 files changed, 45 insertions(+), 41 deletions(-) diff --git a/js/workers/model-worker-anthropic.js b/js/workers/model-worker-anthropic.js index ead40aff..9af3dc17 100644 --- a/js/workers/model-worker-anthropic.js +++ b/js/workers/model-worker-anthropic.js @@ -35,15 +35,15 @@ let assistantResponseAccumulator = ''; self.onmessage = async function(event) { if (event.data.type === 'init') { // console.log(">>>>>>>>>>>>>> event.data: " + JSON.stringify(event.data)); - anthropic = new Anthropic({ - apiKey: event.data.anthropic_api_key, - version: event.data.anthropic_version, - model: event.data.anthropic_model, - system_prompt: event.data.anthropic_system_prompt, - temperature: event.data.anthropic_temperature, - max_tokens: event.data.anthropic_max_tokens, - stream: true - }); + let config = { stream: true }; + for (const key in event.data) { + if (key.startsWith('anthropic_')) { + let newKey = key.replace('anthropic_', ''); + if (newKey === 'api_key') newKey = 'apiKey'; + config[newKey] = event.data[key]; + } + } + anthropic = new Anthropic(config); do_debug = event.data.do_debug; i18nStrings = event.data.i18nStrings; taLog = new taLogger('model-worker-anthropic', do_debug); diff --git a/js/workers/model-worker-google_gemini.js b/js/workers/model-worker-google_gemini.js index 359e0b20..4b6fc138 100644 --- a/js/workers/model-worker-google_gemini.js +++ b/js/workers/model-worker-google_gemini.js @@ -34,14 +34,15 @@ let assistantResponseAccumulator = ''; self.onmessage = async function(event) { if (event.data.type === 'init') { - google_gemini = new GoogleGemini({ - apiKey: event.data.google_gemini_api_key, - model: event.data.google_gemini_model, - system_instruction: event.data.google_gemini_system_instruction, - temperature: event.data.google_gemini_temperature, - thinking_budget: event.data.google_gemini_thinking_budget, - stream: true - }); + let config = { stream: true }; + for (const key in event.data) { + if (key.startsWith('google_gemini_')) { + let newKey = key.replace('google_gemini_', ''); + if (newKey === 'api_key') newKey = 'apiKey'; + config[newKey] = event.data[key]; + } + } + google_gemini = new GoogleGemini(config); do_debug = event.data.do_debug; i18nStrings = event.data.i18nStrings; taLog = new taLogger('model-worker-google_gemini', do_debug); diff --git a/js/workers/model-worker-ollama.js b/js/workers/model-worker-ollama.js index a3374eba..3987df33 100644 --- a/js/workers/model-worker-ollama.js +++ b/js/workers/model-worker-ollama.js @@ -35,14 +35,14 @@ let assistantResponseAccumulator = ''; self.onmessage = async function(event) { switch (event.data.type) { case 'init': - ollama = new Ollama({ - host: event.data.ollama_host, - model: event.data.ollama_model, - stream: true, - num_ctx: event.data.ollama_num_ctx, - temperature: event.data.ollama_temperature, - think: event.data.ollama_think - }); + let config = { stream: true }; + for (const key in event.data) { + if (key.startsWith('ollama_')) { + let newKey = key.replace('ollama_', ''); + config[newKey] = event.data[key]; + } + } + ollama = new Ollama(config); do_debug = event.data.do_debug; i18nStrings = event.data.i18nStrings; taLog = new taLogger('model-worker-ollama', do_debug); diff --git a/js/workers/model-worker-openai_comp.js b/js/workers/model-worker-openai_comp.js index 1e7b8aea..a541ffa8 100644 --- a/js/workers/model-worker-openai_comp.js +++ b/js/workers/model-worker-openai_comp.js @@ -34,14 +34,15 @@ let assistantResponseAccumulator = ''; self.onmessage = async function(event) { if (event.data.type === 'init') { - openai_comp = new OpenAIComp({ - host: event.data.openai_comp_host, - model: event.data.openai_comp_model, - apiKey: event.data.openai_comp_api_key, - stream: true, - use_v1: event.data.openai_comp_use_v1, - openai_comp_temperature: event.data.openai_comp_temperature - }); + let config = { stream: true }; + for (const key in event.data) { + if (key.startsWith('openai_comp_')) { + let newKey = key.replace('openai_comp_', ''); + if (newKey === 'api_key') newKey = 'apiKey'; + config[newKey] = event.data[key]; + } + } + openai_comp = new OpenAIComp(config); do_debug = event.data.do_debug; i18nStrings = event.data.i18nStrings; taLog = new taLogger('model-worker-openai_comp', do_debug); diff --git a/js/workers/model-worker-openai_responses.js b/js/workers/model-worker-openai_responses.js index 3189944d..89803673 100644 --- a/js/workers/model-worker-openai_responses.js +++ b/js/workers/model-worker-openai_responses.js @@ -35,14 +35,16 @@ let previous_response_id = null; self.onmessage = async function(event) { if (event.data.type === 'init') { - openai = new OpenAI({ - apiKey: event.data.chatgpt_api_key, - model: event.data.chatgpt_model, - developer_messages: event.data.chatgpt_developer_messages, - temperature: event.data.chatgpt_api_temperature, - stream: true, - store: event.data.chatgpt_api_store - }); + let config = { stream: true }; + for (const key in event.data) { + if (key.startsWith('chatgpt_')) { + if (key.startsWith('chatgpt_web_')) continue; // Exclude chatgpt_web_ prefixed keys + let newKey = key.replace('chatgpt_', ''); + if (newKey === 'api_key') newKey = 'apiKey'; + config[newKey] = event.data[key]; + } + } + openai = new OpenAI(config); do_debug = event.data.do_debug; i18nStrings = event.data.i18nStrings; taLog = new taLogger('model-worker-openai_responses', do_debug);