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

Commit 44a12fb

Browse files
Update tokenizer.ts
1 parent 11f2846 commit 44a12fb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/tokenizer.ts

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export function splitPrompt(
2222
const promptPieces: string[] = []
2323
let remainingPrompt = prompt
2424
while (remainingPrompt.length > 0) {
25+
if (remainingPrompt.length > maxTokens && !remainingPrompt.includes(' ')) {
26+
throw new Error(`Word length exceeds maxTokens: ${maxTokens}`);
27+
}
2528
const lastSpaceIndex = remainingPrompt.lastIndexOf(' ', maxTokens)
2629
if (lastSpaceIndex >= 0) {
2730
// Split at the last space

0 commit comments

Comments
 (0)