Skip to content

Commit

Permalink
Added version ceiling for anthropic token count.
Browse files Browse the repository at this point in the history
  • Loading branch information
3coins committed Nov 18, 2024
1 parent a867a1d commit e696102
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libs/aws/langchain_aws/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ def enforce_stop_tokens(text: str, stop: List[str]) -> str:
def _get_anthropic_client() -> Any:
try:
import anthropic
from packaging import version

max_supported_version = version.parse("0.38.0")
anthropic_version = version.parse(anthropic.__version__)

if anthropic_version > max_supported_version:
raise NotImplementedError(
"Currently installed anthropic version {anthropic_version} is not "
"supported. Please use ChatAnthropic.get_num_tokens_from_messages "
"instead."
)

except ImportError:
raise ImportError(
"Could not import anthropic python package. "
Expand Down

0 comments on commit e696102

Please sign in to comment.