Skip to content

Commit

Permalink
added new gemini models
Browse files Browse the repository at this point in the history
  • Loading branch information
Concedo authored and Concedo committed Nov 27, 2024
1 parent f913d0d commit 5dce2c9
Showing 1 changed file with 68 additions and 3 deletions.
71 changes: 68 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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=="")
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -18883,7 +18944,8 @@
<div id="palmcustom" class="aidgpopuplistheader anotelabel hidden">
Uses Gemini or PaLM Text Bison by Google.<br><br>
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>
<select style="padding:4px;" class="form-control" id="custom_palm_model" onchange="togglepalmmodel()">
<div>
<select style="padding:4px; width:calc(100% - 110px); display:inline-block" class="form-control" id="custom_palm_model" onchange="togglepalmmodel()">
<option value="gemini-pro" selected="selected">gemini-pro</option>
<option value="gemini-1.5-pro-001">gemini-1.5-pro-001</option>
<option value="gemini-1.5-pro-002">gemini-1.5-pro-002</option>
Expand All @@ -18892,8 +18954,11 @@
<option value="gemini-1.5-pro-exp-0801">gemini-1.5-pro-exp-0801</option>
<option value="gemini-1.5-pro-exp-0827">gemini-1.5-pro-exp-0827</option>
<option value="gemini-exp-1114">gemini-exp-1114</option>
<option value="gemini-exp-1121">gemini-exp-1121</option>
<option value="text-bison-001">text-bison-001</option>
</select>
<button type="button" class="btn btn-primary" style="display:inline;width:105px;" id="geminifetchlist" onclick="gemini_fetch_models()">Fetch List</button>
</div>
<span class="color_green" style="font-weight: bold;">Please input Gemini or PaLM API Key.</span><br><br>
<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>
<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)"
Expand Down

0 comments on commit 5dce2c9

Please sign in to comment.