A sophisticated agentic AI system built with LangGraph that demonstrates advanced multi-agent coordination, web search integration, and real-time information retrieval.
This project implements an intelligent agent framework that can:
- Process complex queries using agentic workflows
- Perform web searches using Tavily Search API for real-time information
- Handle multi-step reasoning and decision-making
- Manage state across distributed agents
- Serve web-based frontend interface
- LangGraph State Management: Robust state handling with TypedDict for type safety
- Web Search Integration: Tavily Search API integration for fetching current information
- HuggingFace LLM: Support for HuggingFace models and endpoints
- Multi-Agent Architecture: Distributed task execution with agent coordination
- Freshness Detection: Built-in logic to detect freshness-related queries
- Full-Stack Application: Python backend + Next.js frontend
agent/
├── basic.py # Core agent logic and workflows
├── server.py # Backend server implementation
├── frontend/ # Next.js frontend application
│ ├── src/
│ ├── public/
│ └── package.json
├── blog_posts/ # Research and documentation
├── requirements.txt # Python dependencies
└── .env # Environment variables
- Python 3.10+
- Node.js 18+
- Tavily API Key
- HuggingFace API Token
# Install Python dependencies
pip install -r requirements.txt
# Install frontend dependencies
cd frontend
npm install
cd ..Create a .env file in the parent directory with:
TAVILY_API_KEY=your_tavily_key
HUGGINGFACEHUB_API_TOKEN=your_hf_token
# Start backend server
python server.py
# In another terminal, start frontend (from frontend directory)
npm run dev- State Management: Defines agent state with message history and routing logic
- Agent Chain: Creates multi-step workflows using LangGraph StateGraph
- Search Integration: Handles web searches for freshness-related queries
- Output Parsing: Uses Pydantic for structured output validation
Next.js-based web interface for interacting with the agent system, featuring:
- Real-time chat interface
- Response streaming
- Type-safe configuration with TypeScript
- LangGraph: Agent orchestration and state management
- LangChain: LLM integration and prompt management
- HuggingFace: LLM models and embeddings
- Tavily: Web search API
- Next.js: Frontend framework
- FastAPI/Starlette: Backend server
TAVILY_API_KEY: API key for Tavily web searchHUGGINGFACEHUB_API_TOKEN: HuggingFace authentication tokenHF_LLM_MODEL: HuggingFace model to use (default: meta-llama/Llama-2-7b-chat)
The agent can handle various query types:
from basic import create_agent_graph
# Create agent graph
graph = create_agent_graph()
# Run agent with a query
response = graph.invoke({
"messages": [HumanMessage("What are the latest trends in AI?")],
"routing": "research"
})MIT
Contributions welcome! Please submit pull requests with clear descriptions of changes.