added nocertify mode

This commit is contained in:
Concedo 2024-02-19 16:05:17 +08:00
parent db0834593b
commit 6181b46eef
3 changed files with 154 additions and 51 deletions

View file

@ -273,7 +273,7 @@ class model_backend(InferenceModel):
unbantokens=False, bantokens=None, usemirostat=None, forceversion=0, nommap=self.kcpp_nommap, unbantokens=False, bantokens=None, usemirostat=None, forceversion=0, nommap=self.kcpp_nommap,
usemlock=False, noavx2=self.kcpp_noavx2, debugmode=self.kcpp_debugmode, skiplauncher=True, hordeconfig=None, noblas=self.kcpp_noblas, usemlock=False, noavx2=self.kcpp_noavx2, debugmode=self.kcpp_debugmode, skiplauncher=True, hordeconfig=None, noblas=self.kcpp_noblas,
useclblast=self.kcpp_useclblast, usecublas=self.kcpp_usecublas, usevulkan=self.kcpp_usevulkan, gpulayers=self.kcpp_gpulayers, tensor_split=self.kcpp_tensor_split, config=None, useclblast=self.kcpp_useclblast, usecublas=self.kcpp_usecublas, usevulkan=self.kcpp_usevulkan, gpulayers=self.kcpp_gpulayers, tensor_split=self.kcpp_tensor_split, config=None,
onready='', multiuser=False, foreground=False, preloadstory=None, noshift=False, remotetunnel=False, ssl=False) onready='', multiuser=False, foreground=False, preloadstory=None, noshift=False, remotetunnel=False, ssl=False, benchmark=False, nocertify=False)
#koboldcpp.main(kcppargs,False) #initialize library without enabling Lite http server #koboldcpp.main(kcppargs,False) #initialize library without enabling Lite http server

View file

@ -6,7 +6,7 @@ It requires no dependencies, installation or setup.
Just copy this single static HTML file anywhere and open it in a browser, or from a webserver. Just copy this single static HTML file anywhere and open it in a browser, or from a webserver.
Please go to https://github.com/LostRuins/lite.koboldai.net for updates on Kobold Lite. Please go to https://github.com/LostRuins/lite.koboldai.net for updates on Kobold Lite.
Kobold Lite is under the AGPL v3.0 License unless otherwise exempted. Please do not remove this line. Kobold Lite is under the AGPL v3.0 License unless otherwise exempted. Please do not remove this line.
Current version: 113 Current version: 114
-Concedo -Concedo
--> -->
@ -108,8 +108,7 @@ Current version: 113
line-height: normal; line-height: normal;
} }
body.connected #topmenu, body.connected #topmenu {
#topmenu.always-available {
background-color: #337ab7; background-color: #337ab7;
} }
@ -298,7 +297,7 @@ Current version: 113
.anotetempbox .anotetempbox
{ {
display: inline; display: inline;
width: calc(100% - 98px); width: 100%;
} }
.anotetempscale .anotetempscale
{ {
@ -309,7 +308,7 @@ Current version: 113
.stopseqbox .stopseqbox
{ {
display: inline; display: inline;
width: calc(100% - 110px); width: 100%;
} }
#popuptitlebar { #popuptitlebar {
@ -1486,12 +1485,23 @@ Current version: 113
} }
.storyimgfloat .storyimgfloat
{ {
width: fit-content;
float: right; float: right;
position: relative; position: relative;
padding: 4px; padding: 4px;
} }
.storyimg .storyimgside
{ {
display: inline-block;
width: fit-content;
text-align: center;
position: relative;
padding: 4px;
margin: 0 auto;
}
.storyimgcenter
{
width: fit-content;
text-align: center; text-align: center;
position: relative; position: relative;
padding: 4px; padding: 4px;
@ -3410,6 +3420,7 @@ Current version: 113
var image_db = {}; //stores a dictionary of pending images var image_db = {}; //stores a dictionary of pending images
var interrogation_db = {}; var interrogation_db = {};
var completed_imgs_meta = {}; //stores temp info on completed images like alt text var completed_imgs_meta = {}; //stores temp info on completed images like alt text
var img_hash_to_b64_lookup = {}; //used to revert imghash to b64. temporary storage
//key is ID, body is {done:false,queue:10,result:""} //key is ID, body is {done:false,queue:10,result:""}
var stablemodels = [{"name": "stable_diffusion","count": 1}]; //stored as {name,count} var stablemodels = [{"name": "stable_diffusion","count": 1}]; //stored as {name,count}
var custom_kobold_endpoint = ""; //if set, does not use horde. Instead, attempts to use this sync endpoint var custom_kobold_endpoint = ""; //if set, does not use horde. Instead, attempts to use this sync endpoint
@ -8334,6 +8345,24 @@ Current version: 113
} }
function simplemodexample()
{
let simplemodscript = `// This mod changes your top menu to yellow color, then displays the current temperature setting as a popup\n\n`+
`document.getElementById("topmenu").style.backgroundColor = 'yellow';\nalert("Congrats, your top menu turned yellow. Also, your temperature was " + localsettings.temperature);`;
document.getElementById("inputboxcontainerinputarea").value = simplemodscript;
}
function apply_user_mod()
{
inputBox("Here, you can apply third-party mod scripts shared by other users.<br><br><span class='color_red'>Caution: This mod will have full access to your story and API keys, so only run third-party mods that you trust! For security, mods must always be manually applied every time.</span><br><br>Want to start modding? <a href='#' class='color_blueurl' onclick='simplemodexample()'>Click here</a> to load a simple example mod.","Apply Third-Party Mod","","Paste Mod Script Here",()=>{
let userinput = getInputBoxValue().trim();
if(userinput!="" && userinput.trim()!="")
{
var userModScript = new Function(userinput);
userModScript();
}
},true,true);
}
function clear_poll_flags() function clear_poll_flags()
{ {
pending_response_id = ""; pending_response_id = "";
@ -9546,12 +9575,19 @@ Current version: 113
} }
} }
else { else {
//apply custom logit bias for official OAI only
let needbaneos = (custom_oai_endpoint.toLowerCase().includes("api.openai.com") && determine_if_ban_eos(input_was_empty));
if(needbaneos)
{
if(oai_payload.logit_bias) if(oai_payload.logit_bias)
{ {
oai_payload.logit_bias["50256"] = -100; oai_payload.logit_bias["50256"] = -100;
}else{ }else{
oai_payload.logit_bias = { "50256": -100 }; oai_payload.logit_bias = { "50256": -100 };
} }
}
oai_payload.prompt = submit_payload.prompt; oai_payload.prompt = submit_payload.prompt;
} }
@ -10194,11 +10230,12 @@ Current version: 113
function update_clicked_image(imghash) function update_clicked_image(imghash)
{ {
let savedmeta = completed_imgs_meta[imghash]; let savedmeta = completed_imgs_meta[imghash];
if(!savedmeta) if(!savedmeta && imghash!="")
{ {
document.getElementById("zoomedimgdesc").innerText = "No Saved Data"; savedmeta = completed_imgs_meta[imghash] = {prompt:"", desc:"", enabled:false};
} }
else
if(savedmeta)
{ {
let origprompt = (savedmeta.prompt?replaceAll(savedmeta.prompt,"\n"," ") : "No Saved Description"); let origprompt = (savedmeta.prompt?replaceAll(savedmeta.prompt,"\n"," ") : "No Saved Description");
origprompt = escapeHtml(origprompt); origprompt = escapeHtml(origprompt);
@ -10210,6 +10247,11 @@ Current version: 113
<br><button type="button" class="btn btn-primary" style="width: 140px; padding: 2px; margin: 3px; font-size:12px;" onclick="msgbox('`+origprompt+`','Original Prompt')">View Original Prompt</button> <br><button type="button" class="btn btn-primary" style="width: 140px; padding: 2px; margin: 3px; font-size:12px;" onclick="msgbox('`+origprompt+`','Original Prompt')">View Original Prompt</button>
`; `;
} }
else
{
document.getElementById("zoomedimgdesc").innerText = "No Saved Data";
}
} }
function click_image(target,imghash) function click_image(target,imghash)
{ {
@ -10246,11 +10288,12 @@ Current version: 113
} }
} }
function render_image_html(data, pend_txt = "", float=true) { function render_image_html(data, pend_txt = "", float=true, center=false) {
var dim = (localsettings.opmode == 2 ? 160 : 200); //adventure mode has smaller pictures var dim = (localsettings.opmode == 2 ? 160 : 200); //adventure mode has smaller pictures
let siclass = (float?"storyimgfloat":"storyimg"); let siclass = (float?"storyimgfloat":(center?"storyimgcenter":"storyimgside"));
let reinvertcolor = localsettings.invert_colors?" invert_colors":""; let reinvertcolor = localsettings.invert_colors?" invert_colors":"";
let alttxt = ""; let alttxt = "";
let suffix = ((float==false&&center==false)?"<br>":"");
if (!data || data == "") { if (!data || data == "") {
let waittime = "Unavailable"; let waittime = "Unavailable";
if (image_db[pend_txt] != null) { if (image_db[pend_txt] != null) {
@ -10261,13 +10304,13 @@ Current version: 113
console.log("Cannot render " + pend_txt); console.log("Cannot render " + pend_txt);
} }
return `<div class="`+siclass+reinvertcolor+`" contenteditable="false"><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDABsSFBcUERsXFhceHBsgKEIrKCUlKFE6PTBCYFVlZF9VXVtqeJmBanGQc1tdhbWGkJ6jq62rZ4C8ybqmx5moq6T/2wBDARweHigjKE4rK06kbl1upKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKT/wAARCAEAAQADASIAAhEBAxEB/8QAGQABAQEBAQEAAAAAAAAAAAAAAAEDAgQF/8QAIBABAAIBBQEBAQEAAAAAAAAAAAECEgMRMVKRIWFBof/EABQBAQAAAAAAAAAAAAAAAAAAAAD/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwD7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABETPENNPT3je3jUHm22HpmInljqUx+xwDgAAAAAAAAAAAAAAAAAAAAAAAAABaxvaIRaztaJB6AAEmN4mFSZ2iZB5wAAAAAAAAAAAAAAAAAAAAAAAAAAAaaeptG1vWrzETMcSD0zMRyx1L5fI4cb7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7rpzNd/HAAAAAAAAAAAAAAAAAAAAAAAAAAAAADTT09/s8Gnp7/Z4agONSmX2OXYDzDbUpl9jliAAAAAAAAAAAAAAAAAAAsVmd9o4KVm0/jeIiI2gHnGupp/2vjIAABpp6e/2TT09/s8NQAAAAHGpTL7HLsB5htqUy+xyxAAAAAAAAAAAAAAAWlZtP4UrNp/G8RFY2gCIiI2hQAZ6mn/a+NAHmaaenv8AZ4dzp1m2/wDjoAAAAAAAABxqUy+xy7AeYbalMvscsQAAAAAAAAAAFpWbT+FKzafxvEREbQBEREbQoAAAAAAAAAAAAAAAAAONSmX2OXYDzDbUpl9jliAAAAAAAtKzafxaVm0/jaIiI2gCIiI2hQAAAAAAAAAAAAAAAAAAAAAcalMvscuwHmG2pTL7HLEAAAAFi0xxMwZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6kzvyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/Z" width=` + dim + ` height=` + dim + ` style="border-radius: 6%;" title="`+alttxt+`" alt="` + pend_txt + `"><div class=\"loader2\"></div><div class=\"imagelabel\">` + waittime + `</div></div>`; return `<div class="`+siclass+reinvertcolor+`" contenteditable="false"><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDABsSFBcUERsXFhceHBsgKEIrKCUlKFE6PTBCYFVlZF9VXVtqeJmBanGQc1tdhbWGkJ6jq62rZ4C8ybqmx5moq6T/2wBDARweHigjKE4rK06kbl1upKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKT/wAARCAEAAQADASIAAhEBAxEB/8QAGQABAQEBAQEAAAAAAAAAAAAAAAEDAgQF/8QAIBABAAIBBQEBAQEAAAAAAAAAAAECEgMRMVKRIWFBof/EABQBAQAAAAAAAAAAAAAAAAAAAAD/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwD7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABETPENNPT3je3jUHm22HpmInljqUx+xwDgAAAAAAAAAAAAAAAAAAAAAAAAABaxvaIRaztaJB6AAEmN4mFSZ2iZB5wAAAAAAAAAAAAAAAAAAAAAAAAAAAaaeptG1vWrzETMcSD0zMRyx1L5fI4cb7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7rpzNd/HAAAAAAAAAAAAAAAAAAAAAAAAAAAAADTT09/s8Gnp7/Z4agONSmX2OXYDzDbUpl9jliAAAAAAAAAAAAAAAAAAAsVmd9o4KVm0/jeIiI2gHnGupp/2vjIAABpp6e/2TT09/s8NQAAAAHGpTL7HLsB5htqUy+xyxAAAAAAAAAAAAAAAWlZtP4UrNp/G8RFY2gCIiI2hQAZ6mn/a+NAHmaaenv8AZ4dzp1m2/wDjoAAAAAAAABxqUy+xy7AeYbalMvscsQAAAAAAAAAAFpWbT+FKzafxvEREbQBEREbQoAAAAAAAAAAAAAAAAAONSmX2OXYDzDbUpl9jliAAAAAAAtKzafxaVm0/jaIiI2gCIiI2hQAAAAAAAAAAAAAAAAAAAAAcalMvscuwHmG2pTL7HLEAAAAFi0xxMwZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6ZW7T6gC5W7T6kzvyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/Z" width=` + dim + ` height=` + dim + ` style="border-radius: 6%;" title="`+alttxt+`" alt="` + pend_txt + `"><div class=\"loader2\"></div><div class=\"imagelabel\">` + waittime + `</div></div>` + suffix;
} else { } else {
let imghash = cyrb_hash(data).trim(); let imghash = cyrb_hash(data).trim();
if (completed_imgs_meta[imghash] != null) { if (completed_imgs_meta[imghash] != null) {
alttxt = completed_imgs_meta[imghash].prompt?escapeHtml(completed_imgs_meta[imghash].prompt):""; alttxt = completed_imgs_meta[imghash].prompt?escapeHtml(completed_imgs_meta[imghash].prompt):"";
} }
return `<div class="`+siclass+reinvertcolor+`"><img src="` + data + `" width=` + dim + ` height=` + dim + ` title="`+alttxt+`" style="border-radius: 6%; cursor: pointer;" onclick="return click_image(this,\'`+imghash+`\');"></div>`; return `<div class="`+siclass+reinvertcolor+`"><img src="` + data + `" width=` + dim + ` height=` + dim + ` title="`+alttxt+`" style="border-radius: 6%; cursor: pointer;" onclick="return click_image(this,\'`+imghash+`\');"></div>` + suffix;
} }
} }
@ -10611,7 +10654,8 @@ Current version: 113
let newstr = "[<|d|" + img.result + "|d|>]"; let newstr = "[<|d|" + img.result + "|d|>]";
console.log("Replacing with Image: " + matchstr); console.log("Replacing with Image: " + matchstr);
gametext_arr[i] = gametext_arr[i].replace(matchstr, newstr); gametext_arr[i] = gametext_arr[i].replace(matchstr, newstr);
completed_imgs_meta[cyrb_hash(img.result)] = {prompt:image_db[key].prompt, desc:"", enabled:false}; let metaid = cyrb_hash(img.result);
completed_imgs_meta[metaid] = {prompt:image_db[key].prompt, desc:"", enabled:false};
delete image_db[key]; delete image_db[key];
} }
} }
@ -10969,13 +11013,30 @@ Current version: 113
} }
} }
function unstash_image_placeholders(text)
{
return text.replace(/{{\[IMG_.{1,8}_REF\]}}/g, function (m) {
let imghash = m.substring(7, m.length - 7);
if(!imghash)
{
return m;
}
let unstash = img_hash_to_b64_lookup[imghash];
if(!unstash)
{
return m;
}
return unstash;
});
}
function merge_edit_field() { function merge_edit_field() {
if (gametext_arr.length > 0 && document.getElementById("allowediting").checked) { if (gametext_arr.length > 0 && document.getElementById("allowediting").checked) {
let oldInnerText = concat_gametext(true, "\n","",""); let oldInnerText = concat_gametext(false, "","","");
let gametext_elem = document.getElementById("gametext"); let gametext_elem = document.getElementById("gametext");
let edited = gametext_elem.innerText; let editedmatcher = unstash_image_placeholders(gametext_elem.innerText);
if (oldInnerText != edited) { if (oldInnerText != editedmatcher) {
gametext_arr = []; gametext_arr = [];
redo_arr = []; redo_arr = [];
last_reply_was_empty = false; last_reply_was_empty = false;
@ -10984,7 +11045,7 @@ Current version: 113
redo_prev_text = ""; redo_prev_text = "";
//stash images //stash images
gametext_elem.querySelectorAll('div.storyimg,div.storyimgfloat').forEach( gametext_elem.querySelectorAll('div.storyimgcenter,div.storyimgside,div.storyimgfloat').forEach(
(el) => { (el) => {
let chimg = el.getElementsByTagName("img")[0]; let chimg = el.getElementsByTagName("img")[0];
if(el && chimg) if(el && chimg)
@ -10994,6 +11055,9 @@ Current version: 113
} }
); );
//replace b64 image placeholders
gametext_elem.innerHTML = unstash_image_placeholders(gametext_elem.innerHTML);
let editedChunks = []; //use to count chunk lengths before merging let editedChunks = []; //use to count chunk lengths before merging
gametext_elem.querySelectorAll('span.txtchunk').forEach( gametext_elem.querySelectorAll('span.txtchunk').forEach(
(el) => { (el) => {
@ -11418,19 +11482,36 @@ Current version: 113
fulltxt += "<span class=\"color_yellow pending_text\">" + escapeHtml(pending_context_preinjection) + escapeHtml(synchro_pending_stream) + "</span>"; fulltxt += "<span class=\"color_yellow pending_text\">" + escapeHtml(pending_context_preinjection) + escapeHtml(synchro_pending_stream) + "</span>";
} }
if(!inEditMode)
{
let floatimg = (localsettings.opmode!=4);
//handle images //handle images
fulltxt = fulltxt.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) { fulltxt = fulltxt.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) {
// m here means the whole matched string // m here means the whole matched string
let inner = m.substring(5, m.length - 5); let inner = m.substring(5, m.length - 5);
inner = render_image_html("", inner); inner = render_image_html("", inner,floatimg,false);
return inner; return inner;
}); });
fulltxt = fulltxt.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) { fulltxt = fulltxt.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) {
// m here means the whole matched string // m here means the whole matched string
let inner = m.substring(5, m.length - 5); let inner = m.substring(5, m.length - 5);
inner = render_image_html(inner, ""); inner = render_image_html(inner, "",floatimg,false);
return inner; return inner;
}); });
}
else
{
fulltxt = fulltxt.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) {
return `<span class=\"color_pink\">`+m+`</span>`;
});
fulltxt = fulltxt.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) {
let inner = m.substring(5, m.length - 5);
let imghash = cyrb_hash(inner);
img_hash_to_b64_lookup[imghash] = m;
return `<span class=\"color_pink\">{{[IMG_${imghash}_REF]}}</span>`;
});
}
fulltxt = fulltxt.replace(/(\r\n|\r|\n)/g, '<br>'); fulltxt = fulltxt.replace(/(\r\n|\r|\n)/g, '<br>');
@ -11642,9 +11723,10 @@ Current version: 113
for(var i=0;i<input.length;++i) for(var i=0;i<input.length;++i)
{ {
let tempfullsearchable = input[i]; let tempfullsearchable = input[i]; //strip out images
var foundopponent = tempfullsearchable.match(othernamesregex); let txtwithnoimages = tempfullsearchable.replace(/\[<\|.+?\|>\]/g, "");
var foundself = tempfullsearchable.match(mynameregex); var foundopponent = txtwithnoimages.match(othernamesregex);
var foundself = txtwithnoimages.match(mynameregex);
if(tempfullsearchable==null) if(tempfullsearchable==null)
{ {
@ -11710,13 +11792,13 @@ Current version: 113
curr.msg = curr.msg.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) { curr.msg = curr.msg.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) {
// m here means the whole matched string // m here means the whole matched string
let inner = m.substring(5, m.length - 5); let inner = m.substring(5, m.length - 5);
inner = render_image_html("", inner,false); inner = render_image_html("", inner,false,true);
return inner; return inner;
}); });
curr.msg = curr.msg.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) { curr.msg = curr.msg.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) {
// m here means the whole matched string // m here means the whole matched string
let inner = m.substring(5, m.length - 5); let inner = m.substring(5, m.length - 5);
inner = render_image_html(inner, "",false); inner = render_image_html(inner, "",false,true);
return inner; return inner;
}); });
curr.msg = curr.msg.replace(/\[<\|.+?\|>\]/g, ""); //remove normal comments too curr.msg = curr.msg.replace(/\[<\|.+?\|>\]/g, ""); //remove normal comments too
@ -12647,13 +12729,13 @@ Current version: 113
newbodystr = newbodystr.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) { newbodystr = newbodystr.replace(/\[<\|p\|.+?\|p\|>\]/g, function (m) {
// m here means the whole matched string // m here means the whole matched string
let inner = m.substring(5, m.length - 5); let inner = m.substring(5, m.length - 5);
inner = render_image_html("", inner,false); inner = render_image_html("", inner,false,true);
return inner; return inner;
}); });
newbodystr = newbodystr.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) { newbodystr = newbodystr.replace(/\[<\|d\|.+?\|d\|>\]/g, function (m) {
// m here means the whole matched string // m here means the whole matched string
let inner = m.substring(5, m.length - 5); let inner = m.substring(5, m.length - 5);
inner = render_image_html(inner, "",false); inner = render_image_html(inner, "",false,true);
return inner; return inner;
}); });
return portraitsStyling + newbodystr.replaceAll(/(\r\n|\r|\n)/g,'<br>'); // Finally, convert newlines to HTML format and return the stylized string. return portraitsStyling + newbodystr.replaceAll(/(\r\n|\r|\n)/g,'<br>'); // Finally, convert newlines to HTML format and return the stylized string.
@ -13558,6 +13640,10 @@ Current version: 113
</table> </table>
</div> </div>
<div id="mirounsupporteddiv" class="color_red" style="font-weight:bold;padding:3px;font-size:12px">Mirostat Not Supported</div> <div id="mirounsupporteddiv" class="color_red" style="font-weight:bold;padding:3px;font-size:12px">Mirostat Not Supported</div>
<div class="settinglabel">
<div class="justifyleft settingsmall">User Mods <span class="helpicon">?<span class="helptext">Allows you to load third-party user created mods (caution).</span></span></div>
<button id="loadusermod" type="button" class="btn btn-primary" style="padding:2px 3px;margin-top:2px;font-size:11px;" onclick="apply_user_mod()">Apply User Mod</button>
</div>
</div> </div>
</div> </div>
@ -13850,6 +13936,7 @@ Current version: 113
</span> </span>
</div> </div>
<div style="display: flex; column-gap: 4px;">
<input class="form-control anotetempbox" type="text" <input class="form-control anotetempbox" type="text"
placeholder="(the &lt;|&gt; will be replaced with the Author's Note text)" value="" id="anotetemplate"> placeholder="(the &lt;|&gt; will be replaced with the Author's Note text)" value="" id="anotetemplate">
<select style="padding:4px;" class="anotetempscale form-control" id="anote_strength"> <select style="padding:4px;" class="anotetempscale form-control" id="anote_strength">
@ -13858,13 +13945,15 @@ Current version: 113
<option value="160">Strong</option> <option value="160">Strong</option>
<option value="0">Immediate</option> <option value="0">Immediate</option>
</select> </select>
<br><br> </div>
<br>
<div class="justifyleft settinglabel">Extra Stopping Sequences <span class="helpicon">?<span <div class="justifyleft settinglabel">Extra Stopping Sequences <span class="helpicon">?<span
class="helptext">Triggers the text generator to stop generating early if this sequence appears, in addition to default stop sequences. If you want multiple sequences, separate them with the following delimiter: ||$||</span></span></div> class="helptext">Triggers the text generator to stop generating early if this sequence appears, in addition to default stop sequences. If you want multiple sequences, separate them with the following delimiter: ||$||</span></span></div>
<div class="color_red hidden" id="noextrastopseq">Stop Sequences may be unavailable.</div> <div class="color_red hidden" id="noextrastopseq">Stop Sequences may be unavailable.</div>
<div style="display: flex; column-gap: 4px; margin-bottom: 4px;">
<input class="form-control stopseqbox" type="text" placeholder="None" value="" id="extrastopseq"> <input class="form-control stopseqbox" type="text" placeholder="None" value="" id="extrastopseq">
<button type="button" class="btn btn-primary" style="width:104px;padding:6px 6px;margin-bottom: 4px;" id="btnlogitbias" onclick="set_logit_bias()">Logit Biases</button> <button type="button" class="btn btn-primary" style="width:104px;padding:6px 6px;" id="btnlogitbias" onclick="set_logit_bias()">Logit Biases</button>
<br> </div>
<div class="popupfooter"> <div class="popupfooter">
<button type="button" class="btn btn-primary" onclick="confirm_memory()">OK</button> <button type="button" class="btn btn-primary" onclick="confirm_memory()">OK</button>
<button type="button" class="btn btn-primary" onclick="hide_popups()">Cancel</button> <button type="button" class="btn btn-primary" onclick="hide_popups()">Cancel</button>

View file

@ -466,7 +466,7 @@ maxhordelen = 256
modelbusy = threading.Lock() modelbusy = threading.Lock()
requestsinqueue = 0 requestsinqueue = 0
defaultport = 5001 defaultport = 5001
KcppVersion = "1.58" KcppVersion = "1.59"
showdebug = True showdebug = True
showsamplerwarning = True showsamplerwarning = True
showmaxctxwarning = True showmaxctxwarning = True
@ -484,6 +484,7 @@ gui_layers_untouched = True
runmode_untouched = True runmode_untouched = True
preloaded_story = None preloaded_story = None
sslvalid = False sslvalid = False
nocertify = False
start_time = time.time() start_time = time.time()
class ServerRequestHandler(http.server.SimpleHTTPRequestHandler): class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
@ -1216,6 +1217,7 @@ def show_new_gui():
debugmode = ctk.IntVar() debugmode = ctk.IntVar()
keepforeground = ctk.IntVar() keepforeground = ctk.IntVar()
quietmode = ctk.IntVar(value=0) quietmode = ctk.IntVar(value=0)
nocertifymode = ctk.IntVar(value=0)
lowvram_var = ctk.IntVar() lowvram_var = ctk.IntVar()
mmq_var = ctk.IntVar(value=1) mmq_var = ctk.IntVar(value=1)
@ -1713,6 +1715,7 @@ def show_new_gui():
makecheckbox(network_tab, "Multiuser Mode", multiuser_var, 3,tooltiptxt="Allows requests by multiple different clients to be queued and handled in sequence.") makecheckbox(network_tab, "Multiuser Mode", multiuser_var, 3,tooltiptxt="Allows requests by multiple different clients to be queued and handled in sequence.")
makecheckbox(network_tab, "Remote Tunnel", remotetunnel, 3, 1,tooltiptxt="Creates a trycloudflare tunnel.\nAllows you to access koboldcpp from other devices over an internet URL.") makecheckbox(network_tab, "Remote Tunnel", remotetunnel, 3, 1,tooltiptxt="Creates a trycloudflare tunnel.\nAllows you to access koboldcpp from other devices over an internet URL.")
makecheckbox(network_tab, "Quiet Mode", quietmode, 4,tooltiptxt="Prevents all generation related terminal output from being displayed.") makecheckbox(network_tab, "Quiet Mode", quietmode, 4,tooltiptxt="Prevents all generation related terminal output from being displayed.")
makecheckbox(network_tab, "NoCertify Mode (Insecure)", nocertifymode, 4, 1,tooltiptxt="Allows insecure SSL connections. Use this if you have cert errors and need to bypass certificate restrictions.")
makefileentry(network_tab, "SSL Cert:", "Select SSL cert.pem file",ssl_cert_var, 5, width=130 ,filetypes=[("Unencrypted Certificate PEM", "*.pem")], singlerow=True,tooltiptxt="Select your unencrypted .pem SSL certificate file for https.\nCan be generated with OpenSSL.") makefileentry(network_tab, "SSL Cert:", "Select SSL cert.pem file",ssl_cert_var, 5, width=130 ,filetypes=[("Unencrypted Certificate PEM", "*.pem")], singlerow=True,tooltiptxt="Select your unencrypted .pem SSL certificate file for https.\nCan be generated with OpenSSL.")
makefileentry(network_tab, "SSL Key:", "Select SSL key.pem file", ssl_key_var, 7, width=130, filetypes=[("Unencrypted Key PEM", "*.pem")], singlerow=True,tooltiptxt="Select your unencrypted .pem SSL key file for https.\nCan be generated with OpenSSL.") makefileentry(network_tab, "SSL Key:", "Select SSL key.pem file", ssl_key_var, 7, width=130, filetypes=[("Unencrypted Key PEM", "*.pem")], singlerow=True,tooltiptxt="Select your unencrypted .pem SSL key file for https.\nCan be generated with OpenSSL.")
@ -1764,6 +1767,7 @@ def show_new_gui():
args.remotetunnel = remotetunnel.get()==1 args.remotetunnel = remotetunnel.get()==1
args.foreground = keepforeground.get()==1 args.foreground = keepforeground.get()==1
args.quiet = quietmode.get()==1 args.quiet = quietmode.get()==1
args.nocertify = nocertifymode.get()==1
gpuchoiceidx = 0 gpuchoiceidx = 0
if gpu_choice_var.get()!="All": if gpu_choice_var.get()!="All":
@ -1816,7 +1820,6 @@ def show_new_gui():
args.ssl = None if (ssl_cert_var.get() == "" or ssl_key_var.get() == "") else ([ssl_cert_var.get(), ssl_key_var.get()]) args.ssl = None if (ssl_cert_var.get() == "" or ssl_key_var.get() == "") else ([ssl_cert_var.get(), ssl_key_var.get()])
args.port_param = defaultport if port_var.get()=="" else int(port_var.get()) args.port_param = defaultport if port_var.get()=="" else int(port_var.get())
args.host = host_var.get() args.host = host_var.get()
args.multiuser = multiuser_var.get() args.multiuser = multiuser_var.get()
@ -1840,6 +1843,7 @@ def show_new_gui():
remotetunnel.set(1 if "remotetunnel" in dict and dict["remotetunnel"] else 0) remotetunnel.set(1 if "remotetunnel" in dict and dict["remotetunnel"] else 0)
keepforeground.set(1 if "foreground" in dict and dict["foreground"] else 0) keepforeground.set(1 if "foreground" in dict and dict["foreground"] else 0)
quietmode.set(1 if "quiet" in dict and dict["quiet"] else 0) quietmode.set(1 if "quiet" in dict and dict["quiet"] else 0)
nocertifymode.set(1 if "nocertify" in dict and dict["nocertify"] else 0)
if "useclblast" in dict and dict["useclblast"]: if "useclblast" in dict and dict["useclblast"]:
if "noavx2" in dict and dict["noavx2"]: if "noavx2" in dict and dict["noavx2"]:
if clblast_noavx2_option is not None: if clblast_noavx2_option is not None:
@ -2024,9 +2028,14 @@ def print_with_time(txt):
print(f"{datetime.now().strftime('[%H:%M:%S]')} " + txt) print(f"{datetime.now().strftime('[%H:%M:%S]')} " + txt)
def make_url_request(url, data, method='POST', headers={}): def make_url_request(url, data, method='POST', headers={}):
import urllib.request import urllib.request, ssl
global nocertify
try: try:
request = None request = None
ssl_context = ssl.create_default_context()
if nocertify:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
if method=='POST': if method=='POST':
json_payload = json.dumps(data).encode('utf-8') json_payload = json.dumps(data).encode('utf-8')
request = urllib.request.Request(url, data=json_payload, headers=headers, method=method) request = urllib.request.Request(url, data=json_payload, headers=headers, method=method)
@ -2034,7 +2043,7 @@ def make_url_request(url, data, method='POST', headers={}):
else: else:
request = urllib.request.Request(url, headers=headers, method=method) request = urllib.request.Request(url, headers=headers, method=method)
response_data = "" response_data = ""
with urllib.request.urlopen(request) as response: with urllib.request.urlopen(request,context=ssl_context) as response:
response_data = response.read().decode('utf-8') response_data = response.read().decode('utf-8')
json_response = json.loads(response_data) json_response = json.loads(response_data)
return json_response return json_response
@ -2433,6 +2442,10 @@ def main(launch_args,start_server=True):
global maxctx global maxctx
maxctx = args.contextsize maxctx = args.contextsize
if args.nocertify:
global nocertify
nocertify = True
init_library() # Note: if blas does not exist and is enabled, program will crash. init_library() # Note: if blas does not exist and is enabled, program will crash.
print("==========") print("==========")
time.sleep(1) time.sleep(1)
@ -2668,6 +2681,7 @@ if __name__ == '__main__':
parser.add_argument("--preloadstory", help="Configures a prepared story json save file to be hosted on the server, which frontends (such as Kobold Lite) can access over the API.", default="") parser.add_argument("--preloadstory", help="Configures a prepared story json save file to be hosted on the server, which frontends (such as Kobold Lite) can access over the API.", default="")
parser.add_argument("--quiet", help="Enable quiet mode, which hides generation inputs and outputs in the terminal. Quiet mode is automatically enabled when running --hordeconfig.", action='store_true') parser.add_argument("--quiet", help="Enable quiet mode, which hides generation inputs and outputs in the terminal. Quiet mode is automatically enabled when running --hordeconfig.", action='store_true')
parser.add_argument("--ssl", help="Allows all content to be served over SSL instead. A valid UNENCRYPTED SSL cert and key .pem files must be provided", metavar=('[cert_pem]', '[key_pem]'), nargs='+') parser.add_argument("--ssl", help="Allows all content to be served over SSL instead. A valid UNENCRYPTED SSL cert and key .pem files must be provided", metavar=('[cert_pem]', '[key_pem]'), nargs='+')
parser.add_argument("--nocertify", help="Allows insecure SSL connections. Use this if you have cert errors and need to bypass certificate restrictions.", action='store_true')
# #deprecated hidden args. they do nothing. do not use # #deprecated hidden args. they do nothing. do not use
# parser.add_argument("--psutil_set_threads", action='store_true', help=argparse.SUPPRESS) # parser.add_argument("--psutil_set_threads", action='store_true', help=argparse.SUPPRESS)