Skip to content

Commit 75ec0ba

Browse files
committed
fixed lite tags
1 parent 48c3682 commit 75ec0ba

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

klite.embd

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,7 +4190,7 @@ Current version indicated by LITEVER below.
41904190
function get_instruct_starttag(doTrim=true)
41914191
{
41924192
let instag = localsettings.instruct_starttag;
4193-
if(instag=="{{[INPUT]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()) && localsettings.placeholder_tags)
4193+
if(instag=="{{[INPUT]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()))
41944194
{
41954195
instag = "\n### Instruction:\n"; //backend not compatible with auto
41964196
}
@@ -4203,7 +4203,7 @@ Current version indicated by LITEVER below.
42034203
function get_instruct_endtag(doTrim=true)
42044204
{
42054205
let instag = localsettings.instruct_endtag;
4206-
if(instag=="{{[OUTPUT]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()) && localsettings.placeholder_tags)
4206+
if(instag=="{{[OUTPUT]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()))
42074207
{
42084208
instag = "\n### Response:\n"; //backend not compatible with auto
42094209
}
@@ -4216,7 +4216,7 @@ Current version indicated by LITEVER below.
42164216
function get_instruct_systag(doTrim=true)
42174217
{
42184218
let instag = localsettings.instruct_systag;
4219-
if(instag=="{{[SYSTEM]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()) && localsettings.placeholder_tags)
4219+
if(instag=="{{[SYSTEM]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()))
42204220
{
42214221
instag = ""; //backend not compatible with auto
42224222
}
@@ -16540,47 +16540,44 @@ Current version indicated by LITEVER below.
1654016540
{
1654116541
let st = get_instruct_starttag(true);
1654216542
let et = get_instruct_endtag(true);
16543-
if(st=="{{[INPUT]}}" || et=="{{[OUTPUT]}}")
16543+
let stripping_arr = [];
16544+
if(st!="")
1654416545
{
16545-
st = "### Instruction:";
16546-
et = "### Response:";
16546+
stripping_arr.push(st);
1654716547
}
16548-
let stet_et = "";
16549-
if(localsettings.separate_end_tags && get_instruct_endtag_end(true))
16548+
if(et!="")
1655016549
{
16551-
stet_et = get_instruct_endtag_end(true);
16550+
stripping_arr.push(et);
1655216551
}
16553-
16554-
//sometimes the OAI type endpoints get confused and repeat the instruct tag, so trim it
16555-
let earlymatch = gentxt.indexOf(et);
16556-
if(earlymatch==0)
16552+
if(st=="{{[INPUT]}}" || et=="{{[OUTPUT]}}")
1655716553
{
16558-
gentxt = gentxt.substring(et.length);
16554+
stripping_arr.push("### Instruction:");
16555+
stripping_arr.push("### Response:");
1655916556
}
16560-
16561-
let found = gentxt.indexOf(st);
16562-
let splitresponse = [];
16563-
if (found != -1) //if found, truncate to it
16557+
if(localsettings.separate_end_tags && get_instruct_endtag_end(true))
1656416558
{
16565-
splitresponse = gentxt.split(st);
16566-
gentxt = splitresponse[0];
16559+
let stet_et = get_instruct_endtag_end(true);
16560+
if(stet_et!="")
16561+
{
16562+
stripping_arr.push(stet_et);
16563+
}
1656716564
}
1656816565

16569-
found = gentxt.indexOf(et);
16570-
splitresponse = [];
16571-
if (found != -1) //if found, truncate to it
16566+
//sometimes the OAI type endpoints get confused and repeat the instruct tag, so trim it
16567+
for(let i=0;i<stripping_arr.length;++i)
1657216568
{
16573-
splitresponse = gentxt.split(et);
16574-
gentxt = splitresponse[0];
16575-
}
16569+
let curtag = stripping_arr[i];
16570+
let earlymatch = gentxt.indexOf(curtag);
16571+
if(earlymatch==0)
16572+
{
16573+
gentxt = gentxt.substring(curtag.length);
16574+
}
1657616575

16577-
if(stet_et && stet_et!="")
16578-
{
16579-
found = gentxt.indexOf(stet_et);
16580-
splitresponse = [];
16576+
let found = gentxt.indexOf(curtag);
16577+
let splitresponse = [];
1658116578
if (found != -1) //if found, truncate to it
1658216579
{
16583-
splitresponse = gentxt.split(stet_et);
16580+
splitresponse = gentxt.split(curtag);
1658416581
gentxt = splitresponse[0];
1658516582
}
1658616583
}

0 commit comments

Comments
 (0)