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
  0114f8ef_ddea_b4b5_1241_647023b433a8["_load_prompt()"]
  968242b5_edb4_6604_0d16_e821da9180f5["loading.py"]
  0114f8ef_ddea_b4b5_1241_647023b433a8 -->|defined in| 968242b5_edb4_6604_0d16_e821da9180f5
  9097629d_a2b8_9c6b_7aad_8779e19c2517["_load_template()"]
  0114f8ef_ddea_b4b5_1241_647023b433a8 -->|calls| 9097629d_a2b8_9c6b_7aad_8779e19c2517
  69c477e6_af8f_601a_81e4_7b2ddde63ff3["_load_output_parser()"]
  0114f8ef_ddea_b4b5_1241_647023b433a8 -->|calls| 69c477e6_af8f_601a_81e4_7b2ddde63ff3
  style 0114f8ef_ddea_b4b5_1241_647023b433a8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/prompts/loading.py lines 117–134

def _load_prompt(config: dict) -> PromptTemplate:
    """Load the prompt template from config."""
    # Load the template from disk if necessary.
    config = _load_template("template", config)
    config = _load_output_parser(config)

    template_format = config.get("template_format", "f-string")
    if template_format == "jinja2":
        # Disabled due to:
        # https://github.com/langchain-ai/langchain/issues/4394
        msg = (
            f"Loading templates with '{template_format}' format is no longer supported "
            f"since it can lead to arbitrary code execution. Please migrate to using "
            f"the 'f-string' template format, which does not suffer from this issue."
        )
        raise ValueError(msg)

    return PromptTemplate(**config)

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 117.
What does _load_prompt() call?
_load_prompt() calls 2 function(s): _load_output_parser, _load_template.

Analyze Your Own Codebase

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

Try Supermodel Free