Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit 4cf4e4d

Browse files
Update tokenizer.ts as per the codereviwer ai comment
1 parent 44a12fb commit 4cf4e4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tokenizer.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export function splitPrompt(
2323
let remainingPrompt = prompt
2424
while (remainingPrompt.length > 0) {
2525
if (remainingPrompt.length > maxTokens && !remainingPrompt.includes(' ')) {
26-
throw new Error(`Word length exceeds maxTokens: ${maxTokens}`);
26+
const piece = remainingPrompt.substring(0, maxTokens).trim();
27+
promptPieces.push(piece);
28+
remainingPrompt = remainingPrompt.substring(maxTokens).trim();
2729
}
2830
const lastSpaceIndex = remainingPrompt.lastIndexOf(' ', maxTokens)
2931
if (lastSpaceIndex >= 0) {

0 commit comments

Comments
 (0)