Skip to content

05: Conversation History

Overview

Shows how AI maintains and evolves its understanding of a user through multi-turn conversation. Each turn adds or refines knowledge, demonstrating incremental memory building in dialogue systems.

Theme

Conversational Memory Evolution

Strategy

MERGE_FIELD with incremental fact accumulation

Key Features

  • ✅ Turn-by-turn memory updates
  • ✅ Incremental fact accumulation
  • ✅ Automatic context maintenance
  • ✅ Memory-aware response generation
  • ✅ User preference tracking

Data Structure

ConversationMemory

session_id: str                    # Conversation session ID
user_name: str | None              # User's name
known_topics: list[str]            # Discussed topics
user_preferences: list[str]        # Stated preferences
user_interests: list[str]          # Inferred interests
communication_style: str | None    # Preferred style
problem_history: list[str]         # Previous issues
solutions_applied: list[str]       # What's been tried
session_count: int                 # Number of sessions
last_interaction: str | None       # Last update time

Use Case

Conversational AI & Chatbots: Build chatbots and dialogue systems that remember user preferences, track conversation history, and improve responses over time through accumulated knowledge.

Benefits: - Personalized responses based on history - Reduced need to re-explain context - Progressive trust building - Improved user experience

Running the Example

cd examples/
python 05_conversation_history.py

Output

Results are stored in temp/conversation_memory/: - memory.json: Conversation memory records - metadata.json: Schema and statistics

No API Required ✅

This example works without any external API keys or dependencies beyond the core OntoMem package.

What You'll Learn

  1. Multi-Turn Updates: Updating memory across conversation turns
  2. Incremental Accumulation: Building profiles gradually through dialogue
  3. Context Maintenance: Keeping track of conversation context
  4. Preference Tracking: Recording user preferences and interests
  5. Dialogue Integration: Integrating OntoMem with chat systems

Complexity

⭐⭐⭐ Intermediate: Shows practical dialogue system integration patterns.

Next Examples