<aside>
<img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />
Table Of Contents
</aside>
1. Core

- AIInteractiveNovelSystem Design Intent:
This system serves as the central engine for AI-powered interactive novels, orchestrating message exchanges with AI, prompt construction, and response processing. The core design focuses on combining various story elements (world settings, characters, variables, etc.) into structured prompts that provide AI with consistent narrative context. Beyond simple conversations, it integrates conversation management, save/load functionality, and memory optimization to deliver rich novel experiences.
- Prompt Construction Process:
Prompts are assembled hierarchically according to a defined order (promptOrder), combining master rules, character information, world settings, current variables, and previous dialogues. Each element serves a specific purpose, guiding the AI to generate responses based on a coherent understanding of the world and characters. The system optimizes by differentiating between complete conversation history and recent exchanges, maintaining long-term context through SuperMemory when necessary.
- Chat History Management:
The chat storage system manages conversations in three categories: Active (currently used), Backup (complete record), and SuperMemory (summaries). This design optimizes context efficiency and storage space while preserving the entire story progression. Each save file includes a unique ID and settings information to manage compatibility between various story branches and configurations.
Core
2. Regex
- Design Intent:
The Regex system functions as a flexible template engine for inserting dynamic content into prompts. It allows developers to easily incorporate real-time information such as variables, game states, and UI elements. Using
{key}
placeholder format, developers can create prompt templates that are replaced with the latest data during execution.
- Regex Pattern Types:
The system supports two primary pattern types: 1) static text replacement and 2) dynamic value extraction through GameObject references. The latter enables referencing component properties of specific GameObjects at runtime, naturally integrating game state and UI elements into prompts.
Regex
3. LoreBook

- Keyword-Based Story Information Management:
LoreBook is a knowledge management system utilizing keyword triggers to selectively include relevant world-building and story information in the prompt based on conversation context. This enables more efficient token usage compared to always including all background information, while still providing appropriately deep context.
- Matching Algorithm:
The system employs a sophisticated keyword matching algorithm to identify relevant keywords in recent conversations. Short words use exact matching, while longer words utilize N-gram based fuzzy matching for greater flexibility. Matched items are sorted by relevance score and included in the prompt up to the configured limit.
LoreBook
4. Sequence