Home / Function/ load_prompt_from_config() — langchain Function Reference

load_prompt_from_config() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b37eb998_e592_c267_0b47_c9558cc484a9["load_prompt_from_config()"]
  968242b5_edb4_6604_0d16_e821da9180f5["loading.py"]
  b37eb998_e592_c267_0b47_c9558cc484a9 -->|defined in| 968242b5_edb4_6604_0d16_e821da9180f5
  a95ffdb2_1800_1638_7e16_d0060630d74c["_load_few_shot_prompt()"]
  a95ffdb2_1800_1638_7e16_d0060630d74c -->|calls| b37eb998_e592_c267_0b47_c9558cc484a9
  5b14e0c3_d5f6_3669_b359_b7fea1b1f6b9["_load_prompt_from_file()"]
  5b14e0c3_d5f6_3669_b359_b7fea1b1f6b9 -->|calls| b37eb998_e592_c267_0b47_c9558cc484a9
  style b37eb998_e592_c267_0b47_c9558cc484a9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/prompts/loading.py lines 20–41

def load_prompt_from_config(config: dict) -> BasePromptTemplate:
    """Load prompt from config dict.

    Args:
        config: Dict containing the prompt configuration.

    Returns:
        A `PromptTemplate` object.

    Raises:
        ValueError: If the prompt type is not supported.
    """
    if "_type" not in config:
        logger.warning("No `_type` key found, defaulting to `prompt`.")
    config_type = config.pop("_type", "prompt")

    if config_type not in type_to_loader_dict:
        msg = f"Loading {config_type} prompt not supported"
        raise ValueError(msg)

    prompt_loader = type_to_loader_dict[config_type]
    return prompt_loader(config)

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free