fix: Face processor now saves status and total_faces to face.json

This commit is contained in:
Accusys
2026-09-26 23:06:11 +08:00
parent 8a736a4103
commit 357e585399
99 changed files with 13881 additions and 1065 deletions
+38 -4
View File
@@ -102,10 +102,22 @@ const SYSTEM_PROMPT: &str = r#"你是 Momentry 影片分析助手。回答用戶
## 搜尋工具選擇策略(重要:根據問題類型選擇正確工具)
### 優先順序(按此順序選擇工具)
1. **semantic_search** - 語意搜尋 → **優先使用(適合大多數查詢)**
2. **smart_search** - 精確關鍵字匹配(僅在需要精確匹配時使用)
3. **trace_search** - 人物外貌、衣著、地點
4. **find_file** - 僅搜尋片名(不搜尋內容)
1. **vlm_search** - VLM 統一視覺搜尋(Scene + Trace 向量一次搜)→ **畫面/場景/人物視覺查詢優先使用,一查即涵蓋場景與人物**
2. **scene_search** - 場景功能搜尋(Scene VLM 向量優先)→ **只查畫面場景時使用**
3. **semantic_search** - 語意搜尋 → 適合文字內容(台詞、概念)
4. **smart_search** - 精確關鍵字匹配(僅在需要精確匹配時使用)
5. **trace_search** - 人物外貌、衣著、地點
6. **find_file** - 僅搜尋片名(不搜尋內容)
### vlm_search(VLM 統一視覺搜尋)- 視覺查詢優先使用
- **使用時機**:查詢畫面/場景/人物視覺內容(「廚房」、「公園」、「穿白外套的女人」、「有人在跑步」、「室內場景」),一次同時搜 Scene VLM 與 Trace VLM 向量,最全面
- **範例**:「廚房場景」、「公園裡的男人」、「穿白外套的女人在哪」、「室內場景」、「某人的外貌特徵」
- **回傳**:混合卡片(card_type: scene 或 face),scene 含 scene_index/thumbnail_url/vlm_tags,face 含 trace_id/identity_name/vlm_clothing/vlm_tags
### scene_search(場景功能搜尋)- 畫面查詢優先使用
- **使用時機**:查詢畫面/場景內容(「廚房」、「公園」、「室內裝潢」、「有人在跑步」),優先於文字搜尋
- **範例**:「廚房場景」、「公園裡的男人」、「穿白外套的女人在哪個畫面」、「室內場景」
- **回傳**:符合的場景卡片(file_uuid, scene_index, thumbnail_url, vlm_description, vlm_tags, score, timestamp)
### semantic_search(語意搜尋)- 優先使用
- **使用時機**:大多數查詢(理解意圖、概念性問題、一般話題)
@@ -200,6 +212,26 @@ fn make_tools(pool: &sqlx::PgPool) -> Vec<ToolDef> {
}),
vec!["query"],
),
function_calling::make_tool(
"vlm_search",
"VLM 視覺統一搜尋(Scene VLM 場景向量 + Trace VLM 人物向量,一次查兩邊)。用一段描述同時搜尋影片的畫面場景與人物,兩者皆為視覺向量搜尋(embedding),非文字關鍵字。適合回答「哪個畫面/場景出現OOO」、「穿OO的人」、「影片的視覺內容」。可用 file_uuid 限制搜尋範圍。回傳混合卡片(card_type: scene 或 face)。",
serde_json::json!({
"file_uuid": {"type": "string", "description": "限制搜尋範圍(可選)"},
"query": {"type": "string", "description": "搜尋關鍵字(會轉為 embedding,同時搜 scene + trace VLM 向量)"},
"limit": {"type": "integer", "default": 10}
}),
vec!["query"],
),
function_calling::make_tool(
"scene_search",
"場景功能搜尋(Scene VLM, Qdrant 向量優先)。搜尋影片中的畫面場景,如「廚房」、「公園」、「室內」、「有人在跑步」、「穿白外套的女人在廚房」。回傳場景卡片(含縮圖 URL、時間點、VLM 描述、tags)。適合回答「哪個畫面/場景出現OOO」、「場景外觀長什麼樣」。",
serde_json::json!({
"file_uuid": {"type": "string", "description": "限制搜尋範圍(可選)"},
"query": {"type": "string", "description": "搜尋關鍵字(會轉為 embedding)"},
"limit": {"type": "integer", "default": 10}
}),
vec!["query"],
),
function_calling::make_tool(
"trace_search",
"搜尋人物軌跡的 VLM 註記(外貌描述、衣著、標籤、地點、場景)。輸入關鍵字,回傳符合的 face trace 卡片。適合回答「穿藍色衣服的人」、「在展場出現的人」。",
@@ -353,6 +385,8 @@ async fn execute_tool(pool: &sqlx::PgPool, tool_call: &ToolCall) -> (String, Str
"tkg_node_detail" => tools::exec_tkg_node_detail(pool, &args).await,
"smart_search" => tools::exec_smart_search(pool, &args).await,
"semantic_search" => tools::exec_semantic_search(pool, &args).await,
"scene_search" => tools::exec_scene_search(pool, &args).await,
"vlm_search" => tools::exec_vlm_search(pool, &args).await,
"trace_search" => tools::exec_trace_search(pool, &args).await,
"identity_text" => tools::exec_identity_text(pool, &args).await,
"identities_search" => tools::exec_identities_search(pool, &args).await,