192 lines
8.8 KiB
Markdown
192 lines
8.8 KiB
Markdown
# Orchestration Layer
|
|
|
|
Business logic services for the DIDI platform. Contains the analysis engine and parameters management API.
|
|
|
|
## Services
|
|
|
|
### Agent V3
|
|
Analysis pipeline engine. Processes content through multiple detection components and generates risk verdicts.
|
|
- Port: 24803
|
|
- Container: didi-agent-v3
|
|
- Access: Via Kong at /agent-v3/*
|
|
|
|
### didiFramework
|
|
CRUD API for detection parameters. Manages techniques, dimensions, weights, and prompts.
|
|
- Port: 3005
|
|
- Container: didi-framework
|
|
- Database: PostgreSQL cluster (bos_parammgmt schema)
|
|
|
|
## Architecture
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────────────────┐
|
|
│ ORCHESTRATION LAYER │
|
|
├─────────────────────────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ ┌─────────────────────────────┐ ┌─────────────────────────────┐ │
|
|
│ │ Agent V3 │ │ didiFramework │ │
|
|
│ │ Port 24803 │ │ Port 3005 │ │
|
|
│ ├─────────────────────────────┤ ├─────────────────────────────┤ │
|
|
│ │ │ │ │ │
|
|
│ │ Pipeline Components: │ │ CRUD Endpoints: │ │
|
|
│ │ - Techniques Detection │ │ - /api/techniques │ │
|
|
│ │ - AI Content Detection │ │ - /api/dimensions │ │
|
|
│ │ - Claims Verification │ │ - /api/subdimensions │ │
|
|
│ │ - Domain Analysis │ │ - /api/indicators │ │
|
|
│ │ - Verdict Aggregation │ │ - /api/weights │ │
|
|
│ │ │ │ - /api/prompts │ │
|
|
│ │ APIs: │ │ - /api/sync-redis │ │
|
|
│ │ - /api/v3/pipeline/* │ │ - /api/history │ │
|
|
│ │ - /api/v3/techniques/* │ │ │ │
|
|
│ │ - /api/v3/ai-tampered/* │ │ │ │
|
|
│ │ - /api/v3/claims/* │ │ │ │
|
|
│ │ - /api/v3/history/* │ │ │ │
|
|
│ │ │ │ │ │
|
|
│ └──────────────┬──────────────┘ └──────────────┬──────────────┘ │
|
|
│ │ │ │
|
|
│ ▼ ▼ │
|
|
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
|
│ │ Redis Cache │ │
|
|
│ │ - Session state │ │
|
|
│ │ - Framework parameters (synced) │ │
|
|
│ │ - Analysis results (temporary) │ │
|
|
│ └─────────────────────────────────────────────────────────────────┘ │
|
|
│ │ │ │
|
|
│ ▼ ▼ │
|
|
│ ┌─────────────────────────────────────────────────────────────────┐ │
|
|
│ │ PostgreSQL Cluster │ │
|
|
│ │ 10.11.50.167:5000 │ │
|
|
│ │ - bos_parammgmt: Detection parameters │ │
|
|
│ │ - bos_analysis: Analysis results │ │
|
|
│ └─────────────────────────────────────────────────────────────────┘ │
|
|
│ │
|
|
└─────────────────────────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
## Directory Structure
|
|
|
|
```
|
|
orchestration-layer/
|
|
├── agent-v3/ # Analysis engine
|
|
│ ├── docker-compose.yml
|
|
│ ├── src/
|
|
│ │ ├── api/ # Route handlers
|
|
│ │ ├── components/ # Analysis components
|
|
│ │ │ ├── techniques/ # Manipulation detection
|
|
│ │ │ ├── ai-tampered/ # AI content detection
|
|
│ │ │ ├── claims/ # Claim verification
|
|
│ │ │ └── pipeline/ # Orchestration
|
|
│ │ ├── config/ # Configuration
|
|
│ │ └── core/ # Core utilities
|
|
│ └── scripts/ # Build/deploy scripts
|
|
├── didiFramework/ # Parameters API
|
|
│ ├── docker-compose.yml
|
|
│ ├── src/
|
|
│ │ ├── routes/ # API endpoints
|
|
│ │ ├── config/ # Database config
|
|
│ │ ├── types/ # TypeScript types
|
|
│ │ └── utils/ # Utilities
|
|
│ ├── sql/ # SQL scripts
|
|
│ └── scripts/ # Utilities
|
|
└── docs/ # Documentation
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
### Start Both Services
|
|
|
|
```bash
|
|
# Start didiFramework
|
|
cd didiFramework
|
|
docker compose up -d
|
|
|
|
# Start Agent V3
|
|
cd ../agent-v3
|
|
docker compose up -d
|
|
```
|
|
|
|
### Check Status
|
|
|
|
```bash
|
|
docker ps | grep -E "framework|agent-v3"
|
|
```
|
|
|
|
### View Logs
|
|
|
|
```bash
|
|
docker logs -f didi-framework
|
|
docker logs -f didi-agent-v3
|
|
```
|
|
|
|
## API Overview
|
|
|
|
### Agent V3 Endpoints
|
|
|
|
Analysis Pipeline:
|
|
- POST /api/v3/pipeline/analyze - Analyze text
|
|
- POST /api/v3/pipeline/analyze-url - Analyze URL
|
|
- POST /api/v3/pipeline/analyze-media - Analyze media
|
|
- GET /api/v3/pipeline/:sessionId/status - Check status
|
|
- GET /api/v3/pipeline/:sessionId/result - Get result
|
|
|
|
Individual Components:
|
|
- POST /api/v3/techniques/analyze - Techniques only
|
|
- POST /api/v3/ai-tampered/analyze - AI detection only
|
|
- POST /api/v3/claims/analyze - Claims only
|
|
|
|
History:
|
|
- GET /api/v3/history - List analyses
|
|
- GET /api/v3/history/:sessionId - Analysis details
|
|
- DELETE /api/v3/history/:sessionId - Delete analysis
|
|
|
|
### didiFramework Endpoints
|
|
|
|
Parameters:
|
|
- GET/POST/PUT/DELETE /api/techniques
|
|
- GET/POST/PUT/DELETE /api/dimensions
|
|
- GET/POST/PUT/DELETE /api/subdimensions
|
|
- GET/POST/PUT/DELETE /api/indicators
|
|
|
|
Weights:
|
|
- GET/PUT /api/weights/component
|
|
- GET/PUT /api/weights/multipliers
|
|
- GET/PUT /api/weights/scenarios
|
|
|
|
Sync:
|
|
- POST /api/sync-redis - Sync all params to Redis
|
|
- GET /api/sync-redis/status - Check sync status
|
|
|
|
History (proxy):
|
|
- GET /api/history - Analysis history
|
|
- GET /api/history/:sessionId - Analysis details
|
|
|
|
## Data Flow
|
|
|
|
1. Request arrives at Kong (/agent-v3/*)
|
|
2. Kong routes to Agent V3 (port 24803)
|
|
3. Agent V3 loads parameters from Redis (synced from didiFramework)
|
|
4. Analysis components process content
|
|
5. Results saved to Redis (temporary) and PostgreSQL (permanent)
|
|
6. Response returned through Kong
|
|
|
|
## Configuration
|
|
|
|
### Agent V3
|
|
|
|
Environment variables in docker-compose.yml:
|
|
- REDIS_HOST, REDIS_PORT, REDIS_PASSWORD
|
|
- PG_HOST, PG_PORT, PG_DATABASE, PG_USER, PG_PASSWORD
|
|
- LLM provider API keys
|
|
|
|
### didiFramework
|
|
|
|
Environment variables:
|
|
- DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD
|
|
- REDIS_HOST, REDIS_PORT, REDIS_PASSWORD
|
|
|
|
## Dependencies
|
|
|
|
Both services depend on:
|
|
- PostgreSQL cluster (10.11.50.167:5000)
|
|
- Redis (didi-cache)
|
|
- Network: didi-staging_didi-staging
|