Skip to content

SalmaOuardi/langgraph-multiagent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LangGraph Multi-Agent System

A modular multi-agent system built with LangGraph, featuring tool routing, conversational memory, and flexible agent orchestration.

🎯 Features

  • Multi-tool routing: Automatically routes queries to web search, calculator, or direct LLM
  • Conversational memory: Maintains context across multiple turns
  • Modular architecture: Easy to extend with new tools and agents
  • Type-safe state management: Pydantic-based state definitions
  • Production-ready: Error handling, logging, tests

πŸ—οΈ Architecture

Multi-Tool Agent

User Query β†’ Router β†’ [Search | Calculator | Direct] β†’ Synthesizer β†’ Answer

Conversational Agent

Query β†’ Memory Check β†’ [Use History | Fetch New Info] β†’ Answer + Update Memory

πŸš€ Quick Start

# Setup with uv
uv venv
source .venv/bin/activate
uv pip install -e .

# Configure environment
cp .env.example .env
# Add your TAVILY_API_KEY

# Install Ollama
ollama pull mistral

# Run examples
python examples/basic_usage.py
python examples/with_memory.py

πŸ“– Examples

Basic Multi-Tool Agent

from src.agents.multi_tool import create_multi_tool_agent

agent = create_multi_tool_agent()
result = agent.invoke({"question": "What are the latest AI trends?"})
print(result["final_answer"])

With Conversation Memory

from src.agents.conversational import create_conversational_agent

agent = create_conversational_agent()
messages = []

# First question
result = agent.invoke({
    "messages": messages,
    "current_question": "Who created LangGraph?"
})

# Follow-up (uses memory)
messages.append({"role": "user", "content": "Who created LangGraph?"})
messages.append({"role": "assistant", "content": result["answer"]})

result = agent.invoke({
    "messages": messages,
    "current_question": "What else did they build?"
})

πŸ› οΈ Tech Stack

  • Framework: LangGraph 0.0.20
  • LLM: Mistral 7B (via Ollama)
  • Search: Tavily API
  • Package Manager: uv
  • Python: 3.9+

πŸ“ Project Structure

langgraph-multiagent/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ multi_tool.py       # Multi-tool routing agent
β”‚   β”‚   └── conversational.py   # Agent with memory
β”‚   β”œβ”€β”€ tools/
β”‚   β”‚   β”œβ”€β”€ search.py           # Web search (Tavily)
β”‚   β”‚   └── calculator.py       # Math calculations
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ state.py            # State type definitions
β”‚   β”‚   └── prompts.py          # Prompt templates
β”‚   └── main.py
β”œβ”€β”€ tests/
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ basic_usage.py
β”‚   └── with_memory.py
β”œβ”€β”€ docs/
└── pyproject.toml

πŸ§ͺ Testing

uv pip install -e ".[dev]"
pytest tests/

πŸ“š Documentation

🀝 Contributing

This is a personal learning project, but suggestions are welcome!

πŸ“ License

MIT


Built with LangGraph | Salma Ouardi | 2024

About

πŸ€– Multi-agent system built with LangGraph featuring intelligent tool routing, web search, calculations, and conversational memory. Demonstrates production-ready agent architecture with StateGraph, conditional edges, and modular design. Built with Mistral 7B (Ollama) and Tavily API.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors