updated lite, allow GUI to import launcher args and config files with showgui

This commit is contained in:
Concedo 2024-09-20 17:52:52 +08:00
parent 29625c3d2e
commit 68aee56498
2 changed files with 214 additions and 43 deletions

View file

@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
--> -->
<script> <script>
const LITEVER = 177; const LITEVER = 178;
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
var localflag = true; var localflag = true;
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_"; const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@ -255,6 +255,10 @@ Current version indicated by LITEVER below.
padding: 10px; padding: 10px;
overflow-y: auto; overflow-y: auto;
} }
#gametext img {
max-width: 100%;
height: auto;
}
.txtchunk, ai_context_koboldlite_internal, #gametext, .chat_received_withd_msg p,.chat_sent_msg p { .txtchunk, ai_context_koboldlite_internal, #gametext, .chat_received_withd_msg p,.chat_sent_msg p {
white-space: pre-wrap; white-space: pre-wrap;
} }
@ -1955,6 +1959,10 @@ Current version indicated by LITEVER below.
.chat_msg_history { .chat_msg_history {
overflow-y: auto; overflow-y: auto;
} }
.chat_msg_history img {
max-width: 100%;
height: auto;
}
.normal_viewport_height .normal_viewport_height
{ {
height: calc(98vh - 240px); height: calc(98vh - 240px);
@ -2352,6 +2360,10 @@ Current version indicated by LITEVER below.
{ {
white-space: pre-wrap; white-space: pre-wrap;
} }
.corpostyleitemcontent img {
max-width: 100%;
height: auto;
}
.corpolastreq .corpolastreq
{ {
text-align:center; text-align:center;
@ -2954,6 +2966,21 @@ Current version indicated by LITEVER below.
"authorsnote": "", "authorsnote": "",
"worldinfo": [] "worldinfo": []
}, },
{
"title":"Reflection (CoT)",
"author":"Concedo / Lisa",
"desc":"Instruct scenario that encourages the model to employ Chain-Of-Thought thinking and reflection in the response.",
"opmode":4,
"gui_type":0,
"instruct_starttag": "\\n### Instruction:\\n",
"instruct_endtag": "\\n### Response:\\n",
"prefmodel1":instructmodels1,
"prefmodel2":instructmodels2,
"prompt": "",
"memory": instructstartplaceholder+"You are a world class AI capable of using complex reasoning and reflection. Apply step-by-step reasoning and chain-of-thought. For your reply, begin with <thinking> and </thinking> tags, and then provide your final response inside <output> and </output> tags.\n",
"authorsnote": "",
"worldinfo": []
},
{ {
"title":"Abi", "title":"Abi",
"author":"Concedo", "author":"Concedo",
@ -4157,6 +4184,7 @@ Current version indicated by LITEVER below.
const oai_submit_endpoint_turbo = "/chat/completions"; const oai_submit_endpoint_turbo = "/chat/completions";
const default_oai_image_endpoint = "/images/generations"; const default_oai_image_endpoint = "/images/generations";
const default_oai_tts_endpoint = "/audio/speech";
const claude_submit_endpoint = "/complete"; const claude_submit_endpoint = "/complete";
const claude_submit_endpoint_v3 = "/messages"; const claude_submit_endpoint_v3 = "/messages";
@ -4197,6 +4225,7 @@ Current version indicated by LITEVER below.
const XTTS_ID = 1000; const XTTS_ID = 1000;
const ALLTALK_ID = 1001; const ALLTALK_ID = 1001;
const OAI_TTS_ID = 1002;
const HD_RES_PX = 512; const HD_RES_PX = 512;
const NO_HD_RES_PX = 320; const NO_HD_RES_PX = 320;
const SAVE_SLOTS = 6; const SAVE_SLOTS = 6;
@ -4295,6 +4324,8 @@ Current version indicated by LITEVER below.
saved_oai_addr: default_oai_base, //do not ever share this in save files! saved_oai_addr: default_oai_base, //do not ever share this in save files!
saved_dalle_key: "", saved_dalle_key: "",
saved_dalle_url: (default_oai_base + "/v1" + default_oai_image_endpoint), saved_dalle_url: (default_oai_base + "/v1" + default_oai_image_endpoint),
saved_oai_tts_key: "",
saved_oai_tts_url: (default_oai_base + "/v1" + default_oai_tts_endpoint),
saved_openrouter_key: "", saved_openrouter_key: "",
saved_mistralai_key: "", saved_mistralai_key: "",
saved_claude_key: "", //do not ever share this in save files! saved_claude_key: "", //do not ever share this in save files!
@ -4373,6 +4404,7 @@ Current version indicated by LITEVER below.
gui_type_instruct: 0, //0=standard, 1=messenger, 2=aesthetic, 3=corpo gui_type_instruct: 0, //0=standard, 1=messenger, 2=aesthetic, 3=corpo
multiline_replies: true, multiline_replies: true,
allow_continue_chat: false, allow_continue_chat: false,
chat_match_any_name: true,
inject_timestamps: false, inject_timestamps: false,
inject_chatnames_instruct: false, inject_chatnames_instruct: false,
inject_jailbreak_instruct: false, inject_jailbreak_instruct: false,
@ -4428,7 +4460,6 @@ Current version indicated by LITEVER below.
dynatemp_range: defaultsettings.dynatemp_range, dynatemp_range: defaultsettings.dynatemp_range,
dynatemp_exponent: defaultsettings.dynatemp_exponent, dynatemp_exponent: defaultsettings.dynatemp_exponent,
smoothing_factor: defaultsettings.smoothing_factor, smoothing_factor: defaultsettings.smoothing_factor,
genamt: defaultsettings.max_length,
top_k: defaultsettings.top_k, top_k: defaultsettings.top_k,
top_p: defaultsettings.top_p, top_p: defaultsettings.top_p,
min_p: defaultsettings.min_p, min_p: defaultsettings.min_p,
@ -4441,7 +4472,7 @@ Current version indicated by LITEVER below.
rep_pen_slope: defaultsettings.rep_pen_slope, rep_pen_slope: defaultsettings.rep_pen_slope,
sampler_order: defaultsettings.sampler_order sampler_order: defaultsettings.sampler_order
}, },
{"preset":"Simple Logical","description":"A very predictable preset with low randomness.","temp":0.25,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":100,"top_p":0.6,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.01,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Simple Balanced","description":"A good balanced preset with medium randomness.","temp":0.7,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":100,"top_p":0.92,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.07,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Simple Creative","description":"A wild and unpredictable preset with higher randomness.","temp":1.0,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":100,"top_p":0.98,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.15,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Basic Min-P","description":"A good default for Min-P, only works on backends with min-p.","temp":1.25,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":0,"top_p":1,"min_p":0.1,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.03,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,5,0,1,3,4,2]},{"preset":"Basic DynaTemp","description":"A good default for DynaTemp, only works on backends with it.","temp":1.25,"dynatemp_range":0.75,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":0,"top_p":1,"min_p":0.05,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.03,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,5,0,1,3,4,2]},{"preset":"Basic SmoothSample","description":"A good default for Smooth Sampling, only works on backends with it.","temp":1.0,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.25,"genamt":200,"top_k":0,"top_p":1,"min_p":0.05,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.03,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,5,0,1,3,4,2]},{"preset":"Basic SillyTavern","description":"Similar to default preset used in SillyTavern.","temp":0.7,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":40,"top_p":0.6,"min_p":0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1.0,"rep_pen":1.18,"rep_pen_range":1024,"rep_pen_slope":0.8,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"CoherentCreativity (Legacy)","description":"Legacy preset. A good balance between coherence, creativity, and quality of prose.","genamt":200,"rep_pen":1.2,"rep_pen_range":360,"rep_pen_slope":0,"sampler_order":[6,5,0,2,3,1,4],"temp":0.5,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"tfs":0.99,"top_a":0,"top_k":0,"top_p":1,"min_p":0.0,"presence_penalty":0.0,"typical":1},{"preset":"Godlike (Legacy)","description":"Legacy preset. Makes AI give a descriptive and sensual output.","temp":0.7,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":0,"top_p":0.5,"min_p":0.0,"presence_penalty":0.0,"top_a":0.75,"typical":0.19,"tfs":0.97,"rep_pen":1.1,"rep_pen_range":1024,"rep_pen_slope":0.7,"sampler_order":[6,5,4,3,2,1,0]},{"preset":"LiminalDrift (Legacy)","description":"Legacy preset. Sometimes surreal situations arise based on information already present in the story.","temp":0.66,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"genamt":200,"top_k":0,"top_p":1,"min_p":0.0,"presence_penalty":0.0,"top_a":0.96,"typical":0.6,"tfs":1,"rep_pen":1.1,"rep_pen_range":1024,"rep_pen_slope":0.7,"sampler_order":[6,4,5,1,0,2,3]} {"preset":"Simple Logical","description":"A very predictable preset with low randomness.","temp":0.3,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":100,"top_p":0.6,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.02,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Simple Balanced","description":"A good balanced preset with medium randomness.","temp":0.7,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":100,"top_p":0.92,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.07,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Simple Creative","description":"A wild and unpredictable preset with higher randomness.","temp":1.0,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":100,"top_p":0.98,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.15,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Basic Min-P","description":"A good default for Min-P, only works on backends with min-p.","temp":1.25,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":0,"top_p":1,"min_p":0.1,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.03,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,5,0,1,3,4,2]},{"preset":"Basic DynaTemp","description":"A good default for DynaTemp, only works on backends with it.","temp":1.25,"dynatemp_range":0.75,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":0,"top_p":1,"min_p":0.05,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.03,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,5,0,1,3,4,2]},{"preset":"Basic SmoothSample","description":"A good default for Smooth Sampling, only works on backends with it.","temp":1.0,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.25,"top_k":0,"top_p":1,"min_p":0.05,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.03,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,5,0,1,3,4,2]},{"preset":"Basic SillyTavern","description":"Similar to default preset used in SillyTavern.","temp":0.7,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":40,"top_p":0.6,"min_p":0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1.0,"rep_pen":1.18,"rep_pen_range":1024,"rep_pen_slope":0.8,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"Neutral (Disabled)","description":"Sets all samplers neutralized, allowing you to customize your own.","temp":1.0,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":200,"top_p":1.0,"min_p":0.0,"presence_penalty":0.0,"top_a":0,"typical":1,"tfs":1,"rep_pen":1.0,"rep_pen_range":360,"rep_pen_slope":0.7,"sampler_order":[6,0,1,3,4,2,5]},{"preset":"CoherentCreativity (Legacy)","description":"Legacy preset. A good balance between coherence, creativity, and quality of prose.","rep_pen":1.2,"rep_pen_range":360,"rep_pen_slope":0,"sampler_order":[6,5,0,2,3,1,4],"temp":0.5,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"tfs":0.99,"top_a":0,"top_k":0,"top_p":1,"min_p":0.0,"presence_penalty":0.0,"typical":1},{"preset":"Godlike (Legacy)","description":"Legacy preset. Makes AI give a descriptive and sensual output.","temp":0.7,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":0,"top_p":0.5,"min_p":0.0,"presence_penalty":0.0,"top_a":0.75,"typical":0.19,"tfs":0.97,"rep_pen":1.1,"rep_pen_range":1024,"rep_pen_slope":0.7,"sampler_order":[6,5,4,3,2,1,0]},{"preset":"LiminalDrift (Legacy)","description":"Legacy preset. Sometimes surreal situations arise based on information already present in the story.","temp":0.66,"dynatemp_range":0.0,"dynatemp_exponent":1.0,"smoothing_factor":0.0,"top_k":0,"top_p":1,"min_p":0.0,"presence_penalty":0.0,"top_a":0.96,"typical":0.6,"tfs":1,"rep_pen":1.1,"rep_pen_range":1024,"rep_pen_slope":0.7,"sampler_order":[6,4,5,1,0,2,3]}
]; ];
const instructpresets = [ const instructpresets = [
@ -4524,10 +4555,17 @@ Current version indicated by LITEVER below.
}, },
{ {
"id":12, "id":12,
"name":"Mistral", "name":"Mistral Gen 1",
"user":"\\n[INST] ", "user":"\\n[INST] ",
"assistant":" [/INST]\\n", "assistant":" [/INST]\\n",
"system":"", "system":"",
},
{
"id":13,
"name":"Mistral Gen 2",
"user":"</s>\\n[INST]",
"assistant":"[/INST]\\n",
"system":"",
} }
]; ];
@ -5324,6 +5362,29 @@ Current version indicated by LITEVER below.
},false); },false);
} }
function set_oai_tts_key()
{
inputBox("Enter OpenAI Compatible TTS API Key","OpenAI Compatible TTS API Key",localsettings.saved_oai_tts_key,"Input OpenAI Compatible TTS API Key", ()=>{
let userinput = getInputBoxValue();
userinput = userinput.trim();
if (userinput != null && userinput!="") {
localsettings.saved_oai_tts_key = userinput.trim();
}
},false,false,true);
}
function set_oai_tts_url()
{
inputBox("Enter OpenAI Compatible TTS API URL","OpenAI Compatible TTS API URL",localsettings.saved_oai_tts_url,"Input OpenAI Compatible TTS API URL", ()=>{
let userinput = getInputBoxValue();
userinput = userinput.trim();
if (userinput != null && userinput!="") {
localsettings.saved_oai_tts_url = userinput.trim();
}else{
localsettings.saved_oai_tts_url = (default_oai_base + "/v1" + default_oai_tts_endpoint);
}
},false);
}
function generate_dalle_image(req_payload, onImagesDone) function generate_dalle_image(req_payload, onImagesDone)
{ {
//split the prompt //split the prompt
@ -6345,6 +6406,8 @@ Current version indicated by LITEVER below.
let tmp_oai2 = localsettings.saved_oai_addr; let tmp_oai2 = localsettings.saved_oai_addr;
let tmp_oai3 = localsettings.saved_dalle_key; let tmp_oai3 = localsettings.saved_dalle_key;
let tmp_oai4 = localsettings.saved_dalle_url; let tmp_oai4 = localsettings.saved_dalle_url;
let tmp_oai5 = localsettings.saved_oai_tts_key;
let tmp_oai6 = localsettings.saved_oai_tts_url;
let tmp_or1 = localsettings.saved_openrouter_key; let tmp_or1 = localsettings.saved_openrouter_key;
let tmp_mai = localsettings.saved_mistralai_key; let tmp_mai = localsettings.saved_mistralai_key;
let tmp_claude1 = localsettings.saved_claude_key; let tmp_claude1 = localsettings.saved_claude_key;
@ -6381,6 +6444,8 @@ Current version indicated by LITEVER below.
localsettings.saved_oai_addr = tmp_oai2; localsettings.saved_oai_addr = tmp_oai2;
localsettings.saved_dalle_key = tmp_oai3; localsettings.saved_dalle_key = tmp_oai3;
localsettings.saved_dalle_url = tmp_oai4; localsettings.saved_dalle_url = tmp_oai4;
localsettings.saved_oai_tts_key = tmp_oai5;
localsettings.saved_oai_tts_url = tmp_oai6;
localsettings.saved_openrouter_key = tmp_or1; localsettings.saved_openrouter_key = tmp_or1;
localsettings.saved_mistralai_key = tmp_mai; localsettings.saved_mistralai_key = tmp_mai;
localsettings.saved_claude_key = tmp_claude1; localsettings.saved_claude_key = tmp_claude1;
@ -6485,6 +6550,22 @@ Current version indicated by LITEVER below.
} }
return loadedwi; return loadedwi;
} }
var tempAltGreetings = [];
function click_more_alt_greeting(idx) {
if (tempAltGreetings.length > idx) {
msgboxYesNo(tempAltGreetings[idx].substr(0, 512) + "...\n\nUse This Greeting?", "Use Greeting " + idx +"?",()=>{
//this is an ugly hack
if(onInputboxOk)
{
document.getElementById("inputboxcontainerinput").value = idx;
onInputboxOk();
}
},()=>{});
} else {
console.log("ERROR ALT GREETING NOT FOUND");
}
}
function load_tavern_obj(obj) function load_tavern_obj(obj)
{ {
let selectedgreeting = ""; let selectedgreeting = "";
@ -6502,23 +6583,23 @@ Current version indicated by LITEVER below.
} }
else if(localsettings.import_tavern_prompt && obj.alternate_greetings && obj.alternate_greetings.length>0) else if(localsettings.import_tavern_prompt && obj.alternate_greetings && obj.alternate_greetings.length>0)
{ {
let bufGreetings = []; tempAltGreetings = [];
if(obj.first_mes) if(obj.first_mes)
{ {
bufGreetings.push(obj.first_mes); tempAltGreetings.push(obj.first_mes);
} }
bufGreetings = bufGreetings.concat(obj.alternate_greetings); tempAltGreetings = tempAltGreetings.concat(obj.alternate_greetings);
bufGreetings = bufGreetings.slice(0,16); tempAltGreetings = tempAltGreetings.slice(0,16);
let bufMsg = "<p><b><u>Select Greeting Message</u></b></p>" let bufMsg = "<p><b><u>Select Greeting Message</u></b></p>"
for (it in bufGreetings) { for (it in tempAltGreetings) {
bufMsg += it + ") " + bufGreetings[it].substr(0, 64) + "...<br>" bufMsg += it + ") " + tempAltGreetings[it].substr(0, 64) + `...<a href="#" onclick="click_more_alt_greeting(${it})">(more)</a><br>`
} }
inputBox(bufMsg,"Choose Greeting Message","","Number 0 to " + (bufGreetings.length-1), ()=>{ inputBox(bufMsg,"Choose Greeting Message","","Number 0 to " + (tempAltGreetings.length-1), ()=>{
let userinput = getInputBoxValue(); let userinput = getInputBoxValue();
userinput = parseInt(userinput); userinput = parseInt(userinput);
userinput = cleannum(userinput,0,bufGreetings.length-1); userinput = cleannum(userinput,0,tempAltGreetings.length-1);
selectedgreeting = bufGreetings[userinput]; selectedgreeting = tempAltGreetings[userinput];
load_tav_obj_confirm_p2(usechatmode); load_tav_obj_confirm_p2(usechatmode);
}, true); }, true);
@ -7132,7 +7213,7 @@ Current version indicated by LITEVER below.
} }
}) })
.then(data => { .then(data => {
if(data) //if cai fetch was successul if(data) //if cai fetch was successful
{ {
console.log(data); console.log(data);
let botname = data.name?data.name:"Bot"; let botname = data.name?data.name:"Bot";
@ -8835,6 +8916,8 @@ Current version indicated by LITEVER below.
localsettings.saved_oai_addr = custom_oai_endpoint; localsettings.saved_oai_addr = custom_oai_endpoint;
localsettings.saved_dalle_key = custom_oai_key; localsettings.saved_dalle_key = custom_oai_key;
localsettings.saved_dalle_url = custom_oai_endpoint + default_oai_image_endpoint; localsettings.saved_dalle_url = custom_oai_endpoint + default_oai_image_endpoint;
localsettings.saved_oai_tts_key = custom_oai_key;
localsettings.saved_oai_tts_url = custom_oai_endpoint + default_oai_tts_endpoint;
} }
else if(epchoice==7) else if(epchoice==7)
{ {
@ -9748,6 +9831,7 @@ Current version indicated by LITEVER below.
} }
document.getElementById("multiline_replies").checked = localsettings.multiline_replies; document.getElementById("multiline_replies").checked = localsettings.multiline_replies;
document.getElementById("allow_continue_chat").checked = localsettings.allow_continue_chat; document.getElementById("allow_continue_chat").checked = localsettings.allow_continue_chat;
document.getElementById("chat_match_any_name").checked = localsettings.chat_match_any_name;
document.getElementById("inject_timestamps").checked = localsettings.inject_timestamps; document.getElementById("inject_timestamps").checked = localsettings.inject_timestamps;
document.getElementById("inject_chatnames_instruct").checked = localsettings.inject_chatnames_instruct; document.getElementById("inject_chatnames_instruct").checked = localsettings.inject_chatnames_instruct;
document.getElementById("inject_jailbreak_instruct").checked = localsettings.inject_jailbreak_instruct; document.getElementById("inject_jailbreak_instruct").checked = localsettings.inject_jailbreak_instruct;
@ -9799,6 +9883,7 @@ Current version indicated by LITEVER below.
var ttshtml = "<option value=\"0\">Disabled</option>"; var ttshtml = "<option value=\"0\">Disabled</option>";
ttshtml += "<option value=\"1000\">XTTS API Server</option>"; ttshtml += "<option value=\"1000\">XTTS API Server</option>";
ttshtml += "<option value=\"1001\">AllTalk API Server</option>"; ttshtml += "<option value=\"1001\">AllTalk API Server</option>";
ttshtml += "<option value=\"1002\">OpenAI-Compat. API Server</option>";
if ('speechSynthesis' in window) { if ('speechSynthesis' in window) {
let voices = window.speechSynthesis.getVoices(); let voices = window.speechSynthesis.getVoices();
console.log("speech synth available: " + voices.length); console.log("speech synth available: " + voices.length);
@ -9853,7 +9938,6 @@ Current version indicated by LITEVER below.
let found = samplerpresets[selp]; let found = samplerpresets[selp];
if (found) { if (found) {
document.getElementById("temperature").value = document.getElementById("temperature_slide").value = found.temp; document.getElementById("temperature").value = document.getElementById("temperature_slide").value = found.temp;
document.getElementById("max_length").value = document.getElementById("max_length_slide").value = found.genamt;
document.getElementById("presence_penalty").value = found.presence_penalty; document.getElementById("presence_penalty").value = found.presence_penalty;
document.getElementById("min_p").value = found.min_p; document.getElementById("min_p").value = found.min_p;
document.getElementById("dynatemp_range").value = found.dynatemp_range; document.getElementById("dynatemp_range").value = found.dynatemp_range;
@ -9942,7 +10026,6 @@ Current version indicated by LITEVER below.
if (found && selp!=9999) { if (found && selp!=9999) {
document.getElementById("presetsdesc").innerText = found.description; document.getElementById("presetsdesc").innerText = found.description;
let changed = (document.getElementById("temperature").value != found.temp || let changed = (document.getElementById("temperature").value != found.temp ||
document.getElementById("max_length").value != found.genamt ||
document.getElementById("presence_penalty").value != found.presence_penalty || document.getElementById("presence_penalty").value != found.presence_penalty ||
document.getElementById("min_p").value != found.min_p || document.getElementById("min_p").value != found.min_p ||
document.getElementById("dynatemp_range").value != found.dynatemp_range || document.getElementById("dynatemp_range").value != found.dynatemp_range ||
@ -10066,6 +10149,7 @@ Current version indicated by LITEVER below.
} }
localsettings.multiline_replies = (document.getElementById("multiline_replies").checked ? true : false); localsettings.multiline_replies = (document.getElementById("multiline_replies").checked ? true : false);
localsettings.allow_continue_chat = (document.getElementById("allow_continue_chat").checked ? true : false); localsettings.allow_continue_chat = (document.getElementById("allow_continue_chat").checked ? true : false);
localsettings.chat_match_any_name = (document.getElementById("chat_match_any_name").checked ? true : false);
localsettings.inject_timestamps = (document.getElementById("inject_timestamps").checked ? true : false); localsettings.inject_timestamps = (document.getElementById("inject_timestamps").checked ? true : false);
localsettings.inject_chatnames_instruct = (document.getElementById("inject_chatnames_instruct").checked ? true : false); localsettings.inject_chatnames_instruct = (document.getElementById("inject_chatnames_instruct").checked ? true : false);
localsettings.inject_jailbreak_instruct = (document.getElementById("inject_jailbreak_instruct").checked ? true : false); localsettings.inject_jailbreak_instruct = (document.getElementById("inject_jailbreak_instruct").checked ? true : false);
@ -11326,12 +11410,16 @@ Current version indicated by LITEVER below.
function toggle_tts_mode() function toggle_tts_mode()
{ {
document.getElementById("xtts_container").classList.add("hidden");
document.getElementById("oai_tts_container").classList.add("hidden");
if(document.getElementById("ttsselect").value==XTTS_ID || document.getElementById("ttsselect").value==ALLTALK_ID) if(document.getElementById("ttsselect").value==XTTS_ID || document.getElementById("ttsselect").value==ALLTALK_ID)
{ {
document.getElementById("xtts_container").classList.remove("hidden"); document.getElementById("xtts_container").classList.remove("hidden");
fetch_xtts_voices(true, document.getElementById("ttsselect").value==XTTS_ID); fetch_xtts_voices(true, document.getElementById("ttsselect").value==XTTS_ID);
}else{ }
document.getElementById("xtts_container").classList.add("hidden"); else if(document.getElementById("ttsselect").value==OAI_TTS_ID)
{
document.getElementById("oai_tts_container").classList.remove("hidden");
} }
} }
function set_xtts_url() function set_xtts_url()
@ -11399,13 +11487,53 @@ Current version indicated by LITEVER below.
} }
} }
if(ssval==XTTS_ID || ssval==ALLTALK_ID) //xtts api server if(ssval==XTTS_ID || ssval==ALLTALK_ID || ssval==OAI_TTS_ID) //xtts api server
{ {
if(xtts_is_connected) let is_xtts = (ssval==XTTS_ID);
{ let is_oai_tts = (ssval==OAI_TTS_ID);
let is_xtts = (ssval==XTTS_ID); const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
if(is_oai_tts)
{
let payload =
{
"model": document.getElementById("oai_tts_model").value,
"input": text,
"voice": document.getElementById("oai_tts_voice").value
};
let oaiheaders = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localsettings.saved_oai_tts_key
};
fetch(localsettings.saved_oai_tts_url, {
method: 'POST',
headers: oaiheaders,
body: JSON.stringify(payload),
})
.then(response => response.arrayBuffer())
.then(data => {
return audioContext.decodeAudioData(data);
})
.then(decodedData => {
const playSound = audioContext.createBufferSource();
playSound.buffer = decodedData;
playSound.connect(audioContext.destination);
xtts_is_playing = true;
update_submit_button(false);
playSound.start(audioContext.currentTime);
playSound.onended = function() {
setTimeout(() => {
xtts_is_playing = false;
update_submit_button(false);
console.log("Audio finished playing");
},300);
};
}).catch((error) => {
console.log("XTTS Speak Error: " + error);
});
}
else if(xtts_is_connected)
{
if(is_xtts) if(is_xtts)
{ {
let xtts_payload = { let xtts_payload = {
@ -11816,6 +11944,12 @@ Current version indicated by LITEVER below.
//examine context to try to determine if there's an existing botname //examine context to try to determine if there's an existing botname
var othernamesregex = new RegExp("\n(?!" + localsettings.chatname + ").+?\: ", "gi"); var othernamesregex = new RegExp("\n(?!" + localsettings.chatname + ").+?\: ", "gi");
if(!localsettings.chat_match_any_name && localsettings.chatopponent!="")
{
let namelist = localsettings.chatopponent.split("||$||");
var namePattern = namelist.map(name => name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
othernamesregex = new RegExp("(" + namePattern + "): ", "gi");
}
var tempfullsearchable = current_memory + current_anote + truncated_context; var tempfullsearchable = current_memory + current_anote + truncated_context;
var foundopponent = tempfullsearchable.match(othernamesregex); var foundopponent = tempfullsearchable.match(othernamesregex);
@ -15695,6 +15829,7 @@ Current version indicated by LITEVER below.
let newbodystr = ""; let newbodystr = "";
input = replace_instruct_placeholders(input); input = replace_instruct_placeholders(input);
input = apply_display_only_regex(input);
let chatunits = []; let chatunits = [];
if(localsettings.opmode==3) //chat mode if(localsettings.opmode==3) //chat mode
{ {
@ -15714,7 +15849,6 @@ Current version indicated by LITEVER below.
let processed_msg = curr.msg; let processed_msg = curr.msg;
if(processed_msg && processed_msg!="") if(processed_msg && processed_msg!="")
{ {
processed_msg = apply_display_only_regex(processed_msg);
processed_msg = replace_noninstruct_placeholders(processed_msg,true); processed_msg = replace_noninstruct_placeholders(processed_msg,true);
let codeblockcount = (processed_msg.match(/```/g) || []).length; let codeblockcount = (processed_msg.match(/```/g) || []).length;
if(codeblockcount>0 && codeblockcount%2!=0 ) if(codeblockcount>0 && codeblockcount%2!=0 )
@ -15908,6 +16042,13 @@ Current version indicated by LITEVER below.
var othernamesregex = new RegExp("(?!" + localsettings.chatname + ").+?\: ", "gi"); var othernamesregex = new RegExp("(?!" + localsettings.chatname + ").+?\: ", "gi");
if(!localsettings.chat_match_any_name && localsettings.chatopponent!="")
{
let namelist = localsettings.chatopponent.split("||$||");
var namePattern = namelist.map(name => name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
othernamesregex = new RegExp("(" + namePattern + "): ", "gi");
}
//a quick fix that adds a newline if there's none before opponent chat and a picture //a quick fix that adds a newline if there's none before opponent chat and a picture
var othernamesregexreplace = new RegExp("\\|[d|p]\\|>(?!" + localsettings.chatname + ").+?\\: ", "gi"); var othernamesregexreplace = new RegExp("\\|[d|p]\\|>(?!" + localsettings.chatname + ").+?\\: ", "gi");
@ -17184,7 +17325,13 @@ Current version indicated by LITEVER below.
var mynameregex2 = new RegExp("(" + localsettings.chatname + ")\: ", "gi"); var mynameregex2 = new RegExp("(" + localsettings.chatname + ")\: ", "gi");
var mynameregex3 = new RegExp("\n(" + localsettings.chatname + ") ", "gi"); var mynameregex3 = new RegExp("\n(" + localsettings.chatname + ") ", "gi");
var othernamesregex = new RegExp("\n(?!" + localsettings.chatname + ").+?\: ", "gi"); var othernamesregex = new RegExp("\n(?!" + localsettings.chatname + ").+?\: ", "gi");
//var othernamesregex2 = new RegExp("(?!" + localsettings.chatname + ").+?\: ", "gi"); if(!localsettings.chat_match_any_name && localsettings.chatopponent!="")
{
let namelist = localsettings.chatopponent.split("||$||");
var namePattern = namelist.map(name => name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
othernamesregex = new RegExp("(" + namePattern + "): ", "gi");
}
input = input.replaceAll(mynameregex, '{{userplaceholder}}'); input = input.replaceAll(mynameregex, '{{userplaceholder}}');
input = input.replaceAll(mynameregex2, '{{userplaceholder}}'); input = input.replaceAll(mynameregex2, '{{userplaceholder}}');
input = input.replaceAll(mynameregex3, '{{userplaceholder}}'); input = input.replaceAll(mynameregex3, '{{userplaceholder}}');
@ -17192,6 +17339,11 @@ Current version indicated by LITEVER below.
{ {
input = input.replaceAll("{{userplaceholder}}", `{{userplaceholder}}<p class='aui_nametag'>`+escapeHtml(localsettings.chatname)+`</p>`); input = input.replaceAll("{{userplaceholder}}", `{{userplaceholder}}<p class='aui_nametag'>`+escapeHtml(localsettings.chatname)+`</p>`);
input = input.replaceAll(othernamesregex, function(match) { input = input.replaceAll(othernamesregex, function(match) {
//edge condition: if matched string already contains placeholders, something went wrong. return original string
if(match.includes("{{userplaceholder}}"))
{
return match;
}
return "{{botplaceholder}}<p class='aui_nametag'>" + escapeHtml(match.substring(0,match.length-2).trim()) + "</p>"; return "{{botplaceholder}}<p class='aui_nametag'>" + escapeHtml(match.substring(0,match.length-2).trim()) + "</p>";
}); });
} }
@ -18089,6 +18241,11 @@ Current version indicated by LITEVER below.
class="helptext">Allow incomplete AI chat mode replies, which can be continued by pressing submit again. Not recommended for newbies.</span></span></div> class="helptext">Allow incomplete AI chat mode replies, which can be continued by pressing submit again. Not recommended for newbies.</span></span></div>
<input type="checkbox" title="Continue Bot Replies" id="allow_continue_chat" style="margin:0px 0px 0px auto;"> <input type="checkbox" title="Continue Bot Replies" id="allow_continue_chat" style="margin:0px 0px 0px auto;">
</div> </div>
<div class="settinglabel">
<div class="justifyleft settingsmall">Chat Match Any Name <span class="helpicon">?<span
class="helptext">In Chat Mode, match formatting against any name, instead of only specified chat names.</span></span></div>
<input type="checkbox" title="Chat Match Any Name" id="chat_match_any_name" style="margin:0px 0px 0px auto;">
</div>
</div> </div>
<div class="settingitem"> <div class="settingitem">
@ -18522,6 +18679,14 @@ Current version indicated by LITEVER below.
</tr><tr style="font-size:12px;padding:2px;margin:0px 0 0;"><td>Language </td><td><input class="settinglabel miniinput" type="text" value="EN" id="xtts_lang" style="margin-left:3px; height:18px; width: 40px; padding: 2px;"></td></tr> </tr><tr style="font-size:12px;padding:2px;margin:0px 0 0;"><td>Language </td><td><input class="settinglabel miniinput" type="text" value="EN" id="xtts_lang" style="margin-left:3px; height:18px; width: 40px; padding: 2px;"></td></tr>
</table> </table>
</div> </div>
<div id="oai_tts_container" class="settinglabel hidden">
<table width="100%"><tr>
<td><button type="button" class="btn btn-primary" style="width:100%; padding:2px 3px;margin-top:2px;font-size:11px;" onclick="set_oai_tts_url()">Set URL</button></td>
<td><button type="button" class="btn btn-primary" style="width:100%; padding:2px 3px;margin-top:2px;font-size:11px;" onclick="set_oai_tts_key()">Set Key</button></td>
</tr><tr style="font-size:12px;padding:2px;margin:0px 0 0;"><td>TTS Model </td><td><input class="settinglabel miniinput" type="text" value="tts-1" id="oai_tts_model" style="margin-left:3px; height:18px; width: 55px; padding: 2px;"></td>
</tr><tr style="font-size:12px;padding:2px;margin:0px 0 0;"><td>TTS Voice </td><td><input class="settinglabel miniinput" type="text" value="alloy" id="oai_tts_voice" style="margin-left:3px; height:18px; width: 55px; padding: 2px;"></td></tr>
</table>
</div>
</div> </div>
<div class="settinglabel"> <div class="settinglabel">
<div class="justifyleft settingsmall" title="If unchecked, only speak AI replies, not other text.">Narrate Both Sides </div> <div class="justifyleft settingsmall" title="If unchecked, only speak AI replies, not other text.">Narrate Both Sides </div>
@ -19307,22 +19472,6 @@ Current version indicated by LITEVER below.
</div> </div>
</div> </div>
<div class="popupcontainer flex hidden" id="yesnocontainer">
<div class="popupbg flex"></div>
<div class="nspopup flexsizevsmall">
<div class="popuptitlebar">
<div class="popuptitletext" id="yesnocontainertitle"></div>
</div>
<div class="aidgpopuplistheader anotelabel" id="yesnocontainertext">
</div>
<div class="aidgpopuplistheader anotelabel hidden" id="yesnocontainercheckboxdiv"><span style="vertical-align: middle; margin:4px" id="yesnocontainercheckboxtext"></span><input type="checkbox" id="yesnocontainercheckbox" style=" vertical-align: top;" checked></div>
<div class="popupfooter">
<button type="button" class="btn btn-primary" onclick="onYesFn()">Yes</button>
<button type="button" class="btn btn-primary" onclick="onNoFn()">No</button>
</div>
</div>
</div>
<div class="popupcontainer flex hidden" id="inputboxcontainer"> <div class="popupcontainer flex hidden" id="inputboxcontainer">
<div class="popupbg flex"></div> <div class="popupbg flex"></div>
<div class="nspopup flexsize moderate"> <div class="nspopup flexsize moderate">
@ -19343,6 +19492,22 @@ Current version indicated by LITEVER below.
</div> </div>
</div> </div>
<div class="popupcontainer flex hidden" id="yesnocontainer">
<div class="popupbg flex"></div>
<div class="nspopup flexsizevsmall">
<div class="popuptitlebar">
<div class="popuptitletext" id="yesnocontainertitle"></div>
</div>
<div class="aidgpopuplistheader anotelabel" id="yesnocontainertext">
</div>
<div class="aidgpopuplistheader anotelabel hidden" id="yesnocontainercheckboxdiv"><span style="vertical-align: middle; margin:4px" id="yesnocontainercheckboxtext"></span><input type="checkbox" id="yesnocontainercheckbox" style=" vertical-align: top;" checked></div>
<div class="popupfooter">
<button type="button" class="btn btn-primary" onclick="onYesFn()">Yes</button>
<button type="button" class="btn btn-primary" onclick="onNoFn()">No</button>
</div>
</div>
</div>
<div class="popupcontainer flex hidden" id="msgboxcontainer"> <div class="popupcontainer flex hidden" id="msgboxcontainer">
<div class="popupbg flex"></div> <div class="popupbg flex"></div>
<div class="nspopup flexsizesmall moderate"> <div class="nspopup flexsizesmall moderate">

View file

@ -2196,7 +2196,7 @@ def show_gui():
from tkinter.filedialog import asksaveasfile from tkinter.filedialog import asksaveasfile
# if args received, launch # if args received, launch
if len(sys.argv) != 1: if len(sys.argv) != 1 and not args.showgui:
import tkinter as tk import tkinter as tk
root = tk.Tk() #we dont want the useless window to be visible, but we want it in taskbar root = tk.Tk() #we dont want the useless window to be visible, but we want it in taskbar
root.attributes("-alpha", 0) root.attributes("-alpha", 0)
@ -3315,6 +3315,11 @@ def show_gui():
gpuinfo_thread = threading.Thread(target=auto_set_backend_gui) gpuinfo_thread = threading.Thread(target=auto_set_backend_gui)
gpuinfo_thread.start() #submit job in new thread so nothing is waiting gpuinfo_thread.start() #submit job in new thread so nothing is waiting
if args.showgui:
if isinstance(args, argparse.Namespace):
dict = vars(args)
import_vars(dict)
# runs main loop until closed or launch clicked # runs main loop until closed or launch clicked
root.mainloop() root.mainloop()
@ -3850,7 +3855,7 @@ def main(launch_args,start_server=True):
if not args.model_param: if not args.model_param:
args.model_param = args.model args.model_param = args.model
if not args.model_param and not args.sdmodel and not args.whispermodel and not args.nomodel: if args.showgui or (not args.model_param and not args.sdmodel and not args.whispermodel and not args.nomodel):
#give them a chance to pick a file #give them a chance to pick a file
print("For command line arguments, please refer to --help") print("For command line arguments, please refer to --help")
print("***") print("***")
@ -4433,6 +4438,7 @@ if __name__ == '__main__':
advparser.add_argument("--smartcontext", help="Reserving a portion of context to try processing less frequently. Outdated. Not recommended.", action='store_true') advparser.add_argument("--smartcontext", help="Reserving a portion of context to try processing less frequently. Outdated. Not recommended.", action='store_true')
advparser.add_argument("--unpack", help="Extracts the file contents of the KoboldCpp binary into a target directory.", metavar=('destination'), type=str, default="") advparser.add_argument("--unpack", help="Extracts the file contents of the KoboldCpp binary into a target directory.", metavar=('destination'), type=str, default="")
advparser.add_argument("--nomodel", help="Allows you to launch the GUI alone, without selecting any model.", action='store_true') advparser.add_argument("--nomodel", help="Allows you to launch the GUI alone, without selecting any model.", action='store_true')
advparser.add_argument("--showgui", help="Always show the GUI instead of launching the model right away when loading settings from a .kcpps file.", action='store_true')
hordeparsergroup = parser.add_argument_group('Horde Worker Commands') hordeparsergroup = parser.add_argument_group('Horde Worker Commands')
hordeparsergroup.add_argument("--hordemodelname", metavar=('[name]'), help="Sets your AI Horde display model name.", default="") hordeparsergroup.add_argument("--hordemodelname", metavar=('[name]'), help="Sets your AI Horde display model name.", default="")