connection_type dynamic loading
This commit is contained in:
parent
76f743e88f
commit
d404897911
3 changed files with 33 additions and 10 deletions
|
|
@ -364,6 +364,35 @@ export function generateCallID(length = 10) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function populateConnectionTypeOptions(selectId) {
|
||||||
|
const selectEl = document.getElementById(selectId);
|
||||||
|
if (!selectEl) return;
|
||||||
|
|
||||||
|
const prevValue = selectEl.value;
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{ value: 'chatgpt_web', msgKey: 'prefs_Connection_type_ChatGPT_Web' },
|
||||||
|
{ value: 'chatgpt_api', msgKey: 'prefs_Connection_type_ChatGPT_API' },
|
||||||
|
{ value: 'google_gemini_api', msgKey: 'prefs_Connection_type_Google_Gemini_API' },
|
||||||
|
{ value: 'anthropic_api', msgKey: 'prefs_Connection_type_Anthropic_API' },
|
||||||
|
{ value: 'ollama_api', msgKey: 'prefs_Connection_type_Ollama_API' },
|
||||||
|
{ value: 'openai_comp_api', msgKey: 'prefs_Connection_type_OpenAI_Comp_API' }
|
||||||
|
];
|
||||||
|
|
||||||
|
selectEl.innerHTML = '';
|
||||||
|
|
||||||
|
for (const opt of options) {
|
||||||
|
const optionEl = document.createElement('option');
|
||||||
|
optionEl.value = opt.value;
|
||||||
|
optionEl.textContent = browser.i18n.getMessage(opt.msgKey) || opt.msgKey;
|
||||||
|
selectEl.appendChild(optionEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.some(o => o.value === prevValue)) {
|
||||||
|
selectEl.value = prevValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function getTagsList(){
|
export async function getTagsList(){
|
||||||
let messageTags = [];
|
let messageTags = [];
|
||||||
if(await isThunderbird128OrGreater()) {
|
if(await isThunderbird128OrGreater()) {
|
||||||
|
|
@ -753,4 +782,4 @@ export async function* getMessages(list) {
|
||||||
yield message;
|
yield message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,14 +121,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select id="connection_type" name="connection_type" class="option-input">
|
<select id="connection_type" name="connection_type" class="option-input"></select>
|
||||||
<option value="chatgpt_web">__MSG_prefs_Connection_type_ChatGPT_Web__</option>
|
|
||||||
<option value="chatgpt_api">__MSG_prefs_Connection_type_ChatGPT_API__</option>
|
|
||||||
<option value="google_gemini_api">__MSG_prefs_Connection_type_Google_Gemini_API__</option>
|
|
||||||
<option value="anthropic_api">__MSG_prefs_Connection_type_Anthropic_API__</option>
|
|
||||||
<option value="ollama_api">__MSG_prefs_Connection_type_Ollama_API__</option>
|
|
||||||
<option value="openai_comp_api">__MSG_prefs_Connection_type_OpenAI_Comp_API__</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { Ollama } from '../js/api/ollama.js';
|
||||||
import { OpenAIComp } from '../js/api/openai_comp.js'
|
import { OpenAIComp } from '../js/api/openai_comp.js'
|
||||||
import { GoogleGemini } from '../js/api/google_gemini.js';
|
import { GoogleGemini } from '../js/api/google_gemini.js';
|
||||||
import { Anthropic } from '../js/api/anthropic.js';
|
import { Anthropic } from '../js/api/anthropic.js';
|
||||||
import { ChatGPTWeb_models, checkSparksPresence, isThunderbird128OrGreater, openTab, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, validateCustomData_ChatGPTWeb, getChatGPTWebModelsList_HTML } from '../js/mzta-utils.js';
|
import { ChatGPTWeb_models, checkSparksPresence, isThunderbird128OrGreater, openTab, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, validateCustomData_ChatGPTWeb, getChatGPTWebModelsList_HTML, populateConnectionTypeOptions } from '../js/mzta-utils.js';
|
||||||
import { openAICompConfigs } from '../js/api/openai_comp_configs.js';
|
import { openAICompConfigs } from '../js/api/openai_comp_configs.js';
|
||||||
|
|
||||||
let taLog = new taLogger("mzta-options",true);
|
let taLog = new taLogger("mzta-options",true);
|
||||||
|
|
@ -405,6 +405,7 @@ function resetMaxPromptLength(){
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
populateConnectionTypeOptions('connection_type');
|
||||||
await restoreOptions();
|
await restoreOptions();
|
||||||
|
|
||||||
permission_all_urls = await messenger.permissions.contains({ origins: ["<all_urls>"] })
|
permission_all_urls = await messenger.permissions.contains({ origins: ["<all_urls>"] })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue