Skip to content

Commit 5d9b7de

Browse files
committed
Move encoding into try block to handle potential errors during model encoding.
1 parent 6ee75be commit 5d9b7de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/core/src/generation.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ async function truncateTiktoken(
107107
context: string,
108108
maxTokens: number
109109
) {
110-
const encoding = encodingForModel(model);
111-
112110
try {
111+
const encoding = encodingForModel(model);
112+
113113
// Encode the text into tokens
114114
const tokens = encoding.encode(context);
115115

0 commit comments

Comments
 (0)