Thuta Learning
LangChain
AdvancedAIAdvanced

Agents with Tools

LangChainLesson 14

By connecting an Agent to a tool (e.g., SerpAPI for Google Search), the LLM can look up real-time information that isn't part of its internal knowledge.

python
# This requires a SerpAPI API key
# pip install langchain-community google-search-results
from langchain_community.tools import SerpAPIWrapper
from langchain.agents import AgentExecutor, create_openai_tools_agent

tools = [SerpAPIWrapper()]
# ... (Agent setup with prompt and LLM)
agent_executor = AgentExecutor(agent=agent, tools=tools)

agent_executor.invoke({"input": "what is the weather in Yangon?"})
You should see
(The Agent uses the SerpAPI tool to look up the weather in Yangon and returns the answer)

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

Agents with Tools | Thuta Learning