-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
langchain[patch]: Migrate top level files to use optional langchain c…
…ommunity (#21152) Migrate a few top level files to treat langchain community as an optional dependency
- Loading branch information
Showing
4 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
"""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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
"""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", | ||
] |