_load_agent_from_file() — langchain Function Reference
Architecture documentation for the _load_agent_from_file() function in loading.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 36f609ad_1082_989b_c5d3_f0de4c508863["_load_agent_from_file()"] 7f3891e0_2de6_b9ba_e16e_a9b4c825778b["loading.py"] 36f609ad_1082_989b_c5d3_f0de4c508863 -->|defined in| 7f3891e0_2de6_b9ba_e16e_a9b4c825778b fbe78043_6ca9_accc_3a94_ee89e75c77c5["load_agent()"] fbe78043_6ca9_accc_3a94_ee89e75c77c5 -->|calls| 36f609ad_1082_989b_c5d3_f0de4c508863 d135c558_d211_f5bf_c272_7dfd2fe8cc5b["load_agent_from_config()"] 36f609ad_1082_989b_c5d3_f0de4c508863 -->|calls| d135c558_d211_f5bf_c272_7dfd2fe8cc5b style 36f609ad_1082_989b_c5d3_f0de4c508863 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/loading.py lines 129–148
def _load_agent_from_file(
file: str | Path,
**kwargs: Any,
) -> BaseSingleActionAgent | BaseMultiActionAgent:
"""Load agent from file."""
valid_suffixes = {"json", "yaml"}
# Convert file to Path object.
file_path = Path(file) if isinstance(file, str) else file
# Load from either json or yaml.
if file_path.suffix[1:] == "json":
with file_path.open() as f:
config = json.load(f)
elif file_path.suffix[1:] == "yaml":
with file_path.open() as f:
config = yaml.safe_load(f)
else:
msg = f"Unsupported file type, must be one of {valid_suffixes}."
raise ValueError(msg)
# Load the agent from the config now.
return load_agent_from_config(config, **kwargs)
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does _load_agent_from_file() do?
_load_agent_from_file() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/loading.py.
Where is _load_agent_from_file() defined?
_load_agent_from_file() is defined in libs/langchain/langchain_classic/agents/loading.py at line 129.
What does _load_agent_from_file() call?
_load_agent_from_file() calls 1 function(s): load_agent_from_config.
What calls _load_agent_from_file()?
_load_agent_from_file() is called by 1 function(s): load_agent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free