Skip to content

Commit

Permalink
Update count_tokens.ts (#2689)
Browse files Browse the repository at this point in the history
* Update count_tokens.ts

* Format

---------

Co-authored-by: jacoblee93 <jacoblee93@gmail.com>
  • Loading branch information
wcummings and jacoblee93 authored Sep 21, 2023
1 parent eadd0f8 commit 85d8e72
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion langchain/src/base_language/count_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export const calculateMaxTokens = async ({
let numTokens;

try {
numTokens = (await encodingForModel(modelName)).encode(prompt).length;
numTokens = (
await encodingForModel(getModelNameForTiktoken(modelName))
).encode(prompt).length;
} catch (error) {
console.warn(
"Failed to calculate number of tokens, falling back to approximate count"
Expand Down

1 comment on commit 85d8e72

@vercel
Copy link

@vercel vercel bot commented on 85d8e72 Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.