superlocalmemory 3.4.17 → 3.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -3
  3. package/pyproject.toml +10 -1
  4. package/src/superlocalmemory/cli/setup_wizard.py +30 -0
  5. package/src/superlocalmemory.egg-info/PKG-INFO +4 -1
  6. package/src/superlocalmemory.egg-info/requires.txt +3 -0
  7. package/docs/ARCHITECTURE.md +0 -149
  8. package/docs/api-reference.md +0 -284
  9. package/docs/auto-memory.md +0 -150
  10. package/docs/cli-reference.md +0 -327
  11. package/docs/cloud-backup.md +0 -174
  12. package/docs/compliance.md +0 -191
  13. package/docs/configuration.md +0 -182
  14. package/docs/getting-started.md +0 -102
  15. package/docs/ide-setup.md +0 -261
  16. package/docs/mcp-tools.md +0 -220
  17. package/docs/migration-from-v2.md +0 -170
  18. package/docs/profiles.md +0 -173
  19. package/docs/screenshots/01-dashboard-main.png +0 -0
  20. package/docs/screenshots/02-knowledge-graph.png +0 -0
  21. package/docs/screenshots/03-math-health.png +0 -0
  22. package/docs/screenshots/03-patterns-learning.png +0 -0
  23. package/docs/screenshots/04-learning-dashboard.png +0 -0
  24. package/docs/screenshots/04-recall-lab.png +0 -0
  25. package/docs/screenshots/05-behavioral-analysis.png +0 -0
  26. package/docs/screenshots/05-trust-dashboard.png +0 -0
  27. package/docs/screenshots/06-graph-communities.png +0 -0
  28. package/docs/screenshots/06-settings.png +0 -0
  29. package/docs/screenshots/07-memories-blurred.png +0 -0
  30. package/docs/skill-evolution.md +0 -256
  31. package/docs/troubleshooting.md +0 -310
  32. package/docs/v2-archive/ACCESSIBILITY.md +0 -291
  33. package/docs/v2-archive/ARCHITECTURE.md +0 -886
  34. package/docs/v2-archive/CLI-COMMANDS-REFERENCE.md +0 -425
  35. package/docs/v2-archive/COMPRESSION-README.md +0 -390
  36. package/docs/v2-archive/FRAMEWORK-INTEGRATIONS.md +0 -300
  37. package/docs/v2-archive/MCP-MANUAL-SETUP.md +0 -775
  38. package/docs/v2-archive/MCP-TROUBLESHOOTING.md +0 -787
  39. package/docs/v2-archive/PATTERN-LEARNING.md +0 -228
  40. package/docs/v2-archive/PROFILES-GUIDE.md +0 -453
  41. package/docs/v2-archive/RESET-GUIDE.md +0 -353
  42. package/docs/v2-archive/SEARCH-ENGINE-V2.2.0.md +0 -749
  43. package/docs/v2-archive/SEARCH-INTEGRATION-GUIDE.md +0 -502
  44. package/docs/v2-archive/UI-SERVER.md +0 -262
  45. package/docs/v2-archive/UNIVERSAL-INTEGRATION.md +0 -488
  46. package/docs/v2-archive/V2.2.0-OPTIONAL-SEARCH.md +0 -666
  47. package/docs/v2-archive/WINDOWS-INSTALL-README.txt +0 -34
  48. package/docs/v2-archive/WINDOWS-POST-INSTALL.txt +0 -45
  49. package/docs/v2-archive/example_graph_usage.py +0 -146
  50. package/ui/index.html +0 -1879
  51. package/ui/js/agents.js +0 -192
  52. package/ui/js/auto-settings.js +0 -399
  53. package/ui/js/behavioral.js +0 -276
  54. package/ui/js/clusters.js +0 -206
  55. package/ui/js/compliance.js +0 -252
  56. package/ui/js/core.js +0 -246
  57. package/ui/js/dashboard.js +0 -110
  58. package/ui/js/events.js +0 -178
  59. package/ui/js/fact-detail.js +0 -92
  60. package/ui/js/feedback.js +0 -333
  61. package/ui/js/graph-core.js +0 -447
  62. package/ui/js/graph-filters.js +0 -220
  63. package/ui/js/graph-interactions.js +0 -351
  64. package/ui/js/graph-ui.js +0 -214
  65. package/ui/js/ide-status.js +0 -102
  66. package/ui/js/init.js +0 -45
  67. package/ui/js/learning.js +0 -435
  68. package/ui/js/lifecycle.js +0 -298
  69. package/ui/js/math-health.js +0 -98
  70. package/ui/js/memories.js +0 -264
  71. package/ui/js/modal.js +0 -357
  72. package/ui/js/patterns.js +0 -93
  73. package/ui/js/profiles.js +0 -236
  74. package/ui/js/recall-lab.js +0 -292
  75. package/ui/js/search.js +0 -59
  76. package/ui/js/settings.js +0 -224
  77. package/ui/js/timeline.js +0 -32
  78. package/ui/js/trust-dashboard.js +0 -73
@@ -1,390 +0,0 @@
1
- # Progressive Summarization Compression for SuperLocalMemory
2
-
3
- ## Overview
4
-
5
- The compression system implements tier-based progressive summarization to efficiently manage 100+ memories without performance degradation. It uses **extractive summarization** (no external LLM calls) to compress older memories while preserving essential information.
6
-
7
- ## Architecture
8
-
9
- ### Compression Tiers
10
-
11
- ```
12
- ┌─────────────────────────────────────────────────────────┐
13
- │ TIER 1: Recent (0-30 days) │
14
- │ Storage: Full content + summary │
15
- │ Size: ~50KB per memory │
16
- │ Access: Instant, no decompression needed │
17
- └─────────────────────────────────────────────────────────┘
18
-
19
- ┌─────────────────────────────────────────────────────────┐
20
- │ TIER 2: Active (30-90 days) │
21
- │ Storage: Summary + key excerpts │
22
- │ Size: ~10KB per memory (80% reduction) │
23
- │ Access: Fast, show summary with "expand" option │
24
- └─────────────────────────────────────────────────────────┘
25
-
26
- ┌─────────────────────────────────────────────────────────┐
27
- │ TIER 3: Archived (90+ days) │
28
- │ Storage: Bullet-point summary only │
29
- │ Size: ~2KB per memory (96% reduction) │
30
- │ Access: Show bullets, full content in cold storage │
31
- └─────────────────────────────────────────────────────────┘
32
-
33
- ┌─────────────────────────────────────────────────────────┐
34
- │ COLD STORAGE: Very Old (1+ year) │
35
- │ Storage: Compressed JSON file (gzip) │
36
- │ Size: ~1KB per memory (98% reduction) │
37
- │ Access: Manual restore from archive │
38
- └─────────────────────────────────────────────────────────┘
39
- ```
40
-
41
- ### Key Features
42
-
43
- 1. **No External APIs**: All compression is local using extractive summarization
44
- 2. **Preserves Important Memories**: High-importance (≥8) memories stay in Tier 1
45
- 3. **Access-Based Protection**: Recently accessed memories remain uncompressed
46
- 4. **Reversible**: Full content stored in archive table until moved to cold storage
47
- 5. **Automatic**: Daily cron job handles all compression tasks
48
- 6. **Safe**: Database backup before each compression run
49
-
50
- ## Implementation
51
-
52
- ### Core Classes
53
-
54
- #### 1. TierClassifier
55
- Classifies memories into tiers based on:
56
- - Age (days since creation)
57
- - Importance score
58
- - Last access time
59
- - Access count
60
-
61
- #### 2. Tier2Compressor
62
- Compresses to summary + key excerpts using:
63
- - Sentence scoring (tech terms, position, numbers)
64
- - Code block extraction
65
- - Bullet list extraction
66
- - Important paragraph detection
67
-
68
- #### 3. Tier3Compressor
69
- Ultra-compresses to 5 bullet points:
70
- - Converts summary to brief bullets
71
- - Each bullet max 80 characters
72
- - Preserves core information only
73
-
74
- #### 4. ColdStorageManager
75
- Archives very old memories:
76
- - Gzipped JSON format
77
- - Monthly archive files
78
- - Restoreable on demand
79
-
80
- #### 5. CompressionOrchestrator
81
- Main controller that runs full compression cycle:
82
- 1. Classify memories into tiers
83
- 2. Compress Tier 2 memories
84
- 3. Compress Tier 3 memories
85
- 4. Move candidates to cold storage
86
- 5. Calculate space savings
87
-
88
- ## Configuration
89
-
90
- Located in `~/.superlocalmemory/config.json`:
91
-
92
- ```json
93
- {
94
- "compression": {
95
- "enabled": true,
96
- "tier2_threshold_days": 30,
97
- "tier3_threshold_days": 90,
98
- "cold_storage_threshold_days": 365,
99
- "preserve_high_importance": true,
100
- "preserve_recently_accessed": true
101
- }
102
- }
103
- ```
104
-
105
- ### Configuration Options
106
-
107
- - `enabled`: Enable/disable compression system
108
- - `tier2_threshold_days`: Days before compressing to Tier 2 (default: 30)
109
- - `tier3_threshold_days`: Days before compressing to Tier 3 (default: 90)
110
- - `cold_storage_threshold_days`: Days before moving to cold storage (default: 365)
111
- - `preserve_high_importance`: Keep importance ≥8 in Tier 1 (default: true)
112
- - `preserve_recently_accessed`: Keep recently accessed in Tier 1 (default: true)
113
-
114
- ## Usage
115
-
116
- ### Command Line Interface
117
-
118
- ```bash
119
- # Initialize compression configuration
120
- ~/.superlocalmemory/memory-compress init-config
121
-
122
- # Classify memories into tiers
123
- ~/.superlocalmemory/memory-compress classify
124
-
125
- # Run full compression cycle
126
- ~/.superlocalmemory/memory-compress compress
127
-
128
- # Show compression statistics
129
- ~/.superlocalmemory/memory-compress stats
130
-
131
- # Compress specific memory to Tier 2
132
- ~/.superlocalmemory/memory-compress tier2 <id>
133
-
134
- # Compress specific memory to Tier 3
135
- ~/.superlocalmemory/memory-compress tier3 <id>
136
-
137
- # Move old memories to cold storage
138
- ~/.superlocalmemory/memory-compress cold-storage
139
-
140
- # Restore memory from cold storage
141
- ~/.superlocalmemory/memory-compress restore <id>
142
- ```
143
-
144
- ### Python API
145
-
146
- ```python
147
- from memory_compression import CompressionOrchestrator
148
-
149
- # Run full compression
150
- orchestrator = CompressionOrchestrator()
151
- stats = orchestrator.run_full_compression()
152
-
153
- print(f"Compressed {stats['tier2_compressed']} to Tier 2")
154
- print(f"Compressed {stats['tier3_compressed']} to Tier 3")
155
- print(f"Space savings: {stats['space_savings']['savings_percent']}%")
156
- ```
157
-
158
- ## Automated Compression
159
-
160
- ### Daily Cron Job
161
-
162
- The system includes a daily cron job script at:
163
- ```
164
- ~/.superlocalmemory/jobs/compress-memories.sh
165
- ```
166
-
167
- #### Setup Cron Job
168
-
169
- 1. Open crontab editor:
170
- ```bash
171
- crontab -e
172
- ```
173
-
174
- 2. Add this line (runs daily at 3 AM):
175
- ```
176
- 0 3 * * * ~/.superlocalmemory/jobs/compress-memories.sh >> ~/.superlocalmemory/logs/compression.log 2>&1
177
- ```
178
-
179
- 3. Save and exit
180
-
181
- #### What the Daily Job Does
182
-
183
- 1. Creates database backup
184
- 2. Classifies memories into tiers
185
- 3. Compresses Tier 2 memories
186
- 4. Compresses Tier 3 memories
187
- 5. Moves old memories to cold storage
188
- 6. Logs results to `~/.superlocalmemory/logs/compression.log`
189
- 7. Cleans up backups older than 7 days
190
-
191
- ## Database Schema
192
-
193
- ### New Columns in `memories` Table
194
-
195
- ```sql
196
- tier INTEGER DEFAULT 1 -- Compression tier (1, 2, or 3)
197
- last_accessed TIMESTAMP -- Last access time
198
- access_count INTEGER DEFAULT 0 -- Number of accesses
199
- ```
200
-
201
- ### New `memory_archive` Table
202
-
203
- ```sql
204
- CREATE TABLE memory_archive (
205
- id INTEGER PRIMARY KEY AUTOINCREMENT,
206
- memory_id INTEGER UNIQUE NOT NULL,
207
- full_content TEXT NOT NULL,
208
- archived_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
209
- FOREIGN KEY (memory_id) REFERENCES memories(id) ON DELETE CASCADE
210
- );
211
- ```
212
-
213
- ## Extractive Summarization Algorithm
214
-
215
- ### Sentence Scoring Heuristics
216
-
217
- Each sentence is scored based on:
218
-
219
- 1. **Tech Terms** (+1 per term): api, database, auth, component, function, class, method, variable, error, bug, fix, implement, refactor, test, deploy
220
-
221
- 2. **Position Boost** (+2): First or last sentence (thesis/conclusion)
222
-
223
- 3. **Numbers/Specifics** (+1): Contains digits (measurements, versions, dates)
224
-
225
- 4. **Important Keywords** (+2 per keyword): important, critical, note, remember, key, main, primary, must, should
226
-
227
- Top-scored sentences are selected until max_length is reached.
228
-
229
- ### Excerpt Extraction
230
-
231
- Priority order:
232
- 1. Code blocks (markdown or indented) - max 2
233
- 2. Bullet lists - max 1
234
- 3. Paragraphs with important keywords - remaining slots
235
-
236
- ## Performance Impact
237
-
238
- ### Before Compression (100 memories @ 50KB each)
239
- - Database size: 5MB
240
- - Search time: 150ms (scan all content)
241
- - Memory load: 5MB into RAM
242
-
243
- ### After Compression (100 memories, tiered)
244
- - Tier 1 (30 memories @ 50KB): 1.5MB
245
- - Tier 2 (40 memories @ 10KB): 400KB
246
- - Tier 3 (30 memories @ 2KB): 60KB
247
- - **Total: 1.96MB (61% reduction)**
248
- - **Search time: Sub-11ms median for typical databases** (only scan Tier 1+2, see wiki Performance Benchmarks)
249
- - **Memory load: 1.9MB** (Tier 3 loaded on-demand)
250
-
251
- ### Space Savings Scale
252
- - 500 memories: ~10MB → ~4MB (60% reduction)
253
- - 1000 memories: ~50MB → ~15MB (70% reduction)
254
-
255
- ## Safety & Rollback
256
-
257
- ### Data Preservation
258
-
259
- 1. **Archive Table**: Full content preserved until moved to cold storage
260
- 2. **Cold Storage**: Gzipped JSON archives (restorable)
261
- 3. **Daily Backups**: Database backup before each compression run
262
- 4. **7-Day Retention**: Last 7 backups kept automatically
263
-
264
- ### Restore Operations
265
-
266
- #### Restore from Archive (Tier 2/3 → Tier 1)
267
- ```python
268
- from memory_compression import ColdStorageManager
269
-
270
- cold_storage = ColdStorageManager()
271
- content = cold_storage.restore_from_cold_storage(memory_id)
272
- ```
273
-
274
- #### Manual Restore from Backup
275
- ```bash
276
- # List backups
277
- ls ~/.superlocalmemory/backups/
278
-
279
- # Restore from backup
280
- cp ~/.superlocalmemory/backups/memory-20260205.db ~/.superlocalmemory/memory.db
281
- ```
282
-
283
- ## Monitoring
284
-
285
- ### Check Compression Stats
286
- ```bash
287
- ~/.superlocalmemory/memory-compress stats
288
- ```
289
-
290
- ### View Compression Logs
291
- ```bash
292
- tail -f ~/.superlocalmemory/logs/compression.log
293
- ```
294
-
295
- ### Check Cron Job Status
296
- ```bash
297
- # View cron jobs
298
- crontab -l
299
-
300
- # Check last run
301
- ls -lt ~/.superlocalmemory/logs/compression.log
302
- ```
303
-
304
- ## Troubleshooting
305
-
306
- ### Compression Not Running
307
-
308
- 1. Check if enabled in config:
309
- ```bash
310
- cat ~/.superlocalmemory/config.json | grep -A 6 compression
311
- ```
312
-
313
- 2. Check cron job is set:
314
- ```bash
315
- crontab -l | grep compress
316
- ```
317
-
318
- 3. Check logs for errors:
319
- ```bash
320
- tail -50 ~/.superlocalmemory/logs/compression.log
321
- ```
322
-
323
- ### Memory Not Being Compressed
324
-
325
- Check tier classification:
326
- ```bash
327
- sqlite3 ~/.superlocalmemory/memory.db "SELECT id, tier, importance, created_at FROM memories WHERE id = <id>;"
328
- ```
329
-
330
- Possible reasons:
331
- - Memory is too recent (< 30 days)
332
- - High importance (≥8) - stays in Tier 1
333
- - Recently accessed (< 7 days) - stays in Tier 1
334
-
335
- ### Restore Failed
336
-
337
- 1. Check if in archive table:
338
- ```bash
339
- sqlite3 ~/.superlocalmemory/memory.db "SELECT memory_id FROM memory_archive WHERE memory_id = <id>;"
340
- ```
341
-
342
- 2. Check cold storage:
343
- ```bash
344
- ls ~/.superlocalmemory/cold-storage/
345
- zgrep '"id": <id>' ~/.superlocalmemory/cold-storage/archive-*.json.gz
346
- ```
347
-
348
- ## Files
349
-
350
- ### Main Files
351
- - `memory_compression.py` - Main compression implementation
352
- - `memory-compress` - CLI wrapper script
353
- - `jobs/compress-memories.sh` - Daily cron job script
354
- - `COMPRESSION-README.md` - This file
355
-
356
- ### Generated Files
357
- - `cold-storage/archive-YYYY-MM.json.gz` - Monthly archive files
358
- - `logs/compression.log` - Compression job logs
359
- - `backups/memory-YYYYMMDD.db` - Daily database backups
360
-
361
- ## Integration with memory_store.py
362
-
363
- The compression system works alongside the existing memory system:
364
-
365
- 1. **Add Memory**: New memories created with `tier=1` by default
366
- 2. **Search**: Searches work across all tiers (compressed content is JSON)
367
- 3. **Access Tracking**: Can update `last_accessed` when retrieving memories
368
- 4. **Display**: UI can check tier and format display accordingly:
369
- - Tier 1: Show full content
370
- - Tier 2: Show summary + excerpts with "expand" button
371
- - Tier 3: Show bullets with "restore" button
372
-
373
- ## Future Enhancements
374
-
375
- 1. **Access Tracking Integration**: Update `last_accessed` in memory_store.py
376
- 2. **UI Indicators**: Show compression tier in memory list
377
- 3. **Manual Override**: CLI command to change tier manually
378
- 4. **Compression Preview**: Show what will be compressed before running
379
- 5. **Selective Compression**: Compress by project or tag
380
- 6. **Adaptive Thresholds**: Adjust thresholds based on storage constraints
381
-
382
- ## References
383
-
384
- - [Progressive Summarization](https://fortelabs.co/blog/progressive-summarization-a-practical-technique-for-designing-discoverable-notes/) by Tiago Forte
385
- - [PageIndex](https://pageindex.ai/) - Vectorless hierarchical RAG
386
- - [GraphRAG](https://microsoft.github.io/graphrag/) - Knowledge graph clustering
387
-
388
- ---
389
-
390
- **Compression system ready. Run daily job to maintain optimal memory performance.**
@@ -1,300 +0,0 @@
1
- # Framework Integrations
2
-
3
- SuperLocalMemory V2 integrates with popular AI frameworks as a memory backend — 100% local, zero cloud dependencies.
4
-
5
- ---
6
-
7
- ## LangChain Integration
8
-
9
- Use SuperLocalMemory as a chat message history store in LangChain applications.
10
-
11
- ### Installation
12
-
13
- ```bash
14
- pip install langchain-superlocalmemory
15
- ```
16
-
17
- ### Basic Usage
18
-
19
- ```python
20
- from langchain_superlocalmemory import SuperLocalMemoryChatMessageHistory
21
- from langchain_core.runnables.history import RunnableWithMessageHistory
22
- from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
23
- from langchain_openai import ChatOpenAI
24
-
25
- # Create chat history with session-based memory
26
- history = SuperLocalMemoryChatMessageHistory(session_id="my-session")
27
-
28
- # Build a conversational chain
29
- prompt = ChatPromptTemplate.from_messages([
30
- ("system", "You are a helpful assistant."),
31
- MessagesPlaceholder(variable_name="history"),
32
- ("human", "{input}"),
33
- ])
34
-
35
- chain = prompt | ChatOpenAI()
36
-
37
- # Wrap with message history
38
- chain_with_history = RunnableWithMessageHistory(
39
- chain,
40
- lambda session_id: SuperLocalMemoryChatMessageHistory(session_id=session_id),
41
- input_messages_key="input",
42
- history_messages_key="history",
43
- )
44
-
45
- # Use the chain
46
- response = chain_with_history.invoke(
47
- {"input": "What is AI?"},
48
- config={"configurable": {"session_id": "my-session"}}
49
- )
50
- ```
51
-
52
- ### Advanced Features
53
-
54
- **Session Isolation:**
55
- ```python
56
- # Different sessions have isolated message histories
57
- history_user1 = SuperLocalMemoryChatMessageHistory(session_id="user-1")
58
- history_user2 = SuperLocalMemoryChatMessageHistory(session_id="user-2")
59
- ```
60
-
61
- **Profile Support:**
62
- ```python
63
- # Use different memory profiles for different contexts
64
- history_work = SuperLocalMemoryChatMessageHistory(
65
- session_id="work-chat",
66
- profile="work"
67
- )
68
- history_personal = SuperLocalMemoryChatMessageHistory(
69
- session_id="personal-chat",
70
- profile="personal"
71
- )
72
- ```
73
-
74
- **Message Filtering:**
75
- ```python
76
- # Retrieve messages with limits
77
- recent_messages = history.get_messages(limit=10)
78
-
79
- # Clear session history
80
- history.clear()
81
- ```
82
-
83
- ### Storage Details
84
-
85
- - Messages persist in `~/.superlocalmemory/memory.db`
86
- - Each message stored as a memory with tags: `langchain`, `chat`, `session:<session_id>`
87
- - Supports all LangChain message types (HumanMessage, AIMessage, SystemMessage)
88
- - Automatic timestamp and metadata tracking
89
-
90
- ---
91
-
92
- ## LlamaIndex Integration
93
-
94
- Use SuperLocalMemory as a chat store for LlamaIndex's memory system.
95
-
96
- ### Installation
97
-
98
- ```bash
99
- pip install llama-index-storage-chat-store-superlocalmemory
100
- ```
101
-
102
- ### Basic Usage
103
-
104
- ```python
105
- from llama_index.storage.chat_store.superlocalmemory import SuperLocalMemoryChatStore
106
- from llama_index.core.memory import ChatMemoryBuffer
107
- from llama_index.core.chat_engine import SimpleChatEngine
108
- from llama_index.llms.openai import OpenAI
109
-
110
- # Create chat store
111
- chat_store = SuperLocalMemoryChatStore()
112
-
113
- # Create memory with chat store
114
- memory = ChatMemoryBuffer.from_defaults(
115
- chat_store=chat_store,
116
- chat_store_key="user-1"
117
- )
118
-
119
- # Use with a chat engine
120
- llm = OpenAI(model="gpt-4")
121
- chat_engine = SimpleChatEngine.from_defaults(
122
- llm=llm,
123
- memory=memory
124
- )
125
-
126
- # Chat
127
- response = chat_engine.chat("What is machine learning?")
128
- print(response)
129
- ```
130
-
131
- ### Advanced Features
132
-
133
- **Multiple Users:**
134
- ```python
135
- # Separate memory for each user
136
- memory_user1 = ChatMemoryBuffer.from_defaults(
137
- chat_store=chat_store,
138
- chat_store_key="user-1"
139
- )
140
- memory_user2 = ChatMemoryBuffer.from_defaults(
141
- chat_store=chat_store,
142
- chat_store_key="user-2"
143
- )
144
- ```
145
-
146
- **Profile Support:**
147
- ```python
148
- # Use different profiles for different contexts
149
- chat_store_work = SuperLocalMemoryChatStore(profile="work")
150
- chat_store_personal = SuperLocalMemoryChatStore(profile="personal")
151
-
152
- memory_work = ChatMemoryBuffer.from_defaults(
153
- chat_store=chat_store_work,
154
- chat_store_key="project-x"
155
- )
156
- ```
157
-
158
- **Message Management:**
159
- ```python
160
- # Get messages for a specific chat
161
- messages = chat_store.get_messages("user-1")
162
-
163
- # Set messages
164
- from llama_index.core.base.llms.types import ChatMessage
165
- chat_store.set_messages(
166
- "user-1",
167
- [ChatMessage(role="user", content="Hello")]
168
- )
169
-
170
- # Delete messages
171
- chat_store.delete_messages("user-1")
172
-
173
- # List all chat keys
174
- all_chats = chat_store.get_keys()
175
- ```
176
-
177
- ### Storage Details
178
-
179
- - Messages persist in `~/.superlocalmemory/memory.db`
180
- - Each message stored as a memory with tags: `llamaindex`, `chat`, `key:<chat_store_key>`
181
- - Supports all LlamaIndex ChatMessage roles (user, assistant, system)
182
- - Automatic timestamp tracking
183
- - Full profile isolation support
184
-
185
- ---
186
-
187
- ## Why Use SuperLocalMemory with Frameworks?
188
-
189
- | Benefit | Description |
190
- |---------|-------------|
191
- | **100% Local** | No cloud dependencies, all data stays on your machine |
192
- | **Zero Configuration** | Works with default settings, no API keys needed |
193
- | **Cross-Framework** | Same local database used by all frameworks and tools |
194
- | **Profile Isolation** | Separate memories for work, personal, clients |
195
- | **Persistent** | Memories survive across sessions and reboots |
196
- | **Free Forever** | No usage limits, no subscriptions |
197
-
198
- ---
199
-
200
- ## Common Patterns
201
-
202
- ### Multi-Context Applications
203
-
204
- ```python
205
- # LangChain for customer support
206
- support_history = SuperLocalMemoryChatMessageHistory(
207
- session_id="customer-123",
208
- profile="customer-support"
209
- )
210
-
211
- # LlamaIndex for internal documentation
212
- docs_store = SuperLocalMemoryChatStore(profile="internal-docs")
213
- docs_memory = ChatMemoryBuffer.from_defaults(
214
- chat_store=docs_store,
215
- chat_store_key="team-wiki"
216
- )
217
- ```
218
-
219
- ### Session Management
220
-
221
- ```python
222
- # Create sessions with metadata
223
- from langchain_core.messages import HumanMessage, AIMessage
224
-
225
- history = SuperLocalMemoryChatMessageHistory(session_id="session-123")
226
- history.add_user_message("What is Python?")
227
- history.add_ai_message("Python is a high-level programming language...")
228
-
229
- # Later, retrieve full conversation
230
- messages = history.get_messages()
231
- ```
232
-
233
- ### Memory Cleanup
234
-
235
- ```python
236
- # LangChain: Clear specific session
237
- history.clear()
238
-
239
- # LlamaIndex: Delete specific chat
240
- chat_store.delete_messages("user-1")
241
-
242
- # CLI: Reset entire profile
243
- # superlocalmemoryv2-reset soft --profile customer-support
244
- ```
245
-
246
- ---
247
-
248
- ## Troubleshooting
249
-
250
- ### Import Errors
251
-
252
- If you get import errors, ensure packages are installed:
253
-
254
- ```bash
255
- # For LangChain
256
- pip install langchain-superlocalmemory langchain-core
257
-
258
- # For LlamaIndex
259
- pip install llama-index-storage-chat-store-superlocalmemory llama-index-core
260
- ```
261
-
262
- ### Database Locked
263
-
264
- If you see "database is locked" errors:
265
-
266
- ```bash
267
- # Check if SuperLocalMemory is running correctly
268
- superlocalmemoryv2-status
269
-
270
- # Restart any MCP servers
271
- # (Close and reopen Cursor/Windsurf)
272
- ```
273
-
274
- ### Profile Not Found
275
-
276
- If a profile doesn't exist:
277
-
278
- ```bash
279
- # List available profiles
280
- superlocalmemoryv2-profile list
281
-
282
- # Create the profile
283
- superlocalmemoryv2-profile create work
284
- ```
285
-
286
- ---
287
-
288
- ## Learn More
289
-
290
- - **[LangChain Wiki Guide](https://github.com/qualixar/superlocalmemory/wiki/LangChain-Integration)** — Full integration tutorial
291
- - **[LlamaIndex Wiki Guide](https://github.com/qualixar/superlocalmemory/wiki/LlamaIndex-Integration)** — Complete setup guide
292
- - **[API Reference](API-REFERENCE.md)** — Python API documentation
293
- - **[Profiles Guide](PROFILES-GUIDE.md)** — Multi-context management
294
-
295
- ---
296
-
297
- <p align="center">
298
- <strong>Built by <a href="https://github.com/varun369">Varun Pratap Bhardwaj</a></strong><br/>
299
- AGPL-3.0 • <a href="https://superlocalmemory.com">superlocalmemory.com</a>
300
- </p>