Bird
0
0

Which of the following is the correct way to create an agent in Langchain that uses a tool?

easy📝 Syntax Q12 of 15
LangChain - Agents
Which of the following is the correct way to create an agent in Langchain that uses a tool?
Aagent = Agent(llm=llm, tools=tools)
Bagent = initialize_agent(llm=llm, tools=tools, agent_type='zero-shot')
Cagent = create_agent(llm, tools)
Dagent = Agent.new(llm, tools)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Langchain agent creation syntax

    The standard way to create an agent with tools is using the function initialize_agent with parameters llm, tools, and agent_type.
  2. Step 2: Evaluate options

    agent = initialize_agent(llm=llm, tools=tools, agent_type='zero-shot') matches the correct syntax. Using Agent class directly, Agent.new, or create_agent are invalid in Langchain.
  3. Final Answer:

    agent = initialize_agent(llm=llm, tools=tools, agent_type='zero-shot') -> Option B
  4. Quick Check:

    Agent creation uses initialize_agent() [OK]
Quick Trick: Use initialize_agent() with llm, tools, and agent_type [OK]
Common Mistakes:
MISTAKES
  • Using Agent class directly instead of initialize_agent
  • Calling non-existent create_agent function
  • Wrong parameter names or missing agent_type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes