compare_versions() — langchain Function Reference
Architecture documentation for the compare_versions() function in import_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4cdc6722_76b5_5bf4_3a03_8c63950a89ee["compare_versions()"] 985cfe60_5707_c25f_5853_ca512ac40832["import_utils.py"] 4cdc6722_76b5_5bf4_3a03_8c63950a89ee -->|defined in| 985cfe60_5707_c25f_5853_ca512ac40832 2f3787c9_3c47_614a_7ccf_875c731058b1["is_optimum_version()"] 2f3787c9_3c47_614a_7ccf_875c731058b1 -->|calls| 4cdc6722_76b5_5bf4_3a03_8c63950a89ee 773ee9c6_6770_6f44_3b6d_8730178baec3["is_optimum_intel_version()"] 773ee9c6_6770_6f44_3b6d_8730178baec3 -->|calls| 4cdc6722_76b5_5bf4_3a03_8c63950a89ee style 4cdc6722_76b5_5bf4_3a03_8c63950a89ee fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/huggingface/langchain_huggingface/utils/import_utils.py lines 45–73
def compare_versions(
library_or_version: str | version.Version,
operation: str,
requirement_version: str,
) -> bool:
"""Compare a library version to some requirement using a given operation.
Args:
library_or_version:
A library name or a version to check.
operation:
A string representation of an operator, such as `">"` or `"<="`.
requirement_version:
The version to compare the library version against
"""
if operation not in STR_OPERATION_TO_FUNC:
msg = (
f"`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys())}"
f", received {operation}"
)
raise ValueError(msg)
if isinstance(library_or_version, str):
library_or_version = version.parse(
importlib.metadata.version(library_or_version)
)
return STR_OPERATION_TO_FUNC[operation](
library_or_version, version.parse(requirement_version)
)
Domain
Subdomains
Source
Frequently Asked Questions
What does compare_versions() do?
compare_versions() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/utils/import_utils.py.
Where is compare_versions() defined?
compare_versions() is defined in libs/partners/huggingface/langchain_huggingface/utils/import_utils.py at line 45.
What calls compare_versions()?
compare_versions() is called by 2 function(s): is_optimum_intel_version, is_optimum_version.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free