Home / Function/ _resolve_cache() — langchain Function Reference

_resolve_cache() — langchain Function Reference

Architecture documentation for the _resolve_cache() function in llms.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  850d0849_18b0_9d36_a562_50a644c67a24["_resolve_cache()"]
  a4692bf1_369d_4673_b1eb_6b9a8cbb9994["llms.py"]
  850d0849_18b0_9d36_a562_50a644c67a24 -->|defined in| a4692bf1_369d_4673_b1eb_6b9a8cbb9994
  9ba11b11_f2bb_a080_89d9_77a37ac38030["get_prompts()"]
  9ba11b11_f2bb_a080_89d9_77a37ac38030 -->|calls| 850d0849_18b0_9d36_a562_50a644c67a24
  3b4b1ea5_be93_ee8f_c595_0a2429d9380b["aget_prompts()"]
  3b4b1ea5_be93_ee8f_c595_0a2429d9380b -->|calls| 850d0849_18b0_9d36_a562_50a644c67a24
  37c0466f_ed37_9b74_0dad_7d106ca16ce8["update_cache()"]
  37c0466f_ed37_9b74_0dad_7d106ca16ce8 -->|calls| 850d0849_18b0_9d36_a562_50a644c67a24
  ad254dee_89a5_8838_896b_a1459cb6753a["aupdate_cache()"]
  ad254dee_89a5_8838_896b_a1459cb6753a -->|calls| 850d0849_18b0_9d36_a562_50a644c67a24
  style 850d0849_18b0_9d36_a562_50a644c67a24 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/language_models/llms.py lines 131–152

def _resolve_cache(*, cache: BaseCache | bool | None) -> BaseCache | None:
    """Resolve the cache."""
    llm_cache: BaseCache | None
    if isinstance(cache, BaseCache):
        llm_cache = cache
    elif cache is None:
        llm_cache = get_llm_cache()
    elif cache is True:
        llm_cache = get_llm_cache()
        if llm_cache is None:
            msg = (
                "No global cache was configured. Use `set_llm_cache`."
                "to set a global cache if you want to use a global cache."
                "Otherwise either pass a cache object or set cache to False/None"
            )
            raise ValueError(msg)
    elif cache is False:
        llm_cache = None
    else:
        msg = f"Unsupported cache value {cache}"
        raise ValueError(msg)
    return llm_cache

Domain

Subdomains

Frequently Asked Questions

What does _resolve_cache() do?
_resolve_cache() is a function in the langchain codebase, defined in libs/core/langchain_core/language_models/llms.py.
Where is _resolve_cache() defined?
_resolve_cache() is defined in libs/core/langchain_core/language_models/llms.py at line 131.
What calls _resolve_cache()?
_resolve_cache() is called by 4 function(s): aget_prompts, aupdate_cache, get_prompts, update_cache.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free