mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-07-10 01:18:32 +00:00
updated lite
This commit is contained in:
parent
0f278d93b3
commit
9b95ade6cc
1 changed files with 40 additions and 3 deletions
|
|
@ -20797,10 +20797,47 @@ Current version indicated by LITEVER below.
|
|||
oaiimgs = oai_append_media(oaiimgs);
|
||||
if(mhistory.length>0 && oaiimgs.length>0)
|
||||
{
|
||||
mhistory[0].msg = [{type: 'text', text: mhistory[0].msg}];
|
||||
for(let i=0;i<oaiimgs.length;++i)
|
||||
//do we have the same number of images as placeholders? if so, assign each image to the right turns
|
||||
let placeholder_count = 0;
|
||||
const regex = /\n\(Attached (Image|Audio) \d+\)\n/g;
|
||||
for(let i=0;i<mhistory.length;++i)
|
||||
{
|
||||
mhistory[0].msg.push(oaiimgs[i]);
|
||||
const matches = mhistory[i].msg.match(regex);
|
||||
const count = matches ? matches.length : 0;
|
||||
placeholder_count += count;
|
||||
}
|
||||
if(placeholder_count==oaiimgs.length)
|
||||
{
|
||||
//exactly same number, so we can put images into matching turns
|
||||
let mediaidx = 0;//for each occurance of the regex in this turn, insert mediaidx from oaiimgs and increment it
|
||||
for (let i = 0; i < mhistory.length; ++i)
|
||||
{
|
||||
let msg = mhistory[i].msg;
|
||||
const matches = msg.match(regex);
|
||||
const count = matches ? matches.length : 0;
|
||||
if(count>0)
|
||||
{
|
||||
msg = msg.replace(regex, '');
|
||||
let newMsg = [{ type: 'text', text: msg }];
|
||||
for (let j = 0; j < count; ++j)
|
||||
{
|
||||
if (mediaidx < oaiimgs.length)
|
||||
{
|
||||
newMsg.push(oaiimgs[mediaidx]);
|
||||
mediaidx++;
|
||||
}
|
||||
}
|
||||
mhistory[i].msg = newMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mhistory[0].msg = [{type: 'text', text: mhistory[0].msg}];
|
||||
for(let i=0;i<oaiimgs.length;++i)
|
||||
{
|
||||
mhistory[0].msg.push(oaiimgs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(let i=0;i<mhistory.length;++i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue