Create Insight Generation Feature

Added integration with Messages API and Ollama
This commit is contained in:
Cameron
2026-01-03 10:30:37 -05:00
parent 0dfec4c8c5
commit 1171f19845
18 changed files with 1365 additions and 34 deletions

View File

@@ -16,6 +16,7 @@ use crate::file_types;
use crate::geo::{gps_bounding_box, haversine_distance};
use crate::memories::extract_date_from_filename;
use crate::{AppState, create_thumbnails};
use actix_web::dev::ResourcePath;
use actix_web::web::Data;
use actix_web::{
HttpRequest, HttpResponse,
@@ -383,7 +384,14 @@ pub async fn list_photos<TagD: TagDao, FS: FileSystemAccess>(
)
})
.map(|path: &PathBuf| {
let relative = path.strip_prefix(&app_state.base_path).unwrap();
let relative = path.strip_prefix(&app_state.base_path).expect(
format!(
"Unable to strip base path {} from file path {}",
&app_state.base_path.path(),
path.display()
)
.as_str(),
);
relative.to_path_buf()
})
.map(|f| f.to_str().unwrap().to_string())
@@ -1018,10 +1026,11 @@ mod tests {
let request: Query<FilesRequest> = Query::from_query("path=").unwrap();
// Create AppState with the same base_path as RealFileSystem
let test_state = AppState::test_state();
// Create a dedicated test directory to avoid interference from other files in system temp
let mut test_base = env::temp_dir();
test_base.push("image_api_test_list_photos");
fs::create_dir_all(&test_base).unwrap();
let test_base = PathBuf::from(test_state.base_path.clone());
let mut test_dir = test_base.clone();
test_dir.push("test-dir");
@@ -1031,17 +1040,6 @@ mod tests {
photo_path.push("photo.jpg");
File::create(&photo_path).unwrap();
// Create AppState with the same base_path as RealFileSystem
use actix::Actor;
let test_state = AppState::new(
std::sync::Arc::new(crate::video::actors::StreamActor {}.start()),
test_base.to_str().unwrap().to_string(),
test_base.join("thumbnails").to_str().unwrap().to_string(),
test_base.join("videos").to_str().unwrap().to_string(),
test_base.join("gifs").to_str().unwrap().to_string(),
Vec::new(),
);
let response: HttpResponse = list_photos(
claims,
TestRequest::default().to_http_request(),
@@ -1049,9 +1047,7 @@ mod tests {
Data::new(test_state),
Data::new(RealFileSystem::new(test_base.to_str().unwrap().to_string())),
Data::new(Mutex::new(SqliteTagDao::default())),
Data::new(Mutex::new(
Box::new(MockExifDao) as Box<dyn crate::database::ExifDao>
)),
Data::new(Mutex::new(Box::new(MockExifDao) as Box<dyn ExifDao>)),
)
.await;
let status = response.status();