Today we are going to see what types of AI agents are available with LangChain.
➡️ The most used.
What it does:
The LLM decides which tool to use at each step based on only the textual description of the tools.
No needs examples or prior instances.
For:
Typical usage example:
agent = initialize_agent( tools=mis_tools, llm=llm, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True )
Search for 2. REACT_DOCSTORE
What it does:
The agent can rationalize documents and perform step-by-step searches within a document repository (docstore).
For:
Example:
from langchain.docstore import InMemoryDocstore docstore = InMemoryDocstore({}) agent = initialize_agent(tools=mis_tools, llm=llm, agent_type=AgentType.REACT_DOCSTORE, docstore=docstore )
📚 3. SELF_ASK_WITH_SEARCH
What it does:
Breaks down complex questions into sub-questions and uses a tool (such as Google Search or DuckDuckGo) to answer them one by one.
Ideal for:
Example:
agent = initialize_agent(tools=search_tools, llm=llm, agent_type=AgentType.SELF_ASK_WITH_SEARCH, verbose=True )
🧩 4. STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION
What it does:
Similar to ZERO_SHOT_REACT_DESCRIPTION, but the tools have structured inputs (inputted with types) and the agent can reason in a more organized way..
Ideal for:
Example:
agent = initialize_agent(tools=mis_tools, llm=llm, agent_type=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True )
5. OPENAI_FUNCTIONS or TOOL_CALLING
What it does:
Uses the function calling system, such as that of OpenAI or Anthropic, to choose tools in a deterministic and efficient manner.
Ideal for:
Example:
agent = initialize_agent(tools=mis_tools, llm=llm, agent_type=AgentType.OPENAI_FUNCTIONS, verbose=True )
💬 6. CHAT_ZERO_SHOT_REACT_DESCRIPTION
What it does:
The conversational version of Zero-Shot normal.
Maintains chat context while using tools.
For:
Example:
agent = initialize_agent(tools=mis_tools, llm=llm, agent_type=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True )
