diff --git a/libs/langchain/langchain/llms/base.py b/libs/langchain/langchain/llms/base.py index 335fbadbcfc..1b34e359f53 100644 --- a/libs/langchain/langchain/llms/base.py +++ b/libs/langchain/langchain/llms/base.py @@ -1,9 +1,17 @@ -# Backwards compatibility. +""" +This module provides backward-compatible exports of core language model classes. + +These classes are re-exported for compatibility with older versions of LangChain +and allow users to import language model interfaces from a stable path. + +Exports: + - LLM: Abstract base class for all LLMs + - BaseLLM: Deprecated or foundational class for legacy LLMs + - BaseLanguageModel: Base class for core language model implementations +""" + from langchain_core.language_models import BaseLanguageModel -from langchain_core.language_models.llms import ( - LLM, - BaseLLM, -) +from langchain_core.language_models.llms import LLM, BaseLLM __all__ = [ "LLM", diff --git a/libs/langchain/langchain/tools/jira/tool.py b/libs/langchain/langchain/tools/jira/tool.py index 9f8b313dc01..b9f2db6c11a 100644 --- a/libs/langchain/langchain/tools/jira/tool.py +++ b/libs/langchain/langchain/tools/jira/tool.py @@ -1,3 +1,14 @@ +""" +This module provides dynamic access to deprecated Jira tools. + +When attributes like `JiraAction` are accessed, they are redirected to their new +locations in `langchain_community.tools`. This ensures backward compatibility +while warning developers about deprecation. + +Attributes: + JiraAction (deprecated): Dynamically loaded from langchain_community.tools. +""" + from typing import TYPE_CHECKING, Any from langchain._api import create_importer @@ -14,7 +25,15 @@ _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_L def __getattr__(name: str) -> Any: - """Look up attributes dynamically.""" + """ + Dynamically retrieve attributes from the updated module path. + + Args: + name (str): The name of the attribute to import. + + Returns: + Any: The resolved attribute from the updated path. + """ return _import_attribute(name) diff --git a/libs/langchain/langchain/tools/json/tool.py b/libs/langchain/langchain/tools/json/tool.py index 5edf1c798d2..d6b2a6a4299 100644 --- a/libs/langchain/langchain/tools/json/tool.py +++ b/libs/langchain/langchain/tools/json/tool.py @@ -1,3 +1,14 @@ +""" +This module provides dynamic access to deprecated JSON tools in LangChain. + +It ensures backward compatibility by forwarding references such as +`JsonGetValueTool`, `JsonListKeysTool`, and `JsonSpec` to their updated +locations within the `langchain_community.tools` namespace. + +This setup allows legacy code to continue working while guiding developers +toward using the updated module paths. +""" + from typing import TYPE_CHECKING, Any from langchain._api import create_importer @@ -19,7 +30,18 @@ _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_L def __getattr__(name: str) -> Any: - """Look up attributes dynamically.""" + """ + Dynamically retrieve attributes from the updated module path. + + This method is used to resolve deprecated attribute imports + at runtime and forward them to their new locations. + + Args: + name (str): The name of the attribute to import. + + Returns: + Any: The resolved attribute from the appropriate updated module. + """ return _import_attribute(name) diff --git a/libs/langchain/langchain/tools/zapier/tool.py b/libs/langchain/langchain/tools/zapier/tool.py index 3211624589c..c0100e3d0cb 100644 --- a/libs/langchain/langchain/tools/zapier/tool.py +++ b/libs/langchain/langchain/tools/zapier/tool.py @@ -1,3 +1,14 @@ +""" +This module provides dynamic access to deprecated Zapier tools in LangChain. + +It supports backward compatibility by forwarding references such as +`ZapierNLAListActions` and `ZapierNLARunAction` to their updated locations +in the `langchain_community.tools` package. + +Developers using older import paths will continue to function, while LangChain +internally redirects access to the newer, supported module structure. +""" + from typing import TYPE_CHECKING, Any from langchain._api import create_importer @@ -17,7 +28,18 @@ _import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_L def __getattr__(name: str) -> Any: - """Look up attributes dynamically.""" + """ + Dynamically retrieve attributes from the updated module path. + + This method is used to resolve deprecated attribute imports + at runtime and forward them to their new locations. + + Args: + name (str): The name of the attribute to import. + + Returns: + Any: The resolved attribute from the appropriate updated module. + """ return _import_attribute(name)