The main controller class that manages the AI-powered interactive novel experience.
| Property | Type | Description |
|---|---|---|
| settings | AINovelSettings | Current active settings |
| firstStartWithAwake | bool | Whether to start on awake |
| loadAtAwakeIfSaveInfoExist | bool | Whether to load saves on awake |
| CurrentId | string | Gets or sets the current save ID |
| Event | Type | Description |
|---|---|---|
| onCurrentSettingsChanged | UnityEvent<string, string> | Triggered when settings change with parameters (currentSettingsName, historySettingsName) |
| onFirstInitialize | UnityEvent | Triggered when initialized for the first time |
| onLastChatUpdated | LastChatUpdateEvent | Triggered when the last chat message is updated |
| onLastChatUpdatedWithContent | UnityEvent<string> | Triggered when the last chat content is updated |
| onResponseReceived | ResponseEvent | Triggered when a response is received |
| onError | UnityEvent<string> | Triggered when an error occurs |
| onRequestComplete | UnityEvent | Triggered when a request is completed |
| onSaveChatHistory | UnityEvent | Triggered when chat history is saved |
| onLoadChatHistory | UnityEvent<List<ChatMessage>, List<ChatMessage>, List<ChatMessage>> | Triggered when chat history is loaded |
| onClearHistory | UnityEvent | Triggered when chat history is cleared |
| Method | Parameters | Return Type | Description |
|---|---|---|---|
| FirstStartAndInitialize | void | Initializes for a new story | |
| LoadAndInitialize | string id | void | Loads a saved story and initializes |
| Initialize | AINovelSettings inputSettings | void | Initializes with specified settings |
| UpdateAIClientSettings | void | Updates the AI client settings | |
| SendMessageToAI | string userMessage | void | Sends a user message to the AI |
| DeleteLastUserMessage | void | Deletes the last user message | |
| SaveChatHistory | string id | bool | Saves chat history with ID |
| LoadChatHistory | string id | bool | Loads chat history with ID |
| GetSaveInfo | string id | ChatHistorySaveInfo | Gets save info for ID |
| ListAllSaves | List<ChatHistorySaveInfo> | Lists all save files | |
| DeleteSavedChatHistory | string id | bool | Deletes a saved chat history |
| ResetStory | void | Resets the current story | |
| SetAPIKey | AIModelCategory category, string apiKey | void | Sets an API key |
| GetAPIKey | AIModelCategory category | string | Gets the current API key |
| ClearHistory | void | Clears all chat history | |
| GetChatHistory | List<ChatMessage> | Gets a copy of chat history |
Data structure representing a single message in the chat history.
| Property | Type | Description |
|---|---|---|
| role | string | "user" or "assistant" |
| content | string | Message content |
| Timestamp | DateTime | Creation timestamp |
| Method | Parameters | Return Type | Description |
|---|---|---|---|
| ToAIMessage | Message | Converts to AI message format |
Contains information about a chat history save file.
| Property | Type | Description |
|---|---|---|
| id | string | Unique save identifier |
| SaveDate | DateTime | Save creation date |
| messageCount | int | Active message count |
| totalMessageCount | int | Total message count |
| lastMessage | ChatMessage | Last message in backup |
| settingsName | string | Settings file name |
| Method | Parameters | Return Type | Description |
|---|---|---|---|
| MatchesSettings | AINovelSettings settings | bool | Checks if save matches settings |