|
| 1 | +# Integrate AoTai Hike Demo with MemOS Multi-View Memory System |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This PR integrates the AoTai Hike game demo with MemOS's multi-view memory capabilities, demonstrating how multiple game roles can maintain independent memory spaces and extract memories from their own first-person perspectives. |
| 6 | + |
| 7 | +## Key Features |
| 8 | + |
| 9 | +### 1. Multi-View Memory Integration |
| 10 | +- **World Memory**: Stores global game events accessible to all roles (`cube_{user_id}_world`) |
| 11 | +- **Role Memory**: Each role has an independent memory space (`cube_{role_id}_{role_id}`) |
| 12 | +- **Automatic Mode Detection**: MemOS automatically enables `multi_view` mode when messages contain `role_id` or `role_name` fields |
| 13 | + |
| 14 | +### 2. Memory Flow |
| 15 | +``` |
| 16 | +GameService.act |
| 17 | + ├─ add_event (world memory write with role_id/role_name) |
| 18 | + ├─ search (world memory retrieval) |
| 19 | + └─ CompanionBrain.generate |
| 20 | + ├─ search_memory (role memory retrieval) |
| 21 | + ├─ chat_complete (LLM generation) |
| 22 | + └─ add_memory (role memory write-back with multi-view extraction) |
| 23 | +``` |
| 24 | + |
| 25 | +### 3. Core Implementation |
| 26 | + |
| 27 | +**MemoryAdapter** (`adapters/memory.py`): |
| 28 | +- Wraps MemOS API calls (`/product/add`, `/product/search`, `/product/chat/complete`) |
| 29 | +- Supports multi-view memory writing and retrieval |
| 30 | +- Handles world memory and role memory isolation |
| 31 | + |
| 32 | +**CompanionBrain** (`adapters/companion.py`): |
| 33 | +- Generates NPC dialogue based on role memory |
| 34 | +- Uses MemOS `chat_complete` API with role-specific context |
| 35 | +- Writes dialogue back to role memory with multi-view extraction |
| 36 | + |
| 37 | +**GameService** (`services/game_service.py`): |
| 38 | +- Coordinates game logic with memory system |
| 39 | +- Formats and writes game events to memory |
| 40 | +- Retrieves world memory for NPC dialogue context |
| 41 | + |
| 42 | +## Technical Details |
| 43 | + |
| 44 | +### Multi-View Memory Detection |
| 45 | +When messages contain `role_id` or `role_name`, MemOS automatically: |
| 46 | +1. Switches to `multi_view` mode |
| 47 | +2. Extracts memories from the role's first-person perspective |
| 48 | +3. Filters irrelevant information |
| 49 | +4. Maintains role memory isolation |
| 50 | + |
| 51 | +### Memory Namespace |
| 52 | +- Role memory: `cube_{role_id}_{role_id}` |
| 53 | +- World memory: `cube_{user_id}_world` |
| 54 | + |
| 55 | +## Files Changed |
| 56 | + |
| 57 | +- `demos/AOTAI_Hike/backend/aotai_hike/adapters/memory.py` - MemOS memory adapter |
| 58 | +- `demos/AOTAI_Hike/backend/aotai_hike/adapters/companion.py` - NPC dialogue generation |
| 59 | +- `demos/AOTAI_Hike/backend/aotai_hike/services/game_service.py` - Game service with memory integration |
| 60 | +- `demos/AOTAI_Hike/backend/aotai_hike/router.py` - API routes |
| 61 | +- `demos/AOTAI_Hike/README.md` - Updated documentation |
| 62 | +- `demos/AOTAI_Hike/INTRODUCTION_ZH.md` - Chinese documentation |
| 63 | +- `demos/AOTAI_Hike/INTRODUCTION_EN.md` - English documentation |
| 64 | + |
| 65 | +## Related Issue |
| 66 | + |
| 67 | +Closes #[ISSUE_NUMBER] |
| 68 | + |
| 69 | +## Documentation |
| 70 | + |
| 71 | +- [Memory Integration Guide](./backend/MEMORY_INTEGRATION.md) |
| 72 | +- [Complete Introduction (中文)](./INTRODUCTION_ZH.md) |
| 73 | +- [Complete Introduction (English)](./INTRODUCTION_EN.md) |
0 commit comments