Home / Function/ aget_prompts() — langchain Function Reference

aget_prompts() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  3b4b1ea5_be93_ee8f_c595_0a2429d9380b["aget_prompts()"]
  a4692bf1_369d_4673_b1eb_6b9a8cbb9994["llms.py"]
  3b4b1ea5_be93_ee8f_c595_0a2429d9380b -->|defined in| a4692bf1_369d_4673_b1eb_6b9a8cbb9994
  99297396_752a_7590_6d2b_c4757fc5a9d8["agenerate()"]
  99297396_752a_7590_6d2b_c4757fc5a9d8 -->|calls| 3b4b1ea5_be93_ee8f_c595_0a2429d9380b
  850d0849_18b0_9d36_a562_50a644c67a24["_resolve_cache()"]
  3b4b1ea5_be93_ee8f_c595_0a2429d9380b -->|calls| 850d0849_18b0_9d36_a562_50a644c67a24
  style 3b4b1ea5_be93_ee8f_c595_0a2429d9380b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/language_models/llms.py lines 191–223

async def aget_prompts(
    params: dict[str, Any],
    prompts: list[str],
    cache: BaseCache | bool | None = None,  # noqa: FBT001
) -> tuple[dict[int, list], str, list[int], list[str]]:
    """Get prompts that are already cached. Async version.

    Args:
        params: Dictionary of parameters.
        prompts: List of prompts.
        cache: Cache object.

    Returns:
        A tuple of existing prompts, llm_string, missing prompt indexes,
            and missing prompts.

    Raises:
        ValueError: If the cache is not set and cache is True.
    """
    llm_string = str(sorted(params.items()))
    missing_prompts = []
    missing_prompt_idxs = []
    existing_prompts = {}
    llm_cache = _resolve_cache(cache=cache)
    for i, prompt in enumerate(prompts):
        if llm_cache:
            cache_val = await llm_cache.alookup(prompt, llm_string)
            if isinstance(cache_val, list):
                existing_prompts[i] = cache_val
            else:
                missing_prompts.append(prompt)
                missing_prompt_idxs.append(i)
    return existing_prompts, llm_string, missing_prompt_idxs, missing_prompts

Domain

Subdomains

Called By

Frequently Asked Questions

What does aget_prompts() do?
aget_prompts() is a function in the langchain codebase, defined in libs/core/langchain_core/language_models/llms.py.
Where is aget_prompts() defined?
aget_prompts() is defined in libs/core/langchain_core/language_models/llms.py at line 191.
What does aget_prompts() call?
aget_prompts() calls 1 function(s): _resolve_cache.
What calls aget_prompts()?
aget_prompts() is called by 1 function(s): agenerate.

Analyze Your Own Codebase

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

Try Supermodel Free