From e58b8fe7437b708f4c353e51feebe1597b6f6b08 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 18 Mar 2026 17:17:21 -0400 Subject: [PATCH] feat: add enrichment parameter to gather_search_context() replacing weak metadata query Co-Authored-By: Claude Sonnet 4.6 --- src/ai/insight_generator.rs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/ai/insight_generator.rs b/src/ai/insight_generator.rs index 9efb6cf..dbad90b 100644 --- a/src/ai/insight_generator.rs +++ b/src/ai/insight_generator.rs @@ -512,22 +512,29 @@ impl InsightGenerator { timestamp: i64, location: Option<&str>, contact: Option<&str>, + enrichment: Option<&str>, ) -> Result> { let tracer = global_tracer(); let span = tracer.start_with_context("ai.context.search", parent_cx); let search_cx = parent_cx.with_span(span); - // Build semantic query from metadata - let query_text = format!( - "searches about {} {} {}", - DateTime::from_timestamp(timestamp, 0) - .map(|dt| dt.format("%B %Y").to_string()) - .unwrap_or_default(), - location.unwrap_or(""), - contact - .map(|c| format!("involving {}", c)) - .unwrap_or_default() - ); + // Use enrichment (topics + photo description + tags) if available; + // fall back to generic temporal query. + let query_text = if let Some(enriched) = enrichment { + enriched.to_string() + } else { + // Fallback: generic temporal query + format!( + "searches about {} {} {}", + DateTime::from_timestamp(timestamp, 0) + .map(|dt| dt.format("%B %Y").to_string()) + .unwrap_or_default(), + location.unwrap_or(""), + contact + .map(|c| format!("involving {}", c)) + .unwrap_or_default() + ) + }; let query_embedding = match self.ollama.generate_embedding(&query_text).await { Ok(emb) => emb, @@ -948,6 +955,7 @@ impl InsightGenerator { timestamp, location.as_deref(), contact.as_deref(), + None, // enrichment — wired up in Task 5 ) .await .ok()