Home / Function/ load_prompt() — langchain Function Reference

load_prompt() — langchain Function Reference

Architecture documentation for the load_prompt() function in loading.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  03095f0c_d553_b94d_6b94_d71c43044869["load_prompt()"]
  fc5c0c58_eb79_058b_cc17_205426e210b8["loading.py"]
  03095f0c_d553_b94d_6b94_d71c43044869 -->|defined in| fc5c0c58_eb79_058b_cc17_205426e210b8
  fef0572d_1685_bdaf_bb9b_9baf7d6f1856["_load_few_shot_prompt()"]
  fef0572d_1685_bdaf_bb9b_9baf7d6f1856 -->|calls| 03095f0c_d553_b94d_6b94_d71c43044869
  b04be8f2_84fb_bd5b_0cee_565c728bde34["_load_prompt_from_file()"]
  03095f0c_d553_b94d_6b94_d71c43044869 -->|calls| b04be8f2_84fb_bd5b_0cee_565c728bde34
  style 03095f0c_d553_b94d_6b94_d71c43044869 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/prompts/loading.py lines 137–157

def load_prompt(path: str | Path, encoding: str | None = None) -> BasePromptTemplate:
    """Unified method for loading a prompt from LangChainHub or local filesystem.

    Args:
        path: Path to the prompt file.
        encoding: Encoding of the file.

    Returns:
        A `PromptTemplate` object.

    Raises:
        RuntimeError: If the path is a LangChainHub path.
    """
    if isinstance(path, str) and path.startswith("lc://"):
        msg = (
            "Loading from the deprecated github-based Hub is no longer supported. "
            "Please use the new LangChain Hub at https://smith.langchain.com/hub "
            "instead."
        )
        raise RuntimeError(msg)
    return _load_prompt_from_file(path, encoding)

Domain

Subdomains

Frequently Asked Questions

What does load_prompt() do?
load_prompt() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/loading.py.
Where is load_prompt() defined?
load_prompt() is defined in libs/core/langchain_core/prompts/loading.py at line 137.
What does load_prompt() call?
load_prompt() calls 1 function(s): _load_prompt_from_file.
What calls load_prompt()?
load_prompt() is called by 1 function(s): _load_few_shot_prompt.

Analyze Your Own Codebase

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

Try Supermodel Free