mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-19 03:01:29 +00:00
langchain[patch]: Update deprecation warning (#21268)
Update deprecation warning
This commit is contained in:
parent
23a05c3986
commit
335bd01e45
@ -1,7 +1,7 @@
|
||||
import importlib
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
from langchain_core._api import warn_deprecated
|
||||
from langchain_core._api import internal, warn_deprecated
|
||||
|
||||
from langchain._api.interactive_env import is_interactive_env
|
||||
|
||||
@ -111,16 +111,22 @@ def create_importer(
|
||||
and name in deprecated_lookups
|
||||
and _should_deprecate_for_package(package)
|
||||
):
|
||||
# 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 imports that look like:"
|
||||
f"`from {package} import {name}`\n"
|
||||
"with the following:\n "
|
||||
f"from {new_module} import {name}"
|
||||
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 result
|
||||
@ -134,16 +140,22 @@ def create_importer(
|
||||
module = importlib.import_module(fallback_module)
|
||||
result = getattr(module, name)
|
||||
if not is_interactive_env() and _should_deprecate_for_package(package):
|
||||
# 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 imports that look like:"
|
||||
f"`from {package} import {name}`\n"
|
||||
"with the following:\n "
|
||||
f"from {fallback_module} import {name}"
|
||||
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 result
|
||||
|
Loading…
Reference in New Issue
Block a user