Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch AnthropicTokenizer to use client.beta.messages.count_tokens() #3212

Open
yifanmai opened this issue Dec 17, 2024 · 0 comments
Open

Switch AnthropicTokenizer to use client.beta.messages.count_tokens() #3212

yifanmai opened this issue Dec 17, 2024 · 0 comments

Comments

@yifanmai
Copy link
Collaborator

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().

@yifanmai yifanmai changed the title Switch AnthropicTokenizer to use Switch AnthropicTokenizer to use client.beta.messages.count_tokens() Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant