06: Temporal Memory Consolidation¶
Overview¶
Turn a stream of fragmented events into a single "Daily Summary" record using Composite Keys. Demonstrates time-slicing aggregation where events throughout a day are consolidated into one coherent record with LLM-synthesized summaries.
Theme¶
Time-Series Data Aggregation
Strategy¶
Time-Slicing with LLM.BALANCED merge
Key Features¶
- â Daily aggregation of fragmented events
- â Temporal bucketing using composite keys
- â Time-aware consolidation
- â LLM-synthesized daily summaries
- â Trend analysis across time
Data Structure¶
DailyTrace¶
user: str # User identifier
date: str # Date (YYYY-MM-DD)
actions: list[str] # Accumulated actions
summary: str # LLM-synthesized summary
mood: str | None # Inferred mood/sentiment
key_events: list[str] # Important events
productivity: str | None # Productivity assessment
notes: list[str] # Additional notes
Use Case¶
Analytics & Logging: Consolidate streaming logs, user events, or telemetry into daily summaries. Useful for dashboards, analytics, and trend analysis across time periods.
Benefits: - Reduced data volume (1 summary per day instead of 1000s of events) - Better pattern recognition over time - Efficient storage and retrieval - Time-aware insights
Running the Example¶
cd examples/
# Set your OpenAI API key for LLM synthesis (optional)
export OPENAI_API_KEY="your-key-here"
python 06_temporal_memory_consolidation.py
Output¶
Results are stored in temp/temporal_memory/:
- memory.json: Daily summary records
- metadata.json: Schema and statistics
- faiss_index/: Vector index for temporal search
API Requirements đ Optional¶
This example works better with an OpenAI API key for LLM-powered synthesis, but can work without it for basic consolidation.
What You'll Learn¶
- Composite Keys: Using composite keys for time-aware grouping
- Time-Slicing: Aggregating events into time buckets
- LLM Synthesis: Generating summaries of events
- Temporal Patterns: Discovering patterns across time
- Stream Processing: Handling continuous event streams
Complexity¶
âââ Intermediate: Shows advanced time-aware consolidation patterns.
Real-World Applications¶
- Daily Activity Summaries: Convert 1000s of user actions into daily digests
- System Monitoring: Aggregate logs into daily health reports
- Analytics: Convert event streams into analyzable daily metrics
- Trend Analysis: Identify patterns across days/weeks/months
Related Concepts¶
Next Steps¶
- Explore Advanced Usage for more patterns
- Learn about Persistence
- Check out API Reference