From c5ea7fad93feefd737edfd98751a6fcac2bbe945 Mon Sep 17 00:00:00 2001
From: Concedo <39025047+LostRuins@users.noreply.github.com>
Date: Wed, 14 May 2025 17:46:54 +0800
Subject: [PATCH] updated lite, only show processed input in debugmode
---
klite.embd | 158 +++++++++++++++++++++++++++++++++++++++++++--------
koboldcpp.py | 10 ++--
2 files changed, 141 insertions(+), 27 deletions(-)
diff --git a/klite.embd b/klite.embd
index 46e07e090..7f0824932 100644
--- a/klite.embd
+++ b/klite.embd
@@ -3022,6 +3022,9 @@ Current version indicated by LITEVER below.
const pollinations_text_endpoint = "https://text.pollinations.ai/openai";
const dummy_pollinations_key = "kobo";
+ //for optionally uploading content to share on dpaste
+ const dpaste_fetch_endpoint = "https://dpaste.org/";
+
//support for quick news updates
const horde_news_endpoint = "https://hordenews.concedo.workers.dev"
@@ -3173,6 +3176,7 @@ Current version indicated by LITEVER below.
var mainmenu_is_untab = false;
var websearch_in_progress = false;
var kcpp_tts_json = "";
+ var avoidwelcome = false;
var localsettings = {
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.
} else {
console.log("Skipped missing local save");
loadok = false;
- //show welcome
- show_welcome_panel();
+ if(!avoidwelcome)
+ {
+ //show welcome
+ show_welcome_panel();
+ }
}
populate_corpo_leftpanel();
update_toggle_lightmode(false); //load theme but dont save or toggle it
@@ -5785,6 +5792,7 @@ Current version indicated by LITEVER below.
{
//read the url params, and autoload a shared story if found
const foundStory = urlParams.get('s');
+ const foundDpaste = urlParams.get('dp');
const foundScenario = urlParams.get('scenario');
const foundScenarioSource = scenario_sources.find(scenario => urlParams.get(scenario.urlParam))
@@ -5795,6 +5803,7 @@ Current version indicated by LITEVER below.
}
if (foundStory && foundStory != "") {
+ avoidwelcome = true;
if (localsettings.persist_session && !safe_to_overwrite()) {
import_compressed_story_prompt_overwrite(foundStory);
} else {
@@ -5802,6 +5811,42 @@ Current version indicated by LITEVER below.
}
//purge url params
window.history.replaceState(null, null, window.location.pathname);
+ } else if (foundDpaste && foundDpaste != "") {
+ avoidwelcome = true;
+ let dpurl = `${dpaste_fetch_endpoint}${foundDpaste}`;
+ if(foundDpaste.includes(".")||foundDpaste.includes("/"))
+ {
+ dpurl = `${foundDpaste}`;
+ if(!foundDpaste.includes("http"))
+ {
+ dpurl = `https://${foundDpaste}`
+ }
+ }
+ fetch(`${dpurl}/raw`)
+ .then(x => {
+ if(x.ok)
+ {
+ return x.text();
+ }else{
+ throw new Error('Error loading dpaste: ' + (x.statusText));
+ return null;
+ }
+ })
+ .then(data => {
+ if(data && data!="")
+ {
+ if (localsettings.persist_session && !safe_to_overwrite()) {
+ import_compressed_story_prompt_overwrite(data);
+ } else {
+ import_compressed_story(data, false);
+ }
+ }
+ }).catch((error) => {
+ console.log("Error: " + error);
+ msgbox("The shared URL provided is invalid or expired.");
+ });
+ //purge url params
+ window.history.replaceState(null, null, window.location.pathname);
} else if (foundScenario && foundScenario != "") {
display_scenarios();
document.getElementById("scenariosearch").value = escape_html(foundScenario);
@@ -6548,9 +6593,12 @@ Current version indicated by LITEVER below.
let cstoryjson = "";
document.getElementById("sharecontainer").classList.remove("hidden");
- document.getElementById("sharewarning").classList.add("hidden");
+ document.getElementById("shareastext").classList.add("hidden");
+ document.getElementById("shareasurl").classList.add("hidden");
+
if(sharetype==0) //base64 data
{
+ document.getElementById("shareastext").classList.remove("hidden");
cstoryjson = generate_compressed_story(localsettings.save_images,localsettings.export_settings,localsettings.export_settings);
console.log("Export Len: " + cstoryjson.length);
document.getElementById("sharecontainertitle").innerText = "Share Story as TextData";
@@ -6558,18 +6606,12 @@ Current version indicated by LITEVER below.
}
else if(sharetype==1) //url share
{
- cstoryjson = generate_compressed_story(false,localsettings.export_settings,false);
- console.log("Export Len: " + cstoryjson.length);
+ document.getElementById("shareasurl").classList.remove("hidden");
document.getElementById("sharecontainertitle").innerText = "Share Story as URL";
- if (cstoryjson.length >= 4800) {
- document.getElementById("sharewarning").classList.remove("hidden");
- }
-
- let fullurl = "https://lite.koboldai.net/?s=" + cstoryjson;
- document.getElementById("sharestorytext").innerHTML = "" + fullurl + "";
}
else
{
+ document.getElementById("shareastext").classList.remove("hidden");
cstoryjson = share_plaintext();
cstoryjson = replaceAll(cstoryjson,"\n","
",false);
console.log("Export Len: " + cstoryjson.length);
@@ -6578,7 +6620,7 @@ Current version indicated by LITEVER below.
}
document.getElementById("choosesharecontainer").classList.add("hidden");
}
- function copy_share_url() {
+ function copy_shared_text() {
var copyText = document.getElementById("sharestorytext");
// Select the text field
@@ -6587,6 +6629,54 @@ Current version indicated by LITEVER below.
// Copy the text inside the text field
navigator.clipboard.writeText(copyText.innerText);
}
+ function upload_to_dpaste()
+ {
+ let serverurl = document.getElementById("dpaste_server_url").value;
+ let cstoryjson = generate_compressed_story(false,localsettings.export_settings,false);
+ if(serverurl=="")
+ {
+ document.getElementById("shareasurl").classList.add("hidden");
+ document.getElementById("shareastext").classList.remove("hidden");
+ let fullurl = "https://lite.koboldai.net/?s=" + cstoryjson;
+ document.getElementById("sharestorytext").innerHTML = "" + fullurl + "";
+ return;
+ }
+
+ msgboxYesNo("Really upload current story? This action cannot be undone.","Confirm Upload Story",()=>{
+ let expiry = document.getElementById("dpaste_duration").value;
+ console.log("Export Len: " + cstoryjson.length);
+ const params = new URLSearchParams();
+ params.append("content", cstoryjson);
+ params.append("expiry", expiry);
+ fetch(serverurl, {
+ method: 'POST',
+ headers: {'Content-Type': 'application/x-www-form-urlencoded'},
+ body: params.toString(),
+ })
+ .then(x => {
+ if(x.ok)
+ {
+ return x.text();
+ }else{
+ throw new Error('Error uploading dpaste: ' + (x.statusText));
+ return null;
+ }
+ })
+ .then((text) => {
+ let pasteurl = replaceAll(text,"\"","");
+ pasteurl = pasteurl.split("/");
+ pasteurl = pasteurl[pasteurl.length-1];
+ let fullurl = "https://lite.koboldai.net/?dp=" + pasteurl;
+ document.getElementById("shareasurl").classList.add("hidden");
+ document.getElementById("shareastext").classList.remove("hidden");
+ document.getElementById("sharestorytext").innerHTML = "" + fullurl + "";
+ })
+ .catch((error) => {
+ msgbox(`Unable to upload story: ${error}`);
+ console.error('Error:', error);
+ });
+ },()=>{});
+ }
function generate_base_storyobj() {
@@ -22099,7 +22189,7 @@ Current version indicated by LITEVER below.