Skip to content

pareshraut/Langgraph-agents

Repository files navigation

Multi-Agent Chatbot Examples

This repository demonstrates two coordination patterns for LLM-based agents using LangGraph Supervisor and LangGraph Swarm architectures. Under src/, you’ll find three example workflows:

  • agent/ A voice-enabled customer support bot implemented in the Swarm style by default (but easily switchable to Supervisor).
  • doc-agent/ An appointment scheduler built on the Supervisor architecture.
  • bookings-template/ A booking workflow sketch in the Swarm architecture.

Table of Contents

  1. Architecture Overview

  2. Quick Start

  3. Example Workflows

  4. Voice-Enabled Customer Agent

  5. License


Architecture Overview

Supervisor

A single supervisor node manages routing to specialized child agents. The workflow always returns control to the supervisor, which decides the next agent or termination step.

Supervisor Handoff

Swarm

Each agent can hand off directly to any other agent in the group, without a central supervisor. The last active agent drives the next step.

Swarm Handoff

🔍 Use Cases by Pattern

Supervisor

A central supervisor orchestrates all hand-offs and returns control after each step.

Use Case Description
Hierarchical Q&A A Supervisor routes between a General Q&A agent, a Resume-Parser agent, and a Web-Search agent (DEV Community).
Doctor Appointment Scheduler Orchestrates information_agent (availability lookup) and booking_agent (set/cancel/reschedule) (Medium).
Automated Bug-Fixing Pipeline Supervisor drives an Agent-Debugger, an LLM Code-Generator, and a Test-Runner agent in sequence (arXiv).
Real-Time Data Analysis & Sentiment Spark-Streaming → Sentiment-Agent → Escalation-Agent with human-in-the-loop via Supervisor (arXiv).
Modular Machine Translation Supervisor orchestrates English, French, Japanese translation agents for a unified MT service (arXiv).

Swarm

Swarm agents hand off directly, peer-to-peer, in a shared workspace.

Use Case Description
Multi-domain QA & Translation General QA ↔ Science ↔ Translation agents collaborate dynamically without a central router (DEV Community).
Travel Booking (Flight ↔ Hotel) Flight agent books a ticket then seamlessly hands off “book hotel” to a Hotel agent (Medium).
Emergency Travel Coordinator Triage by EmergencyCoordinator → MedicalEvacuation / Security / Disaster-Response agents (Medium).
Ensemble Code Review Coder agent writes code → Checker agent reviews and suggests fixes → Coder re-runs fixes (Artificial Intelligence in Plain English).
Customer Support (Flight & Hotel) Flight & Hotel assistants share context in real-time for integrated travel support (Toolify).

Supervisor vs Swarm Comparison


Quick Start

  1. Install & configure

    python3.11 -m venv venv
    source venv/bin/activate
    pip install -e .[inmem] langgraph-cli

    You can use either the pyproject.toml or the requirements.txt for installing dependencies.

  2. Configure your secrets Create a .env file at the project root and add your API keys:

    OPENAI_API_KEY=sk-...
    AZURE_OPENAI_API_KEY=...
    LANGCHAIN_API_KEY=...
  3. Main config Each workflow reads its routing, agents, and tool definitions from langgraph.json at the root—open it to tweak agent names, prompts, or turn on/off streaming.

    Also be carefull to create the appropriate init.py file inside the respective agent directory like done in src/agent.

  4. Launch LangGraph Dev Studio

    uvx --refresh \
        --from "langgraph-cli[inmem]" \
        --with-editable . \
        langgraph dev
    • In Dev Studio you can select any of the three workflows under src/ and test them interactively.
    • For voice-enabled testing, upload pre-recorded WAVs to the transcribe_audio tool, inspect the JSON TTS output, and download/play it locally.

Example Workflows

Customer Agent (Swarm ↔ Supervisor)

  • Directory: src/agent/

  • Pattern: By default, demonstrates the Swarm handoff between:

    1. disambiguation_agent (figures out intent)
    2. service_agent (executes or transfers)
  • Switching: Change create_swarm(...) vs create_supervisor(...) in graph.py to toggle architectures.

Doctor-Scheduler Agent (Supervisor)

  • Directory: src/doc-agent/

  • Pattern: A Supervisor routes between:

    1. information_agent (checks availability)
    2. booking_agent (sets, cancels, reschedules appointments)

Bookings Template (Swarm)

  • Directory: src/bookings-template/
  • Pattern: A minimal Swarm example showing tool-calling between flight, hotel, and car-rental agents.

Voice-Enabled Customer Agent

The Customer Agent in src/agent/graph.py can run locally as a full voice chatbot:

  1. Dependencies (optional)

    pip install -e ".[voice]"
    # or
    pip install sounddevice scipy simpleaudio pydub ffmpeg-python imageio-ffmpeg
    brew install ffmpeg

    These are only required if you want to run the local voice loop. langgraph dev works without them.

  2. Run

    python src/agent/graph.py
    • The script records from your microphone,
    • uses Whisper for STT,
    • invokes the multi-agent workflow,
    • synthesizes the reply with TTS,
    • plays it back—all in a loop until you say “bye.”
  3. Dev Studio Voice Testing

    • Pre-record a series of WAV files (e.g. turn1.wav, turn2.wav, …).
    • In Dev Studio, use the File uploader on the transcribe_audio tool.
    • Examine the JSON with "tts_base64" and decode/play locally.

License

MIT © Paresh Raut

About

This project provides three end-to-end multi-agent chatbot examples built on LangGraph and LangChain, showcasing both centralized “Supervisor” and decentralized “Swarm” coordination patterns. Included are a voice-enabled customer support bot, a doctor appointment scheduler and a booking workflow template—each configurable via `.env` and `langgraph

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors