Prompt templates
Last updated
Last updated
Prompt templates are similar to a blueprint or a recipe that guides the creation of the specific prompt which will be used by the LLM to generate a response. The template is a mix of placeholders (like blanks you'd fill in on a form) and conditions (like directions on how to act).
Here's a non-technical breakdown of what you're seeing in the template:
Placeholders: These are like empty boxes waiting to be filled with specific information each time you chat with the AI. For example, {{user}}
would be replaced with the name of the person talking to the AI.
Conditions: These are "if-then" statements. If something is true, then the prompt gets filled out. Statements like {{#if <something>}} or {{eq <a> "b"}} are conditional statements.
Every time a user sends a chat message, our server fetches the chosen template for the conversation, fills in the placeholders with the right info from the character card and conversation settings, and then generates a response.
When you click "start chat", the Start Chat modal will come up (screenshot 1). Click the gear icon which will open the settings (screenshot 2). When you click the "change" button, the list of prompts will pop up (screenshot 3). Alternatively, you can click the template itself which will open the selected template.
You can also customize the prompt template in the middle of the conversation. To do so, open the conversation panel by clicking the three dots (screenshot 1) and then click "Edit conversation settings". This will open the conversation settings panel (screenshot 2). From there, you should be able to access the prompt templates the same way that you did in the previous section.
The format of the template is based on Handlebars.js, a widely-used templating format: https://handlebarsjs.com/guide/.
With Handlebars.js the placeholders are identified with double or triple braces around it, like {{user}}
. For example, {{user}}
is interpreted the same as {{ user }}
(with spaces around the name of the variable), or {{{user}}}
(triple braces), or {{{ user }}}
(triple braces with space around the name of the variable).
There are three different ways that placeholders will get filled out:
I. Values that a user modifies from their conversation settings.
II. Values that a user cannot modify, filled in dynamically per message,
Examples of I:
additional_character_prompt
: Users can configure additional character prompt in Conversation Settings -> Character -> Additional description.
scenario
: Users can configure custom scenario in Conversation Settings -> Chat -> Scenario Details.
user
: Users will use their profile name by default, but can also configure custom name in Conversation Settings -> Chat -> User Persona.
Examples of II:
current_time
: The current time will be filled out in the following format: "2023-11-08T18:22:44.232686-05:00". It is based on US Eastern time.
char
: The name of the character, which is determined by the character that the user engages with. To edit char
, you will need to either edit the character or create a new one.
conversation_streak_count
: The number of streaks that the user has at that moment.
chat_logs
: history of chat messages (automatically pruned depending on the length of the prompt available for generation).
Changing these parameters significantly change the output of the llm.
https://www.reddit.com/r/SillyTavernAI/comments/14wjgor/what_do_these_settings_do/
https://txt.cohere.com/llm-parameters-best-outputs-language-ai/
https://www.reddit.com/r/LocalLLaMA/comments/1343bgz/what_model_parameters_is_everyone_using/
The following is an example of how all of this works:
We currently expose three templates: Chat Template, Story Template, Story Choices Template.
Chat Template: This template is used to generate a chat message with a character.
Story Template: This template is used to generate a story message (in story mode).
Story Choices Template: This template is used to generate the chocies for a story (in story mode).
No! The following is an example of using minimal placeholders for creating a template for a simple dialogue:
(Modification of the prompt for Pygmalion AI, a different roleplaying product)
Depending on the placeholders that you put in, end users who user your prompt may or may not be able to control the dialogue. For example, the above prompt will not support the user using feeling or score mode since no feeling response will be injected into the chat. It also will not support the user's persona or name that they've customized on their conversation settings.
Depending on the type of experience that you want to provide, you can choose to use or not use certain placeholders.
The easiest way to get started with customizing the prompt template is by cloning existing prompts (such as the default prompts) and then changing the order of different variables or including specific instructions for LLMs.
additional_character_prompt
Can be empty or filled out by the user in conversation settings.
char
The name of the character based on the character card.
character_prompt
The character prompt based on the character card.
current_stage
For conversations with the score plugin enabled, the stage that the user is in with the character. One of the following: stranger, acquaintance, friend, sweetheart, lover
current_time
Current time in US Eastern time
is_feeling_enabled
Denotes whether the user enabled the feeling plugin.
is_score_enabled
Denotes whether the user enabled the feeling and score plugins.
scenario
The plot or story of the conversation.
user
The name of the user. This uses the name in the Profile for the user, or the name overridden in the conversation settings (User persona).
user_gender
The gender of the user. This uses the gender in the Profile for the user.
user_gender_exists
A True or False flag denoting whether the user_gender exists.
user_input
The most recent user input.
user_prompt
The prompt for the user. This uses the prompt overridden in the conversation settings.
user_prompt_exists
A True or False flag denoting whether the user_prompt exists.
chat_logs
The previous 10 chats between the user and the character.
conversation_streak_count
The number of streaks that the user has with the character for the conversation.
conversation_streak_count_exists
A True or False flag that can be used in an {{#if }} clause. Denotes whether the user is in a chatstreak with the character.
emotion
The emotion of the character. If the user has feeling and/or score enabled, it's the value displayed at the top of the conversation that says (feeling <emotion>).
fact_sheet
fact_sheet_exists
A True or False flag that can be used in an {{#if }} clause. Denotes whether a fact sheet exists.
feeling
The feeling of the character. If the user has feeling and/or score enabled, it's the value displayed at the bottom of the conversation that describes the way the charcter is feeling at the moment.
long_term_memory
long_term_memory_exists
A True or False flag that can be used in an {{#if }} clause. Denotes whether there exists long term memory for the conversation relevant to the user's message.
should_suggest_event
A True or False flag that can be used in an {{#if }} clause. Denotes whether the character should suggest the user a story. It's a feature built specifically for Rizz to introduce story mode automatically.
user_input
The most recent user input.
additional_story_prompt
The additional story prompt that a user can add in the conversation settings.
emotion
The emotion of the character. If the user has feeling and/or score enabled, it's the value displayed at the top of the conversation that says (feeling <emotion>).
feeling
The feeling of the character. If the user has feeling and/or score enabled, it's the value displayed at the bottom of the conversation that describes the way the charcter is feeling at the moment.
most_recent_chat_logs
The most recent chat log that existed before an story. This gets truncated as the story_logs goes over the context window.
state
One of "start", "ongoing, "end" - denotes whether the story just started, is ongoing, or is about to end. You can add custom directions based on which state the story is in.
story_logs
The story and user choices that were provided in the story.
story_theme
The theme of the story as shown on the settings of the theme.
user_input
The user's selected choice or the custom input.
most_recent_story
The story that just got generated for which the choices should be generated for.
story_logs
The story and user choices that were provided in the story.
story_theme
The theme of the story as shown on the settings of the theme.
If you require any assistance during the character creation process, please don't hesitate to contact our support team at [email protected] or on our Discord.
Refer to for more details.
Refer to for more details.