Solving anthropic packaging version issue (#7306)

- Description: Solving, anthropic packaging version issue by clearing
the mixup from package.version that is being confused with version from
- importlib.metadata.version.

  - Issue: it fixes the issue #7283 
  - Maintainer: @hwchase17 

The following change has been explained in the comment -
https://github.com/hwchase17/langchain/issues/7283#issuecomment-1624328978
This commit is contained in:
Sparsh Jain 2023-07-07 05:05:42 +05:30 committed by GitHub
parent d642609a23
commit bac56618b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ import warnings
from importlib.metadata import version from importlib.metadata import version
from typing import Any, Callable, Dict, Generator, List, Mapping, Optional from typing import Any, Callable, Dict, Generator, List, Mapping, Optional
import packaging from packaging.version import parse
from pydantic import BaseModel, root_validator from pydantic import BaseModel, root_validator
from langchain.callbacks.manager import ( from langchain.callbacks.manager import (
@ -64,8 +64,8 @@ class _AnthropicCommon(BaseModel):
try: try:
import anthropic import anthropic
anthropic_version = packaging.version.parse(version("anthropic")) anthropic_version = parse(version("anthropic"))
if anthropic_version < packaging.version.parse("0.3"): if anthropic_version < parse("0.3"):
raise ValueError( raise ValueError(
f"Anthropic client version must be > 0.3, got {anthropic_version}. " f"Anthropic client version must be > 0.3, got {anthropic_version}. "
f"To update the client, please run " f"To update the client, please run "