feat: VLM summary vector search integration

- Add vlm_point_id column to trace_profiles (stores Qdrant point ID)
- Add upsert_chunk_embedding_u64 to QdrantDb (numeric ID support)
- Add chunk_id to VLM payload in Qdrant for search enrichment
- Update enrich_from_pg to fallback to VLM lookup when chunk not found
- Add /api/v1/file/:uuid/vlm-summary endpoint for manual trigger
- Fix VLM point_id: use u64 hash instead of string (Qdrant requirement)
- Fix VLM timeout: was 0 (immediate timeout), now 120s

Verified: semantic search returns [vlm] results with proper enrichment
This commit is contained in:
Accusys
2026-08-22 12:10:47 +08:00
parent 476a31ecc6
commit 054545bccd
5 changed files with 184 additions and 10 deletions
+13 -7
View File
@@ -163,7 +163,7 @@ async fn process_single_trace(
"Summarize this key frame.",
vec![base64_img],
512,
0,
120,
)
.await
{
@@ -237,13 +237,21 @@ async fn process_single_trace(
}
};
// Generate Qdrant point_id (unique u64 hash)
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let mut hasher = DefaultHasher::new();
format!("{}_{}", file_uuid, trace_id).hash(&mut hasher);
let point_id = hasher.finish();
// Store embedding in DB
if let Err(e) = sqlx::query(&format!(
"UPDATE {tp_table} SET vlm_embedding = $1 WHERE file_uuid = $2 AND trace_id = $3"
"UPDATE {tp_table} SET vlm_embedding = $1, vlm_point_id = $4 WHERE file_uuid = $2 AND trace_id = $3"
))
.bind(&serde_json::to_value(&vector)?)
.bind(file_uuid)
.bind(trace_id)
.bind(&point_id.to_string())
.execute(db.pool())
.await
{
@@ -253,17 +261,15 @@ async fn process_single_trace(
);
}
// Store in Qdrant
// Store in Qdrant (using u64 ID)
let qdrant = QdrantDb::new();
let point_id = format!("{}_t{}", file_uuid, trace_id);
if let Err(e) = qdrant
.upsert_chunk_embedding(
&point_id,
.upsert_chunk_embedding_u64(
point_id,
&vector,
"vlm_summary",
file_uuid,
&summary,
None,
0.0,
0.0,
)