mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-11 17:44:38 +00:00
fixed bad handling for malformed requests
This commit is contained in:
parent
cfbe8cffbd
commit
010b2a5a71
2 changed files with 88 additions and 38 deletions
72
klite.embd
72
klite.embd
|
@ -7,7 +7,7 @@ Just copy this single static HTML file anywhere and open it in a browser, or fro
|
|||
Please go to https://github.com/LostRuins/lite.koboldai.net for updates on Kobold Lite.
|
||||
If you are submitting a pull request for Lite, PLEASE use the above repo, not the KoboldCpp one.
|
||||
Kobold Lite is under the AGPL v3.0 License unless otherwise exempted. Please do not remove this line.
|
||||
Current version: 132
|
||||
Current version: 133
|
||||
-Concedo
|
||||
-->
|
||||
|
||||
|
@ -5356,7 +5356,8 @@ Current version: 132
|
|||
"comment": itm.comment,
|
||||
"folder": null,
|
||||
"selective": itm.selective,
|
||||
"constant": itm.constant
|
||||
"constant": itm.constant,
|
||||
"probability":100
|
||||
};
|
||||
current_wi.push(nwi);
|
||||
}
|
||||
|
@ -5495,7 +5496,8 @@ Current version: 132
|
|||
"comment": "",
|
||||
"folder": null,
|
||||
"selective": false,
|
||||
"constant": false
|
||||
"constant": false,
|
||||
"probability":100
|
||||
};
|
||||
loadedwi.push(nwi);
|
||||
}
|
||||
|
@ -5524,7 +5526,8 @@ Current version: 132
|
|||
"comment": itm.comment,
|
||||
"folder": null,
|
||||
"selective": itm.selective,
|
||||
"constant": itm.constant
|
||||
"constant": itm.constant,
|
||||
"probability":100
|
||||
};
|
||||
loadedwi.push(nwi);
|
||||
}
|
||||
|
@ -5660,7 +5663,8 @@ Current version: 132
|
|||
"comment": "",
|
||||
"folder": null,
|
||||
"selective": false,
|
||||
"constant": false
|
||||
"constant": false,
|
||||
"probability":100
|
||||
};
|
||||
loadedwi.push(nwi);
|
||||
}
|
||||
|
@ -5718,7 +5722,8 @@ Current version: 132
|
|||
"comment": "",
|
||||
"folder": null,
|
||||
"selective": false,
|
||||
"constant": false
|
||||
"constant": false,
|
||||
"probability":100
|
||||
};
|
||||
temp_scenario.worldinfo.push(nwi);
|
||||
}
|
||||
|
@ -9992,6 +9997,18 @@ Current version: 132
|
|||
for (var x = 0; x < current_wi.length; ++x) {
|
||||
let wi = current_wi[x];
|
||||
|
||||
let shoulduse = false;
|
||||
|
||||
//see if this is a valid wi entry
|
||||
if (wi.content == null || wi.content == "") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wi.constant) {
|
||||
shoulduse = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//see if this is a valid wi entry
|
||||
if (wi.key == null || wi.key == "") {
|
||||
continue;
|
||||
|
@ -10002,11 +10019,7 @@ Current version: 132
|
|||
|
||||
let wiks = wi.key.split(",");
|
||||
|
||||
let shoulduse = false;
|
||||
if (wi.constant) {
|
||||
shoulduse = true;
|
||||
}
|
||||
else if (!wi.selective || invalidseckey) {
|
||||
if (!wi.selective || invalidseckey) {
|
||||
if (localsettings.case_sensitive_wi) {
|
||||
shoulduse = wiks.some(k => wimatch_context.includes(k.trim()));
|
||||
} else {
|
||||
|
@ -10023,13 +10036,26 @@ Current version: 132
|
|||
let t2 = wiks2.some(k => wimatch_context.includes(k.trim().toLowerCase()));
|
||||
shoulduse = (t1 && t2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (shoulduse) {
|
||||
//check if randomness less than 100%
|
||||
if(wi.probability && wi.probability<100)
|
||||
{
|
||||
let roll = Math.floor(Math.random() * 100) + 1;
|
||||
if(roll>=wi.probability)
|
||||
{
|
||||
wistr += wi.content + "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//always insert
|
||||
wistr += wi.content + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -13112,7 +13138,8 @@ Current version: 132
|
|||
"comment": "",
|
||||
"folder": null,
|
||||
"selective": false,
|
||||
"constant": false
|
||||
"constant": false,
|
||||
"probability":100
|
||||
};
|
||||
current_wi.push(ne);
|
||||
update_wi();
|
||||
|
@ -13123,6 +13150,8 @@ Current version: 132
|
|||
current_wi[i].key = document.getElementById("wikey" + i).value;
|
||||
current_wi[i].keysecondary = document.getElementById("wikeysec" + i).value;
|
||||
current_wi[i].content = document.getElementById("wival" + i).value;
|
||||
let prb = document.getElementById("wirng" + i).value;
|
||||
current_wi[i].probability = (prb?prb:100);
|
||||
}
|
||||
localsettings.case_sensitive_wi = (document.getElementById("case_sensitive_wi").checked?true:false);
|
||||
wi_searchdepth = document.getElementById("wi_searchdepth").value;
|
||||
|
@ -13150,12 +13179,13 @@ Current version: 132
|
|||
|
||||
let wilist = document.getElementById("wilist");
|
||||
let qsval = document.getElementById("wiquicksearch").value;
|
||||
selectionhtml = `<table style="border-collapse: separate; border-spacing: 1.5pt;">`;
|
||||
let selectionhtml = `<table style="border-collapse: separate; border-spacing: 1.5pt;">`;
|
||||
for (var i = 0; i < current_wi.length; ++i) {
|
||||
var curr = current_wi[i];
|
||||
var winame = escapeHtml(curr.key);
|
||||
var witxt = escapeHtml(curr.content);
|
||||
var wisec = curr.keysecondary;
|
||||
var wirngval = (curr.probability?curr.probability:100);
|
||||
|
||||
var ishidden = false;
|
||||
if(qsval!="" && !winame.toLowerCase().includes(qsval.toLowerCase()) && !witxt.toLowerCase().includes(qsval.toLowerCase()))
|
||||
|
@ -13163,6 +13193,8 @@ Current version: 132
|
|||
ishidden = true;
|
||||
}
|
||||
|
||||
let probarr = [100,90,75,50,25,10,5,1];
|
||||
|
||||
selectionhtml += `<tr class='`+ (ishidden?"hidden":"") +`' id="wirow` + i + `"><td class="col-8" style="font-size: 10px;">` +
|
||||
`<button type="button" class="btn btn-danger widelbtn" id="widel` + i + `" onclick="return del_wi(` + i + `)">X</button></td>` +
|
||||
`<td class="col-6 wiinputkeycol">
|
||||
|
@ -13170,11 +13202,19 @@ Current version: 132
|
|||
<input class="form-control wiinputkey `+ (curr.selective ? `` : `hidden`) + `" id="wikeysec` + i + `" placeholder="Sec. Key(s)" value="` + wisec + `">` + `</td>
|
||||
<td class="col-10 wiinputvalcol">
|
||||
<textarea class="form-control wiinputval" style="line-height:1.1" id="wival`+ i + `" placeholder="What To Remember" rows="3">` + witxt + `</textarea>
|
||||
</td>`+
|
||||
`
|
||||
</td>
|
||||
<td>
|
||||
<a id="wiskt`+ i + `" href="#" class=` + (curr.selective ? "witoggleron" : "witoggleroff") + ` title="Toggle Selective Key mode (if enabled, this world info entry will be included in memory only if at least one PRIMARY KEY and at least one SECONDARY KEY are both present in the story)" onclick="return toggle_wi_sk(` + i + `)">📑</a>
|
||||
<a id="wickt`+ i + `" href="#" class=` + (curr.constant ? "witoggleron" : "witoggleroff") + ` title="Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)" onclick="return toggle_wi_ck(` + i + `)">📌</a>
|
||||
<select id="wirng`+i+`" style="padding:1px; height:auto; width: 30px; appearance: none; font-size: 7pt;" class="form-control" title="Chance to trigger if allowed">`;
|
||||
|
||||
let opts = "";
|
||||
for(let n=0;n<probarr.length;++n)
|
||||
{
|
||||
opts += `<option value="`+probarr[n]+`" `+(probarr[n]==wirngval?"selected":"")+`>`+probarr[n]+`%</option>`;
|
||||
}
|
||||
selectionhtml += opts +`
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
|
16
koboldcpp.py
16
koboldcpp.py
|
@ -622,7 +622,7 @@ maxhordelen = 256
|
|||
modelbusy = threading.Lock()
|
||||
requestsinqueue = 0
|
||||
defaultport = 5001
|
||||
KcppVersion = "1.62.2"
|
||||
KcppVersion = "1.63"
|
||||
showdebug = True
|
||||
showsamplerwarning = True
|
||||
showmaxctxwarning = True
|
||||
|
@ -1155,7 +1155,11 @@ Enter Prompt:<br>
|
|||
|
||||
def do_POST(self):
|
||||
global modelbusy, requestsinqueue, currentusergenkey, totalgens, pendingabortkey
|
||||
content_length = int(self.headers['content-length'])
|
||||
contlenstr = self.headers['content-length']
|
||||
content_length = 0
|
||||
body = None
|
||||
if contlenstr:
|
||||
content_length = int(contlenstr)
|
||||
body = self.rfile.read(content_length)
|
||||
self.path = self.path.rstrip('/')
|
||||
response_body = None
|
||||
|
@ -1293,7 +1297,13 @@ Enter Prompt:<br>
|
|||
genparams = json.loads(body)
|
||||
except Exception as e:
|
||||
utfprint("Body Err: " + str(body))
|
||||
return self.send_response(503)
|
||||
self.send_response(500)
|
||||
self.end_headers(content_type='application/json')
|
||||
self.wfile.write(json.dumps({"detail": {
|
||||
"msg": "Error parsing input.",
|
||||
"type": "bad_input",
|
||||
}}).encode())
|
||||
return
|
||||
|
||||
is_quiet = args.quiet
|
||||
if (args.debugmode != -1 and not is_quiet) or args.debugmode >= 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue