# Memory Editor - Quick Start Guide

## TL;DR

You now have full control over Miku's memories through the Web UI (Tab 9).

## Quick Actions

### Edit a Memory ✏️
1. Open Web UI → Tab 9 (Memories)
2. Click "Load Facts" or "Load Memories"
3. Click ✏️ button next to any memory
4. Edit content/source → Click "Save Changes"

### Create New Fact ➕
1. Tab 9 → Declarative Facts section
2. Click "➕ Add Fact"
3. Enter fact content (e.g., "My favorite band is Supercell")
4. Click "Create Memory"

### Create New Memory ➕
1. Tab 9 → Episodic Memories section
2. Click "➕ Add Memory"
3. Enter conversation context
4. Click "Create Memory"

### Search Memories 🔍
- Type in the search box above each list
- Results filter in real-time

## Example Use Cases

### Personal Facts
```
Content: "User's birthday is December 25th"
User ID: [Discord User ID]
Source: manual
```

### Bot Facts
```
Content: "My creator is koko210"
User ID: [leave empty]
Source: manual
```

### Conversation Context
```
Content: "We discussed her favorite Vocaloid songs"
Collection: Episodic
Source: manual
```

## Testing Your Changes

**Create a test fact:**
1. Add fact: "My test color is magenta"
2. Save it

**Ask Miku:**
```
User: "What is your test color?"
Miku: Should recall "magenta" from declarative memory
```

**Edit the fact:**
1. Change to "My test color is purple"
2. Save

**Ask again:**
```
User: "What is your test color?"
Miku: Should now say "purple"
```

**Clean up:**
1. Delete the test fact with 🗑️ button

## Important Notes

- ✅ Edit preserves vector if only metadata changes
- ✅ Edit re-embeds if content changes
- ✅ Create generates proper embeddings automatically
- ✅ Search is case-insensitive
- ✅ User ID is optional (for user-specific facts)
- ⚠️ Deleting is permanent (no undo)
- ⚠️ Container must restart after API changes

## UI Layout

```
Tab 9: Memories
├── Memory Statistics
│   └── (Shows counts for declarative, episodic, procedural)
│
├── Memory Consolidation
│   └── (Consolidate chat history into long-term memory)
│
├── Declarative Facts Browser
│   ├── [➕ Add Fact] [Search: ___________]
│   └── Facts List
│       ├── Fact 1 [✏️] [🗑️]
│       ├── Fact 2 [✏️] [🗑️]
│       └── ...
│
├── Episodic Memories Browser
│   ├── [➕ Add Memory] [Search: ___________]
│   └── Memories List
│       ├── Memory 1 [✏️] [🗑️]
│       ├── Memory 2 [✏️] [🗑️]
│       └── ...
│
└── Delete All Memories
    └── (Multi-step confirmation flow)
```

## Access

- **Web UI:** http://localhost:3939
- **Tab:** 9 (Memories)
- **API Endpoints:**
  - GET `/memory/facts` - List all facts
  - GET `/memory/episodic` - List all memories
  - PUT `/memory/point/{collection}/{id}` - Edit memory
  - POST `/memory/create` - Create new memory
  - DELETE `/memory/point/{collection}/{id}` - Delete memory

## Files Modified

- ✅ `/bot/api.py` - Added PUT and POST endpoints
- ✅ `/bot/utils/cat_client.py` - Added update/create methods
- ✅ `/bot/static/index.html` - Added modals and JavaScript functions

## Status

🟢 **READY TO USE** - Container restarted, all features active
