### Author's Note Example Source: https://kwaroran.github.io/docs/characterconfig/basic An example of an author's note used to guide the conversation path. ```text John will go to the park and meet his friend. ``` -------------------------------- ### Example Message for Character Haruhi Source: https://kwaroran.github.io/docs/characterconfig/advsettings Example messages are sent to the AI model to generate responses and are provided until the context is full. The snippet shows two example messages for a character named Haruhi, using to mark the start and {{user}}/{{char}} for speakers. It includes a {{random::apple,banana,orange}} syntax for random selection. ```plaintext {{user}}: hi, how are you? {{char}}: I'm doing great! {{user}}: hi, how are you? {{char}}: I'm eating {{random::apple,banana,orange}}. ``` -------------------------------- ### listenEdit example Source: https://kwaroran.github.io/docs/srp/lua Shows how to use listenEdit to append a prefix from state to the display message. ```lua listenEdit("editDisplay", function(triggerId, data) local prefix = getState(triggerId, "prefix") or "" return prefix .. data end) ``` -------------------------------- ### onInput callback example Source: https://kwaroran.github.io/docs/srp/lua Shows a Lua function that alerts when user input is received. ```lua function onInput(triggerId) alertNormal(triggerId, "input received!") end ``` -------------------------------- ### onButton callback example Source: https://kwaroran.github.io/docs/srp/lua Shows a Lua function that alerts when a button is clicked. ```lua function onButton(triggerId) alertNormal(triggerId, "button clicked!") end ``` -------------------------------- ### Apply @@depth decorator in lore entry prompt Source: https://kwaroran.github.io/docs/characterconfig/lorebook Place decorators at the start of the Prompt field, beginning with @@. This example sets the lore entry's depth to 0, making it more important. The decorator line is followed by a blank line and then the prompt text. ```plaintext @@depth 0 This is the prompt ``` -------------------------------- ### Markdown syntax examples for supported elements Source: https://kwaroran.github.io/docs/syntax/markdown Examples of Markdown syntax for bold, italic, strikethrough, lists, code, links, horizontal rules, headings, and tables. The output for horizontal rules, headings, and tables is not displayed on the Docs page. ```markdown **bold text** ``` ```markdown *italic text* ``` ```markdown ~~strikethrough text~~ ``` ```markdown 1. First item 2. Second item ``` ```markdown - First item - Second item ``` ```markdown `code` ``` ```markdown [text](url) ``` ```markdown --- ``` ```markdown # Heading 1 ## Heading 2 ### Heading 3 ``` ```markdown | Header 1 | Header 2 | | ----------- | ----------- | | Element 1 | Element 2 | ``` -------------------------------- ### {{#if}} example Source: https://kwaroran.github.io/docs/syntax/cbs Renders the content if the condition resolves to 1; otherwise an empty string replaces the block. ```plaintext {{#if {{equal::1::1}}}} Hello Alice! {{/if}} ``` -------------------------------- ### Character Description Format Example Source: https://kwaroran.github.io/docs/characterconfig/basic A recommended structure for character descriptions to help the AI understand attributes better. ```text Basic Information: - Name: John - Age: 25 - Occupation: Student Physical Description: - Height: 6'2" - Weight: 45kg - Hair: Brown - Eyes: Blue ``` -------------------------------- ### Combining bold and italic Source: https://kwaroran.github.io/docs/syntax/markdown Example of combining bold and italic formatting using triple asterisks. ```markdown ***bold and italic text*** ``` -------------------------------- ### Image syntax with title Source: https://kwaroran.github.io/docs/syntax/markdown Example of adding an image using Markdown syntax with a title. The documentation recommends using the `{{image::assetId}}` syntax instead. ```markdown ![foo](/url "title") ``` -------------------------------- ### getFullChat(triggerId) Source: https://kwaroran.github.io/docs/srp/lua Gets the full chat message in a specific format. ```APIDOC ## getFullChat(triggerId) ### Description Gets the full chat message in a specific format. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. ### Returns - A table of chat messages in the format: ``` { {role = "user", data = "user message"}, {role = "char", data = "char message"}, ... } ``` ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### {{#each}} example Source: https://kwaroran.github.io/docs/syntax/cbs Iterates over an array, substituting each element into {{slot::item}}. Rendering produces concatenated string without separators. ```plaintext {{#each {{array::chicken::pizza::hamburger}} item}} {{slot::item}} {{/each}} ``` ```plaintext chickenpizzahamburger ``` -------------------------------- ### getState(triggerId, key) Source: https://kwaroran.github.io/docs/srp/lua Gets the value of a state variable with the given key. ```APIDOC ## getState(triggerId, key) ### Description Gets the value of a state variable with the given key. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **key** (string) - Required - The key of the state variable. ### Returns - The value of the state variable. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### getChatLength(triggerId) Source: https://kwaroran.github.io/docs/srp/lua Gets the chat length. ```APIDOC ## getChatLength(triggerId) ### Description Gets the chat length. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. ### Returns - The number of chat messages. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### Escaping Markdown with backslashes Source: https://kwaroran.github.io/docs/syntax/markdown Example of using backslashes to escape Markdown syntax, so that `~~hello~~` is displayed literally instead of as strikethrough. ```markdown \~\~hello\~\~ ``` -------------------------------- ### setChat(triggerId, index, message) Source: https://kwaroran.github.io/docs/srp/lua Sets the chat message at the given index. Index starts from 0. ```APIDOC ## setChat(triggerId, index, message) ### Description Sets the chat message at the given index. Index starts from 0. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **index** (number) - Required - The index of the chat message (0-based). - **message** (string) - Required - The new message content. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### setChatRole(triggerId, index, role) Source: https://kwaroran.github.io/docs/srp/lua Sets the chat role at the given index. Index starts from 0. Role can be 'user' or 'char'. ```APIDOC ## setChatRole(triggerId, index, role) ### Description Sets the chat role at the given index. Index starts from 0. Role can be 'user' or 'char'. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **index** (number) - Required - The index of the chat message (0-based). - **role** (string) - Required - The role to set. Can be 'user' or 'char'. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### insertChat(triggerId, index, role, message) Source: https://kwaroran.github.io/docs/srp/lua Inserts a chat message at the given index with the given message and role. Index starts from 0. Role can be 'user' or 'char'. ```APIDOC ## insertChat(triggerId, index, role, message) ### Description Inserts a chat message at the given index with the given message and role. Index starts from 0. Role can be 'user' or 'char'. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **index** (number) - Required - The index at which to insert (0-based). - **role** (string) - Required - The role of the message. Can be 'user' or 'char'. - **message** (string) - Required - The message content. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### cutChat(triggerId, start, end) Source: https://kwaroran.github.io/docs/srp/lua Cuts the chat messages from start to end. Both start and end are 0-based indices. To cut only one message, use removeChat(triggerId, index). ```APIDOC ## cutChat(triggerId, start, end) ### Description Cuts the chat messages from start to end. Both start and end are 0-based indices. To cut only one message, use removeChat(triggerId, index). ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **start** (number) - Required - The starting index (0-based). - **end** (number) - Required - The ending index (0-based). ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### generateImage(triggerId, prompt, negative) Source: https://kwaroran.github.io/docs/srp/lua Generates an image with the given prompt and negative. Requires low level access. Returns the asset CBS (like `{{asset::assetId}}`). Async function; use :await() to wait for the result. ```APIDOC ## generateImage(triggerId, prompt, negative) ### Description Generates an image with the given prompt and negative. Requires low level access. Returns the asset CBS (like `{{asset::assetId}}`). Async function; use `generateImage(triggerId, prompt, negative):await()` to wait for the result. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **prompt** (string) - Required - The prompt for image generation. - **negative** (string) - Required - The negative prompt. ### Returns - The asset CBS string (e.g., `{{asset::assetId}}`). ### Notes - Requires low level access. - Async function; use `:await()` to wait for the result. - Works in all events except editDisplay. ``` -------------------------------- ### getChatVar(triggerId, key) Source: https://kwaroran.github.io/docs/srp/lua Gets the value of a chat variable with the given key. ```APIDOC ## getChatVar(triggerId, key) ### Description Gets the value of a chat variable with the given key. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **key** (string) - Required - The key of the chat variable. ### Returns - The value of the chat variable. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### removeChat(triggerId, index) Source: https://kwaroran.github.io/docs/srp/lua Removes the chat message at the given index. Index starts from 0. ```APIDOC ## removeChat(triggerId, index) ### Description Removes the chat message at the given index. Index starts from 0. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **index** (number) - Required - The index of the chat message to remove (0-based). ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### simpleLLM(triggerId, message) Source: https://kwaroran.github.io/docs/srp/lua Performs a simple LLM request with the given message. Requires low level access. Returns the response as a string. Async function; use :await() to wait for the result. ```APIDOC ## simpleLLM(triggerId, message) ### Description Performs a simple LLM request with the given message. Requires low level access. Returns the response as a string. Async function; use `simpleLLM(triggerId, message):await()` to wait for the result. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **message** (string) - Required - The message to send. ### Returns - The response as a string. ### Notes - Requires low level access. - Async function; use `:await()` to wait for the result. - Works in all events except editDisplay. ``` -------------------------------- ### log(message) Source: https://kwaroran.github.io/docs/srp/lua Logs a message to the console in JSON format, making arrays and objects display correctly in the devtools console. ```APIDOC ## log(message) ### Description Logs the message to the console in JSON format, making arrays and objects display correctly in the devtools console. ### Parameters - **message** (any) - Required - The message to log. ### Notes - Unlike `print`, this outputs as JSON format. - Does not require `triggerId`. ``` -------------------------------- ### getDescription(triggerId) Source: https://kwaroran.github.io/docs/srp/lua Returns the description of the current character. ```APIDOC ## getDescription(triggerId) ### Description Returns the description of the current character. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. ### Returns - The description of the current character. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### Character description template Source: https://kwaroran.github.io/docs/guides/making-bots Recommended format for the character description field. Fill in each attribute to define the character's identity and personality. ```plaintext Name: Origin: Age: Gender: Ethnicity: Appearance: Speech: Backstory: Occupation: Motivation: Moral Code: Personality: Traits: ``` -------------------------------- ### similarity(triggerId, source, value) Source: https://kwaroran.github.io/docs/srp/lua Performs a similarity sort between the source and value. Requires low level access. Async function; use :await() to wait for the result. ```APIDOC ## similarity(triggerId, source, value) ### Description Performs a similarity sort between the source and value. Requires low level access. Async function; use `similarity(triggerId, source, value):await()` to wait for the result. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **source** (array of strings) - Required - The source array of strings. - **value** (string) - Required - The value to compare against. ### Returns - An array of indices sorted by similarity. ### Notes - Requires low level access. - Async function; use `:await()` to wait for the result. - Works in all events except editDisplay. ``` -------------------------------- ### setDescription(triggerId, description) Source: https://kwaroran.github.io/docs/srp/lua Sets the description of the current character. ```APIDOC ## setDescription(triggerId, description) ### Description Sets the description of the current character. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **description** (string) - Required - The new description for the character. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### LLM(triggerId, data) Source: https://kwaroran.github.io/docs/srp/lua Performs an LLM request with the given data. Requires low level access. Returns the response. Async function; use :await() to wait for the result. ```APIDOC ## LLM(triggerId, data) ### Description Performs an LLM request with the given data. Requires low level access. Returns the response. Async function; use `LLM(triggerId, data):await()` to wait for the result. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **data** (table) - Required - The message format table: ``` { {role = "system", data = "system message"}, {role = "assistant", data = "char message"}, {role = "user", data = "user message"}, ... } ``` ### Returns - A table with the format: ``` { success = true, message = "response message", } ``` ### Notes - Requires low level access. - Async function; use `:await()` to wait for the result. - Works in all events except editDisplay. ``` -------------------------------- ### addChat(triggerId, role, message) Source: https://kwaroran.github.io/docs/srp/lua Adds a chat message with the given message and role. Role can be 'user' or 'char'. ```APIDOC ## addChat(triggerId, role, message) ### Description Adds a chat message with the given message and role. Role can be 'user' or 'char'. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **role** (string) - Required - The role of the message. Can be 'user' or 'char'. - **message** (string) - Required - The message content. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### setFullChat(triggerId, chat) Source: https://kwaroran.github.io/docs/srp/lua Sets the full chat message with the given chat table. ```APIDOC ## setFullChat(triggerId, chat) ### Description Sets the full chat message with the given chat table. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **chat** (table) - Required - The chat table in the format: ``` { {role = "user", data = "user message"}, {role = "char", data = "char message"}, ... } ``` ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### getCharacterFirstMessage(triggerId) Source: https://kwaroran.github.io/docs/srp/lua Returns the first message of the current character. ```APIDOC ## getCharacterFirstMessage(triggerId) ### Description Returns the first message of the current character. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. ### Returns - The first message of the current character. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### getBackgroundEmbedding(triggerId) Source: https://kwaroran.github.io/docs/srp/lua Returns the background embedding of the current character. ```APIDOC ## getBackgroundEmbedding(triggerId) ### Description Returns the background embedding of the current character. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. ### Returns - The background embedding of the current character. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### setChatVar(triggerId, key, value) Source: https://kwaroran.github.io/docs/srp/lua Sets a chat variable with the given key and value. The value must be a string. ```APIDOC ## setChatVar(triggerId, key, value) ### Description Sets a chat variable with the given key and value. The value must be a string. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **key** (string) - Required - The key of the chat variable. - **value** (string) - Required - The value to set. Must be a string. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### alertInput(triggerId, message) Source: https://kwaroran.github.io/docs/srp/lua Shows an input alert with the given message and returns the input value. ```APIDOC ## alertInput(triggerId, message) ### Description Shows an input alert with the given message and returns the input value. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **message** (string) - Required - The message to display in the alert. ### Returns - The input value entered by the user. ### Notes - Works in all events except editDisplay. ``` -------------------------------- ### setName(triggerId, name) Source: https://kwaroran.github.io/docs/srp/lua Sets the name of the current character. ```APIDOC ## setName(triggerId, name) ### Description Sets the name of the current character. ### Parameters - **triggerId** (string) - Required - The trigger ID obtained from the callback function. - **name** (string) - Required - The new name for the character. ### Notes - Works in all events except editDisplay. ```