mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-21 18:52:02 +00:00
updated lite
This commit is contained in:
parent
7bd95eb505
commit
388a493542
1 changed files with 69 additions and 28 deletions
|
|
@ -4519,8 +4519,8 @@ Current version indicated by LITEVER below.
|
|||
second_ep_model:"gpt2",
|
||||
second_ep_url:"",
|
||||
|
||||
max_context_length: (localflag?8192:3800),
|
||||
max_length: (localflag?1024:500),
|
||||
max_context_length: (localflag?8192:4096),
|
||||
max_length: (localflag?1024:512),
|
||||
last_maxctx: 0,
|
||||
auto_ctxlen: true,
|
||||
auto_genamt: true,
|
||||
|
|
@ -5830,7 +5830,7 @@ Current version indicated by LITEVER below.
|
|||
let instag = localsettings.instruct_systag;
|
||||
if(instag=="{{[SYSTEM]}}" && !(custom_kobold_endpoint != "" && is_using_kcpp_with_autotags()))
|
||||
{
|
||||
instag = ""; //backend not compatible with auto
|
||||
instag = "\n### System:\n"; //backend not compatible with auto
|
||||
}
|
||||
if(doTrim){
|
||||
return replaceAll(instag, "\\n", "\n").trim();
|
||||
|
|
@ -20985,7 +20985,7 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
for(let i=0;i<mhistory.length;++i)
|
||||
{
|
||||
let cturn = { "role": (mhistory[i].myturn?"user":"assistant"), "content": mhistory[i].msg };
|
||||
let cturn = { "role": (mhistory[i].myturn?"user":(mhistory[i].issystem?"system":"assistant")), "content": mhistory[i].msg };
|
||||
if(!mhistory[i].myturn && mhistory[i].tool_calls)
|
||||
{
|
||||
cturn.content = null;
|
||||
|
|
@ -21172,7 +21172,7 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
|
||||
//many backends REFUSE to allow the assistant to go first. If the first turn belongs to assistant, we turn it into user
|
||||
if(mhistory.length>0 && !mhistory[0].myturn)
|
||||
if(mhistory.length>0 && !mhistory[0].myturn && !mhistory[0].issystem)
|
||||
{
|
||||
mhistory[0].myturn = true;
|
||||
}
|
||||
|
|
@ -21202,7 +21202,7 @@ Current version indicated by LITEVER below.
|
|||
|
||||
for(let i=0;i<mhistory.length;++i)
|
||||
{
|
||||
let cturn = { "role": (mhistory[i].myturn?"user":"assistant"), "content": mhistory[i].msg };
|
||||
let cturn = { "role": (mhistory[i].myturn?"user":(mhistory[i].issystem?"system":"assistant")), "content": mhistory[i].msg };
|
||||
if(!mhistory[i].myturn && mhistory[i].tool_calls)
|
||||
{
|
||||
cturn.content = null;
|
||||
|
|
@ -21269,6 +21269,13 @@ Current version indicated by LITEVER below.
|
|||
{
|
||||
oai_payload.messages.unshift({ "role": "system", "content": "Please continue this text directly from where it stopped. Just respond with a direct partial continuation of the text immediately from the latest word." });
|
||||
}
|
||||
|
||||
if(oai_payload.messages.length>1 && oai_payload.messages[0].role=="system" && oai_payload.messages[1].role=="system" )
|
||||
{
|
||||
//first 2 turns are system, merge them
|
||||
oai_payload.messages[0].content += "\n" + oai_payload.messages[1].content;
|
||||
oai_payload.messages.splice(1, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -25200,6 +25207,10 @@ Current version indicated by LITEVER below.
|
|||
//do nothing on cancel
|
||||
},true,true);
|
||||
}
|
||||
function classic_retry_turn(idx)
|
||||
{
|
||||
corpo_retry_chunk(idx);
|
||||
}
|
||||
|
||||
function classic_click_turn(button,idx,toggleopen = true)
|
||||
{
|
||||
|
|
@ -25216,6 +25227,7 @@ Current version indicated by LITEVER below.
|
|||
|
||||
let popcontent = `<button type="button" onclick="classic_edit_turn(${idx})">Edit Turn</button>`;
|
||||
popcontent += `<button type="button" onclick="classic_delete_turn(${idx})">Delete Turn</button>`;
|
||||
popcontent += `<button type="button" onclick="classic_retry_turn(${idx})">Retry Turn</button>`;
|
||||
popcontent += `<button type="button" onclick="">Cancel</button>`;
|
||||
popupMenu.innerHTML = popcontent;
|
||||
|
||||
|
|
@ -25552,9 +25564,10 @@ Current version indicated by LITEVER below.
|
|||
</div>`;
|
||||
}
|
||||
|
||||
function repack_instruct_turns(input,usertag,aitag,allow_blank)
|
||||
function repack_instruct_turns(input,usertag,aitag,systag,allow_blank)
|
||||
{
|
||||
let myturnchat = false; //who is currently speaking?
|
||||
let issystem = false; //is this a system turn?
|
||||
let chatunits = []; //parse chat body into nice chat chunks
|
||||
|
||||
let combined_chunks = [];
|
||||
|
|
@ -25572,27 +25585,44 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
continue;
|
||||
}
|
||||
let turnchunks2 = chnk.split(aitag);
|
||||
for(let j=0;j<turnchunks2.length;++j)
|
||||
|
||||
// NEW: split system first
|
||||
let syschunks = chnk.split(systag);
|
||||
for(let s=0;s<syschunks.length;++s)
|
||||
{
|
||||
if(j==0)
|
||||
let syschnk = syschunks[s];
|
||||
|
||||
// inject system placeholder except first
|
||||
if(s>0)
|
||||
{
|
||||
if(startoppo)
|
||||
combined_chunks.push("%SystemPlaceholder%");
|
||||
}
|
||||
|
||||
let turnchunks2 = syschnk.split(aitag);
|
||||
for(let j=0;j<turnchunks2.length;++j)
|
||||
{
|
||||
if(j==0)
|
||||
{
|
||||
startoppo = false;
|
||||
combined_chunks.push("%AIPlaceholder%");
|
||||
if(s==0) // only apply original logic on first system split
|
||||
{
|
||||
if(startoppo)
|
||||
{
|
||||
startoppo = false;
|
||||
combined_chunks.push("%AIPlaceholder%");
|
||||
}
|
||||
else
|
||||
{
|
||||
combined_chunks.push("%HumanPlaceholder%");
|
||||
}
|
||||
}
|
||||
|
||||
combined_chunks.push(turnchunks2[j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
combined_chunks.push("%HumanPlaceholder%");
|
||||
combined_chunks.push("%AIPlaceholder%");
|
||||
combined_chunks.push(turnchunks2[j]);
|
||||
}
|
||||
|
||||
combined_chunks.push(turnchunks2[j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
combined_chunks.push("%AIPlaceholder%");
|
||||
combined_chunks.push(turnchunks2[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25603,21 +25633,29 @@ Current version indicated by LITEVER below.
|
|||
if(curr=="%HumanPlaceholder%")
|
||||
{
|
||||
myturnchat = true;
|
||||
issystem = false;
|
||||
}
|
||||
else if(curr=="%AIPlaceholder%")
|
||||
{
|
||||
myturnchat = false;
|
||||
issystem = false;
|
||||
}
|
||||
else if(curr=="%SystemPlaceholder%")
|
||||
{
|
||||
myturnchat = false;
|
||||
issystem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(allow_blank || curr.trim()!="")
|
||||
{
|
||||
chatunits.push({
|
||||
msg:curr,
|
||||
myturn:myturnchat,
|
||||
unlabelled_name:unlabelled_turns,
|
||||
unlabelled_img:unlabelled_turns
|
||||
});
|
||||
msg:curr,
|
||||
myturn:myturnchat,
|
||||
issystem:issystem,
|
||||
unlabelled_name:unlabelled_turns,
|
||||
unlabelled_img:unlabelled_turns
|
||||
});
|
||||
}
|
||||
unlabelled_turns = false;
|
||||
}
|
||||
|
|
@ -25626,7 +25664,7 @@ Current version indicated by LITEVER below.
|
|||
//post process the chatunits to handle tool calls
|
||||
for(let i=0;i<chatunits.length;++i)
|
||||
{
|
||||
if(!chatunits[i].myturnchat && (chatunits[i].msg.includes("tool_call_id") || chatunits[i].msg.includes("tool_calls")))
|
||||
if(!chatunits[i].myturn && !chatunits[i].issystem && (chatunits[i].msg.includes("tool_call_id") || chatunits[i].msg.includes("tool_calls")))
|
||||
{
|
||||
try {
|
||||
let unsc = unescape_html(chatunits[i].msg);
|
||||
|
|
@ -25788,9 +25826,12 @@ Current version indicated by LITEVER below.
|
|||
|
||||
let st = get_instruct_starttag(false);
|
||||
let et = get_instruct_endtag(false);
|
||||
let syst = get_instruct_systag(false);
|
||||
|
||||
let ste = get_instruct_starttag_end(false);
|
||||
let ete = get_instruct_endtag_end(false);
|
||||
let syste = get_instruct_systag_end(false);
|
||||
|
||||
let foundpreset = find_matching_instruct_preset(st,et);
|
||||
if(foundpreset && !ete && foundpreset.assistant_end && !ste && foundpreset.user_end)
|
||||
{
|
||||
|
|
@ -25808,7 +25849,7 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
}
|
||||
|
||||
let turns = repack_instruct_turns(input,st,et,allow_blank);
|
||||
let turns = repack_instruct_turns(input,st,et,syst,allow_blank);
|
||||
return turns;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue