This is an extension for SillyTavern that allows you to define pools of variables and use them in your character cards, lorebooks, and messages. The extension will replace placeholders with a randomly chosen value from the corresponding pool for the duration of a chat session.
- Variable Pools: Define named lists of values (e.g., a list of names, locations, or items).
- Random Selection: Automatically selects a random value from a pool when a placeholder is encountered.
- Session Caching: Remembers the chosen value for each variable throughout a single chat session, ensuring consistency.
- Number Ranges: Generate a random number within a specified range.
- Inline Randomization: Quickly get a random value from a temporary list without creating a permanent pool.
- Re-generation: Force a new random value to be selected for a variable that has already been stored in the session.
- User-Friendly UI: Easily add, edit, and delete your variable pools directly in the SillyTavern extensions menu.
- Auto-Cleaning: Automatically removes duplicate values from your pools and sorts them for you.
- In SillyTavern, go to the extensions menu (the wand icon on the top right).
- Click on "Download Extension".
- Paste the URL of this GitHub repository into the text field.
- Click "Download".
- The extension will be installed. You may need to restart SillyTavern for it to take full effect.
Once installed, a "Dynamic Variable Hooks" section will appear in your extensions settings panel.
- Expand the "Dynamic Variable Hooks" drawer.
- Click "Add Variable" to create a new pool.
- In the "Variable Name" field, enter a name for your pool (e.g.,
name
,city
). - In the "Comma-separated values" field, enter the possible values, separated by commas (e.g.,
Alice, Bob, Charlie
).
You can use your variables in any text field that is processed by SillyTavern (character definitions, lorebooks, chat messages, etc.) using the {{getrand::...}}
syntax.
To get a random value from a pool you created, use its name.
My name is {{getrand::name}} and I live in {{getrand::city}}.
To get a random number within an inclusive range, use the format min-max
.
I have {{getrand::1-10}} apples.
For temporary values you don't need to store in a pool, you can provide a pipe-separated list directly in the placeholder. A random value will be chosen from this list and will not be stored for the session.
Let's go to the {{getrand::beach|mountains|city}}.
If you have already used {{getrand::city}}
and it has been stored as "New York" for the session, you might want to get a new random city. Use regetrand
to force a new value to be selected from the pool, which will then overwrite the stored session value.
I used to live in {{getrand::city}}, but now I'm moving to {{regetrand::city}}!
In this example, the first placeholder might resolve to "New York", and the second might resolve to "Los Angeles". Any future calls to {{getrand::city}}
in the same session will now return "Los Angeles".
Here is an example of how you can use Dynamic Variable Hooks in a character's "Description" and "First Message" to make them more varied and dynamic each time you start a new chat.
You can place these placeholders directly into the character card fields in SillyTavern.
Description:
Name: {{getrand::char_name}}
Age: {{getrand::18-22}}
Occupation: {{getrand::Student|Barista|Artist|Musician}}
{{getrand::char_name}} is a college student living in {{getrand::city}}. She's known for her {{getrand::positive_trait}} personality but can sometimes be a bit {{getrand::negative_trait}}.
First Message:
*I sit down across from you at the {{getrand::cafe|library|park_bench}}, offering a shy smile.* "Hi, I'm {{getrand::char_name}}. Is this seat taken?"
For the above example to work, you would set up the following pools in the extension's settings:
Variable Name | Comma-separated values |
---|---|
char_name |
Alice, Bella, Chloe, Diana |
city |
Northwood, Silvercreek, Oakhaven, Maple Valley |
positive_trait |
bubbly, thoughtful, creative, adventurous |
negative_trait |
stubborn, forgetful, shy, impulsive |
This project is licensed under the MIT License.