2024-02-22 00:18:36 +00:00
|
|
|
"""**Storage** is an implementation of key-value store.
|
2023-12-11 21:53:30 +00:00
|
|
|
|
2024-02-22 00:18:36 +00:00
|
|
|
Storage module provides implementations of various key-value stores that conform
|
2023-12-11 21:53:30 +00:00
|
|
|
to a simple key-value interface.
|
|
|
|
|
2024-02-22 00:18:36 +00:00
|
|
|
The primary goal of these storages is to support caching.
|
|
|
|
|
|
|
|
|
|
|
|
**Class hierarchy:**
|
|
|
|
|
|
|
|
.. code-block::
|
|
|
|
|
|
|
|
BaseStore --> <name>Store # Examples: MongoDBStore, RedisStore
|
|
|
|
|
2024-04-30 17:13:48 +00:00
|
|
|
"""
|
2023-12-11 21:53:30 +00:00
|
|
|
|
2024-03-12 22:18:54 +00:00
|
|
|
import importlib
|
2024-04-10 17:01:19 +00:00
|
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from langchain_community.storage.astradb import (
|
2024-04-30 17:13:48 +00:00
|
|
|
AstraDBByteStore,
|
|
|
|
AstraDBStore,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
2024-05-24 14:57:55 +00:00
|
|
|
from langchain_community.storage.cassandra import (
|
|
|
|
CassandraByteStore,
|
|
|
|
)
|
2024-04-10 17:01:19 +00:00
|
|
|
from langchain_community.storage.mongodb import (
|
2024-04-30 17:13:48 +00:00
|
|
|
MongoDBStore,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.storage.redis import (
|
2024-04-30 17:13:48 +00:00
|
|
|
RedisStore,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
2024-06-07 21:17:02 +00:00
|
|
|
from langchain_community.storage.sql import (
|
|
|
|
SQLStore,
|
|
|
|
)
|
2024-04-10 17:01:19 +00:00
|
|
|
from langchain_community.storage.upstash_redis import (
|
2024-04-30 17:13:48 +00:00
|
|
|
UpstashRedisByteStore,
|
|
|
|
UpstashRedisStore,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
"AstraDBByteStore",
|
|
|
|
"AstraDBStore",
|
2024-05-24 14:57:55 +00:00
|
|
|
"CassandraByteStore",
|
2024-04-10 17:01:19 +00:00
|
|
|
"MongoDBStore",
|
|
|
|
"RedisStore",
|
2024-06-07 21:17:02 +00:00
|
|
|
"SQLStore",
|
2024-04-10 17:01:19 +00:00
|
|
|
"UpstashRedisByteStore",
|
|
|
|
"UpstashRedisStore",
|
|
|
|
]
|
2024-03-12 22:18:54 +00:00
|
|
|
|
|
|
|
_module_lookup = {
|
|
|
|
"AstraDBByteStore": "langchain_community.storage.astradb",
|
|
|
|
"AstraDBStore": "langchain_community.storage.astradb",
|
2024-05-24 14:57:55 +00:00
|
|
|
"CassandraByteStore": "langchain_community.storage.cassandra",
|
2024-03-12 22:18:54 +00:00
|
|
|
"MongoDBStore": "langchain_community.storage.mongodb",
|
|
|
|
"RedisStore": "langchain_community.storage.redis",
|
2024-06-07 21:17:02 +00:00
|
|
|
"SQLStore": "langchain_community.storage.sql",
|
2024-03-12 22:18:54 +00:00
|
|
|
"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}")
|