Thuta Learning
AdvancedAIadvanced

Agents with Tools

Relax. We'll talk through this in plain words — no textbook voice.

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)