The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
langchain[patch]: Update deprecation warning (#21268)
Eugene Yurtsev335bd01e45e6
diff --git a/libs/langchain/langchain/_api/module_import.py b/libs/langchain/langchain/_api/module_import.pyindex 1cb84f9a29..48b69ba55c 100644--- a/libs/langchain/langchain/_api/module_import.py+++ b/libs/langchain/langchain/_api/module_import.py@@ -1,7 +1,7 @@import importlibfrom typing import Any, Callable, Dict, Optional-from langchain_core._api import warn_deprecated+from langchain_core._api import internal, warn_deprecatedfrom langchain._api.interactive_env import is_interactive_env@@ -111,18 +111,24 @@ def create_importer(and name in deprecated_lookupsand _should_deprecate_for_package(package)):- warn_deprecated(- since="0.1",- pending=False,- removal="0.4",- message=(- f"Importing {name} from {package} is deprecated."- f"Please replace imports that look like:"- f"`from {package} import {name}`\n"- "with the following:\n "- f"from {new_module} import {name}"- ),- )+ # Depth 3:+ # internal.py+ # module_import.py+ # Module in langchain that uses this function+ # [calling code] whose frame we want to inspect.+ if not internal.is_caller_internal(depth=3):+ warn_deprecated(+ since="0.1",+ pending=False,+ removal="0.4",+ message=(+ f"Importing {name} from {package} is deprecated. "+ f"Please replace deprecated imports:\n\n"+ f">> from {package} import {name}\n\n"+ "with new imports of:\n\n"+ f">> from {new_module} import {name}\n"+ ),+ )return resultexcept Exception as e:raise AttributeError(@@ -134,18 +140,24 @@ def create_importer(module = importlib.import_module(fallback_module)result = getattr(module, name)if not is_interactive_env() and _should_deprecate_for_package(package):- warn_deprecated(- since="0.1",- pending=False,- removal="0.4",- message=(- f"Importing {name} from {package} is deprecated."- f"Please replace imports that look like:"- f"`from {package} import {name}`\n"- "with the following:\n "- f"from {fallback_module} import {name}"- ),- )+ # Depth 3:+ # internal.py+ # module_import.py+ # Module in langchain that uses this function+ # [calling code] whose frame we want to inspect.+ if not internal.is_caller_internal(depth=3):+ warn_deprecated(+ since="0.1",+ pending=False,+ removal="0.4",+ message=(+ f"Importing {name} from {package} is deprecated. "+ f"Please replace deprecated imports:\n\n"+ f">> from {package} import {name}\n\n"+ "with new imports of:\n\n"+ f">> from {fallback_module} import {name}\n"+ ),+ )return resultexcept Exception as e: