Pass raw health metrics to AI instead of hardcoded correlations
- Replace HealthService.analyzeCorrelations() with computeHealthAverages() - Remove hardcoded threshold-based correlation analysis (8k steps, 7hrs sleep, etc.) - Pass raw averages (steps, exercise, sleep, HRV, HR, mindfulness, calories) to AI - Let Apple Intelligence find nuanced multi-variable patterns naturally - Update MoodDataSummarizer to format raw health data for AI prompts - Simplifies code by ~200 lines while improving insight quality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -185,13 +185,13 @@ class FoundationModelsInsightService: ObservableObject {
|
||||
/// - entries: Array of mood entries to analyze
|
||||
/// - periodName: The time period name (e.g., "this month", "this year", "all time")
|
||||
/// - count: Number of insights to generate (default 5)
|
||||
/// - healthCorrelations: Optional health data correlations to include
|
||||
/// - healthAverages: Optional raw health data for AI to analyze correlations
|
||||
/// - Returns: Array of Insight objects
|
||||
func generateInsights(
|
||||
for entries: [MoodEntryModel],
|
||||
periodName: String,
|
||||
count: Int = 5,
|
||||
healthCorrelations: [HealthCorrelation] = []
|
||||
healthAverages: HealthService.HealthAverages? = nil
|
||||
) async throws -> [Insight] {
|
||||
// Check cache first
|
||||
if let cached = cachedInsights[periodName],
|
||||
@@ -216,8 +216,8 @@ class FoundationModelsInsightService: ObservableObject {
|
||||
isGenerating = true
|
||||
defer { isGenerating = false }
|
||||
|
||||
// Prepare data summary with health correlations
|
||||
let summary = summarizer.summarize(entries: validEntries, periodName: periodName, healthCorrelations: healthCorrelations)
|
||||
// Prepare data summary with health data for AI analysis
|
||||
let summary = summarizer.summarize(entries: validEntries, periodName: periodName, healthAverages: healthAverages)
|
||||
let prompt = buildPrompt(from: summary, count: count)
|
||||
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user