diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 8ba8a04c..24678b2d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1577,18 +1577,10 @@ "message": "If checked, your chats will be stored by OpenAI.", "description": "" }, - "prefs_chatgpt_api_temperature": { - "message": "Temperature", - "description": "" - }, "prefs_chatgpt_api_temperature_Info": { "message": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.", "description": "" }, - "ollama_temperature": { - "message": "Temperature", - "description": "" - }, "ollama_temperature_Info": { "message": "The temperature of the model. Increasing the temperature will make the model answer more creatively. The default value is 0.8. It is recommended to use values between 0 and 1.", "description": "" @@ -1689,6 +1681,14 @@ "message": "Are you sure you want to clear the Models List? This action cannot be undone.", "description": "" }, + "prefs_api_temperature": { + "message": "Temperature", + "description": "" + }, + "prefs_openai_comp_temperature_Info": { + "message": "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.", + "description": "" + }, "chatgpt_click_force_completion": { "message": "It seems that it's not possible to get if ChatGPT has finished. Click here to force the completion of the job.", "description": "" @@ -1705,10 +1705,6 @@ "message": "Define the number of tokens to be used for thinking. Leave this field blank if the selected model does not support thinking or if you want to use the default method. Enter 0 to disable thinking, or -1 to enable dynamic thinking.", "description": "" }, - "prefs_google_gemini_temperature": { - "message": "Temperature", - "description": "" - }, "prefs_google_gemini_temperature_Info": { "message": "This parameter must be a number between 0.0 and 2.0. It controls the randomness of the output. The default value varies depending on the model. Leave it empty to avoid setting the parameter in the API call.", "description": "" @@ -1729,10 +1725,6 @@ "message": "You can improve Claude performance by using a System Prompt to give it a role. This technique, known as role prompting, is the most powerful way to use system prompts with Claude. The right role can turn Claude from a general assistant into your virtual domain expert.", "description": "" }, - "prefs_anthropic_temperature": { - "message": "Temperature", - "description": "" - }, "prefs_anthropic_temperature_Info": { "message": "Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic.", "description": "" diff --git a/api_webchat/controller.js b/api_webchat/controller.js index 5f5cdfca..01737a91 100644 --- a/api_webchat/controller.js +++ b/api_webchat/controller.js @@ -106,7 +106,7 @@ switch (llm) { additional_text_elements.push({label: browser.i18n.getMessage("ChatGPT_Developer_Messages"), value: prefs_api.chatgpt_developer_messages}); } if(prefs_api.chatgpt_api_temperature && prefs_api.chatgpt_api_temperature.length > 0){ - additional_text_elements.push({label: browser.i18n.getMessage("prefs_chatgpt_api_temperature"), value: prefs_api.chatgpt_api_temperature}); + additional_text_elements.push({label: browser.i18n.getMessage("prefs_api_temperature"), value: prefs_api.chatgpt_api_temperature}); } messagesArea.appendUserMessage(getAPIsInitMessageString({ api_string: "ChatGPT API", @@ -139,7 +139,7 @@ switch (llm) { additional_text_elements.push({label: browser.i18n.getMessage("GoogleGemini_SystemInstruction"), value: prefs_api.google_gemini_system_instruction}); } if(prefs_api.google_gemini_temperature.length > 0){ - additional_text_elements.push({label: browser.i18n.getMessage("prefs_google_gemini_temperature"), value: prefs_api.google_gemini_temperature}); + additional_text_elements.push({label: browser.i18n.getMessage("prefs_api_temperature"), value: prefs_api.google_gemini_temperature}); } if(prefs_api.google_gemini_thinking_budget.length > 0){ additional_text_elements.push({label: browser.i18n.getMessage("prefs_google_gemini_thinking_budget"), value: prefs_api.google_gemini_thinking_budget}); @@ -197,7 +197,7 @@ switch (llm) { additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)}); additional_text_elements.push({label: browser.i18n.getMessage("prefs_ollama_think"), value: (prefs_api.ollama_think ? 'Yes' : 'No')}); if(prefs_api.ollama_temperature && prefs_api.ollama_temperature.length > 0){ - additional_text_elements.push({label: browser.i18n.getMessage("prefs_ollama_temperature"), value: prefs_api.ollama_temperature}); + additional_text_elements.push({label: browser.i18n.getMessage("prefs_api_temperature"), value: prefs_api.ollama_temperature}); } if(prefs_api.ollama_num_ctx > 0){ additional_text_elements.push({label: browser.i18n.getMessage("prefs_ollama_num_ctx"), value: prefs_api.ollama_num_ctx}); @@ -217,6 +217,7 @@ switch (llm) { openai_comp_api_key: prefs_default.openai_comp_api_key, openai_comp_use_v1: prefs_default.openai_comp_use_v1, openai_comp_chat_name: prefs_default.openai_comp_chat_name, + openai_comp_temperature: prefs_default.openai_comp_temperature, do_debug: prefs_default.do_debug, }); let i18nStrings = {}; @@ -230,11 +231,15 @@ switch (llm) { 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, + openai_comp_temperature: prefs_api.openai_comp_temperature, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings, }); let additional_text_elements = []; additional_text_elements.push({label: browser.i18n.getMessage("prompt_string"), value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)}); + if(prefs_api.openai_comp_temperature && prefs_api.openai_comp_temperature.length > 0){ + additional_text_elements.push({label: browser.i18n.getMessage("prefs_api_temperature"), value: prefs_api.openai_comp_temperature}); + } messagesArea.appendUserMessage(getAPIsInitMessageString({ api_string: "OpenAI Compatible API", model_string: prefs_api.openai_comp_model, @@ -282,7 +287,7 @@ switch (llm) { additional_text_elements.push({label: browser.i18n.getMessage("prefs_OptionText_anthropic_max_tokens"), value: prefs_api.anthropic_max_tokens}); } if(prefs_api.anthropic_temperature && prefs_api.anthropic_temperature.length > 0){ - additional_text_elements.push({label: browser.i18n.getMessage("prefs_anthropic_temperature"), value: prefs_api.anthropic_temperature}); + additional_text_elements.push({label: browser.i18n.getMessage("prefs_api_temperature"), value: prefs_api.anthropic_temperature}); } messagesArea.appendUserMessage(getAPIsInitMessageString({ api_string: "Claude API", diff --git a/js/api/openai_comp.js b/js/api/openai_comp.js index 3e975b62..e6ea5333 100644 --- a/js/api/openai_comp.js +++ b/js/api/openai_comp.js @@ -26,6 +26,7 @@ export class OpenAIComp { apiKey = ''; use_v1 = true; stream = false; + openai_comp_temperature = ''; constructor({ host = '', @@ -33,12 +34,14 @@ export class OpenAIComp { apiKey = '', stream = false, use_v1 = true, + openai_comp_temperature = '', } = {}) { this.host = (host || '').trim().replace(/\/+$/, ""); this.model = model; this.stream = stream; this.apiKey = apiKey; this.use_v1 = use_v1; + this.openai_comp_temperature = openai_comp_temperature; } @@ -91,7 +94,8 @@ export class OpenAIComp { model: this.model, messages: messages, stream: this.stream, - ...(maxTokens > 0 ? { 'max_tokens': parseInt(maxTokens) } : {}) + ...(maxTokens > 0 ? { 'max_tokens': parseInt(maxTokens) } : {}), + ...(parseFloat(this.openai_comp_temperature) != NaN ? { 'temperature': parseFloat(this.openai_comp_temperature) } : {}) }), }); return response; diff --git a/js/workers/model-worker-openai_comp.js b/js/workers/model-worker-openai_comp.js index 333ce148..00b3be58 100644 --- a/js/workers/model-worker-openai_comp.js +++ b/js/workers/model-worker-openai_comp.js @@ -42,12 +42,14 @@ self.onmessage = async function(event) { openai_comp_model = event.data.openai_comp_model; openai_comp_api_key = event.data.openai_comp_api_key; openai_comp_use_v1 = event.data.openai_comp_use_v1; + openai_comp_temperature = event.data.openai_comp_temperature; openai_comp = new OpenAIComp({ host: openai_comp_host, model: openai_comp_model, apiKey: openai_comp_api_key, stream: true, - use_v1: openai_comp_use_v1 + use_v1: openai_comp_use_v1, + openai_comp_temperature: openai_comp_temperature }); do_debug = event.data.do_debug; i18nStrings = event.data.i18nStrings; diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js index c524c89d..1410d645 100644 --- a/options/mzta-options-default.js +++ b/options/mzta-options-default.js @@ -44,6 +44,7 @@ export const prefs_default = { 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: '', diff --git a/pages/_lib/connection-ui.js b/pages/_lib/connection-ui.js index 1b9c8e93..cc6a4cab 100644 --- a/pages/_lib/connection-ui.js +++ b/pages/_lib/connection-ui.js @@ -159,7 +159,7 @@ export async function injectConnectionUI({