Hands-on Agentic AI: LangChain 1.0
What is Agentic AI?
A simple way to think about Agentic AI is: model + tools = agentic AI.
With LangChain 1.0 now stable, building them is straightforward.
Let's build a 'Weather Poet' agent that:
- Uses a web search tool to find a forecast.
- Write a poem about it.
Quick Setup
Get Your Google AI API Key for free (LLM):
- Go to https://aistudio.google.com/api-keys.
- Click "Create API key". Create a new project (e.g., "weather-poet-project") if prompted.
- Copy your newly generated API key.
Get Your Tavily API Key for free (Search Tool):
- Go to https://www.tavily.com/ and sign up.
- After verifying your email, copy the API key from your dashboard.
Set Up Your Python Environment:
- Use Python 3.10 or later.
- Install Libraries: pip install langchain langchain-tavily langchain-google-genai
The Simple Version: Get the Answer
This code creates the agent and prints its final creative response.
Your output would be a creative poem about tomorrow's weather:
In Tel Aviv, the sun will shine so bright,A gentle breeze, a lovely, clear blue light.
With temperatures around twenty-six degrees,
Tomorrow's forecast brings comfort and ease.
The Transparent Version: Cite Your Sources
For transparency, you can also see the sources the agent used.
This version extracts the exact URLs from the agent's process.
Your output would be a creative poem about tomorrow's weather with sources:
In Tel Aviv, a sunny sky,With temperatures around twenty-six,
A gentle autumn day goes by,
No need for heavy coats or tricks.
The breeze will blow, a mild delight,
As day unfolds in golden light.
Sources: ['https://www.weatherapi.com/', 'https://www.easeweather.com/asia/isra
el/tel-aviv/october', 'https://wisemeteo.com/en/country/israel/region/tel-aviv-
district/city/tel-aviv-yafo/date/10-26', 'https://www.weather25.com/asia/israel
/tel-aviv?page=month&month=October', 'https://predictwind.com/weather/israel/te
l-aviv-district/tel-aviv/october?nxtPcountry=israel&nxtPstate=tel-aviv-district
&nxtPcity=tel-aviv&nxtPmonth=october']
Conclusion
LangChain 1.0 provides a stable toolkit for building agents that can reason and use tools.
The ability to start simple and then add features like source extraction makes it a powerful framework for practical AI applications.
