_load_prompt_from_file() — langchain Function Reference
Architecture documentation for the _load_prompt_from_file() function in loading.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b04be8f2_84fb_bd5b_0cee_565c728bde34["_load_prompt_from_file()"] fc5c0c58_eb79_058b_cc17_205426e210b8["loading.py"] b04be8f2_84fb_bd5b_0cee_565c728bde34 -->|defined in| fc5c0c58_eb79_058b_cc17_205426e210b8 03095f0c_d553_b94d_6b94_d71c43044869["load_prompt()"] 03095f0c_d553_b94d_6b94_d71c43044869 -->|calls| b04be8f2_84fb_bd5b_0cee_565c728bde34 afd0dfa8_d6e1_0d44_ce7f_212370f6f020["load_prompt_from_config()"] b04be8f2_84fb_bd5b_0cee_565c728bde34 -->|calls| afd0dfa8_d6e1_0d44_ce7f_212370f6f020 style b04be8f2_84fb_bd5b_0cee_565c728bde34 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/loading.py lines 160–177
def _load_prompt_from_file(
file: str | Path, encoding: str | None = None
) -> BasePromptTemplate:
"""Load prompt from file."""
# Convert file to a Path object.
file_path = Path(file)
# Load from either json or yaml.
if file_path.suffix == ".json":
with file_path.open(encoding=encoding) as f:
config = json.load(f)
elif file_path.suffix.endswith((".yaml", ".yml")):
with file_path.open(encoding=encoding) as f:
config = yaml.safe_load(f)
else:
msg = f"Got unsupported file type {file_path.suffix}"
raise ValueError(msg)
# Load the prompt from the config now.
return load_prompt_from_config(config)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _load_prompt_from_file() do?
_load_prompt_from_file() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/loading.py.
Where is _load_prompt_from_file() defined?
_load_prompt_from_file() is defined in libs/core/langchain_core/prompts/loading.py at line 160.
What does _load_prompt_from_file() call?
_load_prompt_from_file() calls 1 function(s): load_prompt_from_config.
What calls _load_prompt_from_file()?
_load_prompt_from_file() is called by 1 function(s): load_prompt.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free