MCPcopy
hub / github.com/langchain-ai/langchain / from_chains

Method from_chains

libs/langchain/langchain/agents/mrkl/base.py:176–201  ·  view source on GitHub ↗

User-friendly way to initialize the MRKL chain. This is intended to be an easy way to get up and running with the MRKL chain. Args: llm: The LLM to use as the agent LLM. chains: The chains the MRKL system has access to. **kwargs: paramete

(
        cls, llm: BaseLanguageModel, chains: List[ChainConfig], **kwargs: Any
    )

Source from the content-addressed store, hash-verified

174
175 @classmethod
176 def from_chains(
177 cls, llm: BaseLanguageModel, chains: List[ChainConfig], **kwargs: Any
178 ) -> AgentExecutor:
179 """User-friendly way to initialize the MRKL chain.
180
181 This is intended to be an easy way to get up and running with the
182 MRKL chain.
183
184 Args:
185 llm: The LLM to use as the agent LLM.
186 chains: The chains the MRKL system has access to.
187 **kwargs: parameters to be passed to initialization.
188
189 Returns:
190 An initialized MRKL chain.
191 """
192 tools = [
193 Tool(
194 name=c.action_name,
195 func=c.action,
196 description=c.action_description,
197 )
198 for c in chains
199 ]
200 agent = ZeroShotAgent.from_llm_and_tools(llm, tools)
201 return cls(agent=agent, tools=tools, **kwargs)

Callers

nothing calls this directly

Calls 2

ToolClass · 0.90
from_llm_and_toolsMethod · 0.45

Tested by

no test coverage detected