Muthukumarank commited on
Commit
c247444
Β·
verified Β·
1 Parent(s): ea12cef

v2.0: production multi-agent-system/README.md

Browse files
Files changed (1) hide show
  1. multi-agent-system/README.md +93 -68
multi-agent-system/README.md CHANGED
@@ -1,88 +1,113 @@
1
- # πŸ€– Multi-Agent Forensic AI System
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  ## Architecture
4
 
5
  ```
6
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
7
- β”‚ ORCHESTRATOR (Agent 8) β”‚
8
- β”‚ Coordinates all agents β”‚
9
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10
- β”‚
11
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
12
- β”‚ β”‚ β”‚ β”‚ β”‚
13
- β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
14
- β”‚ Autopsy β”‚ β”‚Timeline β”‚ β”‚ CCTV β”‚ β”‚Toxicol. β”‚ β”‚Correlat.β”‚
15
- β”‚ Agent 1 β”‚ β”‚ Agent 2 β”‚ β”‚ Agent 3 β”‚ β”‚ Agent 4 β”‚ β”‚ Agent 5 β”‚
16
- β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
17
- β”‚ β”‚ β”‚ β”‚ β”‚
18
- Gemini Pro Local + Gemini Featherless Featherless
19
- + HuggingFace Gemini Lite Flash + HF + Gemini + HF Embed
20
- β”‚ β”‚ β”‚ β”‚ β”‚
21
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
22
- β”‚
23
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
24
- β”‚ β”‚ β”‚
25
- β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚
26
- β”‚ Risk β”‚ β”‚Explain. β”‚ β”‚
27
- β”‚ Agent 6 β”‚ β”‚ Agent 7 β”‚ β”‚
28
- β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
29
- β”‚ β”‚ β”‚
30
- Local Algo Featherless β”‚
31
- + Gemini Llama 70B β”‚
32
- β”‚ β”‚ β”‚
33
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
34
- β”‚
35
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
36
- β”‚ FINAL REPORT β”‚
37
- β”‚ β€’ Risk Score β”‚
38
- β”‚ β€’ Digital Stratigraphy β”‚
39
- β”‚ β€’ Correlations β”‚
40
- β”‚ β€’ Explanations β”‚
41
- β”‚ β€’ Investigative Leads β”‚
42
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
43
  ```
44
 
45
- ## Files
46
-
47
- | File | Agent | API Providers |
48
- |------|-------|---------------|
49
- | `config.ts` | Configuration & Types | β€” |
50
- | `api-clients.ts` | Unified API layer | Gemini, Featherless, HuggingFace |
51
- | `agent-autopsy.ts` | Agent 1: Autopsy | Gemini 2.5 Pro + HuggingFace NER |
52
- | `agent-timeline.ts` | Agent 2: Timeline | Local + Gemini Flash Lite |
53
- | `agent-cctv.ts` | Agent 3: CCTV | Gemini 2.5 Flash (3-tier) |
54
- | `agent-toxicology.ts` | Agent 4: Toxicology | Featherless 70B + HF + Gemini |
55
- | `agent-correlation.ts` | Agent 5: Correlation | Featherless 70B + HF Embeddings |
56
- | `agent-explainability.ts` | Agent 6: Explainability | Featherless 70B |
57
- | `agent-risk.ts` | Agent 7: Risk | Local Algorithm + Gemini Flash |
58
- | `orchestrator.ts` | Agent 8: Orchestrator | All providers |
59
- | `index.ts` | Public API exports | β€” |
60
-
61
  ## Usage
62
 
63
  ```typescript
64
- import { orchestrator } from './multi-agent-system';
65
 
66
- const report = await orchestrator.runFullAnalysis({
67
  caseId: 'CASE-2024-0847',
68
- reportText: autopsyReportText,
69
- evidence: digitalEvidenceArray,
70
- cctvFrames: [frame1Base64, frame2Base64],
71
- }, (stage, agentId, progress) => {
72
- console.log(`[${progress}%] ${stage}`);
 
 
 
 
 
 
 
 
73
  });
74
 
 
75
  console.log(`Risk: ${report.riskScore}/100 (${report.riskLevel})`);
76
- console.log(`Agents run: ${report.executionSummary.agentsRun}`);
77
- console.log(`Correlations: ${report.correlations.length}`);
78
- console.log(`Leads: ${report.investigativeLeads.join('\n')}`);
 
 
 
79
  ```
80
 
81
- ## Environment Variables Required
82
 
83
  ```env
84
- GEMINI_API_KEY=AIza...
85
- FEATHERLESS_API_KEY=fl-...
86
  FEATHERLESS_MODEL=meta-llama/Meta-Llama-3.1-70B-Instruct
87
- HF_TOKEN=hf_...
88
  ```
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ€– ForensiX AI β€” Multi-Agent System v2.0 (Production)
2
+
3
+ ## What Changed from v1.0
4
+
5
+ | Feature | v1.0 | v2.0 |
6
+ |---------|------|------|
7
+ | Error handling | Basic try/catch | Retry with backoff + timeout + fallback per agent |
8
+ | Rate limiting | None | 429 detection + exponential backoff |
9
+ | Input validation | None | Length checks, timestamp validation, null guards |
10
+ | API failures | System crashes | Graceful degradation (agents fail independently) |
11
+ | JSON parsing | `JSON.parse()` | Robust parser handles markdown, code blocks, partial JSON |
12
+ | Execution | Sequential | **Phase-based parallel** (Phase 1 runs 3 agents simultaneously) |
13
+ | Metrics | Basic timing | Full metrics: retries, API calls per provider, success/fail counts |
14
+ | Risk scoring | AI-influenced | **100% deterministic** (identical input = identical output always) |
15
+ | Safety filters | None | Gemini safety settings configured for forensic content |
16
+ | Progress | None | Real-time callback with stage, agent, percentage, detail |
17
+ | Timeouts | Infinite wait | 30s standard, 60s for Gemini Pro, 45s for Featherless |
18
+ | IDs | Incrementing | Cryptographically-random unique IDs |
19
+ | Timestamps | None on findings | ISO-8601 on every finding |
20
+ | Agent source | Not tracked | Every finding tagged with source agent |
21
 
22
  ## Architecture
23
 
24
  ```
25
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ PHASE 1 (PARALLEL) ────────────────────┐
26
+ β”‚ AutopsyAgent β”‚ TimelineAgent β”‚ CCTVAgent β”‚
27
+ β”‚ Gemini 2.5 Pro β”‚ Local + Gemini β”‚ Gemini 2.5 Flash β”‚
28
+ β”‚ + HuggingFace β”‚ Lite β”‚ (3-tier) β”‚
29
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
30
+ β”‚
31
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
32
+ β”‚ PHASE 2 β”‚
33
+ β”‚ ToxicologyAgent β”‚
34
+ β”‚ Featherless 70B β”‚
35
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
36
+ β”‚
37
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
38
+ β”‚ PHASE 3 β”‚
39
+ β”‚ CorrelationAgent β”‚
40
+ β”‚ Featherless + HF β”‚
41
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
42
+ β”‚
43
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
44
+ β”‚ PHASE 4 β”‚
45
+ β”‚ RiskAgent β”‚
46
+ β”‚ 100% LOCAL (zero AI)β”‚
47
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
48
+ β”‚
49
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
50
+ β”‚ PHASE 5 β”‚
51
+ β”‚ ExplainabilityAgentβ”‚
52
+ β”‚ Featherless 70B β”‚
53
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
54
+ β”‚
55
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
56
+ β”‚ FINAL OUTPUT β”‚
57
+ β”‚ Digital Stratigraphyβ”‚
58
+ β”‚ Prioritized Findingsβ”‚
59
+ β”‚ Investigative Leads β”‚
60
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 
61
  ```
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  ## Usage
64
 
65
  ```typescript
66
+ import { orchestrator, CaseInput } from './multi-agent-system';
67
 
68
+ const input: CaseInput = {
69
  caseId: 'CASE-2024-0847',
70
+ reportText: '... autopsy report text ...',
71
+ evidence: [
72
+ { timestamp: '2024-03-14T01:45', source: 'CCTV-12', eventType: 'person_detected', details: 'Two individuals walking toward warehouse' },
73
+ { timestamp: '2024-03-14T02:15', source: 'CCTV-12', eventType: 'person_detected', details: 'Single individual leaving rapidly' },
74
+ // ... more evidence
75
+ ],
76
+ cctvFrames: [
77
+ { base64: '...', timestamp: '2024-03-14T01:45', cameraId: 'CAM-12' },
78
+ ],
79
+ };
80
+
81
+ const report = await orchestrator.run(input, (stage, agentId, progress, detail) => {
82
+ console.log(`[${progress}%] ${stage} (${agentId}) ${detail || ''}`);
83
  });
84
 
85
+ // Results
86
  console.log(`Risk: ${report.riskScore}/100 (${report.riskLevel})`);
87
+ console.log(`Findings: ${report.execution.totalFindings}`);
88
+ console.log(`Correlations: ${report.execution.totalCorrelations}`);
89
+ console.log(`Time: ${report.execution.totalTimeMs}ms`);
90
+ console.log(`API calls: ${JSON.stringify(report.execution.apiCalls)}`);
91
+ console.log(`Agents: ${report.execution.agentsSucceeded}/${report.execution.agentsRun} succeeded`);
92
+ console.log(`Leads: ${report.investigativeLeads.length}`);
93
  ```
94
 
95
+ ## Environment
96
 
97
  ```env
98
+ GEMINI_API_KEY=AIza... # Required for CCTV + Autopsy
99
+ FEATHERLESS_API_KEY=fl-... # Required for Toxicology + Correlation + Explain
100
  FEATHERLESS_MODEL=meta-llama/Meta-Llama-3.1-70B-Instruct
101
+ HF_TOKEN=hf_... # Required for NER + Embeddings
102
  ```
103
+
104
+ ## Files (6 files, ~65KB total)
105
+
106
+ | File | Purpose | Lines |
107
+ |------|---------|-------|
108
+ | `config.ts` | Types, validation, utilities | ~160 |
109
+ | `api-clients.ts` | Gemini/Featherless/HF with retry+timeout | ~210 |
110
+ | `agents-primary.ts` | Agents 1-4 (Autopsy, Timeline, CCTV, Toxicology) | ~380 |
111
+ | `agents-secondary.ts` | Agents 5-7 (Correlation, Explainability, Risk) | ~320 |
112
+ | `orchestrator.ts` | Agent 8 (Master coordination) | ~250 |
113
+ | `index.ts` | Public exports | ~25 |