mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 23:00:00 +00:00
drop support for Anthropic.get_num_tokens
This commit is contained in:
parent
b2e8df4cea
commit
ff2ef48b35
@ -109,7 +109,6 @@ class _AnthropicCommon(BaseLanguageModel):
|
||||
)
|
||||
self.HUMAN_PROMPT = anthropic.HUMAN_PROMPT
|
||||
self.AI_PROMPT = anthropic.AI_PROMPT
|
||||
self.count_tokens = self.client.count_tokens
|
||||
return self
|
||||
|
||||
@property
|
||||
@ -375,9 +374,11 @@ class AnthropicLLM(LLM, _AnthropicCommon):
|
||||
|
||||
def get_num_tokens(self, text: str) -> int:
|
||||
"""Calculate number of tokens."""
|
||||
if not self.count_tokens:
|
||||
raise NameError("Please ensure the anthropic package is loaded")
|
||||
return self.count_tokens(text)
|
||||
raise NotImplementedError(
|
||||
"Anthropic's legacy count_tokens method was removed in anthropic 0.39.0 "
|
||||
"and langchain-anthropic 0.2.5. Please use "
|
||||
"ChatAnthropic.get_num_tokens_from_messages instead."
|
||||
)
|
||||
|
||||
|
||||
@deprecated(since="0.1.0", removal="0.3.0", alternative="AnthropicLLM")
|
||||
|
Loading…
Reference in New Issue
Block a user