Spaces:
Configuration error
Configuration error
Add LangGraph agent system: README.md
Browse files- langgraph-agents/README.md +93 -0
langgraph-agents/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π€ ForensiX AI β LangGraph Multi-Agent System
|
| 2 |
+
|
| 3 |
+
## Architecture
|
| 4 |
+
|
| 5 |
+
```
|
| 6 |
+
START
|
| 7 |
+
β
|
| 8 |
+
βββββββββββββββββββββββββββββββββββββ PARALLEL (Phase 1)
|
| 9 |
+
β β β β
|
| 10 |
+
β [Autopsy] [Timeline] [CCTV]
|
| 11 |
+
β Gemini Pro Local Math Gemini Flash
|
| 12 |
+
β β β β
|
| 13 |
+
β ββββββββββββββββ΄βββββββββββββββ
|
| 14 |
+
β β
|
| 15 |
+
β [phase1_join]
|
| 16 |
+
β β
|
| 17 |
+
β ββββ conditional ββββ
|
| 18 |
+
β β β
|
| 19 |
+
β [Toxicology] β
|
| 20 |
+
β Featherless 70B β
|
| 21 |
+
β β β
|
| 22 |
+
β ββββ merge ββββββββββ
|
| 23 |
+
β β
|
| 24 |
+
β [Correlation]
|
| 25 |
+
β Featherless + Embeddings
|
| 26 |
+
β β
|
| 27 |
+
β [Risk]
|
| 28 |
+
β 100% Deterministic
|
| 29 |
+
β β
|
| 30 |
+
β ββββ conditional ββββ
|
| 31 |
+
β β β
|
| 32 |
+
β [Human Review] β
|
| 33 |
+
β interrupt() HITL β
|
| 34 |
+
β β β
|
| 35 |
+
β ββββ merge ββββββββββ
|
| 36 |
+
β β
|
| 37 |
+
β [Explainability]
|
| 38 |
+
β Featherless 70B
|
| 39 |
+
β β
|
| 40 |
+
β [Leads]
|
| 41 |
+
β β
|
| 42 |
+
β END
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Quick Start
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
# Install
|
| 49 |
+
pip install -r requirements.txt
|
| 50 |
+
|
| 51 |
+
# Configure
|
| 52 |
+
cp example.env .env
|
| 53 |
+
# Edit .env with your API keys
|
| 54 |
+
|
| 55 |
+
# Run
|
| 56 |
+
python server.py
|
| 57 |
+
# β http://localhost:8000/docs (Swagger UI)
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## API Endpoints
|
| 61 |
+
|
| 62 |
+
| Method | Path | Description |
|
| 63 |
+
|--------|------|-------------|
|
| 64 |
+
| POST | `/api/investigate/stream` | Run full pipeline with SSE streaming |
|
| 65 |
+
| POST | `/api/investigate/resume` | Resume after human-in-the-loop pause |
|
| 66 |
+
| POST | `/api/investigate/state` | Get investigation thread state |
|
| 67 |
+
| GET | `/api/health` | Health check + provider status |
|
| 68 |
+
|
| 69 |
+
## Next.js Integration
|
| 70 |
+
|
| 71 |
+
```typescript
|
| 72 |
+
// Call from your Next.js frontend:
|
| 73 |
+
const evtSource = new EventSource('/api/investigate/stream');
|
| 74 |
+
// Or use fetch with ReadableStream (see client.ts)
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Files
|
| 78 |
+
|
| 79 |
+
| File | Purpose |
|
| 80 |
+
|------|---------|
|
| 81 |
+
| `graph.py` | LangGraph StateGraph with all 8 agents (~750 lines) |
|
| 82 |
+
| `server.py` | FastAPI server with SSE streaming + HITL (~220 lines) |
|
| 83 |
+
| `requirements.txt` | Python dependencies |
|
| 84 |
+
| `example.env` | Configuration template |
|
| 85 |
+
| `client.ts` | TypeScript client for Next.js integration |
|
| 86 |
+
|
| 87 |
+
## Key Design Decisions
|
| 88 |
+
|
| 89 |
+
1. **LangGraph StateGraph** (not Supervisor) β gives us deterministic execution order
|
| 90 |
+
2. **Parallel fan-out** via `Send()` β Autopsy + Timeline + CCTV run simultaneously
|
| 91 |
+
3. **Human-in-the-loop** via `interrupt()` β pauses at high-risk cases for approval
|
| 92 |
+
4. **Risk scoring is LOCAL** β zero AI, pure math, reproducible
|
| 93 |
+
5. **Graceful degradation** β each agent handles its own errors independently
|