mirror of https://github.com/hwchase17/langchain
langchain[patch]: Migrate top level files to use optional langchain community (#21152)
Migrate a few top level files to treat langchain community as an optional dependencypull/21157/head
parent
daab9789a8
commit
7230e430db
@ -1,4 +1,24 @@
|
|||||||
"""For backwards compatibility."""
|
"""For backwards compatibility."""
|
||||||
from langchain_community.utilities.serpapi import SerpAPIWrapper
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
__all__ = ["SerpAPIWrapper"]
|
from langchain._api import create_importer
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from langchain_community.utilities import SerpAPIWrapper
|
||||||
|
|
||||||
|
# Create a way to dynamically look up deprecated imports.
|
||||||
|
# Used to consolidate logic for raising deprecation warnings and
|
||||||
|
# handling optional imports.
|
||||||
|
DEPRECATED_LOOKUP = {"SerpAPIWrapper": "langchain_community.utilities"}
|
||||||
|
|
||||||
|
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||||
|
|
||||||
|
|
||||||
|
def __getattr__(name: str) -> Any:
|
||||||
|
"""Look up attributes dynamically."""
|
||||||
|
return _import_attribute(name)
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"SerpAPIWrapper",
|
||||||
|
]
|
||||||
|
@ -1,4 +1,24 @@
|
|||||||
"""Keep here for backwards compatibility."""
|
"""Keep here for backwards compatibility."""
|
||||||
from langchain_community.utilities.sql_database import SQLDatabase
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
__all__ = ["SQLDatabase"]
|
from langchain._api import create_importer
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from langchain_community.utilities import SQLDatabase
|
||||||
|
|
||||||
|
# Create a way to dynamically look up deprecated imports.
|
||||||
|
# Used to consolidate logic for raising deprecation warnings and
|
||||||
|
# handling optional imports.
|
||||||
|
DEPRECATED_LOOKUP = {"SQLDatabase": "langchain_community.utilities"}
|
||||||
|
|
||||||
|
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||||
|
|
||||||
|
|
||||||
|
def __getattr__(name: str) -> Any:
|
||||||
|
"""Look up attributes dynamically."""
|
||||||
|
return _import_attribute(name)
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"SQLDatabase",
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue