--- title: langgraph-support-agent colorFrom: blue colorTo: indigo sdk: docker ---

πŸ€– LangGraph Support Agent Studio

Typing SVG
[![Python](https://img.shields.io/badge/Python-3.11+-3b82f6?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/) [![Flask](https://img.shields.io/badge/Flask-3.x-4f46e5?style=for-the-badge&logo=flask&logoColor=white)](https://flask.palletsprojects.com/) [![LangGraph](https://img.shields.io/badge/LangGraph-0.2.x-06b6d4?style=for-the-badge)](https://langchain-ai.github.io/langgraph/) [![Docker](https://img.shields.io/badge/Docker-Ready-3b82f6?style=for-the-badge&logo=docker&logoColor=white)](https://www.docker.com/) [![HuggingFace](https://img.shields.io/badge/HuggingFace-Spaces-ffcc00?style=for-the-badge&logo=huggingface&logoColor=black)](https://huggingface.co/mnoorchenar/spaces) [![Status](https://img.shields.io/badge/Status-Active-22c55e?style=for-the-badge)](#) **πŸ€– LangGraph Support Agent Studio** β€” A production-grade multi-turn customer support agent built with LangGraph's ReAct architecture, powered entirely by free HuggingFace Inference API models, with live graph tracing, tool call logging, and session analytics streamed in real time via SSE. ---
## ✨ Features
🧠 ReAct Agent LoopLangGraph StateGraph orchestrates Thought β†’ Action β†’ Observation with up to 4 tool calls per turn, parsed from free-tier HuggingFace model output
πŸ”§ 5 Live Toolssearch_faq, check_order_status, create_ticket, get_product_info, escalate_to_human β€” each with real logic and mock data
πŸ—ΊοΈ Live Graph TraceAnimated node visualizer showing Router β†’ Agent β†’ Tool Executor β†’ Responder with per-node timing via SSE
πŸ“‘ Token StreamingServer-Sent Events stream LLM tokens and graph events simultaneously, updating chat, trace, and tool log in real time
πŸ”’ Secure by DesignHF_TOKEN injected via HuggingFace Space secrets, never committed to source. All state is in-memory per session
🐳 Containerized DeploymentDocker-first with gunicorn gthread workers, HuggingFace Spaces-compatible (uid 1000, port 7860)
## πŸ—οΈ Architecture ``` Browser (SSE) ◀──▢ Flask + gunicorn β”‚ LangGraph StateGraph β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Router β†’ Agent β”‚ β”‚ ↓ ↑ β”‚ β”‚ Tool Exec β†β”˜ β”‚ β”‚ ↓ β”‚ β”‚ Responder β†’ END β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ HuggingFace Inference API Mistral 7B Β· Zephyr 7B Β· Phi-3 Β· Llama 3 ``` ## πŸš€ Getting Started ```bash git clone https://github.com/mnoorchenar/langgraph-support-agent.git cd langgraph-support-agent python -m venv venv && source venv/bin/activate pip install -r requirements.txt cp .env.example .env # add your HF_TOKEN python app.py # open http://localhost:7860 ``` ## 🐳 Docker ```bash docker build -t langgraph-support-agent . docker run -p 7860:7860 -e HF_TOKEN=hf_your_token_here langgraph-support-agent ``` For HuggingFace Spaces: push this repo and add `HF_TOKEN` as a Space secret under **Settings β†’ Variables and Secrets**. ## πŸ“Š Dashboard Modules | Module | Description | Status | |--------|-------------|--------| | πŸ’¬ Chat Interface | Multi-turn streaming chat with SSE token delivery | βœ… Live | | πŸ—ΊοΈ Graph Trace | Animated LangGraph node visualizer with per-node timing | βœ… Live | | πŸ› οΈ Tool Call Log | Expandable log of every tool invocation with input/output | βœ… Live | | πŸ“ˆ Session Analytics | Chart.js charts β€” tool usage frequency and latency history | βœ… Live | | πŸ“œ Conversation History | Full chat history with timestamps and estimated token counts | βœ… Live | | πŸ€– Model Selector | Switch between 4 HuggingFace-hosted LLMs mid-session | βœ… Live | ## 🧠 ML Models ```python models = { "mistral": "mistralai/Mistral-7B-Instruct-v0.3", "zephyr": "HuggingFaceH4/zephyr-7b-beta", "phi3": "microsoft/Phi-3-mini-4k-instruct", "llama3": "meta-llama/Meta-Llama-3-8B-Instruct", } agent_type = "ReAct (Reason + Act)" tool_count = 5 max_iters = 4 streaming = True # token-level SSE via InferenceClient ``` ## πŸ“ Project Structure ``` langgraph-support-agent/ β”œβ”€β”€ app.py # Flask app, SSE endpoints, session management β”œβ”€β”€ events.py # Thread-safe per-session SSE event queue β”œβ”€β”€ agent/ β”‚ β”œβ”€β”€ state.py # AgentState TypedDict for LangGraph β”‚ β”œβ”€β”€ tools.py # 5 tool functions + execute_tool dispatcher β”‚ β”œβ”€β”€ llm.py # HF InferenceClient wrapper, ReAct prompt, parsers β”‚ β”œβ”€β”€ nodes.py # Router, Agent, ToolExecutor, Responder node functions β”‚ └── graph.py # StateGraph builder with conditional routing β”œβ”€β”€ data/ β”‚ └── faq.json # 15-entry FAQ knowledge base β”œβ”€β”€ templates/ β”‚ └── index.html # Single-page UI, 4-panel layout, SSE client β”œβ”€β”€ static/ β”‚ └── app.js # SSE client, Chart.js, node trace UI, analytics β”œβ”€β”€ requirements.txt β”œβ”€β”€ Dockerfile β”œβ”€β”€ .env.example └── docs/ └── project-template.html # Portfolio page ``` ## πŸ‘¨β€πŸ’» Author
**Mohammad Noorchenarboo** β€” Data Scientist | AI Researcher | Biostatistician πŸ“ Ontario, Canada Β· [LinkedIn](https://www.linkedin.com/in/mnoorchenar) Β· [Website](https://mnoorchenar.github.io/) Β· [HuggingFace](https://huggingface.co/mnoorchenar/spaces) Β· [GitHub](https://github.com/mnoorchenar)
## Disclaimer This project is developed strictly for educational and research purposes. All datasets are synthetically generated β€” no real user data is stored. Provided "as is" without warranty of any kind. ## πŸ“œ License MIT License. See `LICENSE` for details.