Scene VLM Stats API¶
Endpoint: /api/v1/file/{file_uuid}/scene-vlm-stats
Method: GET
Purpose: 快速获取文件的 Scene VLM 统计数据
Overview¶
Scope: File processing statistics
Status: Active
Applicable to: All registered files with Scene VLM processing
Request¶
Parameters¶
| Parameter | Type | Location | Required | Description |
|---|---|---|---|---|
file_uuid |
String | Path | Yes | File UUID |
Example¶
Response¶
Success (200 OK)¶
Fields¶
| Field | Type | Description |
|---|---|---|
total_scenes |
i64 | Total number of scenes detected |
status |
String | Scene VLM processing status (pending, processing, completed) |
vlm_done |
i64 | Number of scenes with VLM descriptions completed |
vlm_total |
i64 | Total scenes needing VLM processing |
Default Response¶
If the file has no scenes file:
Performance¶
Response Time: < 10ms
Why Fast:
- Directly reads {file_uuid}.scenes.json
- No database queries
- No complex calculations
Use Cases¶
1. UI Display¶
Display Scene VLM progress in Library view:
const stats = await loadSceneVlmStats(fileUuid)
console.log(`${stats.vlm_done}/${stats.vlm_total} scenes completed`)
2. Performance Optimization¶
Replace expensive get_file_stats call:
- Old: get_file_stats - 100-500ms
- New: scene-vlm-stats - < 10ms
- Improvement: 10-50x faster
3. Real-time Updates¶
Poll for Scene VLM progress without heavy API load:
Implementation Details¶
Backend¶
File: src/api/scan.rs:1647
Logic:
1. Check if {file_uuid}.scenes.json exists
2. Read JSON file
3. Parse and count scenes
4. Return statistics
Code:
async fn get_scene_vlm_stats(
Path(file_uuid): Path<String>,
) -> Result<Json<SceneVlmStats>, StatusCode> {
let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid);
if !Path::new(&scenes_path).exists() {
return Ok(Json(SceneVlmStats::default()));
}
let scenes_json = std::fs::read_to_string(&scenes_path)?;
let scenes_data: Value = serde_json::from_str(&scenes_json)?;
// ... parse and return stats
}
Error Handling¶
File Not Found¶
Status: 200 OK
Response: Default values (all zeros)
Parse Error¶
Status: 500 Internal Server Error
Note: Rare case, indicates corrupted JSON file
Related APIs¶
GET /api/v1/file/{file_uuid}- Full file info (slower)GET /api/v1/file/{file_uuid}/processor-counts- Processor countsGET /api/v1/stats/file/{file_uuid}- Detailed stats (slower)
Best Practices¶
1. Use for Scene VLM Progress¶
Recommended: Use this API for Scene VLM progress display
Avoid: Using get_file_stats for simple Scene VLM stats
2. Caching¶
Frontend should cache results:
3. Error Handling¶
Always handle failures gracefully:
try {
const stats = await loadSceneVlmStats(fileUuid)
} catch (e) {
console.warn('Scene VLM stats failed:', e)
// Use cached data or show 'Unknown'
}
Version History¶
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-10-14 | Initial API endpoint |
Cross-References¶
- Frontend Integration: Studio team commit 3e7eba0
- Test Script:
momentry_studio/scripts/test_scene_vlm_api.sh - Backend Code:
src/api/scan.rs:1647
Last Updated: 2026-10-14