mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Split overlap size in two
This commit is contained in:
@ -603,11 +603,12 @@ function getPromptText(queriedMessages) {
|
|||||||
* @returns {string} Overlapped chunks, with overlap trimmed to sentence boundaries
|
* @returns {string} Overlapped chunks, with overlap trimmed to sentence boundaries
|
||||||
*/
|
*/
|
||||||
function overlapChunks(chunk, index, chunks, overlapSize) {
|
function overlapChunks(chunk, index, chunks, overlapSize) {
|
||||||
|
const halfOverlap = Math.floor(overlapSize / 2);
|
||||||
const nextChunk = chunks[index + 1];
|
const nextChunk = chunks[index + 1];
|
||||||
const prevChunk = chunks[index - 1];
|
const prevChunk = chunks[index - 1];
|
||||||
|
|
||||||
const nextOverlap = trimToEndSentence(nextChunk?.substring(0, overlapSize)) || '';
|
const nextOverlap = trimToEndSentence(nextChunk?.substring(0, halfOverlap)) || '';
|
||||||
const prevOverlap = trimToStartSentence(prevChunk?.substring(prevChunk.length - overlapSize)) || '';
|
const prevOverlap = trimToStartSentence(prevChunk?.substring(prevChunk.length - halfOverlap)) || '';
|
||||||
const overlappedChunk = [prevOverlap, chunk, nextOverlap].filter(x => x).join(' ');
|
const overlappedChunk = [prevOverlap, chunk, nextOverlap].filter(x => x).join(' ');
|
||||||
|
|
||||||
return overlappedChunk;
|
return overlappedChunk;
|
||||||
|
Reference in New Issue
Block a user