diff --git a/src/ai/insight_generator.rs b/src/ai/insight_generator.rs index db3fb20..2e2da33 100644 --- a/src/ai/insight_generator.rs +++ b/src/ai/insight_generator.rs @@ -1749,8 +1749,8 @@ Return ONLY the summary, nothing else."#, .iter() .enumerate() .map(|(i, c)| { - let trimmed = if c.len() > 1000 { - format!("{}…", &c[..1000]) + let trimmed = if c.chars().count() > 1000 { + format!("{}…", c.chars().take(1000).collect::()) } else { c.clone() }; @@ -3406,8 +3406,8 @@ Return ONLY the summary, nothing else."#, obj.iter() .map(|(k, v)| { let rendered = match v { - serde_json::Value::String(s) if s.len() > 40 => { - format!("\"{}...\"", &s[..40]) + serde_json::Value::String(s) if s.chars().count() > 40 => { + format!("\"{}...\"", s.chars().take(40).collect::()) } _ => v.to_string(), }; @@ -4088,10 +4088,11 @@ Return ONLY the summary, nothing else."#, let title = title_raw.trim().trim_matches('"').to_string(); log::info!("Agentic generated title: {}", title); + let summary_preview: String = final_content.chars().take(200).collect(); log::info!( "Agentic generated summary ({} chars): {}", final_content.len(), - &final_content[..final_content.len().min(200)] + summary_preview ); // 14. Serialize the full message history for training data @@ -4671,7 +4672,7 @@ mod tests { assert!( out.starts_with("You are a journal writer in first person, warm and reflective."), "custom prompt must lead the system content; got: {}", - &out[..out.len().min(200)], + out.chars().take(200).collect::(), ); assert!( !out.contains("personal photo memory assistant"),