@@ -8732,7 +8732,7 @@ Current version indicated by LITEVER below.
87328732 function togglepalmmodel()
87338733 {
87348734 let mdlname = document.getElementById("custom_palm_model").value;
8735- 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" )
8735+ if(mdlname.includes(" gemini-1.5-") || mdlname.includes(" gemini-exp-") )
87368736 {
87378737 document.getElementById("gemini_system_instruction").classList.remove("hidden");
87388738 if(localsettings.saved_palm_jailbreak=="")
@@ -8803,6 +8803,67 @@ Current version indicated by LITEVER below.
88038803 }
88048804 toggleoaichatcompl();
88058805 }
8806+ function gemini_fetch_models()
8807+ {
8808+ let desired_gemini_key = document.getElementById("custom_palm_key").value.trim();
8809+ if(desired_gemini_key=="")
8810+ {
8811+ msgbox("Gemini requires an API key to fetch model list!");
8812+ return;
8813+ }
8814+
8815+ let dropdown = document.getElementById("custom_palm_model");
8816+ fetch((default_gemini_base + "?key=" + desired_gemini_key), {
8817+ method: 'GET',
8818+ referrerPolicy: 'no-referrer',
8819+ })
8820+ .then((response) => response.json())
8821+ .then((data) => {
8822+ console.log(data);
8823+ if (data && data.models && data.models.length > 0)
8824+ {
8825+ var lastOption = dropdown.lastElementChild;
8826+ for (var i = dropdown.options.length - 1; i >= 0; i--) {
8827+ var option = dropdown.options[i];
8828+ dropdown.remove(option);
8829+ }
8830+ let selidx = 0;
8831+ for(var i = 0; i < data.models.length; i++) {
8832+ var opt = data.models[i];
8833+ var el = document.createElement("option");
8834+ let optname = opt.name;
8835+ if(optname.toLowerCase().startsWith("models/"))
8836+ {
8837+ optname = optname.substring(7);
8838+ }
8839+ el.textContent = optname;
8840+ el.value = optname;
8841+ dropdown.appendChild(el);
8842+ }
8843+ dropdown.selectedIndex = selidx;
8844+ togglepalmmodel();
8845+ }
8846+ else
8847+ {
8848+ let errmsg = "";
8849+ if(data && data.error)
8850+ {
8851+ errmsg = data.error;
8852+ }
8853+ else
8854+ {
8855+ errmsg = data;
8856+ }
8857+ msgbox(JSON.stringify(errmsg),"Error Encountered",false,false);
8858+ }
8859+ })
8860+ .catch(error => {
8861+ console.log("Error: " + error);
8862+ msgbox("Error: " + error,"Error Encountered",false,false,()=>{
8863+ hide_msgbox();
8864+ });
8865+ });
8866+ }
88068867 function oai_fetch_models()
88078868 {
88088869 let desired_oai_key = document.getElementById("custom_oai_key").value.trim();
@@ -13473,7 +13534,7 @@ Current version indicated by LITEVER below.
1347313534 };
1347413535
1347513536 let sysinst = document.getElementById("gemini_system_instruction").value;
13476- 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" ))
13537+ if(sysinst!="" && (mdlname.includes(" gemini-1.5-") || mdlname.includes(" gemini-exp-") ))
1347713538 {
1347813539 payload["systemInstruction"] = {
1347913540 "role": "system",
@@ -18883,7 +18944,8 @@ Current version indicated by LITEVER below.
1888318944 <div id="palmcustom" class="aidgpopuplistheader anotelabel hidden">
1888418945 Uses Gemini or PaLM Text Bison by Google.<br><br>
1888518946 Note that KoboldAI Lite takes no responsibility for your usage or consequences of this feature. Your API key is used directly with the Gemini API and is not transmitted to us.<br><br>
18886- <select style="padding:4px;" class="form-control" id="custom_palm_model" onchange="togglepalmmodel()">
18947+ <div>
18948+ <select style="padding:4px; width:calc(100% - 110px); display:inline-block" class="form-control" id="custom_palm_model" onchange="togglepalmmodel()">
1888718949 <option value="gemini-pro" selected="selected">gemini-pro</option>
1888818950 <option value="gemini-1.5-pro-001">gemini-1.5-pro-001</option>
1888918951 <option value="gemini-1.5-pro-002">gemini-1.5-pro-002</option>
@@ -18892,8 +18954,11 @@ Current version indicated by LITEVER below.
1889218954 <option value="gemini-1.5-pro-exp-0801">gemini-1.5-pro-exp-0801</option>
1889318955 <option value="gemini-1.5-pro-exp-0827">gemini-1.5-pro-exp-0827</option>
1889418956 <option value="gemini-exp-1114">gemini-exp-1114</option>
18957+ <option value="gemini-exp-1121">gemini-exp-1121</option>
1889518958 <option value="text-bison-001">text-bison-001</option>
1889618959 </select>
18960+ <button type="button" class="btn btn-primary" style="display:inline;width:105px;" id="geminifetchlist" onclick="gemini_fetch_models()">Fetch List</button>
18961+ </div>
1889718962 <span class="color_green" style="font-weight: bold;">Please input Gemini or PaLM API Key.</span><br><br>
1889818963 <input class="form-control" type="password" id="custom_palm_key" placeholder="PaLM/Gemini API Key (Required)" value="" onfocus="focus_api_keys()" onblur="blur_api_keys()"><br>
1889918964 <textarea class="form-control" rows="3" style="resize: vertical; line-height:1.1; padding:4px; display:inline; width: 100%" type="text" id="gemini_system_instruction" placeholder="(Enter System Instruction)"
0 commit comments