Context Management
Understanding how Zonia maintains conversation context
How Context Works
Context management allows Zonia to maintain a coherent conversation by remembering previous messages and understanding their relevance to new queries.
Short-term Memory
- • Remembers current conversation flow
- • Maintains topic relevance
- • Tracks recent references
Long-term Memory
- • Stores user preferences
- • Remembers common patterns
- • Maintains user history
Example Conversations
Basic Context Maintenance
User: "Tell me about React"
Zonia: "React is a JavaScript library for building user interfaces..."
User: "What are its main features?"
Zonia: "The main features of React include: Virtual DOM, Component-based architecture..."
Note: Zonia understands "its" refers to React from the previous message
Complex Context Handling
User: "I want to build an e-commerce site"
Zonia: "Great! Let's plan your e-commerce site. What features do you need?"
User: "It should have a shopping cart and user accounts"
Zonia: "For an e-commerce site with shopping cart and user accounts, here's a suggested tech stack..."
Note: Zonia maintains the e-commerce context and builds upon previous requirements
Context Management API
// Initialize a conversation with context const chat = zonia.createChat({ context: { topic: 'web development', expertise: 'beginner' } }); // Send messages with context const response = await chat.send({ message: 'How do I start?', context: { previousTopics: ['HTML', 'CSS'], preferredLanguage: 'JavaScript' } }); // Update context during conversation chat.updateContext({ currentTopic: 'React basics', codeExamples: true }); // Clear specific context chat.clearContext(['previousTopics']); // Reset all context chat.resetContext();
Best Practices
Recommended
- ✓ Keep conversations focused on one topic
- ✓ Use clear references to previous points
- ✓ Provide context when switching topics
Avoid
- ✗ Mixing multiple unrelated topics
- ✗ Making unclear references
- ✗ Assuming context is always maintained