updated lite

This commit is contained in:
Concedo 2025-12-07 17:13:23 +08:00
parent 17c0c8d55d
commit 40d3d830a1

View file

@ -3809,7 +3809,7 @@ Current version indicated by LITEVER below.
img_gen_from_instruct: true,
img_autogen_type: 0, //0 is off, 1 is on, 2 is smart
img_allownsfw: true,
img_cfgscale: 6,
img_cfgscale: 5,
img_allowhd: true,
img_crop: false,
img_newturn: false,
@ -6468,12 +6468,26 @@ Current version indicated by LITEVER below.
}
else if(event.data.choices[0].delta && event.data.choices[0].delta.content)
{
if(streaming_was_thinking)
let cnt = event.data.choices[0].delta.content;
if(cnt && cnt.length>0 && cnt[0].type=="thinking") //mistral
{
if(cnt[0].thinking && cnt[0].thinking.length>0 && cnt[0].thinking[0].text)
{
streaming_was_thinking = true;
cnt = cnt[0].thinking[0].text;
}
else
{
cnt = "";
}
}
else if(streaming_was_thinking)
{
streaming_was_thinking = false;
synchro_pending_stream = `${localsettings.start_thinking_tag}${synchro_pending_stream}${localsettings.stop_thinking_tag}`;
}
synchro_pending_stream += event.data.choices[0].delta.content;
synchro_pending_stream += cnt;
}
else if(event.data.choices[0].delta && !event.data.choices[0].delta.content && event.data.choices[0].delta.reasoning_content!=null&& event.data.choices[0].delta.reasoning_content!="")
{
@ -7726,7 +7740,7 @@ Current version indicated by LITEVER below.
const reader = new FileReader();
reader.onloadend = () => {
let origImg = reader.result;
let imgres = localsettings.img_allowhd?(localsettings.img_aspect==0?NO_HD_RES_PX:HD_RES_PX):NO_HD_RES_PX;
let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX;
compressImage(origImg, (newDataUri) => {
image_db[imgid].done = true;
image_db[imgid].result = newDataUri;
@ -8201,7 +8215,7 @@ Current version indicated by LITEVER below.
document.getElementById("enhancedchatinterface").classList.add("transparentbg");
document.getElementById("enhancedchatinterface_inner").classList.add("transparentbg");
indexeddb_save("bgimg", compressedImageURI);
}, false, 1024, 0.5);
}, false, 1024);
}
};
function clear_bg_img()
@ -16169,7 +16183,7 @@ Current version indicated by LITEVER below.
{
image_db[imgid].aspect = 2; //landscape
}
}, false, imgres,0.45,true);
}, false, imgres, true);
}
function self_upload_audio(origAudio,filename,modify_curr_turn=false)
@ -18408,7 +18422,7 @@ Current version indicated by LITEVER below.
//mistral api does not support presence pen
oai_payload.presence_penalty = scaled_rep_pen;
}
if(document.getElementById("useoainonstandard").checked || targetep.toLowerCase().includes("featherless.ai"))
if(document.getElementById("useoainonstandard").checked)
{
//featherless api supports additional fields, include them
oai_payload.top_k = (submit_payload.params.top_k<1?300:submit_payload.params.top_k);
@ -18610,6 +18624,15 @@ Current version indicated by LITEVER below.
oaiheaders['nostream'] = true;
}
if(targetep.toLowerCase().includes("api.novita.ai"))
{
if(oai_payload.reasoning_effort && oai_payload.reasoning_effort!="") //adapt reasoning effort for openrouter
{
oai_payload.enable_thinking = (oai_payload.reasoning_effort=="none"?false:true);
delete oai_payload["reasoning_effort"];
}
}
if(targetep.toLowerCase().includes("openrouter.ai"))
{
oaiheaders["HTTP-Referer"] = "https://lite.koboldai.net";
@ -19332,7 +19355,7 @@ Current version indicated by LITEVER below.
{
//console.log(outputimg);
let origImg = "data:image/jpeg;base64," + outputimg;
let imgres = localsettings.img_allowhd?(localsettings.img_aspect==0?NO_HD_RES_PX:HD_RES_PX):NO_HD_RES_PX;
let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX;
compressImage(origImg, (newDataUri) => {
image_db[imgid].done = true;
image_db[imgid].result = newDataUri;
@ -19377,11 +19400,11 @@ Current version indicated by LITEVER below.
{
//console.log(outputimg);
let origImg = "data:image/jpeg;base64," + outputimg;
let imgres = localsettings.img_allowhd?HD_RES_PX:NO_HD_RES_PX;
let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX;
compressImage(origImg, (newDataUri) => {
image_db[imgid].done = true;
image_db[imgid].result = newDataUri;
}, true, imgres);
}, false, imgres);
}else{
image_db[imgid].queue = "Failed";
msgbox(`Image Generation Failed!\n\n${outputerr?(outputerr+"\n\n"):""}Please make sure your OpenAI key is set correctly and you are allowed to use DALL-E.\n`);
@ -20392,8 +20415,7 @@ Current version indicated by LITEVER below.
else {
img.queue = 0;
let origImg = "data:image/jpeg;base64," + finalimg.generations[0].img;
//console.log("Original image: " + origImg);
let imgres = localsettings.img_allowhd ? (localsettings.img_aspect == 0 ? NO_HD_RES_PX : HD_RES_PX) : NO_HD_RES_PX;
let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX;
compressImage(origImg, (newDataUri) => {
img.result = newDataUri;
}, false, imgres);
@ -20447,7 +20469,7 @@ Current version indicated by LITEVER below.
reader.onloadend = () => {
img.queue = 0;
let origImg = reader.result;
let imgres = localsettings.img_allowhd?(localsettings.img_aspect==0?NO_HD_RES_PX:HD_RES_PX):NO_HD_RES_PX;
let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX;
compressImage(origImg, (newDataUri) => {
img.result = newDataUri;
}, false, imgres);
@ -20513,7 +20535,7 @@ Current version indicated by LITEVER below.
}
}
function compressImage(inputDataUri, onDone, fixedSize=true, maxSize=NO_HD_RES_PX, quality = 0.45, letterboxAspect=false) {
function compressImage(inputDataUri, onDone, fixedSize=true, maxSize=NO_HD_RES_PX, letterboxAspect=false) {
let img = document.createElement('img');
let wantedWidth = maxSize;
let wantedHeight = maxSize;
@ -20532,15 +20554,25 @@ Current version indicated by LITEVER below.
// We set the dimensions at the wanted size for fixedsize.
if(!fixedSize)
{
const minAllowedSize = 256; //do not allow smaller than this
//otherwise, we preserve the original ratio but scale them down to fit
let maxImgDim = Math.max(origW,origH);
wantedWidth = origW;
wantedHeight = origH;
if(maxImgDim > maxSize)
let smallestSide = Math.min(wantedWidth,wantedHeight);
if(smallestSide<minAllowedSize && smallestSide>0)
{
let scalef = minAllowedSize/smallestSide;
wantedWidth *= scalef;
wantedHeight *= scalef;
}
let maxImgDim = Math.max(wantedWidth,wantedHeight);
if(maxImgDim > maxSize && maxImgDim>0)
{
let scalef = maxImgDim/maxSize;
wantedWidth = origW/scalef;
wantedHeight = origH/scalef;
wantedWidth = wantedWidth/scalef;
wantedHeight = wantedHeight/scalef;
}
}
@ -20623,6 +20655,7 @@ Current version indicated by LITEVER below.
}
var dataURI = "";
let quality = 0.5; //standardize quality for all, too many conflicting answers
if(isJpeg)
{
dataURI = canvas.toDataURL(`image/jpeg`, quality);
@ -28216,7 +28249,7 @@ Current version indicated by LITEVER below.
<div><input type="checkbox" id="useoaichatcompl" title="Use ChatCompletions API" onchange="toggleoaichatcompl()">
<div class="box-label">Chat-Completions API</div></div>
<div><input type="checkbox" id="useoainonstandard" title="Send Non-Standard Fields">
<div class="box-label">Non-Standard Fields</div></div>
<div class="box-label">Non-Standard Fields <span class="helpicon">?<span class="helptext">Send extra non-standard samplers like Min-P, Top-K and Top-A.</span></span></div></div>
</div>
<div id="useoaichatcomplbox" class="hidden" onload="toggleoaichatcompl();">
<div style="display: inline-block;">