feat: VLM summary vector storage in Qdrant for semantic search
- Add upsert_vlm_embedding to QdrantDb with trace_id in payload
- chunk_id format: {file_uuid}_t{trace_id_hex} for search enrichment
- Update enrich_vlm_from_pg to extract trace_id from chunk_id
- VLM summary now searchable via semantic search with source_type=vlm
This commit is contained in:
@@ -887,6 +887,50 @@ impl QdrantDb {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Store VLM summary embedding with trace_id in payload
|
||||
pub async fn upsert_vlm_embedding(
|
||||
&self,
|
||||
point_id: u64,
|
||||
vector: &[f32],
|
||||
file_uuid: &str,
|
||||
trace_id: i32,
|
||||
text: &str,
|
||||
) -> Result<()> {
|
||||
let url = format!(
|
||||
"{}/collections/{}/points?wait=true",
|
||||
self.base_url, self.collection_name
|
||||
);
|
||||
// chunk_id in format "{file_uuid}_t{trace_id_hex}" for search enrichment
|
||||
let chunk_id = format!("{}_t{:x}", file_uuid, trace_id);
|
||||
let mut payload_map = std::collections::HashMap::new();
|
||||
payload_map.insert("file_uuid".to_string(), serde_json::json!(file_uuid));
|
||||
payload_map.insert("chunk_id".to_string(), serde_json::json!(chunk_id));
|
||||
payload_map.insert("chunk_type".to_string(), serde_json::json!("vlm_summary"));
|
||||
payload_map.insert("text".to_string(), serde_json::json!(text));
|
||||
payload_map.insert("trace_id".to_string(), serde_json::json!(trace_id));
|
||||
payload_map.insert("start_time".to_string(), serde_json::json!(0.0));
|
||||
payload_map.insert("end_time".to_string(), serde_json::json!(0.0));
|
||||
|
||||
let point = serde_json::json!({
|
||||
"points": [{
|
||||
"id": point_id,
|
||||
"vector": vector,
|
||||
"payload": payload_map
|
||||
}]
|
||||
});
|
||||
let resp = self
|
||||
.client
|
||||
.put(&url)
|
||||
.header("api-key", &self.api_key)
|
||||
.json(&point)
|
||||
.send()
|
||||
.await?;
|
||||
if !resp.status().is_success() {
|
||||
anyhow::bail!("Qdrant upsert VLM failed: {}", resp.status());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Scroll points matching a filter, returning payload data (single page)
|
||||
pub async fn scroll_points(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user