insight-chat: include Date taken + GPS in bootstrap photo context
The bootstrap system message gave the model a file path and (in hybrid mode) a visual description, but no temporal anchor. Models defaulted to today's date when calling get_sms_messages — Nov 2014 photos were getting "2024-03-11" passed as `date`, missing every historical message and leading the model to confidently misreport context. This commit folds two more EXIF-sourced facts into the --- PHOTO CONTEXT --- block: Date taken: <YYYY-MM-DD or "unknown"> GPS: <lat, lon to 4dp> (omitted when no GPS) Resolution waterfall for date_taken matches the documented canonical date pipeline at the EXIF / filename steps, but intentionally stops short of the fs-time fallback `generate_agentic_insight_for_photo` uses — for chat we'd rather show "unknown" than mislead the model with an inode mtime. GPS is taken straight from EXIF when both lat/lon are populated; absent GPS suppresses the line entirely so the model doesn't hallucinate coordinates. InsightGenerator gains a `fetch_exif(file_path)` accessor (crate- visible) so the chat service doesn't need its own ExifDao plumbing. build_bootstrap_system_message picks up two new params (date, gps); existing tests updated and 5 new tests cover: - date present / absent / waterfall (EXIF wins, filename fallback, None when neither source has it) - GPS present / absent - ordering (path → date → visual) Total insight_chat unit tests: 33 (up from 27).
This commit is contained in:
@@ -229,6 +229,17 @@ impl InsightGenerator {
|
||||
None
|
||||
}
|
||||
|
||||
/// Look up the EXIF row for a photo. Returns `None` when no row
|
||||
/// exists yet (file watcher hasn't reached it) or the DAO call
|
||||
/// fails. Used by callers — including the chat-bootstrap path —
|
||||
/// that need a few specific fields (date_taken, GPS) without
|
||||
/// duplicating DAO plumbing.
|
||||
pub(crate) fn fetch_exif(&self, file_path: &str) -> Option<crate::database::models::ImageExif> {
|
||||
let cx = opentelemetry::Context::current();
|
||||
let mut dao = self.exif_dao.lock().expect("Unable to lock ExifDao");
|
||||
dao.get_exif(&cx, file_path).ok().flatten()
|
||||
}
|
||||
|
||||
/// Load image file, resize it, and encode as base64 for vision models
|
||||
/// Resizes to max 1024px on longest edge to reduce context usage
|
||||
pub(crate) fn load_image_as_base64(&self, file_path: &str) -> Result<String> {
|
||||
|
||||
Reference in New Issue
Block a user