
π€ Build a Weather Search Agent (LangChain + Ollama)
In this tutorial, weβll build a simple AI agent that can fetch real-time weather information for a given country. Weβll keep it: π» Fully local (LLM via Ollama) π Real-time (weather via API) π§ Agent-based (tool usage with LangChain) π― What Youβll Build An agent that can answer: βWhatβs the weather in India?β Flow: User β Agent β Tool (Weather API) β Agent β Response β οΈ Important Reality Local models (via Ollama) cannot browse the internet . So we solve this by: π Giving the agent a tool that calls a real API π The agent decides when to use that tool π§± Project Structure root/ β βββ main.py βββ projects/ βββ search_agent/ βββ app.py βββ tools.py π Step 1: Get Free Weather API Use: https://openweathermap.org/api Sign up Get API key π¦ Step 2: Install Dependencies pip install langchain langchain-ollama requests python-dotenv π Step 3: Add ".env" WEATHER_API_KEY=your_api_key_here π Step 4: Create Tool (REAL API) π projects/search_agent/tools.py import requests import os from langchain.tools i
Continue reading on Dev.to Python
Opens in a new tab




