lookup(prompt, llm_string)
Look up based on prompt and llm_string.
update(prompt, llm_string, return_val)
Update cache based on prompt and llm_string.
__init__(*, collection_name: str = 'langchain_astradb_cache', token: Optional[str] = None, api_endpoint: Optional[str] = None, astra_db_client: Optional[Any] = None, namespace: Optional[str] = None)[source]¶
Create an AstraDB cache using a collection for storage.
Args (only keyword-arguments accepted):collection_name (str): name of the Astra DB collection to create/use.
token (Optional[str]): API token for Astra DB usage.
api_endpoint (Optional[str]): full URL to the API endpoint,
such as “https://<DB-ID>-us-east1.apps.astra.datastax.com”.
astra_db_client (Optional[Any]): alternative to token+api_endpoint,you can pass an already-created ‘astrapy.db.AstraDB’ instance.
namespace (Optional[str]): namespace (aka keyspace) where thecollection is created. Defaults to the database’s “default namespace”.
clear(**kwargs: Any) → None[source]¶
Clear cache. This is for all LLMs at once.
delete(prompt: str, llm_string: str) → None[source]¶
Evict from cache if there’s an entry.
delete_through_llm(prompt: str, llm: LLM, stop: Optional[List[str]] = None) → None[source]¶
A wrapper around delete with the LLM being passed.
In case the llm(prompt) calls have a stop param, you should pass it here
lookup(prompt: str, llm_string: str) → Optional[Sequence[Generation]][source]¶
Look up based on prompt and llm_string.