feat: add Tags section to combine_contexts() for insight context
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,9 +15,9 @@ use crate::database::models::InsertPhotoInsight;
|
||||
use crate::database::{
|
||||
CalendarEventDao, DailySummaryDao, ExifDao, InsightDao, LocationHistoryDao, SearchHistoryDao,
|
||||
};
|
||||
use crate::tags::TagDao;
|
||||
use crate::memories::extract_date_from_filename;
|
||||
use crate::otel::global_tracer;
|
||||
use crate::tags::TagDao;
|
||||
use crate::utils::normalize_path;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -589,6 +589,7 @@ impl InsightGenerator {
|
||||
calendar: Option<String>,
|
||||
location: Option<String>,
|
||||
search: Option<String>,
|
||||
tags: Option<String>,
|
||||
) -> String {
|
||||
let mut parts = Vec::new();
|
||||
|
||||
@@ -604,6 +605,9 @@ impl InsightGenerator {
|
||||
if let Some(s) = search {
|
||||
parts.push(format!("## Searches\n{}", s));
|
||||
}
|
||||
if let Some(t) = tags {
|
||||
parts.push(format!("## Tags\n{}", t));
|
||||
}
|
||||
|
||||
if parts.is_empty() {
|
||||
"No additional context available".to_string()
|
||||
@@ -955,6 +959,7 @@ impl InsightGenerator {
|
||||
calendar_context,
|
||||
location_context,
|
||||
search_context,
|
||||
None, // tags — wired up in Task 5
|
||||
);
|
||||
|
||||
log::info!(
|
||||
@@ -1301,3 +1306,38 @@ Return ONLY the summary, nothing else."#,
|
||||
data.display_name
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn combine_contexts_includes_tags_section_when_tags_present() {
|
||||
let result = InsightGenerator::combine_contexts(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some("vacation, hiking, mountains".to_string()),
|
||||
);
|
||||
assert!(result.contains("## Tags"), "Should include Tags section");
|
||||
assert!(result.contains("vacation, hiking, mountains"), "Should include tag names");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn combine_contexts_omits_tags_section_when_no_tags() {
|
||||
let result = InsightGenerator::combine_contexts(
|
||||
Some("some messages".to_string()),
|
||||
None, None, None,
|
||||
None, // no tags
|
||||
);
|
||||
assert!(!result.contains("## Tags"), "Should not include Tags section when None");
|
||||
assert!(result.contains("## Messages"), "Should still include Messages");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn combine_contexts_returns_no_context_message_when_all_none() {
|
||||
let result = InsightGenerator::combine_contexts(None, None, None, None, None);
|
||||
assert_eq!(result, "No additional context available");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user