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:
@@ -512,13 +512,19 @@ 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.
|
||||||
|
let query_text = if let Some(enriched) = enrichment {
|
||||||
|
enriched.to_string()
|
||||||
|
} else {
|
||||||
|
// Fallback: generic temporal query
|
||||||
|
format!(
|
||||||
"searches about {} {} {}",
|
"searches about {} {} {}",
|
||||||
DateTime::from_timestamp(timestamp, 0)
|
DateTime::from_timestamp(timestamp, 0)
|
||||||
.map(|dt| dt.format("%B %Y").to_string())
|
.map(|dt| dt.format("%B %Y").to_string())
|
||||||
@@ -527,7 +533,8 @@ impl InsightGenerator {
|
|||||||
contact
|
contact
|
||||||
.map(|c| format!("involving {}", c))
|
.map(|c| format!("involving {}", c))
|
||||||
.unwrap_or_default()
|
.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()
|
||||||
|
|||||||
Reference in New Issue
Block a user