mem-llm 1.3.0__tar.gz → 1.3.2__tar.gz

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.

Potentially problematic release.


This version of mem-llm might be problematic. Click here for more details.

Files changed (53) hide show
  1. {mem_llm-1.3.0 → mem_llm-1.3.2}/CHANGELOG.md +69 -0
  2. {mem_llm-1.3.0/mem_llm.egg-info → mem_llm-1.3.2}/PKG-INFO +109 -34
  3. {mem_llm-1.3.0 → mem_llm-1.3.2}/README.md +108 -33
  4. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/__init__.py +9 -2
  5. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/config_manager.py +3 -1
  6. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/mem_agent.py +400 -16
  7. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/memory_db.py +186 -4
  8. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/memory_manager.py +10 -1
  9. mem_llm-1.3.2/mem_llm/response_metrics.py +221 -0
  10. mem_llm-1.3.2/mem_llm/vector_store.py +278 -0
  11. {mem_llm-1.3.0 → mem_llm-1.3.2/mem_llm.egg-info}/PKG-INFO +109 -34
  12. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm.egg-info/SOURCES.txt +2 -0
  13. {mem_llm-1.3.0 → mem_llm-1.3.2}/pyproject.toml +1 -1
  14. {mem_llm-1.3.0 → mem_llm-1.3.2}/requirements-optional.txt +4 -0
  15. {mem_llm-1.3.0 → mem_llm-1.3.2}/MANIFEST.in +0 -0
  16. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/base_llm_client.py +0 -0
  17. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/cli.py +0 -0
  18. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/clients/__init__.py +0 -0
  19. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/clients/gemini_client.py +0 -0
  20. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/clients/lmstudio_client.py +0 -0
  21. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/clients/ollama_client.py +0 -0
  22. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/config.yaml.example +0 -0
  23. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/config_from_docs.py +0 -0
  24. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/conversation_summarizer.py +0 -0
  25. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/data_export_import.py +0 -0
  26. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/dynamic_prompt.py +0 -0
  27. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/knowledge_loader.py +0 -0
  28. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/llm_client.py +0 -0
  29. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/llm_client_factory.py +0 -0
  30. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/logger.py +0 -0
  31. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/memory_tools.py +0 -0
  32. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/prompt_security.py +0 -0
  33. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/retry_handler.py +0 -0
  34. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm/thread_safe_db.py +0 -0
  35. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm.egg-info/dependency_links.txt +0 -0
  36. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm.egg-info/entry_points.txt +0 -0
  37. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm.egg-info/requires.txt +0 -0
  38. {mem_llm-1.3.0 → mem_llm-1.3.2}/mem_llm.egg-info/top_level.txt +0 -0
  39. {mem_llm-1.3.0 → mem_llm-1.3.2}/requirements-dev.txt +0 -0
  40. {mem_llm-1.3.0 → mem_llm-1.3.2}/requirements.txt +0 -0
  41. {mem_llm-1.3.0 → mem_llm-1.3.2}/setup.cfg +0 -0
  42. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_advanced_coverage.py +0 -0
  43. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_backward_compatibility.py +0 -0
  44. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_conversation_summarizer.py +0 -0
  45. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_data_export_import.py +0 -0
  46. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_improvements.py +0 -0
  47. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_integration.py +0 -0
  48. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_llm_backends.py +0 -0
  49. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_llm_client.py +0 -0
  50. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_mem_agent.py +0 -0
  51. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_memory_manager.py +0 -0
  52. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_memory_tools.py +0 -0
  53. {mem_llm-1.3.0 → mem_llm-1.3.2}/tests/test_qwen3_model.py +0 -0
@@ -5,6 +5,75 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.2] - 2025-11-02
9
+
10
+ ### 🎉 Major Features
11
+
12
+ - 📊 **Response Metrics & Quality Analytics** (v1.3.1+)
13
+ - `ChatResponse` dataclass: Comprehensive response tracking
14
+ - `ResponseMetricsAnalyzer`: Aggregate analytics and monitoring
15
+ - Confidence scoring: Based on KB usage, memory, temperature, and length
16
+ - Real-time latency tracking: Monitor response performance
17
+ - Quality labels: High/Medium/Low classification
18
+ - Export metrics: JSON and summary formats for dashboards
19
+ - Production monitoring: Health checks and SLA tracking
20
+
21
+ - 🔍 **Vector Search & Semantic Knowledge Base** (v1.3.2+)
22
+ - ChromaDB integration: Semantic search with embeddings
23
+ - Sentence-transformers support: `all-MiniLM-L6-v2` default model
24
+ - Cross-lingual search: Understands meaning across languages
25
+ - Hybrid search: Vector + keyword search combination
26
+ - Better relevancy: Semantic understanding vs keyword matching
27
+ - Optional feature: Install with `pip install chromadb sentence-transformers`
28
+
29
+ ### 🆕 New Components
30
+
31
+ - `response_metrics.py`: `ChatResponse`, `ResponseMetricsAnalyzer`, `calculate_confidence`
32
+ - `vector_store.py`: `VectorStore`, `ChromaVectorStore`, `create_vector_store`
33
+ - Enhanced `SQLMemoryManager`: Vector search integration
34
+ - Enhanced `MemAgent`: Response metrics and vector search support
35
+
36
+ ### 🔄 Enhanced Features
37
+
38
+ - **MemAgent.chat()**: New `return_metrics` parameter for detailed response analysis
39
+ - **Memory Metadata**: Automatic saving of response metrics in conversations
40
+ - **User Profile**: Improved preferences and summary extraction/parsing
41
+ - **Knowledge Base Search**: Optional vector search with `use_vector_search=True`
42
+ - **ChromaDB Sync**: `sync_all_kb_to_vector_store()` method for existing KB entries
43
+
44
+ ### 📚 New Examples
45
+
46
+ - `15_response_metrics.py`: Response quality metrics and analytics
47
+ - `16_vector_search.py`: Semantic/vector search demonstration
48
+
49
+ ### 🐛 Bug Fixes
50
+
51
+ - Fixed metadata not being saved in conversation history
52
+ - Fixed preferences parsing from JSON string to dict
53
+ - Fixed summary generation for existing users
54
+ - Fixed `get_user_profile()` SQL/JSON memory detection logic
55
+ - Fixed ChromaDB embedding function compatibility
56
+
57
+ ### 📝 Documentation
58
+
59
+ - Updated all examples: Simplified and more readable
60
+ - Enhanced README with new features
61
+ - Vector search usage guide
62
+
63
+ ### ⚡ Improved
64
+
65
+ - Better error handling for ChromaDB initialization
66
+ - Fallback mechanism for embedding function loading
67
+ - Enhanced similarity score calculation for vector search
68
+ - Improved conversation metadata tracking
69
+
70
+ ## [1.3.1] - 2025-10-31
71
+
72
+ ### 📝 Documentation
73
+
74
+ - ✅ **README Update**: Fixed PyPI package README to show v1.3.0 features correctly
75
+ - ✅ No code changes - all v1.3.0 functionality remains the same
76
+
8
77
  ## [1.3.0] - 2025-10-31
9
78
 
10
79
  ### 🎉 Major Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mem-llm
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Memory-enabled AI assistant with multi-backend LLM support (Ollama, LM Studio, Gemini) - Local and cloud ready
5
5
  Author-email: "C. Emre Karataş" <karatasqemre@gmail.com>
6
6
  License: MIT
@@ -59,9 +59,9 @@ Requires-Dist: pymongo>=4.6.0; extra == "all"
59
59
  [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
60
60
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
61
61
 
62
- **Memory-enabled AI assistant with local LLM support**
62
+ **Memory-enabled AI assistant with multi-backend LLM support (Ollama, LM Studio, Gemini)**
63
63
 
64
- Mem-LLM is a powerful Python library that brings persistent memory capabilities to local Large Language Models. Build AI assistants that remember user interactions, manage knowledge bases, and work completely offline with Ollama.
64
+ Mem-LLM is a powerful Python library that brings persistent memory capabilities to Large Language Models. Build AI assistants that remember user interactions, manage knowledge bases, and choose between local (Ollama, LM Studio) or cloud (Gemini) backends.
65
65
 
66
66
  ## 🔗 Links
67
67
 
@@ -70,29 +70,40 @@ Mem-LLM is a powerful Python library that brings persistent memory capabilities
70
70
  - **Issues**: https://github.com/emredeveloper/Mem-LLM/issues
71
71
  - **Documentation**: See examples/ directory
72
72
 
73
- ## 🆕 What's New in v1.2.0
73
+ ## 🆕 What's New in v1.3.2
74
74
 
75
- - **Conversation Summarization**: Automatic conversation compression (~40-60% token reduction)
76
- - 📤 **Data Export/Import**: JSON, CSV, SQLite, PostgreSQL, MongoDB support
77
- - 🗄️ **Multi-Database**: Enterprise-ready PostgreSQL & MongoDB integration
78
- - �️ **In-Memory DB**: Use `:memory:` for temporary operations
79
- - � **Cleaner Logs**: Default WARNING level for production-ready output
80
- - � **Bug Fixes**: Database path handling, organized SQLite files
75
+ - 📊 **Response Metrics** (v1.3.1+) Track confidence, latency, KB usage, and quality analytics
76
+ - 🔍 **Vector Search** (v1.3.2+) Semantic search with ChromaDB, cross-lingual support
77
+ - 🎯 **Quality Monitoring** – Production-ready metrics for response quality
78
+ - 🌐 **Semantic Understanding** Understands meaning, not just keywords
81
79
 
82
- [See full changelog](CHANGELOG.md#120---2025-10-21)
80
+ ## What's New in v1.3.0
81
+
82
+ - 🔌 **Multi-Backend Support**: Choose between Ollama (local), LM Studio (local), or Google Gemini (cloud)
83
+ - 🏗️ **Factory Pattern**: Clean, extensible architecture for easy backend switching
84
+ - 🔍 **Auto-Detection**: Automatically finds and uses available local LLM services
85
+ - ⚡ **Unified API**: Same code works across all backends - just change one parameter
86
+ - 📚 **New Examples**: 4 additional examples showing multi-backend usage
87
+ - 🎯 **Backward Compatible**: All v1.2.0 code still works without changes
88
+
89
+ [See full changelog](CHANGELOG.md)
83
90
 
84
91
  ## ✨ Key Features
85
92
 
93
+ - 🔌 **Multi-Backend Support** (v1.3.0+) - Choose Ollama, LM Studio, or Gemini with unified API
94
+ - 🔍 **Auto-Detection** (v1.3.0+) - Automatically find and use available LLM services
95
+ - 📊 **Response Metrics** (v1.3.1+) - Track confidence, latency, KB usage, and quality analytics
96
+ - 🔍 **Vector Search** (v1.3.2+) - Semantic search with ChromaDB, cross-lingual support
86
97
  - 🧠 **Persistent Memory** - Remembers conversations across sessions
87
- - 🤖 **Universal Ollama Support** - Works with ALL Ollama models (Qwen3, DeepSeek, Llama3, Granite, etc.)
98
+ - 🤖 **Universal Model Support** - Works with 100+ Ollama models, LM Studio models, and Gemini
88
99
  - 💾 **Dual Storage Modes** - JSON (simple) or SQLite (advanced) memory backends
89
100
  - 📚 **Knowledge Base** - Built-in FAQ/support system with categorized entries
90
101
  - 🎯 **Dynamic Prompts** - Context-aware system prompts that adapt to active features
91
102
  - 👥 **Multi-User Support** - Separate memory spaces for different users
92
103
  - 🔧 **Memory Tools** - Search, export, and manage stored memories
93
104
  - 🎨 **Flexible Configuration** - Personal or business usage modes
94
- - 📊 **Production Ready** - Comprehensive test suite with 34+ automated tests
95
- - 🔒 **100% Local & Private** - No cloud dependencies, your data stays yours
105
+ - 📊 **Production Ready** - Comprehensive test suite with 50+ automated tests
106
+ - 🔒 **Privacy Options** - 100% local (Ollama/LM Studio) or cloud (Gemini)
96
107
  - 🛡️ **Prompt Injection Protection** (v1.1.0+) - Advanced security against prompt attacks (opt-in)
97
108
  - ⚡ **High Performance** (v1.1.0+) - Thread-safe operations, 15K+ msg/s throughput
98
109
  - 🔄 **Retry Logic** (v1.1.0+) - Automatic exponential backoff for network errors
@@ -130,8 +141,9 @@ pip install -U mem-llm
130
141
 
131
142
  ### Prerequisites
132
143
 
133
- Install and start [Ollama](https://ollama.ai):
144
+ **Choose one of the following LLM backends:**
134
145
 
146
+ #### Option 1: Ollama (Local, Privacy-First)
135
147
  ```bash
136
148
  # Install Ollama (visit https://ollama.ai)
137
149
  # Then pull a model
@@ -141,15 +153,38 @@ ollama pull granite4:tiny-h
141
153
  ollama serve
142
154
  ```
143
155
 
156
+ #### Option 2: LM Studio (Local, GUI-Based)
157
+ ```bash
158
+ # 1. Download and install LM Studio: https://lmstudio.ai
159
+ # 2. Download a model from the UI
160
+ # 3. Start the local server (default port: 1234)
161
+ ```
162
+
163
+ #### Option 3: Google Gemini (Cloud, Powerful)
164
+ ```bash
165
+ # Get API key from: https://makersuite.google.com/app/apikey
166
+ # Set environment variable
167
+ export GEMINI_API_KEY="your-api-key-here"
168
+ ```
169
+
144
170
  ### Basic Usage
145
171
 
146
172
  ```python
147
173
  from mem_llm import MemAgent
148
174
 
149
- # Create an agent
175
+ # Option 1: Use Ollama (default)
150
176
  agent = MemAgent(model="granite4:tiny-h")
151
177
 
152
- # Set user and chat
178
+ # Option 2: Use LM Studio
179
+ agent = MemAgent(backend='lmstudio', model='local-model')
180
+
181
+ # Option 3: Use Gemini
182
+ agent = MemAgent(backend='gemini', model='gemini-2.5-flash', api_key='your-key')
183
+
184
+ # Option 4: Auto-detect available backend
185
+ agent = MemAgent(auto_detect_backend=True)
186
+
187
+ # Set user and chat (same for all backends!)
153
188
  agent.set_user("alice")
154
189
  response = agent.chat("My name is Alice and I love Python!")
155
190
  print(response)
@@ -159,10 +194,34 @@ response = agent.chat("What's my name and what do I love?")
159
194
  print(response) # Agent remembers: "Your name is Alice and you love Python!"
160
195
  ```
161
196
 
162
- That's it! Just 5 lines of code to get started.
197
+ That's it! Just 5 lines of code to get started with any backend.
163
198
 
164
199
  ## 📖 Usage Examples
165
200
 
201
+ ### Multi-Backend Examples (v1.3.0+)
202
+
203
+ ```python
204
+ from mem_llm import MemAgent
205
+
206
+ # LM Studio - Fast local inference
207
+ agent = MemAgent(
208
+ backend='lmstudio',
209
+ model='local-model',
210
+ base_url='http://localhost:1234'
211
+ )
212
+
213
+ # Google Gemini - Cloud power
214
+ agent = MemAgent(
215
+ backend='gemini',
216
+ model='gemini-2.5-flash',
217
+ api_key='your-api-key'
218
+ )
219
+
220
+ # Auto-detect - Universal compatibility
221
+ agent = MemAgent(auto_detect_backend=True)
222
+ print(f"Using: {agent.llm.get_backend_info()['name']}")
223
+ ```
224
+
166
225
  ### Multi-User Conversations
167
226
 
168
227
  ```python
@@ -379,16 +438,21 @@ Mem-LLM works with **ALL Ollama models**, including:
379
438
  ```
380
439
  mem-llm/
381
440
  ├── mem_llm/
382
- │ ├── mem_agent.py # Main agent class
383
- │ ├── memory_manager.py # JSON memory backend
384
- │ ├── memory_db.py # SQL memory backend
385
- │ ├── llm_client.py # Ollama API client
386
- │ ├── knowledge_loader.py # Knowledge base system
387
- │ ├── dynamic_prompt.py # Context-aware prompts
388
- ├── memory_tools.py # Memory management tools
389
- │ ├── config_manager.py # Configuration handler
390
- └── cli.py # Command-line interface
391
- └── examples/ # Usage examples
441
+ │ ├── mem_agent.py # Main agent class (multi-backend)
442
+ │ ├── base_llm_client.py # Abstract LLM interface
443
+ │ ├── llm_client_factory.py # Backend factory pattern
444
+ │ ├── clients/ # LLM backend implementations
445
+ ├── ollama_client.py # Ollama integration
446
+ ├── lmstudio_client.py # LM Studio integration
447
+ │ └── gemini_client.py # Google Gemini integration
448
+ │ ├── memory_manager.py # JSON memory backend
449
+ ├── memory_db.py # SQL memory backend
450
+ │ ├── knowledge_loader.py # Knowledge base system
451
+ │ ├── dynamic_prompt.py # Context-aware prompts
452
+ │ ├── memory_tools.py # Memory management tools
453
+ │ ├── config_manager.py # Configuration handler
454
+ │ └── cli.py # Command-line interface
455
+ └── examples/ # Usage examples (14 total)
392
456
  ```
393
457
 
394
458
  ## 🔥 Advanced Features
@@ -430,10 +494,12 @@ stats = agent.get_memory_stats()
430
494
  ## 📦 Project Structure
431
495
 
432
496
  ### Core Components
433
- - **MemAgent**: Main interface for building AI assistants
497
+ - **MemAgent**: Main interface for building AI assistants (multi-backend support)
498
+ - **LLMClientFactory**: Factory pattern for backend creation
499
+ - **BaseLLMClient**: Abstract interface for all LLM backends
500
+ - **OllamaClient / LMStudioClient / GeminiClient**: Backend implementations
434
501
  - **MemoryManager**: JSON-based memory storage (simple)
435
502
  - **SQLMemoryManager**: SQLite-based storage (advanced)
436
- - **OllamaClient**: LLM communication handler
437
503
  - **KnowledgeLoader**: Knowledge base management
438
504
 
439
505
  ### Optional Features
@@ -457,14 +523,19 @@ The `examples/` directory contains ready-to-run demonstrations:
457
523
  8. **08_conversation_summarization.py** - Token compression with auto-summary (v1.2.0+)
458
524
  9. **09_data_export_import.py** - Multi-format export/import demo (v1.2.0+)
459
525
  10. **10_database_connection_test.py** - Enterprise PostgreSQL/MongoDB migration (v1.2.0+)
526
+ 11. **11_lmstudio_example.py** - Using LM Studio backend (v1.3.0+)
527
+ 12. **12_gemini_example.py** - Using Google Gemini API (v1.3.0+)
528
+ 13. **13_multi_backend_comparison.py** - Compare different backends (v1.3.0+)
529
+ 14. **14_auto_detect_backend.py** - Auto-detection feature demo (v1.3.0+)
460
530
 
461
531
  ## 📊 Project Status
462
532
 
463
- - **Version**: 1.2.0
533
+ - **Version**: 1.3.0
464
534
  - **Status**: Production Ready
465
- - **Last Updated**: October 21, 2025
466
- - **Test Coverage**: 16/16 automated tests (100% success rate)
535
+ - **Last Updated**: October 31, 2025
536
+ - **Test Coverage**: 50+ automated tests (100% success rate)
467
537
  - **Performance**: Thread-safe operations, <1ms search latency
538
+ - **Backends**: Ollama, LM Studio, Google Gemini
468
539
  - **Databases**: SQLite, PostgreSQL, MongoDB, In-Memory
469
540
 
470
541
  ## 📈 Roadmap
@@ -476,10 +547,14 @@ The `examples/` directory contains ready-to-run demonstrations:
476
547
  - [x] ~~Conversation Summarization~~ (v1.2.0)
477
548
  - [x] ~~Multi-Database Export/Import~~ (v1.2.0)
478
549
  - [x] ~~In-Memory Database~~ (v1.2.0)
550
+ - [x] ~~Multi-Backend Support (Ollama, LM Studio, Gemini)~~ (v1.3.0)
551
+ - [x] ~~Auto-Detection~~ (v1.3.0)
552
+ - [x] ~~Factory Pattern Architecture~~ (v1.3.0)
553
+ - [ ] OpenAI & Claude backends
554
+ - [ ] Streaming support
479
555
  - [ ] Web UI dashboard
480
556
  - [ ] REST API server
481
557
  - [ ] Vector database integration
482
- - [ ] Advanced analytics dashboard
483
558
 
484
559
  ## 📄 License
485
560
 
@@ -4,9 +4,9 @@
4
4
  [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- **Memory-enabled AI assistant with local LLM support**
7
+ **Memory-enabled AI assistant with multi-backend LLM support (Ollama, LM Studio, Gemini)**
8
8
 
9
- Mem-LLM is a powerful Python library that brings persistent memory capabilities to local Large Language Models. Build AI assistants that remember user interactions, manage knowledge bases, and work completely offline with Ollama.
9
+ Mem-LLM is a powerful Python library that brings persistent memory capabilities to Large Language Models. Build AI assistants that remember user interactions, manage knowledge bases, and choose between local (Ollama, LM Studio) or cloud (Gemini) backends.
10
10
 
11
11
  ## 🔗 Links
12
12
 
@@ -15,29 +15,40 @@ Mem-LLM is a powerful Python library that brings persistent memory capabilities
15
15
  - **Issues**: https://github.com/emredeveloper/Mem-LLM/issues
16
16
  - **Documentation**: See examples/ directory
17
17
 
18
- ## 🆕 What's New in v1.2.0
18
+ ## 🆕 What's New in v1.3.2
19
19
 
20
- - **Conversation Summarization**: Automatic conversation compression (~40-60% token reduction)
21
- - 📤 **Data Export/Import**: JSON, CSV, SQLite, PostgreSQL, MongoDB support
22
- - 🗄️ **Multi-Database**: Enterprise-ready PostgreSQL & MongoDB integration
23
- - �️ **In-Memory DB**: Use `:memory:` for temporary operations
24
- - � **Cleaner Logs**: Default WARNING level for production-ready output
25
- - � **Bug Fixes**: Database path handling, organized SQLite files
20
+ - 📊 **Response Metrics** (v1.3.1+) Track confidence, latency, KB usage, and quality analytics
21
+ - 🔍 **Vector Search** (v1.3.2+) Semantic search with ChromaDB, cross-lingual support
22
+ - 🎯 **Quality Monitoring** – Production-ready metrics for response quality
23
+ - 🌐 **Semantic Understanding** Understands meaning, not just keywords
26
24
 
27
- [See full changelog](CHANGELOG.md#120---2025-10-21)
25
+ ## What's New in v1.3.0
26
+
27
+ - 🔌 **Multi-Backend Support**: Choose between Ollama (local), LM Studio (local), or Google Gemini (cloud)
28
+ - 🏗️ **Factory Pattern**: Clean, extensible architecture for easy backend switching
29
+ - 🔍 **Auto-Detection**: Automatically finds and uses available local LLM services
30
+ - ⚡ **Unified API**: Same code works across all backends - just change one parameter
31
+ - 📚 **New Examples**: 4 additional examples showing multi-backend usage
32
+ - 🎯 **Backward Compatible**: All v1.2.0 code still works without changes
33
+
34
+ [See full changelog](CHANGELOG.md)
28
35
 
29
36
  ## ✨ Key Features
30
37
 
38
+ - 🔌 **Multi-Backend Support** (v1.3.0+) - Choose Ollama, LM Studio, or Gemini with unified API
39
+ - 🔍 **Auto-Detection** (v1.3.0+) - Automatically find and use available LLM services
40
+ - 📊 **Response Metrics** (v1.3.1+) - Track confidence, latency, KB usage, and quality analytics
41
+ - 🔍 **Vector Search** (v1.3.2+) - Semantic search with ChromaDB, cross-lingual support
31
42
  - 🧠 **Persistent Memory** - Remembers conversations across sessions
32
- - 🤖 **Universal Ollama Support** - Works with ALL Ollama models (Qwen3, DeepSeek, Llama3, Granite, etc.)
43
+ - 🤖 **Universal Model Support** - Works with 100+ Ollama models, LM Studio models, and Gemini
33
44
  - 💾 **Dual Storage Modes** - JSON (simple) or SQLite (advanced) memory backends
34
45
  - 📚 **Knowledge Base** - Built-in FAQ/support system with categorized entries
35
46
  - 🎯 **Dynamic Prompts** - Context-aware system prompts that adapt to active features
36
47
  - 👥 **Multi-User Support** - Separate memory spaces for different users
37
48
  - 🔧 **Memory Tools** - Search, export, and manage stored memories
38
49
  - 🎨 **Flexible Configuration** - Personal or business usage modes
39
- - 📊 **Production Ready** - Comprehensive test suite with 34+ automated tests
40
- - 🔒 **100% Local & Private** - No cloud dependencies, your data stays yours
50
+ - 📊 **Production Ready** - Comprehensive test suite with 50+ automated tests
51
+ - 🔒 **Privacy Options** - 100% local (Ollama/LM Studio) or cloud (Gemini)
41
52
  - 🛡️ **Prompt Injection Protection** (v1.1.0+) - Advanced security against prompt attacks (opt-in)
42
53
  - ⚡ **High Performance** (v1.1.0+) - Thread-safe operations, 15K+ msg/s throughput
43
54
  - 🔄 **Retry Logic** (v1.1.0+) - Automatic exponential backoff for network errors
@@ -75,8 +86,9 @@ pip install -U mem-llm
75
86
 
76
87
  ### Prerequisites
77
88
 
78
- Install and start [Ollama](https://ollama.ai):
89
+ **Choose one of the following LLM backends:**
79
90
 
91
+ #### Option 1: Ollama (Local, Privacy-First)
80
92
  ```bash
81
93
  # Install Ollama (visit https://ollama.ai)
82
94
  # Then pull a model
@@ -86,15 +98,38 @@ ollama pull granite4:tiny-h
86
98
  ollama serve
87
99
  ```
88
100
 
101
+ #### Option 2: LM Studio (Local, GUI-Based)
102
+ ```bash
103
+ # 1. Download and install LM Studio: https://lmstudio.ai
104
+ # 2. Download a model from the UI
105
+ # 3. Start the local server (default port: 1234)
106
+ ```
107
+
108
+ #### Option 3: Google Gemini (Cloud, Powerful)
109
+ ```bash
110
+ # Get API key from: https://makersuite.google.com/app/apikey
111
+ # Set environment variable
112
+ export GEMINI_API_KEY="your-api-key-here"
113
+ ```
114
+
89
115
  ### Basic Usage
90
116
 
91
117
  ```python
92
118
  from mem_llm import MemAgent
93
119
 
94
- # Create an agent
120
+ # Option 1: Use Ollama (default)
95
121
  agent = MemAgent(model="granite4:tiny-h")
96
122
 
97
- # Set user and chat
123
+ # Option 2: Use LM Studio
124
+ agent = MemAgent(backend='lmstudio', model='local-model')
125
+
126
+ # Option 3: Use Gemini
127
+ agent = MemAgent(backend='gemini', model='gemini-2.5-flash', api_key='your-key')
128
+
129
+ # Option 4: Auto-detect available backend
130
+ agent = MemAgent(auto_detect_backend=True)
131
+
132
+ # Set user and chat (same for all backends!)
98
133
  agent.set_user("alice")
99
134
  response = agent.chat("My name is Alice and I love Python!")
100
135
  print(response)
@@ -104,10 +139,34 @@ response = agent.chat("What's my name and what do I love?")
104
139
  print(response) # Agent remembers: "Your name is Alice and you love Python!"
105
140
  ```
106
141
 
107
- That's it! Just 5 lines of code to get started.
142
+ That's it! Just 5 lines of code to get started with any backend.
108
143
 
109
144
  ## 📖 Usage Examples
110
145
 
146
+ ### Multi-Backend Examples (v1.3.0+)
147
+
148
+ ```python
149
+ from mem_llm import MemAgent
150
+
151
+ # LM Studio - Fast local inference
152
+ agent = MemAgent(
153
+ backend='lmstudio',
154
+ model='local-model',
155
+ base_url='http://localhost:1234'
156
+ )
157
+
158
+ # Google Gemini - Cloud power
159
+ agent = MemAgent(
160
+ backend='gemini',
161
+ model='gemini-2.5-flash',
162
+ api_key='your-api-key'
163
+ )
164
+
165
+ # Auto-detect - Universal compatibility
166
+ agent = MemAgent(auto_detect_backend=True)
167
+ print(f"Using: {agent.llm.get_backend_info()['name']}")
168
+ ```
169
+
111
170
  ### Multi-User Conversations
112
171
 
113
172
  ```python
@@ -324,16 +383,21 @@ Mem-LLM works with **ALL Ollama models**, including:
324
383
  ```
325
384
  mem-llm/
326
385
  ├── mem_llm/
327
- │ ├── mem_agent.py # Main agent class
328
- │ ├── memory_manager.py # JSON memory backend
329
- │ ├── memory_db.py # SQL memory backend
330
- │ ├── llm_client.py # Ollama API client
331
- │ ├── knowledge_loader.py # Knowledge base system
332
- │ ├── dynamic_prompt.py # Context-aware prompts
333
- ├── memory_tools.py # Memory management tools
334
- │ ├── config_manager.py # Configuration handler
335
- └── cli.py # Command-line interface
336
- └── examples/ # Usage examples
386
+ │ ├── mem_agent.py # Main agent class (multi-backend)
387
+ │ ├── base_llm_client.py # Abstract LLM interface
388
+ │ ├── llm_client_factory.py # Backend factory pattern
389
+ │ ├── clients/ # LLM backend implementations
390
+ ├── ollama_client.py # Ollama integration
391
+ ├── lmstudio_client.py # LM Studio integration
392
+ │ └── gemini_client.py # Google Gemini integration
393
+ │ ├── memory_manager.py # JSON memory backend
394
+ ├── memory_db.py # SQL memory backend
395
+ │ ├── knowledge_loader.py # Knowledge base system
396
+ │ ├── dynamic_prompt.py # Context-aware prompts
397
+ │ ├── memory_tools.py # Memory management tools
398
+ │ ├── config_manager.py # Configuration handler
399
+ │ └── cli.py # Command-line interface
400
+ └── examples/ # Usage examples (14 total)
337
401
  ```
338
402
 
339
403
  ## 🔥 Advanced Features
@@ -375,10 +439,12 @@ stats = agent.get_memory_stats()
375
439
  ## 📦 Project Structure
376
440
 
377
441
  ### Core Components
378
- - **MemAgent**: Main interface for building AI assistants
442
+ - **MemAgent**: Main interface for building AI assistants (multi-backend support)
443
+ - **LLMClientFactory**: Factory pattern for backend creation
444
+ - **BaseLLMClient**: Abstract interface for all LLM backends
445
+ - **OllamaClient / LMStudioClient / GeminiClient**: Backend implementations
379
446
  - **MemoryManager**: JSON-based memory storage (simple)
380
447
  - **SQLMemoryManager**: SQLite-based storage (advanced)
381
- - **OllamaClient**: LLM communication handler
382
448
  - **KnowledgeLoader**: Knowledge base management
383
449
 
384
450
  ### Optional Features
@@ -402,14 +468,19 @@ The `examples/` directory contains ready-to-run demonstrations:
402
468
  8. **08_conversation_summarization.py** - Token compression with auto-summary (v1.2.0+)
403
469
  9. **09_data_export_import.py** - Multi-format export/import demo (v1.2.0+)
404
470
  10. **10_database_connection_test.py** - Enterprise PostgreSQL/MongoDB migration (v1.2.0+)
471
+ 11. **11_lmstudio_example.py** - Using LM Studio backend (v1.3.0+)
472
+ 12. **12_gemini_example.py** - Using Google Gemini API (v1.3.0+)
473
+ 13. **13_multi_backend_comparison.py** - Compare different backends (v1.3.0+)
474
+ 14. **14_auto_detect_backend.py** - Auto-detection feature demo (v1.3.0+)
405
475
 
406
476
  ## 📊 Project Status
407
477
 
408
- - **Version**: 1.2.0
478
+ - **Version**: 1.3.0
409
479
  - **Status**: Production Ready
410
- - **Last Updated**: October 21, 2025
411
- - **Test Coverage**: 16/16 automated tests (100% success rate)
480
+ - **Last Updated**: October 31, 2025
481
+ - **Test Coverage**: 50+ automated tests (100% success rate)
412
482
  - **Performance**: Thread-safe operations, <1ms search latency
483
+ - **Backends**: Ollama, LM Studio, Google Gemini
413
484
  - **Databases**: SQLite, PostgreSQL, MongoDB, In-Memory
414
485
 
415
486
  ## 📈 Roadmap
@@ -421,10 +492,14 @@ The `examples/` directory contains ready-to-run demonstrations:
421
492
  - [x] ~~Conversation Summarization~~ (v1.2.0)
422
493
  - [x] ~~Multi-Database Export/Import~~ (v1.2.0)
423
494
  - [x] ~~In-Memory Database~~ (v1.2.0)
495
+ - [x] ~~Multi-Backend Support (Ollama, LM Studio, Gemini)~~ (v1.3.0)
496
+ - [x] ~~Auto-Detection~~ (v1.3.0)
497
+ - [x] ~~Factory Pattern Architecture~~ (v1.3.0)
498
+ - [ ] OpenAI & Claude backends
499
+ - [ ] Streaming support
424
500
  - [ ] Web UI dashboard
425
501
  - [ ] REST API server
426
502
  - [ ] Vector database integration
427
- - [ ] Advanced analytics dashboard
428
503
 
429
504
  ## 📄 License
430
505
 
@@ -63,7 +63,14 @@ try:
63
63
  except ImportError:
64
64
  __all_export_import__ = []
65
65
 
66
- __version__ = "1.3.0"
66
+ # Response Metrics (v1.3.1+)
67
+ try:
68
+ from .response_metrics import ChatResponse, ResponseMetricsAnalyzer, calculate_confidence
69
+ __all_metrics__ = ["ChatResponse", "ResponseMetricsAnalyzer", "calculate_confidence"]
70
+ except ImportError:
71
+ __all_metrics__ = []
72
+
73
+ __version__ = "1.3.2"
67
74
  __author__ = "C. Emre Karataş"
68
75
 
69
76
  # Multi-backend LLM support (v1.3.0+)
@@ -80,4 +87,4 @@ __all__ = [
80
87
  "MemAgent",
81
88
  "MemoryManager",
82
89
  "OllamaClient",
83
- ] + __all_llm_backends__ + __all_tools__ + __all_pro__ + __all_cli__ + __all_security__ + __all_enhanced__ + __all_summarizer__ + __all_export_import__
90
+ ] + __all_llm_backends__ + __all_tools__ + __all_pro__ + __all_cli__ + __all_security__ + __all_enhanced__ + __all_summarizer__ + __all_export_import__ + __all_metrics__
@@ -62,7 +62,9 @@ class ConfigManager:
62
62
  "default_kb": "ecommerce",
63
63
  "custom_kb_file": None,
64
64
  "search_limit": 5,
65
- "min_relevance_score": 0.3
65
+ "min_relevance_score": 0.3,
66
+ "enable_vector_search": False, # v1.3.2+ - Optional semantic search
67
+ "embedding_model": "all-MiniLM-L6-v2" # Sentence transformers model
66
68
  },
67
69
  "response": {
68
70
  "use_knowledge_base": True,