Repository navigation
Anthropic and get_count_tokens #623
Replies: 1 comment
|
The warning is from Accurate counts, in order of how close they are to what Bedrock will bill:
import tiktoken
enc = tiktoken.get_encoding("cl100k_base") # close, not identical to Claude
chat = ChatBedrock(
model_id="anthropic.claude-3-5-sonnet-20241022-v2:0",
custom_get_token_ids=lambda text: enc.encode(text),
)
Do not install |
Uh oh!
There was an error while loading. Please reload this page.
I'm using Anthropic models via Bedrock and I'm getting the following warning when trying to count tokens for this model.
I understand this is because the newer Anthropic API is not yet supported in Bedrock itself.
what's the recommended approach to get somewhat accurate token counts other than using the fallback?
All reactions