Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/concedo'
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowRoseCx committed Jan 21, 2025
2 parents 2b5cf34 + 02d5bb5 commit 7bcb7cb
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 114 deletions.
1 change: 1 addition & 0 deletions expose.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ struct tts_load_model_inputs
const int cublas_info = 0;
const char * vulkan_info = nullptr;
const int gpulayers = 0;
const bool flash_attention = false;
const int debugmode = 0;
};
struct tts_generation_inputs
Expand Down
2 changes: 1 addition & 1 deletion ggml/src/ggml-cuda/ggml-cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ggml-impl.h"
#include "ggml-backend-impl.h"

bool g_mul_mat_q = false;
bool g_mul_mat_q = true;

#include "ggml-cuda/common.cuh"
#include "ggml-cuda/acc.cuh"
Expand Down
196 changes: 126 additions & 70 deletions klite.embd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
-->

<script>
const LITEVER = 204;
const LITEVER = 205;
const urlParams = new URLSearchParams(window.location.search);
var localflag = true;
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
Expand Down Expand Up @@ -2939,6 +2939,7 @@ Current version indicated by LITEVER below.
var temp_scenario = null;
var last_token_budget = ""; //to display token limits
var last_known_filename = "saved_story.json";
var backup_localmodeport = 5001; //sometimes we reattempt a different port, this stores a backup
var localmodeport = 5001;
var localmodehost = "localhost";
var localprotocol = "http://";
Expand Down Expand Up @@ -3639,6 +3640,7 @@ Current version indicated by LITEVER below.
if (inputport) {
localmodeport = parseInt(inputport);
}
backup_localmodeport = localmodeport;

let inputhost = urlParams.get('host');
sublocalpathname = "";
Expand Down Expand Up @@ -3947,15 +3949,21 @@ initializeInstructUIFunctionality();
}
function replace_noninstruct_placeholders(inputtxt,escape=false)
{
let firstopponent = localsettings.chatopponent;
if (firstopponent && firstopponent.includes("||$||")) {
let coarr = firstopponent.split("||$||");
coarr = coarr.filter(x => (x && x != ""));
firstopponent = coarr.length>0?coarr[0]:defaultchatopponent;
}
if(escape)
{
inputtxt = replaceAll(inputtxt,"{{user}}",escape_html(localsettings.chatname?localsettings.chatname:"User"),true);
inputtxt = replaceAll(inputtxt,"{{char}}",escape_html(localsettings.chatopponent?localsettings.chatopponent:defaultchatopponent),true);
inputtxt = replaceAll(inputtxt,"{{char}}",escape_html(localsettings.chatopponent?firstopponent:defaultchatopponent),true);
}
else
{
inputtxt = replaceAll(inputtxt,"{{user}}",(localsettings.chatname?localsettings.chatname:"User"),true);
inputtxt = replaceAll(inputtxt,"{{char}}",(localsettings.chatopponent?localsettings.chatopponent:defaultchatopponent),true);
inputtxt = replaceAll(inputtxt,"{{char}}",(localsettings.chatopponent?firstopponent:defaultchatopponent),true);
}

for(let i=0;i<placeholder_tags_data.length;++i)
Expand Down Expand Up @@ -5136,10 +5144,10 @@ initializeInstructUIFunctionality();
}
}





function clear_cors_proxy_flag()
{
uses_cors_proxy = false;
}

// attempt to connect to the selected backend
function attempt_connect(popup_aiselect = true)
Expand Down Expand Up @@ -5797,6 +5805,9 @@ initializeInstructUIFunctionality();
|| target_url.toLowerCase().includes("192.168.")
|| target_url.toLowerCase().includes("10.0.0.")
|| target_url.toLowerCase().includes("://10.0.")
|| (target_url.toLowerCase().includes(".lan:") || target_url.toLowerCase().includes(".lan?") || target_url.toLowerCase().includes(".lan/") || target_url.toLowerCase().endsWith(".lan"))
|| (target_url.toLowerCase().includes(".local:") || target_url.toLowerCase().includes(".local?") || target_url.toLowerCase().includes(".local/") || target_url.toLowerCase().endsWith(".local"))
|| (target_url.toLowerCase().includes(".internal:") || target_url.toLowerCase().includes(".internal?") || target_url.toLowerCase().includes(".internal/") || target_url.toLowerCase().endsWith(".internal"))
|| !target_url.toLowerCase().includes(".")); //hostname without dots cannot be wan accessible
return is_local;
}
Expand Down Expand Up @@ -9090,6 +9101,9 @@ initializeInstructUIFunctionality();
custom_cohere_key = "";

let epchoice = document.getElementById("customapidropdown").value;
document.getElementById("connectstatusproxied").classList.add("hidden");
document.getElementById("connectstatus").innerHTML = "Connecting";

if(epchoice==0) //ai horde
{
confirm_horde_models();
Expand Down Expand Up @@ -9122,6 +9136,7 @@ initializeInstructUIFunctionality();
custom_kobold_key = desiredkoboldkey;

let fetchedurl = apply_proxy_url(desiredkoboldendpoint + kobold_custom_mdl_endpoint);

fetch(fetchedurl,{
method: 'GET',
headers: get_kobold_header(),
Expand All @@ -9144,6 +9159,15 @@ initializeInstructUIFunctionality();
custom_kobold_endpoint = "";
render_gametext();
} else {

if(uses_cors_proxy && !is_local_url(fetchedurl))
{
document.getElementById("connectstatusproxied").classList.remove("hidden");
}else
{
document.getElementById("connectstatusproxied").classList.add("hidden");
}

//good to go
custom_kobold_endpoint = desiredkoboldendpoint;
custom_kobold_key = desiredkoboldkey;
Expand Down Expand Up @@ -9362,34 +9386,40 @@ initializeInstructUIFunctionality();

let is_local = is_local_url(custom_kobold_endpoint);

if (uses_cors_proxy || is_local) {
if(is_local && sublocalpathname!="")
{
sublocalpathname = ""; //one more try
attempt_connect(false);
}
else if(is_local && reattempt_local_port80)
{
reattempt_local_port80 = false;
localmodeport = 80;
attempt_connect(false);
}
else
//we will go down the fallbacks one by one until we run out of options
localmodeport = backup_localmodeport;
if(is_local && sublocalpathname!="")
{
sublocalpathname = ""; // first fallback, check subdir paths
attempt_connect(false);
}
else if(reattempt_local_port80) // second fallback, try port 80
{
reattempt_local_port80 = false;
localmodeport = 80;
attempt_connect(false);
}
else if(!is_local && !uses_cors_proxy) //third fallback, use cors proxy if not a local IP
{
uses_cors_proxy = true; // fallback to cors proxy, this will remain for rest of session
connect_custom_endpoint(); //one more try
}
else //finally, we give up
{
msgbox("Failed to connect to Custom KoboldAI Endpoint!<br><br>Please check if KoboldAI is running at the url: " + desiredkoboldendpoint + "<br><br>You can also <a href='#' class='color_blueurl' onclick='hide_popups();display_endpoint_container();'>try a different URL or API type</a>.","Error Encountered",true);
selected_models = [];
selected_workers = [];
custom_kobold_endpoint = "";
if(localflag)
{
msgbox("Failed to connect to Custom KoboldAI Endpoint!<br><br>Please check if KoboldAI is running at the url: " + desiredkoboldendpoint + "<br><br>You can also <a href='#' class='color_blueurl' onclick='hide_popups();display_endpoint_container();'>try a different URL or API type</a>.","Error Encountered",true);
selected_models = [];
selected_workers = [];
custom_kobold_endpoint = "";
if(localflag)
{
document.getElementById("connectstatus").innerHTML = "Offline Mode";
}
render_gametext();
document.getElementById("connectstatus").innerHTML = "Offline Mode";
}else{
document.getElementById("connectstatus").innerHTML = "Error";
}
} else {
uses_cors_proxy = true; //fallback to cors proxy, this will remain for rest of session
connect_custom_endpoint(); //one more try

render_gametext();
}

});
}
}
Expand Down Expand Up @@ -9488,6 +9518,11 @@ initializeInstructUIFunctionality();
{
dismiss_endpoint_container();

if(desired_claude_ep.toLowerCase().includes("api.anthropic.com"))
{
document.getElementById("connectstatusproxied").classList.remove("hidden");
}

//good to go
custom_claude_endpoint = desired_claude_ep;
custom_claude_key = desired_claude_key;
Expand Down Expand Up @@ -9897,12 +9932,19 @@ initializeInstructUIFunctionality();
custom_palm_key = "";
custom_cohere_key = "";

if (selected_idx_arr.length > 0) {
let prep_sel_models = [];
let prep_sel_workers = []; //if selected, pick a specific worker ids to use
let prep_sel_models = [];
let prep_sel_workers = []; //if selected, pick a specific worker ids to use

let manualworker = (document.getElementById("manualworker").checked ? true : false);
let manualworker = (document.getElementById("manualworker").checked ? true : false);

if (selected_idx_arr.length == 0) { //select everything
manualworker = false;
for (let i = 0; i < models_data.length; ++i) {
prep_sel_models.push(models_data[i]);
}
}
else
{
for (var i = 0; i < selected_idx_arr.length; ++i) {
if (manualworker) //we are looping through selected workers
{
Expand All @@ -9922,24 +9964,24 @@ initializeInstructUIFunctionality();
prep_sel_models.push(addedmodel);
}
}
}

//remove undefined and nulls
prep_sel_models = prep_sel_models.filter(x=>x);
prep_sel_workers = prep_sel_workers.filter(x=>x);
//remove undefined and nulls
prep_sel_models = prep_sel_models.filter(x=>x);
prep_sel_workers = prep_sel_workers.filter(x=>x);

selected_models = prep_sel_models;
selected_workers = prep_sel_workers;
localsettings.my_api_key = document.getElementById("apikey").value;
if(localsettings.my_api_key==null || localsettings.my_api_key=="")
{
localsettings.my_api_key = defaultsettings.my_api_key;
}
selected_models = prep_sel_models;
selected_workers = prep_sel_workers;
localsettings.my_api_key = document.getElementById("apikey").value;
if(localsettings.my_api_key==null || localsettings.my_api_key=="")
{
localsettings.my_api_key = defaultsettings.my_api_key;
}

document.getElementById("connectstatus").innerHTML = "AI Horde";
render_gametext();
hide_popups();

render_gametext();
hide_popups();
}
document.getElementById("connectstatus").innerHTML = "AI Horde";
}

function delete_my_worker(index)
Expand Down Expand Up @@ -14511,7 +14553,7 @@ initializeInstructUIFunctionality();
//fix alpaca leakage
if(localsettings.fix_alpaca_leak && (localsettings.opmode == 2 || localsettings.opmode == 3 || localsettings.opmode == 4) && get_instruct_starttag(true).toLowerCase().includes("### instruction"))
{
let matches = gentxt.match(/\n### (.+?):/g);
let matches = gentxt.match(/\n### ([^\s]+?):\n/g);
for(let m in matches)
{
let foundStop = gentxt.indexOf(matches[m]);
Expand Down Expand Up @@ -19059,6 +19101,7 @@ initializeInstructUIFunctionality();
<div id="connectstatusdiv">
<div id="connectstatus">Connecting</div>
<div class="hidden" style="font-size: 12px;" id="connectstatusmultiplayer"></div>
<div class="hidden color_orange" style="font-size: 12px;" id="connectstatusproxied">(Proxied)</div>
</div>
</div>

Expand Down Expand Up @@ -19588,7 +19631,7 @@ initializeInstructUIFunctionality();
</span>
</div>
<div class="popupfooter">
<button type="button" class="btn btn-primary" onclick="connect_custom_endpoint()">Ok</button>
<button type="button" class="btn btn-primary" onclick="clear_cors_proxy_flag();connect_custom_endpoint()">Ok</button>
<button type="button" class="btn btn-primary" onclick="dismiss_endpoint_container()">Cancel</button>
</div>
</div>
Expand Down Expand Up @@ -20170,18 +20213,22 @@ initializeInstructUIFunctionality();
<button id="generate_images_horde_setkey" type="button" class="btn btn-primary" style="width:100%; padding:2px 3px;margin-top:2px;font-size:11px;" onclick="set_horde_key()">Set Horde Key</button>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="If NSFW is disabled, explicit images will be censored">Allow NSFW </div>
<input title="Allow NSFW Images" type="checkbox" id="img_allownsfw" style="margin:0px 0 0;">
<input title="Allow NSFW Images" type="checkbox" id="img_allownsfw" style="margin:0px 0px 0px auto;">
</div>
</div>

<div id="generate_images_local_model_container" class="settinglabel hidden">
<select title="Select Image Model" class="form-control" id="generate_images_local_model" style="height:20px;padding:0;margin:0px 0 0; width:calc(100% - 30px)">
<option value="">[None]</option>
</select>
<button type="button" class="btn btn-primary" onclick="set_a1111_endpoint()" style="height: 20px; padding: 0px 2px; margin: 0px 0px 0px 3px;">⚙️</button>
<div id="generate_images_local_model_container" class="hidden">
<div class="settinglabel">
<select title="Select Image Model" class="form-control" id="generate_images_local_model"
style="height:20px;padding:0;margin:0px 0 0; width:calc(100% - 30px)">
<option value="">[None]</option>
</select>
<button type="button" class="btn btn-primary" onclick="set_a1111_endpoint()"
style="height: 20px; padding: 0px 2px; margin: 0px 0px 0px 3px;">⚙️</button>
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Save images remotely on A1111/Forge host (caution)">Save In A1111/Forge </div>
<input type="checkbox" id="save_remote_images" style="margin:0px 0 0;">
<input type="checkbox" id="save_remote_images" style="margin:0px 0px 0px auto;">
</div>
</div>
<div id="generate_images_comfy_container" class="settinglabel hidden">
Expand All @@ -20201,15 +20248,32 @@ initializeInstructUIFunctionality();
<div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Parse user input text in instruct mode, and trigger image generation if requested">Detect ImgGen Instructions </div>
<input title="Detect ImgGen Instructions" type="checkbox" id="img_gen_from_instruct" style="margin:0px 0 0;">
<input title="Detect ImgGen Instructions" type="checkbox" id="img_gen_from_instruct" style="margin:0px 0px 0px auto;">
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Automatically generates images periodically as you write">Autogenerate </div>
<input title="Autogenerate Images" type="checkbox" id="img_autogen" style="margin:0px 0 0;">
<input title="Autogenerate Images" type="checkbox" id="img_autogen" style="margin:0px 0px 0px auto;">
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Includes images when saving to json file">Save Images </div>
<input title="Save Images in File" type="checkbox" id="save_images" style="margin:0px 0 0;">
<input title="Save Images in File" type="checkbox" id="save_images" style="margin:0px 0px 0px auto;">
</div>
</div>

<div style="border-top: 1px solid #12324f; margin-top: 4px;">
<div>
<div class="settinglabel" style="margin-top: 2px;">
<div class="justifyleft settingsmall">Alerts <span class="helpicon">?<span class="helptext">Triggers alerts when a generation is completed.</span></span></div>
</div>
<div class="settinglabel" style="margin-top: 2px;">
<div class="justifyleft settingsmall" title="Play a sound when generation is complete">Beep on Done </div>
<input title="Beep On Done" type="checkbox" id="beep_on" style="margin:0px 0px 0px auto;">
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Show notification when generation is complete">Notify on Done
</div>
<input title="Notify On Done" type="checkbox" id="notify_on" style="margin:0px 0px 0px auto;">
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -20284,14 +20348,6 @@ initializeInstructUIFunctionality();
<div class="justifyleft settingsmall" title="If unchecked, only speak AI replies, not other text.">Narrate Only Dialog </div>
<input title="Narrate Only Dialog" type="checkbox" id="narrate_only_dialog" style="margin:0px 0px 0px auto;">
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Play a sound when generation is complete">Beep on Done </div>
<input title="Beep On Done" type="checkbox" id="beep_on" style="margin:0px 0px 0px auto;">
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Show notification when generation is complete">Notify on Done </div>
<input title="Notify On Done" type="checkbox" id="notify_on" style="margin:0px 0px 0px auto;">
</div>
<div class="inlinelabel" style="font-size: 11px;">
<div class="justifyleft">Browser TTS Speed: </div>
<input title="Browser Narration Speed" type="text" inputmode="decimal" value="1" id="tts_speed" style="width:40px">
Expand Down
Loading

0 comments on commit 7bcb7cb

Please sign in to comment.