fix: VLM semantic search enrich + cleanup debug logging

This commit is contained in:
Accusys
2026-08-25 16:43:56 +08:00
parent 771115b42b
commit 8b53384059
+9 -21
View File
@@ -155,30 +155,21 @@ async fn enrich_vlm_from_pg(
// file_uuid is 32 chars, then "_t" (2 chars), then hex trace_id // file_uuid is 32 chars, then "_t" (2 chars), then hex trace_id
let trace_id: i32 = if chunk_id.len() > 34 && chunk_id.starts_with(file_uuid) { let trace_id: i32 = if chunk_id.len() > 34 && chunk_id.starts_with(file_uuid) {
let hex_part = &chunk_id[34..]; // after "{file_uuid}_t" let hex_part = &chunk_id[34..]; // after "{file_uuid}_t"
tracing::info!("[VLM-enrich] chunk_id={}, hex_part={}", chunk_id, hex_part);
i32::from_str_radix(hex_part, 16).ok()? i32::from_str_radix(hex_part, 16).ok()?
} else { } else {
tracing::info!("[VLM-enrich] chunk_id parse failed: len={}, starts_with={}", chunk_id.len(), chunk_id.starts_with(file_uuid));
return None; return None;
}; };
let tp_table = crate::core::db::schema::table_name("trace_profiles"); let tp_table = crate::core::db::schema::table_name("trace_profiles");
let query = format!( let rows: Vec<(Option<i64>, Option<i64>, Option<String>)> = sqlx::query_as(&format!(
"SELECT start_frame, end_frame, vlm_description FROM {tp_table} \ "SELECT start_frame, end_frame, vlm_description FROM {tp_table} \
WHERE file_uuid = $1 AND trace_id = $2" WHERE file_uuid = $1 AND trace_id = $2"
); ))
let result = sqlx::query_as(&query) .bind(file_uuid)
.bind(file_uuid) .bind(trace_id)
.bind(trace_id) .fetch_all(db.pool())
.fetch_all(db.pool()) .await
.await; .ok()?;
let rows: Vec<(Option<i64>, Option<i64>, Option<String>)> = match result {
Ok(r) => r,
Err(e) => {
tracing::warn!("[VLM-enrich] Query failed: {}", e);
return None;
}
};
let (start_frame, end_frame, vlm_desc) = rows.into_iter().next()?; let (start_frame, end_frame, vlm_desc) = rows.into_iter().next()?;
let text = vlm_desc.unwrap_or_default(); let text = vlm_desc.unwrap_or_default();
@@ -801,7 +792,7 @@ pub async fn semantic_search(
results results
} }
Err(e) => { Err(e) => {
tracing::error!("[qdrant-search] FAILED: {}", e); tracing::warn!("Qdrant search_in_uuid failed: {}", e);
vec![] vec![]
} }
} }
@@ -809,7 +800,7 @@ pub async fn semantic_search(
match qdrant.search(&embedding, limit).await { match qdrant.search(&embedding, limit).await {
Ok(results) => results, Ok(results) => results,
Err(e) => { Err(e) => {
tracing::error!("[qdrant-search] global FAILED: {}", e); tracing::warn!("Qdrant search failed: {}", e);
vec![] vec![]
} }
} }
@@ -823,7 +814,6 @@ pub async fn semantic_search(
let mut results = Vec::new(); let mut results = Vec::new();
for hit in semantic_results.iter() { for hit in semantic_results.iter() {
tracing::info!("[semantic-enrich] uuid={}, chunk_id={}", hit.uuid, hit.chunk_id);
if let Some(p) = enrich_from_pg(db, &hit.uuid, &hit.chunk_id, hit.score).await { if let Some(p) = enrich_from_pg(db, &hit.uuid, &hit.chunk_id, hit.score).await {
if let Some(ref filter) = source_filter { if let Some(ref filter) = source_filter {
if p.source_type.as_deref() != Some(filter.as_str()) { if p.source_type.as_deref() != Some(filter.as_str()) {
@@ -831,8 +821,6 @@ pub async fn semantic_search(
} }
} }
results.push(p); results.push(p);
} else {
tracing::info!("[semantic-enrich] enrich returned None for chunk_id={}", hit.chunk_id);
} }
} }