core[patch]: Update sys info information (#16297)

Update information collected in sys info.

python -m langchain_core.sys_info     

System Information
------------------
> OS:  Linux
> OS Version: #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30
UTC 2
> Python Version:  3.11.4 (main, Sep 25 2023, 10:06:23) [GCC 11.4.0]

Package Information
-------------------
> langchain_core: 0.1.10
> langchain: 0.1.0
> langchain_community: 0.0.11
> langchain_cli: 0.0.20
> langchain_experimental: 0.0.36
> langchain_openai: 0.0.2
> langchainhub: 0.1.14
> langserve: 0.0.19

Packages not installed (Not Necessarily a Problem)
--------------------------------------------------
The following packages were not found:

> langgraph
This commit is contained in:
Eugene Yurtsev 2024-01-22 10:18:04 -05:00 committed by GitHub
parent 5396604ef4
commit 89372fca22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,16 +4,32 @@ from typing import Sequence
def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None: def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
"""Print information about the environment for debugging purposes.""" """Print information about the environment for debugging purposes."""
import pkgutil
import platform import platform
import sys import sys
from importlib import metadata, util from importlib import metadata, util
packages = [ # Packages that do not start with "langchain" prefix.
"langchain_core", other_langchain_packages = [
"langchain",
"langchain_community",
"langserve", "langserve",
] + list(additional_pkgs) "langgraph",
]
langchain_pkgs = [
name for _, name, _ in pkgutil.iter_modules() if name.startswith("langchain")
]
all_packages = sorted(
set(langchain_pkgs + other_langchain_packages + list(additional_pkgs))
)
# Always surface these packages to the top
order_by = ["langchain_core", "langchain", "langchain_community"]
for pkg in reversed(order_by):
if pkg in all_packages:
all_packages.remove(pkg)
all_packages = [pkg] + list(all_packages)
system_info = { system_info = {
"OS": platform.system(), "OS": platform.system(),
@ -32,13 +48,15 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
print("Package Information") print("Package Information")
print("-------------------") print("-------------------")
for pkg in packages: not_installed = []
for pkg in all_packages:
try: try:
found_package = util.find_spec(pkg) found_package = util.find_spec(pkg)
except Exception: except Exception:
found_package = None found_package = None
if found_package is None: if found_package is None:
print(f"> {pkg}: Not Found") not_installed.append(pkg)
continue continue
# Package version # Package version
@ -51,7 +69,16 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
if package_version is not None: if package_version is not None:
print(f"> {pkg}: {package_version}") print(f"> {pkg}: {package_version}")
else: else:
print(f"> {pkg}: Found") print(f"> {pkg}: Installed. No version info available.")
if not_installed:
print()
print("Packages not installed (Not Necessarily a Problem)")
print("--------------------------------------------------")
print("The following packages were not found:")
print()
for pkg in not_installed:
print(f"> {pkg}")
if __name__ == "__main__": if __name__ == "__main__":