Enhanced Insights with daily summary embeddings
Bump to 0.5.0. Added daily summary generation job
This commit is contained in:
46
src/main.rs
46
src/main.rs
@@ -718,7 +718,7 @@ fn main() -> std::io::Result<()> {
|
||||
}
|
||||
|
||||
create_thumbnails();
|
||||
generate_video_gifs().await;
|
||||
// generate_video_gifs().await;
|
||||
|
||||
let app_data = Data::new(AppState::default());
|
||||
|
||||
@@ -742,6 +742,50 @@ fn main() -> std::io::Result<()> {
|
||||
directory: app_state.base_path.clone(),
|
||||
});
|
||||
|
||||
// Spawn background job to generate daily conversation summaries
|
||||
{
|
||||
use crate::ai::generate_daily_summaries;
|
||||
use crate::database::{DailySummaryDao, SqliteDailySummaryDao};
|
||||
use chrono::NaiveDate;
|
||||
|
||||
// Configure date range for summary generation
|
||||
// Default: August 2024 ±30 days (July 1 - September 30, 2024)
|
||||
// To expand: change start_date and end_date
|
||||
let start_date = Some(NaiveDate::from_ymd_opt(2015, 10, 1).unwrap());
|
||||
let end_date = Some(NaiveDate::from_ymd_opt(2020, 1, 1).unwrap());
|
||||
|
||||
let contacts_to_summarize = vec!["Domenique", "Zach", "Paul"]; // Add more contacts as needed
|
||||
|
||||
let ollama = app_state.ollama.clone();
|
||||
let sms_client = app_state.sms_client.clone();
|
||||
|
||||
for contact in contacts_to_summarize {
|
||||
let ollama_clone = ollama.clone();
|
||||
let sms_client_clone = sms_client.clone();
|
||||
let summary_dao: Arc<Mutex<Box<dyn DailySummaryDao>>> =
|
||||
Arc::new(Mutex::new(Box::new(SqliteDailySummaryDao::new())));
|
||||
|
||||
let start = start_date;
|
||||
let end = end_date;
|
||||
|
||||
tokio::spawn(async move {
|
||||
log::info!("Starting daily summary generation for {}", contact);
|
||||
if let Err(e) = generate_daily_summaries(
|
||||
contact,
|
||||
start,
|
||||
end,
|
||||
&ollama_clone,
|
||||
&sms_client_clone,
|
||||
summary_dao
|
||||
).await {
|
||||
log::error!("Daily summary generation failed for {}: {:?}", contact, e);
|
||||
} else {
|
||||
log::info!("Daily summary generation completed for {}", contact);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
HttpServer::new(move || {
|
||||
let user_dao = SqliteUserDao::new();
|
||||
let favorites_dao = SqliteFavoriteDao::new();
|
||||
|
||||
Reference in New Issue
Block a user