Spaces:
Sleeping
Sleeping
| title: langgraph-support-agent | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: docker | |
| <div align="center"> | |
| <h1>π€ LangGraph Support Agent Studio</h1> | |
| <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&size=22&duration=3000&pause=1000&color=4F8EF7¢er=true&vCenter=true&width=700&lines=Multi-turn+Customer+Support+Agent+powered+by+LangGraph;5+AI+Tools+%C2%B7+4+HuggingFace+Models+%C2%B7+ReAct+Architecture;Live+Graph+Tracing+%C2%B7+Tool+Logs+%C2%B7+Session+Analytics" alt="Typing SVG"/> | |
| <br/> | |
| [](https://www.python.org/) | |
| [](https://flask.palletsprojects.com/) | |
| [](https://langchain-ai.github.io/langgraph/) | |
| [](https://www.docker.com/) | |
| [](https://huggingface.co/mnoorchenar/spaces) | |
| [](#) | |
| **π€ 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. | |
| --- | |
| </div> | |
| ## β¨ Features | |
| <table> | |
| <tr><td>π§ <b>ReAct Agent Loop</b></td><td>LangGraph StateGraph orchestrates Thought β Action β Observation with up to 4 tool calls per turn, parsed from free-tier HuggingFace model output</td></tr> | |
| <tr><td>π§ <b>5 Live Tools</b></td><td>search_faq, check_order_status, create_ticket, get_product_info, escalate_to_human β each with real logic and mock data</td></tr> | |
| <tr><td>πΊοΈ <b>Live Graph Trace</b></td><td>Animated node visualizer showing Router β Agent β Tool Executor β Responder with per-node timing via SSE</td></tr> | |
| <tr><td>π‘ <b>Token Streaming</b></td><td>Server-Sent Events stream LLM tokens and graph events simultaneously, updating chat, trace, and tool log in real time</td></tr> | |
| <tr><td>π <b>Secure by Design</b></td><td>HF_TOKEN injected via HuggingFace Space secrets, never committed to source. All state is in-memory per session</td></tr> | |
| <tr><td>π³ <b>Containerized Deployment</b></td><td>Docker-first with gunicorn gthread workers, HuggingFace Spaces-compatible (uid 1000, port 7860)</td></tr> | |
| </table> | |
| ## ποΈ 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 | |
| <div align="center"> | |
| <img src="https://avatars.githubusercontent.com/mnoorchenar" width="100" style="border-radius:50%"/> | |
| **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) | |
| </div> | |
| ## 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. |