feat: add enrichment parameter to gather_search_context() replacing weak metadata query

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cameron
2026-03-18 17:17:21 -04:00
parent c0d27d0b9e
commit e58b8fe743

View File

@@ -512,22 +512,29 @@ impl InsightGenerator {
timestamp: i64, timestamp: i64,
location: Option<&str>, location: Option<&str>,
contact: Option<&str>, contact: Option<&str>,
enrichment: Option<&str>,
) -> Result<Option<String>> { ) -> Result<Option<String>> {
let tracer = global_tracer(); let tracer = global_tracer();
let span = tracer.start_with_context("ai.context.search", parent_cx); let span = tracer.start_with_context("ai.context.search", parent_cx);
let search_cx = parent_cx.with_span(span); let search_cx = parent_cx.with_span(span);
// Build semantic query from metadata // Use enrichment (topics + photo description + tags) if available;
let query_text = format!( // fall back to generic temporal query.
"searches about {} {} {}", let query_text = if let Some(enriched) = enrichment {
DateTime::from_timestamp(timestamp, 0) enriched.to_string()
.map(|dt| dt.format("%B %Y").to_string()) } else {
.unwrap_or_default(), // Fallback: generic temporal query
location.unwrap_or(""), format!(
contact "searches about {} {} {}",
.map(|c| format!("involving {}", c)) DateTime::from_timestamp(timestamp, 0)
.unwrap_or_default() .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 { let query_embedding = match self.ollama.generate_embedding(&query_text).await {
Ok(emb) => emb, Ok(emb) => emb,
@@ -948,6 +955,7 @@ impl InsightGenerator {
timestamp, timestamp,
location.as_deref(), location.as_deref(),
contact.as_deref(), contact.as_deref(),
None, // enrichment — wired up in Task 5
) )
.await .await
.ok() .ok()