from_llm_and_tools() — langchain Function Reference
Architecture documentation for the from_llm_and_tools() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f50a836d_579d_7ed4_e51f_6bb4bd0b8059["from_llm_and_tools()"] efa737fc_e2bb_00c6_fe6e_ee6cb1f6cb6c["ZeroShotAgent"] f50a836d_579d_7ed4_e51f_6bb4bd0b8059 -->|defined in| efa737fc_e2bb_00c6_fe6e_ee6cb1f6cb6c d76c1f53_4db7_bb60_a9d5_23fc16890cf0["from_chains()"] d76c1f53_4db7_bb60_a9d5_23fc16890cf0 -->|calls| f50a836d_579d_7ed4_e51f_6bb4bd0b8059 1c25b3ee_1cc2_569b_6970_bd431e6f54ca["_validate_tools()"] f50a836d_579d_7ed4_e51f_6bb4bd0b8059 -->|calls| 1c25b3ee_1cc2_569b_6970_bd431e6f54ca a98a6213_7754_f1a3_d0c4_c6068b628192["create_prompt()"] f50a836d_579d_7ed4_e51f_6bb4bd0b8059 -->|calls| a98a6213_7754_f1a3_d0c4_c6068b628192 66bbb2d3_d68f_0d1b_d3bc_2f021869e9e1["_get_default_output_parser()"] f50a836d_579d_7ed4_e51f_6bb4bd0b8059 -->|calls| 66bbb2d3_d68f_0d1b_d3bc_2f021869e9e1 style f50a836d_579d_7ed4_e51f_6bb4bd0b8059 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/mrkl/base.py lines 114–159
def from_llm_and_tools(
cls,
llm: BaseLanguageModel,
tools: Sequence[BaseTool],
callback_manager: BaseCallbackManager | None = None,
output_parser: AgentOutputParser | None = None,
prefix: str = PREFIX,
suffix: str = SUFFIX,
format_instructions: str = FORMAT_INSTRUCTIONS,
input_variables: list[str] | None = None,
**kwargs: Any,
) -> Agent:
"""Construct an agent from an LLM and tools.
Args:
llm: The LLM to use as the agent LLM.
tools: The tools to use.
callback_manager: The callback manager to use.
output_parser: The output parser to use.
prefix: The prefix to use.
suffix: The suffix to use.
format_instructions: The format instructions to use.
input_variables: The input variables to use.
kwargs: Additional parameters to pass to the agent.
"""
cls._validate_tools(tools)
prompt = cls.create_prompt(
tools,
prefix=prefix,
suffix=suffix,
format_instructions=format_instructions,
input_variables=input_variables,
)
llm_chain = LLMChain(
llm=llm,
prompt=prompt,
callback_manager=callback_manager,
)
tool_names = [tool.name for tool in tools]
_output_parser = output_parser or cls._get_default_output_parser()
return cls(
llm_chain=llm_chain,
allowed_tools=tool_names,
output_parser=_output_parser,
**kwargs,
)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does from_llm_and_tools() do?
from_llm_and_tools() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/mrkl/base.py.
Where is from_llm_and_tools() defined?
from_llm_and_tools() is defined in libs/langchain/langchain_classic/agents/mrkl/base.py at line 114.
What does from_llm_and_tools() call?
from_llm_and_tools() calls 3 function(s): _get_default_output_parser, _validate_tools, create_prompt.
What calls from_llm_and_tools()?
from_llm_and_tools() is called by 1 function(s): from_chains.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free