From 6181b46eefd508e5ce8900e419aa01ece2d68aee Mon Sep 17 00:00:00 2001
From: Concedo <39025047+LostRuins@users.noreply.github.com>
Date: Mon, 19 Feb 2024 16:05:17 +0800
Subject: [PATCH] added nocertify mode
---
class.py | 2 +-
klite.embd | 181 ++++++++++++++++++++++++++++++++++++++-------------
koboldcpp.py | 22 +++++--
3 files changed, 154 insertions(+), 51 deletions(-)
diff --git a/class.py b/class.py
index fc90d35fc..f2f8432d1 100644
--- a/class.py
+++ b/class.py
@@ -273,7 +273,7 @@ class model_backend(InferenceModel):
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,
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
diff --git a/klite.embd b/klite.embd
index 469bfca7d..9a17dc57e 100644
--- a/klite.embd
+++ b/klite.embd
@@ -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.
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.
-Current version: 113
+Current version: 114
-Concedo
-->
@@ -108,8 +108,7 @@ Current version: 113
line-height: normal;
}
- body.connected #topmenu,
- #topmenu.always-available {
+ body.connected #topmenu {
background-color: #337ab7;
}
@@ -298,7 +297,7 @@ Current version: 113
.anotetempbox
{
display: inline;
- width: calc(100% - 98px);
+ width: 100%;
}
.anotetempscale
{
@@ -309,7 +308,7 @@ Current version: 113
.stopseqbox
{
display: inline;
- width: calc(100% - 110px);
+ width: 100%;
}
#popuptitlebar {
@@ -1486,12 +1485,23 @@ Current version: 113
}
.storyimgfloat
{
+ width: fit-content;
float: right;
position: relative;
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;
position: relative;
padding: 4px;
@@ -3410,6 +3420,7 @@ Current version: 113
var image_db = {}; //stores a dictionary of pending images
var interrogation_db = {};
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:""}
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
@@ -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.
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.
Want to start modding? Click here 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()
{
pending_response_id = "";
@@ -9546,11 +9575,18 @@ Current version: 113
}
}
else {
- if(oai_payload.logit_bias)
+ //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)
{
- oai_payload.logit_bias["50256"] = -100;
- }else{
- oai_payload.logit_bias = { "50256": -100 };
+ if(oai_payload.logit_bias)
+ {
+ oai_payload.logit_bias["50256"] = -100;
+ }else{
+ oai_payload.logit_bias = { "50256": -100 };
+ }
}
oai_payload.prompt = submit_payload.prompt;
}
@@ -10194,11 +10230,12 @@ Current version: 113
function update_clicked_image(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");
origprompt = escapeHtml(origprompt);
@@ -10210,6 +10247,11 @@ Current version: 113
`;
}
+ else
+ {
+ document.getElementById("zoomedimgdesc").innerText = "No Saved Data";
+ }
+
}
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
- let siclass = (float?"storyimgfloat":"storyimg");
+ let siclass = (float?"storyimgfloat":(center?"storyimgcenter":"storyimgside"));
let reinvertcolor = localsettings.invert_colors?" invert_colors":"";
let alttxt = "";
+ let suffix = ((float==false&¢er==false)?"
":"");
if (!data || data == "") {
let waittime = "Unavailable";
if (image_db[pend_txt] != null) {
@@ -10261,13 +10304,13 @@ Current version: 113
console.log("Cannot render " + pend_txt);
}
- return `