mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-23 19:39:58 +00:00
langchain[patch]: Turn on all deprecations for 0.2 (#21999)
- Turn on all 0.2 import deprecations. - Update error messag with URL to upgrade instructions.
This commit is contained in:
@@ -12,33 +12,6 @@ ALLOWED_TOP_LEVEL_PKGS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# For 0.1 releases keep this here
|
|
||||||
# Remove for 0.2 release so that deprecation warnings will
|
|
||||||
# be raised for all the new namespaces.
|
|
||||||
_NAMESPACES_WITH_DEPRECATION_WARNINGS_IN_0_1 = {
|
|
||||||
"langchain",
|
|
||||||
"langchain.adapters.openai",
|
|
||||||
"langchain.agents.agent_toolkits",
|
|
||||||
"langchain.callbacks",
|
|
||||||
"langchain.chat_models",
|
|
||||||
"langchain.docstore",
|
|
||||||
"langchain.document_loaders",
|
|
||||||
"langchain.document_transformers",
|
|
||||||
"langchain.embeddings",
|
|
||||||
"langchain.llms",
|
|
||||||
"langchain.memory.chat_message_histories",
|
|
||||||
"langchain.storage",
|
|
||||||
"langchain.tools",
|
|
||||||
"langchain.utilities",
|
|
||||||
"langchain.vectorstores",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def _should_deprecate_for_package(package: str) -> bool:
|
|
||||||
"""Should deprecate for this package?"""
|
|
||||||
return bool(package in _NAMESPACES_WITH_DEPRECATION_WARNINGS_IN_0_1)
|
|
||||||
|
|
||||||
|
|
||||||
def create_importer(
|
def create_importer(
|
||||||
package: str,
|
package: str,
|
||||||
*,
|
*,
|
||||||
@@ -109,7 +82,6 @@ def create_importer(
|
|||||||
not is_interactive_env()
|
not is_interactive_env()
|
||||||
and deprecated_lookups
|
and deprecated_lookups
|
||||||
and name in deprecated_lookups
|
and name in deprecated_lookups
|
||||||
and _should_deprecate_for_package(package)
|
|
||||||
):
|
):
|
||||||
# Depth 3:
|
# Depth 3:
|
||||||
# internal.py
|
# internal.py
|
||||||
@@ -127,6 +99,9 @@ def create_importer(
|
|||||||
f">> from {package} import {name}\n\n"
|
f">> from {package} import {name}\n\n"
|
||||||
"with new imports of:\n\n"
|
"with new imports of:\n\n"
|
||||||
f">> from {new_module} import {name}\n"
|
f">> from {new_module} import {name}\n"
|
||||||
|
"You can use the langchain cli to **automatically** "
|
||||||
|
"upgrade many imports. Please see documentation here "
|
||||||
|
"https://python.langchain.com/v0.2/docs/versions/v0_2/ "
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
@@ -139,7 +114,7 @@ def create_importer(
|
|||||||
try:
|
try:
|
||||||
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():
|
||||||
# Depth 3:
|
# Depth 3:
|
||||||
# internal.py
|
# internal.py
|
||||||
# module_import.py
|
# module_import.py
|
||||||
@@ -156,6 +131,9 @@ def create_importer(
|
|||||||
f">> from {package} import {name}\n\n"
|
f">> from {package} import {name}\n\n"
|
||||||
"with new imports of:\n\n"
|
"with new imports of:\n\n"
|
||||||
f">> from {fallback_module} import {name}\n"
|
f">> from {fallback_module} import {name}\n"
|
||||||
|
"You can use the langchain cli to **automatically** "
|
||||||
|
"upgrade many imports. Please see documentation here "
|
||||||
|
"https://python.langchain.com/v0.2/docs/versions/v0_2/ "
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
Reference in New Issue
Block a user