docs: add processor configuration v2/v3 with full commands

新增配置文件:
- processor_tools_v2.json: Tool/Model 分離設計
- processor_tools_v3.json: 完整命令和參數

新增文檔:
- Processor_Config_V2_Design.md: V2 設計文檔
- Processor_Commands_Reference.md: 完整命令參考

V3 配置特點:
- 明確區分 tool (python/rust/swift) 和 model (whisper/mediapipe)
- 包含完整執行命令和參數
- 支持變量替換 ({video_path}, {file_uuid}, etc.)
- 包含環境變量配置

命令示例:
- POSE (Python): python3.11 scripts/pose_processor_mediapipe.py {video} {output} --model-complexity 2
- FACE_TRACE (Rust): rust_store_traced_faces {uuid} --output-dir {dir}
- ASR (Python): python3.11 scripts/asr_processor_simplified.py {video} {output} --model large-v3

下一步:
- 更新 ToolSelector 支持 V3 格式
- 更新 Worker 使用新配置
This commit is contained in:
Accusys
2026-09-28 11:04:33 +08:00
parent f15842e9cf
commit 7d5afba1cd
4 changed files with 1526 additions and 0 deletions
@@ -0,0 +1,370 @@
---
title: Processor Configuration V2 Design
version: 2.0
date: 2026-09-27
author: OpenCode
status: draft
---
## 背景
當前配置結構混淆了 tool 和 model 的概念。
---
## 問題分析
### 舊格式 (V1)
```json
{
"pose": {
"tools": [
{
"name": "mediapipe", // ❌ 是 model 還是 tool?
"priority": 0,
"enabled": true,
"parameters": {...}
},
{
"name": "rust", // ❌ 是 tool,沒有 model 信息
"priority": 1
}
]
}
}
```
**問題**:
- `name` 混合了 tool 和 model
- 沒有明確區分實現方式和模型
- 難以追蹤使用了哪個模型
---
## 新格式 (V2)
```json
{
"pose": {
"implementations": [
{
"tool": "python", // ✅ 明確是 Python 實現
"model": "mediapipe", // ✅ 明確使用 MediaPipe 模型
"priority": 0,
"enabled": true,
"parameters": {...},
"script": "pose_processor_mediapipe.py" // ✅ 明確指定腳本
},
{
"tool": "rust", // ✅ 明確是 Rust 實現
"model": null, // ✅ 沒有特定模型
"priority": 1,
"enabled": true,
"parameters": {},
"binary": "rust_pose" // ✅ 明確指定二進制
}
],
"default": {
"tool": "python",
"model": "mediapipe"
}
}
}
```
---
## 結構說明
### Processor 配置
```typescript
interface ProcessorConfig {
implementations: Implementation[];
default: {
tool: Tool;
model: Model | null;
};
timeout?: number;
enabled: boolean;
}
```
### Implementation
```typescript
interface Implementation {
tool: "python" | "rust" | "swift";
model: Model | null;
priority: number;
enabled: boolean;
parameters: Record<string, any>;
// Tool-specific fields
script?: string; // for Python
binary?: string; // for Rust/Swift
}
```
### Model
```typescript
type Model =
| "whisper"
| "mediapipe"
| "yolov8-pose"
| "gemma-4-12b-it"
| "tesseract"
| null;
```
---
## 配置示例
### ASR (使用 Whisper)
```json
{
"asr": {
"implementations": [
{
"tool": "python",
"model": "whisper",
"priority": 0,
"enabled": true,
"parameters": {
"model_size": "large-v3",
"model_dir": "/Users/accusys/models/whisper-small-mlx"
},
"script": "asr_processor_whisper.py"
}
],
"default": {
"tool": "python",
"model": "whisper"
}
}
}
```
### Face Trace (Rust 實現)
```json
{
"face_trace": {
"implementations": [
{
"tool": "rust",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {
"min_trace_len": 0,
"min_confidence": 0.0
},
"binary": "rust_store_traced_faces"
}
],
"default": {
"tool": "rust",
"model": null
}
}
}
```
### VLM Summary (使用 Gemma4)
```json
{
"vlm_summary": {
"implementations": [
{
"tool": "rust",
"model": "gemma-4-12b-it",
"priority": 0,
"enabled": true,
"parameters": {
"max_tokens": 800,
"use_vision": true,
"llm_url": "http://localhost:8080/v1/chat/completions"
},
"binary": "rust_vlm_summary"
}
],
"default": {
"tool": "rust",
"model": "gemma-4-12b-it"
}
}
}
```
---
## Tool 映射
### Python
| Processor | Script | Model |
|-----------|--------|-------|
| pose | `pose_processor_mediapipe.py` | mediapipe |
| face | `face_detector.py` | - |
| asr | `asr_processor_whisper.py` | whisper |
| face_trace | `store_traced_faces.py` | - |
| tkg | `build_tkg.py` | - |
### Rust
| Processor | Binary | Model |
|-----------|--------|-------|
| pose | `rust_pose` | - |
| face_trace | `rust_store_traced_faces` | - |
| vlm_summary | `rust_vlm_summary` | gemma-4-12b-it |
| cut | `rust_cut` | - |
### Swift
| Processor | Binary | Model |
|-----------|--------|-------|
| pose | `swift_pose` | - |
| face | `swift_face` | - |
| asrx | `swift_asrx` | - |
| ocr | `swift_ocr` | - |
---
## Model 參數
### Whisper
```json
{
"model_size": "large-v3",
"model_dir": "/path/to/models",
"language": "auto",
"task": "transcribe"
}
```
### MediaPipe
```json
{
"model_complexity": 2,
"min_confidence": 0.5,
"model_path": "/path/to/pose_landmarker_heavy.task"
}
```
### Gemma4
```json
{
"max_tokens": 800,
"use_vision": true,
"llm_url": "http://localhost:8080/v1/chat/completions"
}
```
---
## 遷移計劃
### Phase 1: 並行運行
- 保留舊格式 `processor_tools.json`
- 新增新格式 `processor_tools_v2.json`
- 更新 `ToolSelector` 支持兩種格式
### Phase 2: 全面遷移
- 更新所有配置為新格式
- 移除舊格式支持
- 更新文檔
### Phase 3: 增強功能
- 支持動態模型選擇
- 支持模型性能監控
- 支持自動降級
---
## Rust 結構體更新
### V1 (當前)
```rust
struct ToolConfig {
name: String,
priority: u8,
enabled: bool,
parameters: HashMap<String, Value>,
}
struct ProcessorConfig {
tools: Vec<ToolConfig>,
default_tool: String,
enabled: bool,
}
```
### V2 (新版)
```rust
struct Implementation {
tool: Tool,
model: Option<Model>,
priority: u8,
enabled: bool,
parameters: HashMap<String, Value>,
script: Option<String>,
binary: Option<String>,
}
struct ProcessorConfigV2 {
implementations: Vec<Implementation>,
default: DefaultConfig,
timeout: Option<u64>,
enabled: bool,
}
enum Tool {
Python,
Rust,
Swift,
}
enum Model {
Whisper,
MediaPipe,
YoloV8Pose,
Gemma4,
Tesseract,
}
```
---
## 優勢
1. **清晰性**: tool 和 model 明確分離
2. **可追蹤性**: 知道使用了哪個模型
3. **靈活性**: 支持多個實現版本
4. **可擴展性**: 易於添加新工具和模型
---
## 文件位置
- **舊格式**: `config/processor_tools.json`
- **新格式**: `config/processor_tools_v2.json`
- **合併格式**: `config/admin_config.json` (待更新)
---
**狀態**: 📝 草稿
**下一步**: 更新 Rust 代碼支持 V2 格式