- Visual Interface: Web-based UI for memory examination
- Memory Editing: Update or delete specific memories
- Memory Search: Find memories using keyword search
- Visualization: Interactive network graph of memory relationships
- Cache Management: Load and save memory caches
The editor is a FastAPI application that operates on the same memory cache structure used by the agent. Key components:
-
Cache Loading: Loads agent memory caches
@app.post("/load/{bot_name}") async def load_cache(bot_name: str): """Load cache for specific bot"""
-
Memory Viewing and Search: Provides search with hybrid scoring
@app.get("/search/") async def search_memories(query: str = "", user_id: Optional[str] = None, per_page: Optional[int] = None): """Search memories with hybrid TF-IDF and BM25-like weighting"""
-
Memory Editing: Updates memories and rebuilds indices
@app.put("/memory/{memory_id}") async def update_memory(memory_id: int, update: MemoryUpdate): """Update specific memory"""
-
Memory Visualization: Creates interactive network visualization
@app.get("/visualize/") async def visualize_network(query: str = "", user_id: Optional[str] = None): """Visualize memory network as simple SVG based on current search results"""
- Force-directed layout with simulated annealing
- Node sizing based on keyword density
- Edge weights from shared keywords
- Interactive node highlighting
The editor works with the same cache structure used by the agent:
cache_structure = {
'memories': List[str], # All memory texts
'user_memories': Dict[str, List[int]], # User ID -> Memory IDs
'inverted_index': Dict[str, List[int]], # Word -> Memory IDs
'metadata': {
'last_modified': str,
'version': str,
'memory_stats': Dict[int, Dict]
}
}The Memory Editor and Agent Memory System interact through the shared cache file structure:
- The agent continuously writes to the memory cache file during operation
- The editor can load this cache file to provide visualization and management
- Any edits made through the editor are saved back to the cache file
- The agent loads the updated cache file when restarted or periodically
This separation of concerns allows:
- Agent to focus on real-time memory utilization
- Editor to provide human oversight and management
- Both systems to operate on the same underlying data structure
- Start the FastAPI server:
uvicorn memory_editor:app --host localhost --port 8000- Access the web interface at
http://localhost:8000 - Select a bot cache to load
- View, edit, or delete memories
- Visualize memory networks
- Save changes
The editor provides a sophisticated search interface with:
- Relevance-based ranking of results
- Keyword highlighting
- User-specific filtering
- Pagination controls
The network visualization shows:
- Memory nodes sized by importance
- Connections based on shared keywords
- Interactive highlighting
- Tooltips showing memory content
The editor allows:
- Deleting obsolete memories
- Updating memory content
- Rebuilding indices
- Cleaning up broken references
- FastAPI
- Pydantic
- Python 3.7+
- Modern web browser with SVG support
