langchain_community.cache.SQLAlchemyCache¶

class langchain_community.cache.SQLAlchemyCache(engine: ~sqlalchemy.engine.base.Engine, cache_schema: ~typing.Type[~langchain_community.cache.FullLLMCache] = <class 'langchain_community.cache.FullLLMCache'>)[source]¶

Cache that uses SQAlchemy as a backend.

Initialize by creating all tables.

Methods

__init__(engine[, cache_schema])

Initialize by creating all tables.

clear(**kwargs)

Clear cache.

lookup(prompt, llm_string)

Look up based on prompt and llm_string.

update(prompt, llm_string, return_val)

Update based on prompt and llm_string.

__init__(engine: ~sqlalchemy.engine.base.Engine, cache_schema: ~typing.Type[~langchain_community.cache.FullLLMCache] = <class 'langchain_community.cache.FullLLMCache'>)[source]¶

Initialize by creating all tables.

clear(**kwargs: Any) None[source]¶

Clear cache.

lookup(prompt: str, llm_string: str) Optional[Sequence[Generation]][source]¶

Look up based on prompt and llm_string.

update(prompt: str, llm_string: str, return_val: Sequence[Generation]) None[source]¶

Update based on prompt and llm_string.

Examples using SQLAlchemyCache¶