An advanced memory system for anime waifu characters that provides persistent memory, personality learning, and emotional state tracking for integration with chat and voice synthesis systems.
- π§ Persistent Memory: Long-term conversation history and context retention
- π€ Personality Learning: Adaptive personality traits based on user interactions
- π Emotional State Tracking: Maintains emotional context between sessions
- π Knowledge Base: Structured storage of facts, preferences, and relationships
- π Easy Integration: RESTful API for seamless integration with existing waifu systems
- π― Event Tracking: Remembers important moments and milestones
- π Smart Retrieval: Context-aware memory retrieval and relevance scoring
This project is backed by comprehensive research. Read our paper: Waifu Memory Engine: A Context-Aware Memory System for Conversational AI Characters
The Waifu Memory Engine presents a novel approach to persistent memory management in conversational AI systems, specifically designed for anime-style virtual characters (waifus). This system implements advanced memory storage, retrieval, and association mechanisms to enable AI characters to maintain coherent, long-term conversational context and develop consistent personalities through user interactions.
- π Research Paper - Complete technical paper on the memory engine architecture
- π API Documentation - Full API reference with examples
- π οΈ Technical Documentation - Detailed setup and usage guide
- π¬ Examples - Integration examples and demos
- Python 3.8+
- SQLite (included with Python)
# Clone and navigate to the project
cd waifu-memory-engine
# Create virtual environment
python -m venv .venv
.\.venv\Scripts\Activate.ps1 # Windows PowerShell
# Install dependencies
pip install -r requirements.txt
# Initialize the database
python -c "from memory_engine.database import init_db; init_db()"python app.pyThe API will be available at http://localhost:5002
POST /memory/store
Store a new memory entry.
{
"user_id": "user123",
"character": "sakura",
"content": "User mentioned they love cherry blossoms",
"memory_type": "preference",
"emotion": "happy",
"importance": 0.8
}GET /memory/retrieve
Retrieve relevant memories based on query.
{
"user_id": "user123",
"character": "sakura",
"query": "flowers",
"limit": 10
}POST /personality/update
Update character personality traits.
{
"user_id": "user123",
"character": "sakura",
"trait": "cheerfulness",
"value": 0.9
}POST /emotion/set
Update current emotional state.
{
"user_id": "user123",
"character": "sakura",
"emotion": "excited",
"intensity": 0.7,
"context": "discussing favorite anime"
}import requests
def get_memory_context(user_id, message):
# Retrieve relevant memories
response = requests.get('http://localhost:5002/memory/retrieve', json={
'user_id': user_id,
'character': 'sakura',
'query': message,
'limit': 5
})
memories = response.json().get('memories', [])
context = '\n'.join([mem['content'] for mem in memories])
# Store new conversation
requests.post('http://localhost:5002/memory/store', json={
'user_id': user_id,
'character': 'sakura',
'content': f"User said: {message}",
'memory_type': 'conversation',
'emotion': 'neutral',
'importance': 0.5
})
return contextdef get_emotional_voice_params(user_id, character):
response = requests.get(f'http://localhost:5002/emotion/current/{user_id}/{character}')
emotion_data = response.json()
# Map emotion to voice synthesis parameters
emotion_mapping = {
'happy': {'emotion': 'cheerful', 'pitch': '+10%'},
'sad': {'emotion': 'sad', 'pitch': '-5%'},
'excited': {'emotion': 'excited', 'rate': '+10%'}
}
return emotion_mapping.get(emotion_data.get('emotion'), {'emotion': 'neutral'})waifu-memory-engine/
βββ app.py # Flask API server
βββ memory_engine/
β βββ __init__.py
β βββ database.py # Database models and operations
β βββ memory_manager.py # Core memory management
β βββ personality.py # Personality trait system
β βββ emotion_tracker.py # Emotional state management
β βββ utils.py # Utility functions
βββ config/
β βββ config.py # Configuration settings
βββ tests/
β βββ test_memory.py
β βββ test_personality.py
β βββ test_emotions.py
βββ examples/
β βββ integration_demo.py # Integration examples
βββ requirements.txt # Dependencies
βββ .env.example # Environment template
βββ README.md # This documentation
- conversation: General chat history
- preference: User likes/dislikes
- fact: Concrete information about user
- event: Important moments/milestones
- relationship: Information about relationships
- personality: Character trait adjustments
The emotion system tracks:
- Current emotional state
- Emotional intensity (0.0 - 1.0)
- Emotional context and triggers
- Historical emotional patterns
flask>=2.3.3flask-cors>=4.0.0sqlite3(built-in)python-dotenv>=1.0.0datetimejsonuuid
Create a .env file:
FLASK_PORT=5002
FLASK_DEBUG=True
DATABASE_PATH=waifu_memory.db
MAX_MEMORIES_PER_QUERY=50
MEMORY_RETENTION_DAYS=365The memory engine can enhance your chat system by:
- Providing conversation context
- Remembering user preferences
- Maintaining personality consistency
- Tracking relationship progression
Enhance voice responses with:
- Emotion-appropriate voice parameters
- Context-aware tone adjustments
- Personality-driven speech patterns
MIT License - Perfect for your waifu ecosystem! πΈ
Built to complement the Waifu-AI-Labs ecosystem:
- waifu-chat-ollama
- waifu-voice-synthesis
Made with β€οΈ for the waifu community