Production-grade RAG memory system for Hermes Agent with hybrid TF-IDF + Neural retrieval, auto-capture, and zero-configuration setup
Project description
RAG Memory Plugin for Hermes Agent
Production-grade Retrieval-Augmented Generation memory system with hybrid TF-IDF + Neural search, automatic context injection, and zero-configuration setup.
Features
- ๐ Hybrid Search: TF-IDF + Neural retrieval with sqlite-vec and sentence-transformers
- ๐ช Auto-Capture: Hooks inject relevant context before LLM calls, capture responses after
- ๐ท๏ธ Namespace Isolation: Separate memory spaces for conversations, files, projects
- โก Performance: Query caching, connection pooling, lazy loading
- ๐ง Zero-Config: Works out of the box, graceful fallback when models unavailable
- ๐ฆ Pip Installable: Standard Python package with entry points
- ๐ Fast: <2ms search time, 40-60% cache hit rate
Installation
From PyPI (Recommended)
# Basic (TF-IDF only)
pip install rag-memory-plugin
# Full (with Neural Search)
pip install rag-memory-plugin[neural]
From GitHub (Latest Development Version)
# Install directly from GitHub
pip install git+https://github.com/favouraka/rag-memory-plugin.git[neural]
# Or clone and install in editable mode
git clone https://github.com/favouraka/rag-memory-plugin.git
cd rag-memory-plugin
pip install -e ".[neural]"
Quick Start
1. Install Plugin
From PyPI:
pip install rag-memory-plugin[neural]
From GitHub:
pip install git+https://github.com/favouraka/rag-memory-plugin.git[neural]
2. Migrate Existing Data (Optional)
If you have a legacy ~/rag-system installation:
rag-memory migrate-from-legacy
3. Verify Installation
rag-memory doctor
Output:
โ Database: /home/user/.hermes/plugins/rag-memory/rag_memory.db
โ Documents: 168
โ Embeddings: 168
โ Mode: hybrid
4. Restart Hermes
The plugin auto-discovers via entry points. Just restart Hermes:
hermes
You should see in the banner:
Plugins (1): โ rag-memory v1.0.0 (4 tools, 4 hooks)
Usage
Via Hermes Tools
The plugin registers 4 tools that Hermes can use:
rag_search: Search memory by semantic similarity
rag_add_document: Add document to memory
rag_stats: Show database statistics
rag_flush: Flush write buffers
Example in Hermes:
You: What did we work on yesterday?
Hermes: [Uses rag_search tool] Let me check... [Retrieves relevant context]
Via Command Line
# Search memory
rag-memory search "AI agent"
# Health check
rag-memory doctor
# Export data
rag-memory export backup.json
# Import data
rag-memory import-data backup.json
As a Python Library
from rag_memory import RAGCore
# Initialize
rag = RAGCore()
rag.initialize()
# Add document
rag.add_document(
content="Hermes is an AI agent",
namespace="test",
metadata={"source": "user"}
)
# Search
results = rag.search(
"AI agent",
namespace="test",
limit=5
)
for result in results:
print(f"{result['score']:.2f}: {result['content'][:100]}")
Configuration
Plugin configuration in Hermes ~/.hermes/config.yaml:
plugins:
rag_memory:
enabled: true
mode: hybrid # tfidf | neural | hybrid
auto_capture: true # Enable hooks
cache_enabled: true # Query caching
cache_ttl: 300 # Cache lifetime (seconds)
max_results: 10 # Max search results
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Hermes Agent โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ RAG Memory Plugin โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โ โ Tools โ โ Hooks โ โ โ
โ โ โ - rag_searchโ โ - pre_llm โ โ โ
โ โ โ - rag_add โ โ - post_llm โ โ โ
โ โ โ - rag_stats โ โ - session โ โ โ
โ โ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โ โ
โ โ โ โ โ โ
โ โ โโโโโโโโผโโโโโโโโโโโโโโโโโโโโโผโโโโโโโ โ โ
โ โ โ RAGCore โ โ โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โ โ โ TF-IDF Index (sqlite-vec) โ โ โ โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โ โ โ Neural Embeddings โ โ โ โ
โ โ โ โ (sentence-transformers) โ โ โ โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โ โ โ Query Cache (LRU) โ โ โ โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Performance
| Operation | Time | Notes |
|---|---|---|
| TF-IDF search | <10ms | No model required |
| Neural search | 60-100ms | sentence-transformers |
| Cached search | <1ms | 40-60% hit rate |
| Add document | 20-50ms | With embedding generation |
Development
Setup Development Environment
git clone https://github.com/yourname/rag-memory-plugin.git
cd rag-memory-plugin
pip install -e ".[dev]"
Run Tests
pytest tests/
Type Checking
mypy src/rag_memory
Linting
ruff check src/rag_memory
Migration from ~/rag-system
If you have a legacy ~/rag-system installation:
# Automatic migration
rag-memory migrate-from-legacy
# Or manual export/import
rag-memory export backup.json
rag-memory import-data backup.json
The migration script:
- Connects to
~/rag-system/rag_data.db - Exports all documents with embeddings
- Imports to
~/.hermes/plugins/rag-memory/rag_core.db - Verifies data integrity
License
MIT
Contributing
Contributions welcome! Please read CONTRIBUTING.md for details.
Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rag_memory_plugin-1.0.0-py3-none-any.whl.
File metadata
- Download URL: rag_memory_plugin-1.0.0-py3-none-any.whl
- Upload date:
- Size: 48.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ebbbce054892eca8155c75f911b1b7538d319e7ca417f093e236e13d14eb37f
|
|
| MD5 |
dad91a97253ff2ade5ad8d32143a62d4
|
|
| BLAKE2b-256 |
abca98b87b4f11402c5589b3b9a672ffc71b7c3cbe5c581c8235f56fcb73786c
|