Skip to content

Commit c5ea7fa

Browse files
committed
updated lite, only show processed input in debugmode
1 parent b686f4b commit c5ea7fa

File tree

2 files changed

+141
-27
lines changed

2 files changed

+141
-27
lines changed

klite.embd

Lines changed: 135 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,6 +3022,9 @@ Current version indicated by LITEVER below.
30223022
const pollinations_text_endpoint = "https://text.pollinations.ai/openai";
30233023
const dummy_pollinations_key = "kobo";
30243024

3025+
//for optionally uploading content to share on dpaste
3026+
const dpaste_fetch_endpoint = "https://dpaste.org/";
3027+
30253028
//support for quick news updates
30263029
const horde_news_endpoint = "https://hordenews.concedo.workers.dev"
30273030

@@ -3173,6 +3176,7 @@ Current version indicated by LITEVER below.
31733176
var mainmenu_is_untab = false;
31743177
var websearch_in_progress = false;
31753178
var kcpp_tts_json = "";
3179+
var avoidwelcome = false;
31763180

31773181
var localsettings = {
31783182
my_api_key: "0000000000", //put here so it can be saved and loaded in persistent mode
@@ -4085,8 +4089,11 @@ Current version indicated by LITEVER below.
40854089
} else {
40864090
console.log("Skipped missing local save");
40874091
loadok = false;
4088-
//show welcome
4089-
show_welcome_panel();
4092+
if(!avoidwelcome)
4093+
{
4094+
//show welcome
4095+
show_welcome_panel();
4096+
}
40904097
}
40914098
populate_corpo_leftpanel();
40924099
update_toggle_lightmode(false); //load theme but dont save or toggle it
@@ -5785,6 +5792,7 @@ Current version indicated by LITEVER below.
57855792
{
57865793
//read the url params, and autoload a shared story if found
57875794
const foundStory = urlParams.get('s');
5795+
const foundDpaste = urlParams.get('dp');
57885796
const foundScenario = urlParams.get('scenario');
57895797
const foundScenarioSource = scenario_sources.find(scenario => urlParams.get(scenario.urlParam))
57905798

@@ -5795,13 +5803,50 @@ Current version indicated by LITEVER below.
57955803
}
57965804

57975805
if (foundStory && foundStory != "") {
5806+
avoidwelcome = true;
57985807
if (localsettings.persist_session && !safe_to_overwrite()) {
57995808
import_compressed_story_prompt_overwrite(foundStory);
58005809
} else {
58015810
import_compressed_story(foundStory, false);
58025811
}
58035812
//purge url params
58045813
window.history.replaceState(null, null, window.location.pathname);
5814+
} else if (foundDpaste && foundDpaste != "") {
5815+
avoidwelcome = true;
5816+
let dpurl = `${dpaste_fetch_endpoint}${foundDpaste}`;
5817+
if(foundDpaste.includes(".")||foundDpaste.includes("/"))
5818+
{
5819+
dpurl = `${foundDpaste}`;
5820+
if(!foundDpaste.includes("http"))
5821+
{
5822+
dpurl = `https://${foundDpaste}`
5823+
}
5824+
}
5825+
fetch(`${dpurl}/raw`)
5826+
.then(x => {
5827+
if(x.ok)
5828+
{
5829+
return x.text();
5830+
}else{
5831+
throw new Error('Error loading dpaste: ' + (x.statusText));
5832+
return null;
5833+
}
5834+
})
5835+
.then(data => {
5836+
if(data && data!="")
5837+
{
5838+
if (localsettings.persist_session && !safe_to_overwrite()) {
5839+
import_compressed_story_prompt_overwrite(data);
5840+
} else {
5841+
import_compressed_story(data, false);
5842+
}
5843+
}
5844+
}).catch((error) => {
5845+
console.log("Error: " + error);
5846+
msgbox("The shared URL provided is invalid or expired.");
5847+
});
5848+
//purge url params
5849+
window.history.replaceState(null, null, window.location.pathname);
58055850
} else if (foundScenario && foundScenario != "") {
58065851
display_scenarios();
58075852
document.getElementById("scenariosearch").value = escape_html(foundScenario);
@@ -6548,28 +6593,25 @@ Current version indicated by LITEVER below.
65486593
let cstoryjson = "";
65496594

65506595
document.getElementById("sharecontainer").classList.remove("hidden");
6551-
document.getElementById("sharewarning").classList.add("hidden");
6596+
document.getElementById("shareastext").classList.add("hidden");
6597+
document.getElementById("shareasurl").classList.add("hidden");
6598+
65526599
if(sharetype==0) //base64 data
65536600
{
6601+
document.getElementById("shareastext").classList.remove("hidden");
65546602
cstoryjson = generate_compressed_story(localsettings.save_images,localsettings.export_settings,localsettings.export_settings);
65556603
console.log("Export Len: " + cstoryjson.length);
65566604
document.getElementById("sharecontainertitle").innerText = "Share Story as TextData";
65576605
document.getElementById("sharestorytext").innerHTML = "<p>"+cstoryjson+"</p>";
65586606
}
65596607
else if(sharetype==1) //url share
65606608
{
6561-
cstoryjson = generate_compressed_story(false,localsettings.export_settings,false);
6562-
console.log("Export Len: " + cstoryjson.length);
6609+
document.getElementById("shareasurl").classList.remove("hidden");
65636610
document.getElementById("sharecontainertitle").innerText = "Share Story as URL";
6564-
if (cstoryjson.length >= 4800) {
6565-
document.getElementById("sharewarning").classList.remove("hidden");
6566-
}
6567-
6568-
let fullurl = "https://lite.koboldai.net/?s=" + cstoryjson;
6569-
document.getElementById("sharestorytext").innerHTML = "<a href=\"" + fullurl + "\">" + fullurl + "</a>";
65706611
}
65716612
else
65726613
{
6614+
document.getElementById("shareastext").classList.remove("hidden");
65736615
cstoryjson = share_plaintext();
65746616
cstoryjson = replaceAll(cstoryjson,"\n","<br>",false);
65756617
console.log("Export Len: " + cstoryjson.length);
@@ -6578,7 +6620,7 @@ Current version indicated by LITEVER below.
65786620
}
65796621
document.getElementById("choosesharecontainer").classList.add("hidden");
65806622
}
6581-
function copy_share_url() {
6623+
function copy_shared_text() {
65826624
var copyText = document.getElementById("sharestorytext");
65836625

65846626
// Select the text field
@@ -6587,6 +6629,54 @@ Current version indicated by LITEVER below.
65876629
// Copy the text inside the text field
65886630
navigator.clipboard.writeText(copyText.innerText);
65896631
}
6632+
function upload_to_dpaste()
6633+
{
6634+
let serverurl = document.getElementById("dpaste_server_url").value;
6635+
let cstoryjson = generate_compressed_story(false,localsettings.export_settings,false);
6636+
if(serverurl=="")
6637+
{
6638+
document.getElementById("shareasurl").classList.add("hidden");
6639+
document.getElementById("shareastext").classList.remove("hidden");
6640+
let fullurl = "https://lite.koboldai.net/?s=" + cstoryjson;
6641+
document.getElementById("sharestorytext").innerHTML = "<a href=\"" + fullurl + "\">" + fullurl + "</a>";
6642+
return;
6643+
}
6644+
6645+
msgboxYesNo("Really upload current story? This action cannot be undone.","Confirm Upload Story",()=>{
6646+
let expiry = document.getElementById("dpaste_duration").value;
6647+
console.log("Export Len: " + cstoryjson.length);
6648+
const params = new URLSearchParams();
6649+
params.append("content", cstoryjson);
6650+
params.append("expiry", expiry);
6651+
fetch(serverurl, {
6652+
method: 'POST',
6653+
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
6654+
body: params.toString(),
6655+
})
6656+
.then(x => {
6657+
if(x.ok)
6658+
{
6659+
return x.text();
6660+
}else{
6661+
throw new Error('Error uploading dpaste: ' + (x.statusText));
6662+
return null;
6663+
}
6664+
})
6665+
.then((text) => {
6666+
let pasteurl = replaceAll(text,"\"","");
6667+
pasteurl = pasteurl.split("/");
6668+
pasteurl = pasteurl[pasteurl.length-1];
6669+
let fullurl = "https://lite.koboldai.net/?dp=" + pasteurl;
6670+
document.getElementById("shareasurl").classList.add("hidden");
6671+
document.getElementById("shareastext").classList.remove("hidden");
6672+
document.getElementById("sharestorytext").innerHTML = "<a href=\"" + fullurl + "\">" + fullurl + "</a>";
6673+
})
6674+
.catch((error) => {
6675+
msgbox(`Unable to upload story: ${error}`);
6676+
console.error('Error:', error);
6677+
});
6678+
},()=>{});
6679+
}
65906680

65916681

65926682
function generate_base_storyobj() {
@@ -22099,7 +22189,7 @@ Current version indicated by LITEVER below.
2209922189

2210022190
<div class="settingitem">
2210122191
<div class="settinglabel">
22102-
<div class="justifyleft settingsmall">Top-K Sampling <span class="helpicon">?<span class="helptext">Top-K Sampling. Discards all but the K most likely tokens. Set 0 to Deactivate.</span></span></div>
22192+
<div class="justifyleft settingsmall">Top-K Sampling <span class="helpicon">?<span class="helptext">Top-K Sampling. Discards all but the K most likely tokens. Set 0 to Deactivate. Range 0 to 100.</span></span></div>
2210322193
<input title="Top-K Sampling"inputmode="decimal" class="justifyright flex-push-right settingsmall" id="top_k" oninput="
2210422194
document.getElementById('top_k_slide').value = this.value;">
2210522195
</div>
@@ -22117,27 +22207,27 @@ Current version indicated by LITEVER below.
2211722207
</div>
2211822208
<div style="display:flex;width:100%;">
2211922209
<div class="settinglabel settingcell">
22120-
<div title="Top-A Sampling. 0 to Deactivate." class="justifyleft settingsmall" style="width:100%">Top-A</div>
22210+
<div title="Top-A Sampling. 0 to Deactivate. Range 0 to 1." class="justifyleft settingsmall" style="width:100%">Top-A</div>
2212122211
<div class="justifyleft settingsmall" style="width:100%">
2212222212
<input title="Top-A Sampling" class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="top_a"></div>
2212322213
</div>
2212422214
<div class="settinglabel settingcell">
22125-
<div title="Typical Sampling. 1 to Deactivate." class="justifyleft settingsmall" style="width:100%">Typical</div>
22215+
<div title="Typical Sampling. 1 to Deactivate. Range 0 to 1." class="justifyleft settingsmall" style="width:100%">Typical</div>
2212622216
<div class="justifyleft settingsmall" style="width:100%">
2212722217
<input title="Typical Sampling"class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="typ_s"></div>
2212822218
</div>
2212922219
<div class="settinglabel settingcell">
22130-
<div title="Tail-Free Sampling. 1 to Deactivate." class="justifyleft settingsmall" style="width:100%">TFS</div>
22220+
<div title="Tail-Free Sampling. 1 to Deactivate. Range 0 to 1." class="justifyleft settingsmall" style="width:100%">TFS</div>
2213122221
<div class="justifyleft settingsmall" style="width:100%">
2213222222
<input title="Tail-Free Sampling" class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="tfs_s"></div>
2213322223
</div>
2213422224
<div class="settinglabel settingcell">
22135-
<div title="Min-P Sampling. 0 to Deactivate." class="justifyleft settingsmall" style="width:100%">Min-P</div>
22225+
<div title="Min-P Sampling. 0 to Deactivate. Range 0 to 1." class="justifyleft settingsmall" style="width:100%">Min-P</div>
2213622226
<div class="justifyleft settingsmall" style="width:100%">
2213722227
<input title="Min-P Sampling" class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="min_p"></div>
2213822228
</div>
2213922229
<div class="settinglabel settingcell">
22140-
<div title="Presence Penalty. 0 to Deactivate." class="justifyleft settingsmall" style="width:100%">Pr. Pen.</div>
22230+
<div title="Presence Penalty. 0 to Deactivate. Range -2 to 2." class="justifyleft settingsmall" style="width:100%">Pr. Pen.</div>
2214122231
<div class="justifyleft settingsmall" style="width:100%">
2214222232
<input title="Presence Penalty" class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="presence_penalty"></div>
2214322233
</div>
@@ -22293,9 +22383,9 @@ Current version indicated by LITEVER below.
2229322383
</div>
2229422384
</div>
2229522385
<div class="settinglabel settingcell">
22296-
<div title="Top N Sigma. 0 to deactivate." class="justifyleft settingsmall" style="width:100%">T.NSigma</div>
22386+
<div title="Top N Sigma. 0 to deactivate. Range 0 to 5." class="justifyleft settingsmall" style="width:100%">T.NSigma</div>
2229722387
<div class="justifyleft settingsmall" style="width:100%">
22298-
<input title="Top N Sigma. 0 to deactivate." class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="nsigma"></div>
22388+
<input title="Top N Sigma. 0 to deactivate. Range 0 to 5." class="settinglabel miniinput" type="text" inputmode="decimal" placeholder="0" value="0" id="nsigma"></div>
2229922389
</div>
2230022390
</div>
2230122391
</div>
@@ -23726,14 +23816,36 @@ Current version indicated by LITEVER below.
2372623816
<div class="popuptitlebar">
2372723817
<div class="popuptitletext" id="sharecontainertitle">Share Story</div>
2372823818
</div>
23819+
<div id="shareastext">
2372923820
<div class="menutext shareStory" id="sharestorytext" style=" word-wrap: break-word;">
23730-
2373123821
</div>
2373223822
<div class="popupfooter">
23733-
<button type="button" class="btn btn-primary" onclick="copy_share_url()">Copy</button>
23823+
<button type="button" class="btn btn-primary" onclick="copy_shared_text()">Copy</button>
23824+
<button type="button" class="btn btn-primary" onclick="hide_popups()">Close</button>
23825+
</div>
23826+
</div>
23827+
<div id="shareasurl" class="hidden">
23828+
<div class="inlinelabel">
23829+
<h3>Please Note</h3>
23830+
<p>Clicking the button below will <b>upload</b> your current story to <b><a href="https://dpaste.org/about/" target="_blank" class="color_blueurl">dpaste.org</a></b> where it will be <u><b>publically available</b></u> to <i>anyone</i> who has the link.</p>
23831+
<p>Once shared, the file will be available online, and cannot be removed until it expires! Therefore, you're not recommended to use this service for any senstive content.</p>
23832+
<p class="color_red">Disclaimer: KoboldAI is not associated with dpaste.org, you are personally responsible for whatever you upload or share to their service.</p>
23833+
<div style="width:100%">
23834+
<input class="settinglabel" style="padding:2px;margin:0px;margin-bottom: 4px; width:100%" type="text" placeholder="(dPaste Server URL)" value="https://dpaste.org/api/" id="dpaste_server_url">
23835+
<select class="form-control" id="dpaste_duration" style="width:100%">
23836+
<option value="3600">Expires in 1 hour</option>
23837+
<option value="86400" selected>Expires in 1 day</option>
23838+
<option value="604800">Expires in 1 week</option>
23839+
<option value="2592000">Expires in 1 month</option>
23840+
<option value="never">Permanent</option>
23841+
</select>
23842+
</div>
23843+
<div class="popupfooter">
23844+
<button type="button" class="btn btn-primary" onclick="upload_to_dpaste()">Upload</button>
2373423845
<button type="button" class="btn btn-primary" onclick="hide_popups()">Close</button>
2373523846
</div>
23736-
<div class="box-label hidden" id="sharewarning">Warning: This story is very long. It may not load in some browsers. You should save it as a file instead.</div>
23847+
</div>
23848+
</div>
2373723849
</div>
2373823850
</div>
2373923851

koboldcpp.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,14 +3475,16 @@ def do_POST(self):
34753475
trunc_len = 8000
34763476
if args.debugmode >= 1:
34773477
trunc_len = 16000
3478-
printablegenparams_raw = truncate_long_json(genparams,trunc_len)
3479-
utfprint("\nReceived Raw Input: " + json.dumps(printablegenparams_raw),1)
3478+
3479+
printablegenparams_raw = truncate_long_json(genparams,trunc_len)
3480+
utfprint("\nInput: " + json.dumps(printablegenparams_raw),1)
34803481

34813482
# transform genparams (only used for text gen) first
34823483
genparams = transform_genparams(genparams, api_format)
34833484

3484-
printablegenparams = truncate_long_json(genparams,trunc_len)
3485-
utfprint("\nInput: " + json.dumps(printablegenparams),1)
3485+
if args.debugmode >= 1:
3486+
printablegenparams = truncate_long_json(genparams,trunc_len)
3487+
utfprint("\nAdapted Input: " + json.dumps(printablegenparams),1)
34863488

34873489
if args.foreground:
34883490
bring_terminal_to_foreground()

0 commit comments

Comments
 (0)