A comprehensive multi-agent system built with LangGraph that provides a wide range of tools and capabilities through a modular, well-organized architecture.
This project implements a sophisticated agent system with the following capabilities:
- Addition: Add two numbers
- Multiplication: Multiply two numbers
- Division: Divide two numbers
- Get current weather data for any city
- Supports multiple countries
- Returns temperature, humidity, wind speed, and weather description
- Fetch latest news articles by category
- Support for multiple countries
- Categories: business, entertainment, general, health, science, sports, technology
- Cryptocurrency Prices: Get real-time crypto prices
- Support for major cryptocurrencies (Bitcoin, Ethereum, etc.)
- Price in USD and EUR with 24-hour change
- IP Information: Get detailed information about your IP address
- Location data including city, country, timezone
- ISP and network information
- Word Definitions: Look up word definitions, parts of speech, and examples
- Phonetic pronunciation
- Multiple definitions per word
- Web Search: Perform comprehensive web searches using Tavily API
- News Search: Search for recent news articles from trusted sources
- Academic Search: Search for research papers and academic content
- Support for domain filtering and search depth control
Gets NASA Astronomy Picture of the Day (APOD).
apod = get_nasa_apod()
# Returns: {"title": ..., "date": ..., "explanation": ..., "url": ..., ...}
Gets a summary for a topic from Wikipedia.
summary = get_wikipedia_summary("Python (programming language)")
# Returns: {"title": ..., "summary": ..., "url": ...}
Gets public holidays for a country and year.
holidays = get_public_holidays("IN", 2024)
# Returns: list of holidays with date, localName, name, etc.
Gets trending GitHub repositories for a given language (most starred in the last week).
repos = get_trending_github_repos("javascript")
# Returns: list of repos with name, full_name, html_url, description, stars, etc.
Shortens a URL using TinyURL API.
short = shorten_url("https://example.com")
# Returns: {"short_url": ...}
Generates a QR code for the given data using goqr.me API.
qr = generate_qr_code("hello world")
# Returns: {"qr_code_url": ...}
Gets the full current time and timezone info for a given time zone using WorldTimeAPI.
timeinfo = get_current_timezone("Asia/Kolkata")
# Returns: {"datetime": ..., "utc_offset": ..., ...}
Converts units (length, mass, temperature, etc.).
result = convert_unit(1000, "meter", "kilometer")
# Returns: {"value": 1000, "from": "meter", "to": "kilometer", "result": 1.0}
Converts Indian land units, supporting regional variations for bigha, biswa, katha, etc.
result = convert_land_unit(2, "bigha", "acre", region="up_west")
# Returns: {"value": 2, "from": "bigha", "to": "acre", "region": "up_west", "result": ...}
The project follows a modular architecture with tools organized into logical categories:
lang-agent-multi-1/
βββ tools/ # Tool modules
β βββ __init__.py # Package initialization
β βββ math_tools.py # Mathematical operations
β βββ weather_tools.py # Weather information
β βββ news_tools.py # News and articles
β βββ finance_tools.py # Financial data
β βββ network_tools.py # IP and location info
β βββ dictionary_tools.py # Word definitions
β βββ tavily_search.py # Web search and research
β βββ nasa_apod.py # NASA APOD tool
β βββ wikipedia.py # Wikipedia summary tool
β βββ public_holidays.py # Public holidays lookup
β βββ github_trending.py # GitHub trending repos
β βββ shorten_url.py # URL shortener
β βββ qr_code.py # QR code generator
β βββ timezone_converter.py # Timezone info
β βββ unit_converter.py # General unit converter
β βββ convert_land_unit.py # Indian land unit converter
βββ web/ # Next.js frontend application
β βββ src/ # Source code
β β βββ app/ # Next.js App Router
β β β βββ api/ # API routes
β β β βββ globals.css # Global styles
β β β βββ layout.tsx # Root layout with CopilotKit provider
β β β βββ page.tsx # Main application page
β β βββ components/ # React components
β β βββ MainContent.tsx # Dashboard and tool examples
β β βββ ToolActions.tsx # CopilotKit tool action definitions
β β βββ ToolResultCard.tsx # Tool execution result display
β βββ package.json # Node.js dependencies
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ next.config.js # Next.js configuration
β βββ .env.local # Environment variables
βββ agents.py # Main agent orchestration
βββ langgraph.json # LangGraph configuration
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Python 3.11 or higher
- pip package manager
- LangSmith/LangChain API Keys (see below)
-
Clone the repository
git clone <repository-url> cd lang-agent-multi-1
-
Create a virtual environment
python -m venv env source env/bin/activate # On Windows: env\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.env
file in the project root with the following variables:# Essential for LangGraph, LangSmith, and LangChain LANGCHAIN_API_KEY=your_langchain_api_key_here LANGSMITH_API_KEY=your_langsmith_api_key_here LANGCHAIN_TRACING_V2=true # LLM and tool APIs OPENAI_API_KEY=your_openai_api_key_here OPENWEATHERMAP_API_KEY=your_openweathermap_api_key_here NEWS_API_KEY=your_news_api_key_here TAVILY_API_KEY=your_tavily_api_key_here XRAPID_API_KEY=your_xrapid_api_key_here
Tip: You can get your LangSmith/LangChain API key from https://smith.langchain.com/ under your account settings. The same key works for both
LANGCHAIN_API_KEY
andLANGSMITH_API_KEY
.
- LANGCHAIN_API_KEY: Required for LangGraph and LangChain functionality (get from LangSmith)
- LANGSMITH_API_KEY: Required for LangSmith functionality (same as above)
- LANGCHAIN_TRACING_V2: Set to
true
to enable advanced tracing and debugging - OpenAI API Key: Required for the LLM functionality
- OpenWeatherMap API Key: Required for weather information (free tier available)
- News API Key: Required for news articles (free tier available)
- Tavily API Key: Required for web search functionality (free tier available)
-
Start the development server
langgraph dev
-
Access the interfaces
- API: http://127.0.0.1:2024
- Studio UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
- API Docs: http://127.0.0.1:2024/docs
from agents import graph
from langchain_core.messages import HumanMessage
# Create a message
messages = [HumanMessage(content="What's the weather like in New York?")]
# Invoke the graph
result = graph.invoke({"messages": messages})
print(result["messages"][-1].content)
Adds two integers.
result = add(5, 3) # Returns 8
Multiplies two integers.
result = multiply(4, 6) # Returns 24
Divides two integers.
result = divide(10, 2) # Returns 5.0
Gets current weather information for a city.
weather = get_weather("London", "GB")
# Returns: {"city": "London", "temperature": "15Β°C", "description": "cloudy", ...}
Fetches latest news articles.
news = get_news("technology", "us")
# Returns list of articles with title, description, url, published_at
Gets a random inspirational quote.
quote = get_random_quote()
# Returns: {"quote": "...", "author": "...", "tags": [...]}
Gets a random joke.
joke = get_joke()
# Returns: {"joke": "..."} or {"setup": "...", "delivery": "..."}
Gets current cryptocurrency price.
price = get_crypto_price("ethereum")
# Returns: {"cryptocurrency": "ethereum", "price_usd": "$2,500.00", ...}
Gets detailed information about the current IP address.
ip_info = get_ip_info()
# Returns: {"ip": "192.168.1.1", "city": "New York", "country": "United States", ...}
Gets definition and information about a word.
definition = get_word_definition("serendipity")
# Returns: {"word": "serendipity", "phonetic": "...", "definitions": [...]}
web_search(query: str, search_depth: str = "basic", include_domains: Optional[List[str]] = None, exclude_domains: Optional[List[str]] = None) -> Dict
Performs a comprehensive web search using Tavily API.
results = web_search("artificial intelligence trends 2024", search_depth="advanced")
# Returns: {"query": "...", "answer": "...", "results": [...], "total_results": 10}
Searches for recent news articles from trusted sources.
news = search_news("climate change", include_domains=["bbc.com", "cnn.com"])
# Returns: {"query": "...", "results": [...], "total_results": 5}
Searches for academic papers and research content.
papers = search_academic("machine learning applications", include_domains=["arxiv.org"])
# Returns: {"query": "...", "results": [...], "total_results": 8}
{
"dockerfile_lines": [],
"graphs": {
"agent": "./agents.py:graph"
},
"env": "./.env",
"python_version": "3.11",
"dependencies": [
"."
]
}
# Essential for LangGraph, LangSmith, and LangChain
LANGCHAIN_API_KEY=your_langchain_api_key_here
LANGSMITH_API_KEY=your_langsmith_api_key_here
LANGCHAIN_TRACING_V2=true
# LLM and tool APIs
OPENAI_API_KEY=your_openai_api_key_here
OPENWEATHERMAP_API_KEY=your_openweathermap_api_key_here
NEWS_API_KEY=your_news_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
XRAPID_API_KEY=your_xrapid_api_key_here
# Test weather tool
from tools.weather_tools import get_weather
result = get_weather("San Francisco", "US")
print(result)
# Test math tools
from tools.math_tools import add, multiply, divide
print(add(10, 5)) # 15
print(multiply(4, 7)) # 28
print(divide(20, 4)) # 5.0
# Test web search tools
from tools.tavily_search import web_search, search_news, search_academic
results = web_search("Python programming best practices")
print(results)
from agents import graph
from langchain_core.messages import HumanMessage
# Test various queries
test_messages = [
"What's 15 + 27?",
"Tell me a joke",
"What's the weather in Tokyo?",
"Get me the latest technology news",
"What does 'serendipity' mean?",
"Search for information about renewable energy",
"Find recent news about artificial intelligence"
]
for message in test_messages:
result = graph.invoke({"messages": [HumanMessage(content=message)]})
print(f"Query: {message}")
print(f"Response: {result['messages'][-1].content}\n")
-
Python Version Error
- Ensure you're using Python 3.11 or higher
- Check with:
python --version
-
Missing API Keys
- Ensure all required API keys are set in
.env
- Some tools will work without API keys (math, quotes, jokes)
- LANGCHAIN_API_KEY and LANGSMITH_API_KEY are essential for LangGraph and LangSmith features
- LANGCHAIN_TRACING_V2 should be set to
true
for best tracing/debugging - Get your LangSmith/LangChain API key from https://smith.langchain.com/
- Ensure all required API keys are set in
-
Import Errors
- Ensure virtual environment is activated
- Reinstall dependencies:
pip install -r requirements.txt
-
LangGraph CLI Issues
- Install LangGraph CLI:
pip install -U "langgraph-cli[inmem]"
- Ensure Python 3.11+ is being used
- Install LangGraph CLI:
-
Tavily API Issues
- Ensure TAVILY_API_KEY is set in
.env
- Check API key validity at https://tavily.com/
- Verify internet connection for web searches
- Ensure TAVILY_API_KEY is set in
Enable debug output by setting environment variables:
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=your_langchain_api_key_here
langgraph dev
This project includes a modern Next.js frontend powered by CopilotKit, which provides a beautiful UI and connects seamlessly to the LangGraph agent backend.
- The frontend (in
web/
) uses CopilotKit to communicate with the LangGraph agent running athttp://localhost:2024
(or127.0.0.1:2024
). - The integration is handled via an API route at
/api/copilotkit
, which proxies requests from the frontend to the backend agent. - The key integration code is in [
web/app/api/copilotkit/route.ts
]:
import {
CopilotRuntime,
ExperimentalEmptyAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
LangGraphAgent
} from "@copilotkit/runtime";
import { NextRequest } from "next/server";
const serviceAdapter = new ExperimentalEmptyAdapter();
const runtime = new CopilotRuntime({
agents: {
agent: new LangGraphAgent({
deploymentUrl: "http://127.0.0.1:2024", // or "http://localhost:2024"
graphId: "agent"
})
}
});
export const POST = async (req: NextRequest) => {
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter,
endpoint: "/api/copilotkit",
});
return handleRequest(req);
};
- Install dependencies (only needed once):
cd web npm install
- Start the frontend development server:
This will start the Next.js app at http://localhost:3000.
npm run dev
Note: The LangGraph backend agent must be running at
http://localhost:2024
for the CopilotKit frontend to function.
- Start the LangGraph agent backend:
langgraph dev --host localhost --port 2024
- Start the CopilotKit Next.js frontend:
cd web npm install # only needed once npm run dev
You can now access the full multi-agent system with a modern UI at http://localhost:3000.
The CopilotKit-powered frontend requires some environment variables to be set in a .env.local
file in the web/
directory. You can use the provided web/.env copy.local
as a template:
# CopilotKit Configuration
# Replace with your actual CopilotKit Cloud API key
NEXT_PUBLIC_COPILOT_API_KEY=
# Your local LangGraph dev server URL
NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=http://localhost:2024
# Your LangGraph agent name (matches agents.py)
NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=agent
NEXT_PUBLIC_COPILOT_API_KEY
: (Optional for local/dev) Your CopilotKit Cloud API key, if using CopilotKit Cloud features.NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL
: The URL of your running LangGraph backend (default:http://localhost:2024
).NEXT_PUBLIC_COPILOTKIT_AGENT_NAME
: The agent name as defined in your backend (default:agent
).
To set up:
- Copy the template:
cp .env\ copy.local .env.local
- Edit
.env.local
and fill in any required values.
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-tool
- Add your tool to the appropriate module in
tools/
- Update
tools/__init__.py
to export your tool - Add your tool to the tools list in
agents.py
- Test your changes
- Submit a pull request
- Create a new file in
tools/
(e.g.,tools/calendar_tools.py
) - Implement your tool function with proper type hints and docstrings
- Add the import to
tools/__init__.py
- Add the tool to the tools list in
agents.py
- Update this README with documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- LangGraph: For the powerful graph-based agent framework
- LangChain: For the LLM integration capabilities
- LangSmith: For tracing, observability, and API key management
- OpenAI: For the GPT models
- Tavily: For the web search API
- OpenWeatherMap: For weather data API
- NewsAPI: For news articles
- Various Free APIs: For quotes, jokes, crypto prices, and dictionary data
For issues and questions:
- Check the troubleshooting section above
- Review the LangGraph documentation
- Open an issue on the repository
Happy coding! π