diff --git a/index.html b/index.html index b2592f9..89e1df0 100644 --- a/index.html +++ b/index.html @@ -8732,7 +8732,7 @@ function togglepalmmodel() { let mdlname = document.getElementById("custom_palm_model").value; - if(mdlname=="gemini-1.5-pro-latest" || mdlname=="gemini-1.5-pro-001" || mdlname=="gemini-1.5-pro-002" || mdlname=="gemini-1.5-flash-latest" || mdlname=="gemini-1.5-pro-exp-0801" || mdlname=="gemini-1.5-pro-exp-0827" || mdlname=="gemini-exp-1114") + if(mdlname.includes("gemini-1.5-") || mdlname.includes("gemini-exp-")) { document.getElementById("gemini_system_instruction").classList.remove("hidden"); if(localsettings.saved_palm_jailbreak=="") @@ -8803,6 +8803,67 @@ } toggleoaichatcompl(); } + function gemini_fetch_models() + { + let desired_gemini_key = document.getElementById("custom_palm_key").value.trim(); + if(desired_gemini_key=="") + { + msgbox("Gemini requires an API key to fetch model list!"); + return; + } + + let dropdown = document.getElementById("custom_palm_model"); + fetch((default_gemini_base + "?key=" + desired_gemini_key), { + method: 'GET', + referrerPolicy: 'no-referrer', + }) + .then((response) => response.json()) + .then((data) => { + console.log(data); + if (data && data.models && data.models.length > 0) + { + var lastOption = dropdown.lastElementChild; + for (var i = dropdown.options.length - 1; i >= 0; i--) { + var option = dropdown.options[i]; + dropdown.remove(option); + } + let selidx = 0; + for(var i = 0; i < data.models.length; i++) { + var opt = data.models[i]; + var el = document.createElement("option"); + let optname = opt.name; + if(optname.toLowerCase().startsWith("models/")) + { + optname = optname.substring(7); + } + el.textContent = optname; + el.value = optname; + dropdown.appendChild(el); + } + dropdown.selectedIndex = selidx; + togglepalmmodel(); + } + else + { + let errmsg = ""; + if(data && data.error) + { + errmsg = data.error; + } + else + { + errmsg = data; + } + msgbox(JSON.stringify(errmsg),"Error Encountered",false,false); + } + }) + .catch(error => { + console.log("Error: " + error); + msgbox("Error: " + error,"Error Encountered",false,false,()=>{ + hide_msgbox(); + }); + }); + } function oai_fetch_models() { let desired_oai_key = document.getElementById("custom_oai_key").value.trim(); @@ -13473,7 +13534,7 @@ }; let sysinst = document.getElementById("gemini_system_instruction").value; - if(sysinst!="" && (mdlname=="gemini-1.5-pro-latest" || mdlname=="gemini-1.5-pro-001" || mdlname=="gemini-1.5-pro-002" || mdlname=="gemini-1.5-flash-latest" || mdlname=="gemini-1.5-pro-exp-0801")) + if(sysinst!="" && (mdlname.includes("gemini-1.5-") || mdlname.includes("gemini-exp-"))) { payload["systemInstruction"] = { "role": "system", @@ -18883,7 +18944,8 @@