Spaces:
Configuration error
Configuration error
v2.0: production multi-agent-system/README.md
Browse files- multi-agent-system/README.md +93 -68
multi-agent-system/README.md
CHANGED
|
@@ -1,88 +1,113 @@
|
|
| 1 |
-
# π€ Multi-Agent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
## Architecture
|
| 4 |
|
| 5 |
```
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
β
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
β
|
| 38 |
-
β
|
| 39 |
-
β
|
| 40 |
-
β
|
| 41 |
-
|
| 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
|
| 67 |
caseId: 'CASE-2024-0847',
|
| 68 |
-
reportText:
|
| 69 |
-
evidence:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
});
|
| 74 |
|
|
|
|
| 75 |
console.log(`Risk: ${report.riskScore}/100 (${report.riskLevel})`);
|
| 76 |
-
console.log(`
|
| 77 |
-
console.log(`Correlations: ${report.
|
| 78 |
-
console.log(`
|
|
|
|
|
|
|
|
|
|
| 79 |
```
|
| 80 |
|
| 81 |
-
## Environment
|
| 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 |
|