Skip to content

Commit da6d60c

Browse files
batudoodilitime
andauthored
Fix splitText (elizaOS#3653)
Co-authored-by: Odilitime <janesmith@airmail.cc>
1 parent 05d679e commit da6d60c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

packages/core/src/generation.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1493,19 +1493,13 @@ export function splitText(
14931493

14941494
while (start < content.length) {
14951495
const end = Math.min(start + chunkSize, content.length);
1496-
14971496
// Ensure we're not creating empty or invalid chunks
14981497
if (end > start) {
14991498
chunks.push(content.substring(start, end));
15001499
}
15011500

1502-
// Ensure forward progress and prevent infinite loops
1503-
const nextStart = end - bleed;
1504-
if (nextStart <= start) {
1505-
start = end; // If no progress would be made, skip the bleed
1506-
} else {
1507-
start = nextStart;
1508-
}
1501+
// Ensure forward progress while preventing infinite loops
1502+
start = Math.max(end - bleed, start + 1);
15091503
}
15101504

15111505
return chunks;

0 commit comments

Comments
 (0)