Skip to content

The agent engineering platform.

community: Use langchain-astradb for AstraDB caches (#18419)

Christophe Bornet30e4a35d7aa1
diff --git a/docs/docs/integrations/providers/astradb.mdx b/docs/docs/integrations/providers/astradb.mdx
index bda8621395..49a41ee5ca 100644
--- a/docs/docs/integrations/providers/astradb.mdx
+++ b/docs/docs/integrations/providers/astradb.mdx
@@ -56,7 +56,7 @@ See the [usage example](/docs/integrations/memory/astradb_chat_message_history#e
```python
from langchain.globals import set_llm_cache
-from langchain_community.cache import AstraDBCache
+from langchain_astradb import AstraDBCache
set_llm_cache(AstraDBCache(
api_endpoint=ASTRA_DB_API_ENDPOINT,
@@ -71,7 +71,7 @@ Learn more in the [example notebook](/docs/integrations/llms/llm_caching#astra-d
```python
from langchain.globals import set_llm_cache
-from langchain_community.cache import
+from langchain_astradb import AstraDBSemanticCache
set_llm_cache(AstraDBSemanticCache(
embedding=my_embedding,
diff --git a/libs/community/langchain_community/cache.py b/libs/community/langchain_community/cache.py
index f247b5643a..584c7aa7f6 100644
--- a/libs/community/langchain_community/cache.py
+++ b/libs/community/langchain_community/cache.py
@@ -62,6 +62,7 @@ try:
except ImportError:
from sqlalchemy.ext.declarative import declarative_base
+from langchain_core._api.deprecation import deprecated
from langchain_core.caches import RETURN_VAL_TYPE, BaseCache
from langchain_core.embeddings import Embeddings
from langchain_core.language_models.llms import LLM, aget_prompts, get_prompts
@@ -1390,6 +1391,11 @@ class SQLAlchemyMd5Cache(BaseCache):
ASTRA_DB_CACHE_DEFAULT_COLLECTION_NAME = "langchain_astradb_cache"
+@deprecated(
+ since="0.0.28",
+ removal="0.2.0",
+ alternative_import="langchain_astradb.AstraDBCache",
+)
class AstraDBCache(BaseCache):
@staticmethod
def _make_id(prompt: str, llm_string: str) -> str:
@@ -1588,6 +1594,11 @@ def _async_lru_cache(maxsize: int = 128, typed: bool = False) -> Callable:
return decorating_function
+@deprecated(
+ since="0.0.28",
+ removal="0.2.0",
+ alternative_import="langchain_astradb.AstraDBSemanticCache",
+)
class AstraDBSemanticCache(BaseCache):
def __init__(
self,