codekingpro/portable-devtools
114k
1"""Implementations of key-value stores and storage helpers.2 3Module provides implementations of various key-value stores that conform4to a simple key-value interface.5 6The primary goal of these storages is to support implementation of caching.7"""8 9from typing import TYPE_CHECKING, Any10 11from langchain_core.stores import (12 InMemoryByteStore,13 InMemoryStore,14 InvalidKeyException,15)16 17from langchain_classic._api import create_importer18from langchain_classic.storage._lc_store import create_kv_docstore, create_lc_store19from langchain_classic.storage.encoder_backed import EncoderBackedStore20from langchain_classic.storage.file_system import LocalFileStore21 22if TYPE_CHECKING:23 from langchain_community.storage import (24 RedisStore,25 UpstashRedisByteStore,26 UpstashRedisStore,27 )28 29# Create a way to dynamically look up deprecated imports.30# Used to consolidate logic for raising deprecation warnings and31# handling optional imports.32DEPRECATED_LOOKUP = {33 "RedisStore": "langchain_community.storage",34 "UpstashRedisByteStore": "langchain_community.storage",35 "UpstashRedisStore": "langchain_community.storage",36}37 38_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)39 40 41def __getattr__(name: str) -> Any:42 """Look up attributes dynamically."""43 return _import_attribute(name)44 45 46__all__ = [47 "EncoderBackedStore",48 "InMemoryByteStore",49 "InMemoryStore",50 "InvalidKeyException",51 "LocalFileStore",52 "RedisStore",53 "UpstashRedisByteStore",54 "UpstashRedisStore",55 "create_kv_docstore",56 "create_lc_store",57]58 