Switch AnthropicTokenizer to use client.beta.messages.count_tokens()
Opened this issue · 0 comments
yifanmai commented
When anthropic
is upgraded to 0.39.0 or newer, the following error happens:
src/helm/tokenizers/anthropic_tokenizer.py:26: error: "Anthropic" has no attribute "get_tokenizer" [attr-defined]
This is because of this breaking change:
### ⚠ BREAKING CHANGES
* **client:** remove legacy `client.count_tokens()` & `client.get_tokenizer()` methods ([#726](https://github.com/anthropics/anthropic-sdk-python/issues/726))
* This functionality has been replaced by the `client.beta.messages.count_tokens()` API which supports newer models and all content functionality, such as images and PDFs.
The temporary workaround is to limit anthropic
to versions before 0.39.0. The long term change is to limit anthropic
to after 0.39.0 and switch AnthropicTokenizer
to use client.beta.messages.count_tokens()
.