check_package_version() — langchain Function Reference
Architecture documentation for the check_package_version() function in utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3f909b26_53a6_04d5_6fdd_e7bf229b592a["check_package_version()"] b77fd012_b825_e350_c8f5_a8f1b44997d9["utils.py"] 3f909b26_53a6_04d5_6fdd_e7bf229b592a -->|defined in| b77fd012_b825_e350_c8f5_a8f1b44997d9 style 3f909b26_53a6_04d5_6fdd_e7bf229b592a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/utils/utils.py lines 146–190
def check_package_version(
package: str,
lt_version: str | None = None,
lte_version: str | None = None,
gt_version: str | None = None,
gte_version: str | None = None,
) -> None:
"""Check the version of a package.
Args:
package: The name of the package.
lt_version: The version must be less than this.
lte_version: The version must be less than or equal to this.
gt_version: The version must be greater than this.
gte_version: The version must be greater than or equal to this.
Raises:
ValueError: If the package version does not meet the requirements.
"""
imported_version = parse(version(package))
if lt_version is not None and imported_version >= parse(lt_version):
msg = (
f"Expected {package} version to be < {lt_version}. Received "
f"{imported_version}."
)
raise ValueError(msg)
if lte_version is not None and imported_version > parse(lte_version):
msg = (
f"Expected {package} version to be <= {lte_version}. Received "
f"{imported_version}."
)
raise ValueError(msg)
if gt_version is not None and imported_version <= parse(gt_version):
msg = (
f"Expected {package} version to be > {gt_version}. Received "
f"{imported_version}."
)
raise ValueError(msg)
if gte_version is not None and imported_version < parse(gte_version):
msg = (
f"Expected {package} version to be >= {gte_version}. Received "
f"{imported_version}."
)
raise ValueError(msg)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does check_package_version() do?
check_package_version() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/utils.py.
Where is check_package_version() defined?
check_package_version() is defined in libs/core/langchain_core/utils/utils.py at line 146.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free