mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +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.HUMAN_PROMPT = anthropic.HUMAN_PROMPT
|
||||||
self.AI_PROMPT = anthropic.AI_PROMPT
|
self.AI_PROMPT = anthropic.AI_PROMPT
|
||||||
self.count_tokens = self.client.count_tokens
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -375,9 +374,11 @@ class AnthropicLLM(LLM, _AnthropicCommon):
|
|||||||
|
|
||||||
def get_num_tokens(self, text: str) -> int:
|
def get_num_tokens(self, text: str) -> int:
|
||||||
"""Calculate number of tokens."""
|
"""Calculate number of tokens."""
|
||||||
if not self.count_tokens:
|
raise NotImplementedError(
|
||||||
raise NameError("Please ensure the anthropic package is loaded")
|
"Anthropic's legacy count_tokens method was removed in anthropic 0.39.0 "
|
||||||
return self.count_tokens(text)
|
"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")
|
@deprecated(since="0.1.0", removal="0.3.0", alternative="AnthropicLLM")
|
||||||
|
Loading…
Reference in New Issue
Block a user