mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-03 21:54:04 +00:00
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 dependency
This commit is contained in:
parent
daab9789a8
commit
7230e430db
@ -1,21 +1,56 @@
|
|||||||
from langchain_community.cache import (
|
from typing import TYPE_CHECKING, Any
|
||||||
AstraDBCache,
|
|
||||||
AstraDBSemanticCache,
|
from langchain._api import create_importer
|
||||||
AzureCosmosDBSemanticCache,
|
|
||||||
CassandraCache,
|
if TYPE_CHECKING:
|
||||||
CassandraSemanticCache,
|
from langchain_community.cache import (
|
||||||
FullLLMCache,
|
AstraDBCache,
|
||||||
FullMd5LLMCache,
|
AstraDBSemanticCache,
|
||||||
GPTCache,
|
AzureCosmosDBSemanticCache,
|
||||||
InMemoryCache,
|
CassandraCache,
|
||||||
MomentoCache,
|
CassandraSemanticCache,
|
||||||
RedisCache,
|
FullLLMCache,
|
||||||
RedisSemanticCache,
|
FullMd5LLMCache,
|
||||||
SQLAlchemyCache,
|
GPTCache,
|
||||||
SQLAlchemyMd5Cache,
|
InMemoryCache,
|
||||||
SQLiteCache,
|
MomentoCache,
|
||||||
UpstashRedisCache,
|
RedisCache,
|
||||||
)
|
RedisSemanticCache,
|
||||||
|
SQLAlchemyCache,
|
||||||
|
SQLAlchemyMd5Cache,
|
||||||
|
SQLiteCache,
|
||||||
|
UpstashRedisCache,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create a way to dynamically look up deprecated imports.
|
||||||
|
# Used to consolidate logic for raising deprecation warnings and
|
||||||
|
# handling optional imports.
|
||||||
|
DEPRECATED_LOOKUP = {
|
||||||
|
"FullLLMCache": "langchain_community.cache",
|
||||||
|
"SQLAlchemyCache": "langchain_community.cache",
|
||||||
|
"SQLiteCache": "langchain_community.cache",
|
||||||
|
"UpstashRedisCache": "langchain_community.cache",
|
||||||
|
"RedisCache": "langchain_community.cache",
|
||||||
|
"RedisSemanticCache": "langchain_community.cache",
|
||||||
|
"GPTCache": "langchain_community.cache",
|
||||||
|
"MomentoCache": "langchain_community.cache",
|
||||||
|
"InMemoryCache": "langchain_community.cache",
|
||||||
|
"CassandraCache": "langchain_community.cache",
|
||||||
|
"CassandraSemanticCache": "langchain_community.cache",
|
||||||
|
"FullMd5LLMCache": "langchain_community.cache",
|
||||||
|
"SQLAlchemyMd5Cache": "langchain_community.cache",
|
||||||
|
"AstraDBCache": "langchain_community.cache",
|
||||||
|
"AstraDBSemanticCache": "langchain_community.cache",
|
||||||
|
"AzureCosmosDBSemanticCache": "langchain_community.cache",
|
||||||
|
}
|
||||||
|
|
||||||
|
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
|
||||||
|
|
||||||
|
|
||||||
|
def __getattr__(name: str) -> Any:
|
||||||
|
"""Look up attributes dynamically."""
|
||||||
|
return _import_attribute(name)
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"FullLLMCache",
|
"FullLLMCache",
|
||||||
|
@ -1,5 +1,31 @@
|
|||||||
"""DEPRECATED: Kept for backwards compatibility."""
|
"""DEPRECATED: Kept for backwards compatibility."""
|
||||||
from langchain_community.utilities import Requests, RequestsWrapper, TextRequestsWrapper
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
|
from langchain._api import create_importer
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from langchain_community.utilities import (
|
||||||
|
Requests,
|
||||||
|
RequestsWrapper,
|
||||||
|
TextRequestsWrapper,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create a way to dynamically look up deprecated imports.
|
||||||
|
# Used to consolidate logic for raising deprecation warnings and
|
||||||
|
# handling optional imports.
|
||||||
|
DEPRECATED_LOOKUP = {
|
||||||
|
"Requests": "langchain_community.utilities",
|
||||||
|
"RequestsWrapper": "langchain_community.utilities",
|
||||||
|
"TextRequestsWrapper": "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__ = [
|
__all__ = [
|
||||||
"Requests",
|
"Requests",
|
||||||
|
@ -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
Block a user