mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-19 19:11:33 +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
|
import importlib
|
||||||
from typing import Any, Callable, Dict, Optional
|
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
|
from langchain._api.interactive_env import is_interactive_env
|
||||||
|
|
||||||
@ -111,18 +111,24 @@ def create_importer(
|
|||||||
and name in deprecated_lookups
|
and name in deprecated_lookups
|
||||||
and _should_deprecate_for_package(package)
|
and _should_deprecate_for_package(package)
|
||||||
):
|
):
|
||||||
warn_deprecated(
|
# Depth 3:
|
||||||
since="0.1",
|
# internal.py
|
||||||
pending=False,
|
# module_import.py
|
||||||
removal="0.4",
|
# Module in langchain that uses this function
|
||||||
message=(
|
# [calling code] whose frame we want to inspect.
|
||||||
f"Importing {name} from {package} is deprecated."
|
if not internal.is_caller_internal(depth=3):
|
||||||
f"Please replace imports that look like:"
|
warn_deprecated(
|
||||||
f"`from {package} import {name}`\n"
|
since="0.1",
|
||||||
"with the following:\n "
|
pending=False,
|
||||||
f"from {new_module} import {name}"
|
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 result
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AttributeError(
|
raise AttributeError(
|
||||||
@ -134,18 +140,24 @@ def create_importer(
|
|||||||
module = importlib.import_module(fallback_module)
|
module = importlib.import_module(fallback_module)
|
||||||
result = getattr(module, name)
|
result = getattr(module, name)
|
||||||
if not is_interactive_env() and _should_deprecate_for_package(package):
|
if not is_interactive_env() and _should_deprecate_for_package(package):
|
||||||
warn_deprecated(
|
# Depth 3:
|
||||||
since="0.1",
|
# internal.py
|
||||||
pending=False,
|
# module_import.py
|
||||||
removal="0.4",
|
# Module in langchain that uses this function
|
||||||
message=(
|
# [calling code] whose frame we want to inspect.
|
||||||
f"Importing {name} from {package} is deprecated."
|
if not internal.is_caller_internal(depth=3):
|
||||||
f"Please replace imports that look like:"
|
warn_deprecated(
|
||||||
f"`from {package} import {name}`\n"
|
since="0.1",
|
||||||
"with the following:\n "
|
pending=False,
|
||||||
f"from {fallback_module} import {name}"
|
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 result
|
return result
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user