Bird
0
0

Which of the following is the correct way to create a ReAct agent in LangChain?

easy📝 Syntax Q12 of 15
LangChain - Agents
Which of the following is the correct way to create a ReAct agent in LangChain?
Aagent = ReActAgent(llm=llm, tools=tools)
Bagent = ReActAgent(tools=llm, llm=tools)
Cagent = ReActAgent()
Dagent = ReActAgent(llm)
Step-by-Step Solution
Solution:
  1. Step 1: Recall ReAct agent constructor parameters

    The ReAct agent requires a language model (llm) and a list of tools (tools) as named arguments.
  2. Step 2: Check each option for correct syntax

    agent = ReActAgent(llm=llm, tools=tools) correctly passes llm and tools by name. agent = ReActAgent(tools=llm, llm=tools) swaps them incorrectly. agent = ReActAgent() misses required arguments. agent = ReActAgent(llm) passes only llm without tools.
  3. Final Answer:

    agent = ReActAgent(llm=llm, tools=tools) -> Option A
  4. Quick Check:

    Correct parameters = llm and tools [OK]
Quick Trick: Pass llm and tools as named parameters to ReActAgent [OK]
Common Mistakes:
MISTAKES
  • Swapping llm and tools arguments
  • Omitting required parameters
  • Passing parameters positionally without names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes