()
| 7 | from openmemory import OpenMemory |
| 8 | |
| 9 | def sector_example(): |
| 10 | print('🧠 OpenMemory Python SDK - Brain Sectors') |
| 11 | print('=========================================') |
| 12 | |
| 13 | mem = OpenMemory( |
| 14 | path='./data/sectors-demo.sqlite', |
| 15 | tier='smart', |
| 16 | embeddings={'provider': 'synthetic'} |
| 17 | ) |
| 18 | |
| 19 | print('✅ OpenMemory initialized\n') |
| 20 | |
| 21 | # Demonstrate each sector |
| 22 | print('📝 Adding memories to different sectors...\n') |
| 23 | |
| 24 | # 1. Episodic (Events & Experiences) |
| 25 | print('1️⃣ EPISODIC SECTOR (Events & Experiences)') |
| 26 | mem.add("Last Tuesday I attended a conference on AI safety in San Francisco", |
| 27 | tags=["event", "conference", "ai"], |
| 28 | metadata={"date": "2024-01-15", "location": "San Francisco"}) |
| 29 | mem.add("I remember the first time I wrote a recursive function - it was confusing but exciting") |
| 30 | print(' ✅ Time-bound experiences stored\n') |
| 31 | |
| 32 | # 2. Semantic (Facts & Knowledge) |
| 33 | print('2️⃣ SEMANTIC SECTOR (Facts & Knowledge)') |
| 34 | mem.add("Python is an interpreted, high-level programming language known for readability", |
| 35 | tags=["programming", "python", "facts"]) |
| 36 | mem.add("The mitochondria is the powerhouse of the cell", |
| 37 | tags=["biology", "facts"]) |
| 38 | print(' ✅ Timeless facts stored\n') |
| 39 | |
| 40 | # 3. Procedural (Skills & How-to) |
| 41 | print('3️⃣ PROCEDURAL SECTOR (Skills & How-to)') |
| 42 | mem.add("To deploy to production: 1) Run tests, 2) Build Docker image, 3) Push to registry, 4) Update k8s manifests", |
| 43 | tags=["devops", "procedure"]) |
| 44 | mem.add("When debugging, always check: logs, network tab, console errors, and stack traces", |
| 45 | tags=["debugging", "procedure"]) |
| 46 | print(' ✅ Procedures stored\n') |
| 47 | |
| 48 | # 4. Emotional (Feelings & Sentiment) |
| 49 | print('4️⃣ EMOTIONAL SECTOR (Feelings & Sentiment)') |
| 50 | mem.add("I'm extremely proud of finishing that complex algorithm! 🎉", |
| 51 | tags=["emotion", "achievement"]) |
| 52 | mem.add("Feeling a bit anxious about the upcoming presentation tomorrow", |
| 53 | tags=["emotion", "anxiety"]) |
| 54 | print(' ✅ Emotional states stored\n') |
| 55 | |
| 56 | # 5. Reflective (Meta-cognition & Insights) |
| 57 | print('5️⃣ REFLECTIVE SECTOR (Meta-cognition & Insights)') |
| 58 | mem.add("I notice I learn best when I can practice concepts immediately after learning them", |
| 59 | tags=["reflection", "learning"]) |
| 60 | mem.add("Looking back, I realize my coding style has evolved to prioritize readability over cleverness", |
| 61 | tags=["reflection", "growth"]) |
| 62 | print(' ✅ Reflections stored\n') |
| 63 | |
| 64 | # Query across sectors |
| 65 | print('🔍 Querying across sectors...') |
| 66 | results = mem.query("learning and programming") |
no test coverage detected