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

Fix get_num_tokens for Anthropic models #4911

Merged
merged 1 commit into from
May 18, 2023

Conversation

jarib
Copy link
Contributor

@jarib jarib commented May 18, 2023

The Anthropic classes used BaseLanguageModel.get_num_tokens because of an issue with multiple inheritance. Fixed by moving the method from _AnthropicCommon to both its subclasses.

This change will significantly speed up token counting for Anthropic users.

@agola11 @mikelambert

The Anthropic classes used BaseLanguageModel.get_num_tokens
because of an inheritance issue. We fix it by moving the method
from _AnthropicCommon to both its subclasses.
@dev2049
Copy link
Contributor

dev2049 commented May 18, 2023

good catch @jarib!

@dev2049 dev2049 merged commit 3df2d83 into langchain-ai:master May 18, 2023
@mikelambert
Copy link
Contributor

Nice catch Jarib, thank you! And sorry I'm late to chiming in, but could we just reverse the order we list our superclasses to avoid the code duplication?

@jarib
Copy link
Contributor Author

jarib commented May 22, 2023

Ah, maybe? I've not really used multiple inheritance much and wasn't sure if there was a reason for the order.

@danielchalef danielchalef mentioned this pull request Jun 5, 2023
This was referenced Jun 25, 2023
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

Successfully merging this pull request may close these issues.

3 participants