mirror of
https://github.com/hwchase17/langchain
synced 2024-11-02 09:40:22 +00:00
4cb5f4c353
This PR should make it easier for linters to do type checking and for IDEs to jump to definition of code. See #20050 as a template for this PR. - As a byproduct: Added 3 missed `test_imports`. - Added missed `SolarChat` in to __init___.py Added it into test_import ut. - Added `# type: ignore` to fix linting. It is not clear, why linting errors appear after ^ changes. --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
"""**Storage** is an implementation of key-value store.
|
|
|
|
Storage module provides implementations of various key-value stores that conform
|
|
to a simple key-value interface.
|
|
|
|
The primary goal of these storages is to support caching.
|
|
|
|
|
|
**Class hierarchy:**
|
|
|
|
.. code-block::
|
|
|
|
BaseStore --> <name>Store # Examples: MongoDBStore, RedisStore
|
|
|
|
""" # noqa: E501
|
|
|
|
import importlib
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
if TYPE_CHECKING:
|
|
from langchain_community.storage.astradb import (
|
|
AstraDBByteStore, # noqa: F401
|
|
AstraDBStore, # noqa: F401
|
|
)
|
|
from langchain_community.storage.mongodb import (
|
|
MongoDBStore, # noqa: F401
|
|
)
|
|
from langchain_community.storage.redis import (
|
|
RedisStore, # noqa: F401
|
|
)
|
|
from langchain_community.storage.upstash_redis import (
|
|
UpstashRedisByteStore, # noqa: F401
|
|
UpstashRedisStore, # noqa: F401
|
|
)
|
|
|
|
__all__ = [
|
|
"AstraDBByteStore",
|
|
"AstraDBStore",
|
|
"MongoDBStore",
|
|
"RedisStore",
|
|
"UpstashRedisByteStore",
|
|
"UpstashRedisStore",
|
|
]
|
|
|
|
_module_lookup = {
|
|
"AstraDBByteStore": "langchain_community.storage.astradb",
|
|
"AstraDBStore": "langchain_community.storage.astradb",
|
|
"MongoDBStore": "langchain_community.storage.mongodb",
|
|
"RedisStore": "langchain_community.storage.redis",
|
|
"UpstashRedisByteStore": "langchain_community.storage.upstash_redis",
|
|
"UpstashRedisStore": "langchain_community.storage.upstash_redis",
|
|
}
|
|
|
|
|
|
def __getattr__(name: str) -> Any:
|
|
if name in _module_lookup:
|
|
module = importlib.import_module(_module_lookup[name])
|
|
return getattr(module, name)
|
|
raise AttributeError(f"module {__name__} has no attribute {name}")
|
|
|
|
|
|
__all__ = list(_module_lookup.keys())
|