### Override SillyTavern Config with Command Line Arguments
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Demonstrates how to override `config.yaml` settings using command-line arguments when starting the server. This allows for dynamic configuration changes without editing the configuration file directly. Examples include setting the port, enabling remote listening, and configuring SSL or basic authentication.
```bash
# Start with custom port and enable remote listening
node server.js --port 8000 --listen true
# Enable SSL
node server.js --ssl --certPath ./certs/cert.pem --keyPath ./certs/privkey.pem
# Enable basic authentication
node server.js --basicAuthMode true
# Using npm start
npm run start -- --port 8000 --listen true
# Windows batch file
Start.bat --port 8000 --listen false
```
--------------------------------
### Ollama Integration Setup
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Instructions for setting up Ollama to work with SillyTavern. This includes pulling a model, running the Ollama server, and configuring SillyTavern to connect to the Ollama API.
```bash
# Install Ollama from https://ollama.com/
# Pull a model
ollama pull llama3
# Run Ollama server (default port 11434)
ollama serve
# In SillyTavern:
# 1. Select "Chat Completion" API type
# 2. Select "Ollama" source
# 3. Enter URL: http://localhost:11434
# config.yaml - Ollama settings
ollama:
keepAlive: -1 # -1 = keep loaded indefinitely, 0 = unload immediately
batchSize: -1 # -1 = model default
```
--------------------------------
### STscript: Basic Commands and Pipes
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Demonstrates basic STscript commands and how to pipe output from one command to the input of another. Includes examples for 'Hello World', user input, displaying popups, and creating buttons.
```stscript
// Hello World - basic pipe usage
/pass Hello, World! | /echo
// User input
/input Enter your name | /echo Hello, my name is {{pipe}}
// Display popup with HTML formatting
/popup Warning! This is important.
// Buttons for user choice
/setglobalvar key=options ["Option A", "Option B", "Option C"] |
/buttons labels=options Choose an option: |
/echo You selected: {{pipe}}
```
--------------------------------
### Launch KoboldCpp with GGUF Model
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Launches KoboldCpp with a specified GGUF model and sets the API port. This is the basic command to get KoboldCpp running for use with SillyTavern.
```bash
./koboldcpp --model /path/to/model.gguf --port 5001
```
--------------------------------
### Regex Key Example (Javascript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Defines a regular expression to trigger content activation. This example uses Javascript regex syntax to match phrases related to a character wielding a sword. The 'i' flag makes the match case-insensitive.
```javascript
Keys: /{{char}} (?:wields|holds|draws) (?:the )?sword/i
```
--------------------------------
### Text-to-Speech (TTS) Commands (STScript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Demonstrates how to use the `/speak` command for text-to-speech integration. It shows how to specify a voice and provides examples of supported TTS providers and configuration options within the Extensions panel.
```stscript
// Speak text with TTS
/speak voice="Character" Hello, how are you today?
// TTS is configured in Extensions panel:
// - Supported: ElevenLabs, Silero, System TTS, AllTalk
// - Map character names to specific voices
// - Auto-generate speech for AI responses
```
--------------------------------
### Web Search Integration (STScript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Illustrates the use of the `/websearch` command to retrieve information from the web and inject it into the chat. The example shows how to perform a search and then use the `{{pipe}}` variable to insert the results into a subsequent message.
```stscript
// Search the web and inject results
/websearch current weather in Tokyo |
/inject id=weather position=chat depth=0 Weather info: {{pipe}}
// Web Search extension provides:
// - Real-time information retrieval
// - Configurable search providers
// - Result summarization
```
--------------------------------
### STscript: Math Operations
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Provides examples of performing various mathematical operations in STscript, including basic arithmetic, math functions, min/max, random number generation, and a practical example of calculating circle area.
```stscript
// Basic arithmetic
/add 10 20 30 | /echo Sum: {{pipe}}
/mul 5 4 3 | /echo Product: {{pipe}}
/sub 100 25 | /echo Difference: {{pipe}}
/div 100 4 | /echo Quotient: {{pipe}}
/mod 17 5 | /echo Remainder: {{pipe}}
/pow 2 8 | /echo 2^8 = {{pipe}}
// Math functions
/sqrt 144 | /echo Square root: {{pipe}}
/abs -42 | /echo Absolute value: {{pipe}}
/round 3.7 | /echo Rounded: {{pipe}}
/sin 1.5708 | /echo Sin(pi/2): {{pipe}}
/cos 0 | /echo Cos(0): {{pipe}}
/log 2.718 | /echo Ln(e): {{pipe}}
// Min/max
/max 5 2 9 1 | /echo Maximum: {{pipe}}
/min 5 2 9 1 | /echo Minimum: {{pipe}}
// Random number generation
/rand | /echo Random 0-1: {{pipe}}
/rand from=1 to=100 round=floor | /echo Random integer 1-100: {{pipe}}
// Calculate circle area (pi * r^2)
/setglobalvar key=PI 3.1415 |
/setvar key=r 50 |
/mul r r PI | /round |
/echo Circle area: {{pipe}}
```
--------------------------------
### Run SillyTavern with Docker
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Guide to running SillyTavern using Docker. This method involves pulling the official Docker image and running it as a container, ensuring persistent data storage through volume mounting. Access the application via http://localhost:8000.
```bash
# Pull and run the official Docker image
docker pull ghcr.io/sillytavern/sillytavern:latest
docker run -d \
--name sillytavern \
-p 8000:8000 \
-v /path/to/data:/home/node/app/data \
ghcr.io/sillytavern/sillytavern:latest
# Access at http://localhost:8000
```
--------------------------------
### STscript: Conditional Logic and Flow Control
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Explains how to implement conditional logic and control the flow of STscripts using if-else statements, while loops, and times loops. Includes examples of different comparison rules and loop control mechanisms.
```stscript
// If-else conditional
/input What's your favorite drink? |
/if left={{pipe}} right="coffee" rule=eq
else="/echo You should try coffee!"
"/echo Great choice, coffee lover!"
// Boolean comparison rules:
// eq (equals), neq (not equals), lt (less than), gt (greater than)
// lte (less or equal), gte (greater or equal), not (negation)
// in (contains substring), nin (not contains)
// While loop with guard (max 100 iterations by default)
/setvar key=i 0 |
/while left=i right=10 rule=lt "/addvar key=i 1" |
/echo Final value: {{getvar::i}}
// Times loop
/times 5 "/echo Iteration {{timesIndex}}"
// Disable guard for unlimited iterations (use carefully)
/while left=i right=1000 rule=lt guard=off "/addvar key=i 1"
// Break out of loops early
/times 10 {:
/echo {{timesIndex}} |
/if left={{timesIndex}} rule=gt right=5 {:
/break
:}
:}
```
--------------------------------
### Clone SillyTavern Repository (Git)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Instructions for cloning the SillyTavern repository using Git. Users can choose between the stable 'release' branch or the potentially unstable 'staging' branch. Ensure NodeJS LTS and Git for Windows are installed prior to cloning.
```bash
# Install NodeJS LTS from https://nodejs.org/en
# Install Git for Windows from https://gitforwindows.org/
# Clone the release branch (recommended for most users)
git clone https://github.com/SillyTavern/SillyTavern -b release
# Or clone staging branch (latest features, may be unstable)
git clone https://github.com/SillyTavern/SillyTavern -b staging
# Start SillyTavern (Windows)
cd SillyTavern
Start.bat
# Start SillyTavern (Linux/Mac)
cd SillyTavern
./start.sh
```
--------------------------------
### Configure OpenAI API Connection (JavaScript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Details on connecting SillyTavern to OpenAI's API for models like GPT-4. Users need to configure this in the UI's API Connections panel, selecting 'Chat Completion' and 'OpenAI' as the source, then entering their API key. An example of the internal API request format is provided.
```javascript
// API Connection Settings in SillyTavern UI:
// 1. Go to API Connections panel (plug icon)
// 2. Select "Chat Completion" from dropdown
// 3. Select "OpenAI" as the source
// 4. Enter your API key from https://platform.openai.com/
// Example API request format (internal):
{
"model": "gpt-4-turbo",
"messages": [{"role": "system", "content": "Character description and instructions"},
{"role": "user", "content": "User message"},
{"role": "assistant", "content": "Previous AI response"}
],
"temperature": 0.7,
"max_tokens": 500
}
```
--------------------------------
### STscript: Closures and Scoped Variables
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Details the use of closures in STscript for creating reusable blocks of code and managing variable scope. Covers anonymous functions, closures with parameters, immediately executed closures, and recursive examples.
```stscript
// Basic closure (anonymous function)
/let myClosure {:
/echo This is my closure |
/delay 500
:} |
/:myClosure
// Closure with parameters
/let greet {: name="World"
/echo Hello, {{var::name}}!
:} |
/:greet name="Alice"
// Immediately executed closure
/if left={:/len foo:}() rule=eq right={:/len bar:}() "/echo Same length!"
// Recursive factorial using closures
/let fact {: n=
/if left={{var::n}} rule=gt right=1
else={: /return 1 :}
{:
/sub {{var::n}} 1 |
/:fact n={{pipe}} |
/mul {{var::n}} {{pipe}}
:}
:} |
/input Calculate factorial of: |
/:fact n={{pipe}} |
/echo Result: {{pipe}}
```
--------------------------------
### World Info Management Commands (stscript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Commands for dynamically managing World Info (lorebook) entries. Includes functions to get chat-bound books, find entries by keyword, retrieve entry content, create new entries, and update existing entry fields.
```stscript
// Get chat-bound World Info file
/getchatbook | /setvar key=chatLore
// Find entry by keyword
/findentry file={{getvar::chatLore}} field=key "Shadowfang" |
/setvar key=entryUID
// Get entry content
/getentryfield file={{getvar::chatLore}} field=content {{getvar::entryUID}} |
/echo {{pipe}}
// Create new entry
/createentry file={{getvar::chatLore}} key="Dragon"
A fearsome red dragon guards the mountain pass. |
/echo Created entry with UID: {{pipe}}
// Update entry field
/setentryfield file={{getvar::chatLore}} uid={{getvar::entryUID}}
field=content "Updated lore content here"
// Set multiple keywords
/setentryfield file={{getvar::chatLore}} uid=123
field=key "sword,weapon,legendary"
```
--------------------------------
### Character Card Structure (YAML)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Defines character behavior and personality using structured fields within a character card. Key fields include Name, Description, Personality, First Message, Scenario, and Example Messages.
```yaml
# Character Card Structure:
# Name: Short, used in every message
Name: Seraphina
# Description: Always included in prompt (permanent tokens)
Description: |
Seraphina is a 25-year-old elven mage with silver hair and violet eyes.
She specializes in illusion magic and works as a traveling performer.
Personality: Witty, curious, slightly mischievous but kind-hearted.
# Personality Summary: Brief traits
Personality: playful, intelligent, mysterious, caring
# First Message: Sets conversation tone and style
First Message: |
*A shimmer of light dances across your vision as a figure materializes
from thin air* Well, well... a visitor! *She tilts her head with a
curious smile* I don't get many guests in my little corner of reality.
What brings you to seek out an illusionist?
# Scenario: Context and setting
Scenario: |
The story takes place in a medieval fantasy world. You've sought out
Seraphina to learn about a mysterious artifact that's been causing
strange occurrences in your village.
# Example Messages: Show conversation style (uses separator)
Example Messages: |
{{user}}: Can you teach me magic?
{{char}}: *She laughs melodically* Teach you? Magic isn't taught,
darling—it's awakened. *Her fingers trail sparks of light* But
perhaps I can help coax it out of you... for a price.
{{user}}: What's your price?
{{char}}: *A mischievous glint in her eye* Nothing too terrible.
Just... a story. Tell me something true about yourself, something
you've never told anyone else.
```
--------------------------------
### Launch KoboldCpp with CPU Offloading
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Launches KoboldCpp with a model, enabling GPU offloading for users with limited VRAM. The `gpulayers` parameter specifies how many layers to offload to the GPU.
```bash
./koboldcpp --model model.gguf --gpulayers 20 --contextsize 4096
```
--------------------------------
### Configure SillyTavern with Environment Variables
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Instructions for configuring SillyTavern using environment variables, which take precedence over `config.yaml` settings. Variables should be prefixed with `SILLYTAVERN_`. This method is useful for containerized environments or automated deployments. Alternatively, a `.env` file can be used with Node.js v20+.
```bash
# Set environment variables (prefix with SILLYTAVERN_)
export SILLYTAVERN_PORT=8000
export SILLYTAVERN_LISTEN=true
export SILLYTAVERN_WHITELIST='["127.0.0.1", "::1", "192.168.1.100"]'
# Start server
node server.js
# Or use .env file (Node.js v20+)
echo 'SILLYTAVERN_PORT=8000' > .env
node --env-file=.env server.js
```
--------------------------------
### Configure SillyTavern Server Settings (config.yaml)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Configuration options for SillyTavern's server, managed via the `config.yaml` file. This includes network settings like listening port and protocol (IPv4/IPv6), SSL configuration, IP whitelisting, and basic authentication. Multi-user accounts and session timeouts can also be adjusted.
```yaml
# config.yaml - Basic network configuration
listen: false # Set to true to allow remote connections
port: 8000 # Server port (1-65535)
protocol:
ipv4: true # Enable IPv4
ipv6: false # Enable IPv6
# SSL Configuration
ssl:
enabled: false
keyPath: "./certs/privkey.pem"
certPath: "./certs/cert.pem"
# IP Whitelist
whitelistMode: true
whitelist: ["::1", "127.0.0.1"]
# Basic Authentication
basicAuthMode: false
basicAuthUser:
username: "user"
password: "password"
# Multi-user mode
enableUserAccounts: false
sessionTimeout: -1 # -1 = disabled, 0 = browser close, >0 = seconds
```
--------------------------------
### World Info Activation Settings (YAML)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Configures how World Info entries are scanned and activated within the chat. Settings include scan depth, context budget, case sensitivity, and recursive scanning behavior.
```yaml
# World Info Activation Settings (in UI):
Scan Depth: 5 # Messages to scan (0 = only recursive/constant)
Context Budget: 2048 # Max tokens for World Info
Min Activations: 0 # Search entire chat until N entries found
Max Recursion Steps: 0 # Limit recursive activation depth (0 = unlimited)
Case Sensitive: false # Require exact case matching
Match Whole Words: true # Prevent partial word matches
Recursive Scan: true # Allow entries to activate other entries
```
--------------------------------
### Quick Reply Management Commands (stscript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Commands for programmatically creating and managing quick reply buttons. Allows creation, updating, deletion, and execution of quick replies, as well as preset management.
```stscript
// Create a quick reply button
/qr-create set=MyPreset label="Greet" /echo Hello!
// Create with auto-execution options
/qr-create set=MyPreset label="AutoGreet"
hidden=true startup=true user=false bot=true
title="Auto greeting on AI message"
/echo AI just responded!
// Update existing quick reply
/qr-update set=MyPreset label="Greet" newlabel="Say Hi" /echo Hi there!
// Delete quick reply
/qr-delete set=MyPreset label="Say Hi"
// Run a quick reply by label
/run MyPreset.MyButton
// Create/update preset
/qr-presetadd slots=5 enabled=true MyNewPreset
```
--------------------------------
### World Info Entry Configuration (YAML)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Configuration for World Info entries, defining keywords that trigger the entry. Keywords can be comma-separated strings or regular expressions.
```yaml
# World Info Entry Configuration:
# Keywords: Trigger the entry (comma-separated or regex)
Keys: "Shadowfang, the cursed blade, ancient sword"
```
--------------------------------
### STscript: Variables and Data Storage
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Shows how to use local and global variables in STscript for storing and manipulating data. Covers setting, incrementing/decrementing, accessing, and clearing variables, as well as handling arrays and objects.
```stscript
// Local variables (saved to current chat metadata)
/setvar key=counter 0 |
/addvar key=counter 1 |
/echo Counter is now: {{getvar::counter}}
// Increment/decrement shortcuts
/incvar counter | /echo {{pipe}}
/decvar counter | /echo {{pipe}}
// Global variables (saved to settings.json, available everywhere)
/setglobalvar key=username John |
/echo Hello, {{getglobalvar::username}}!
// Arrays and objects
/setvar key=fruits ["apple", "banana", "orange"] |
/len fruits | /echo Array has {{pipe}} items
// Access array elements by index
/getvar key=fruits index=0 | /echo First fruit: {{pipe}}
// Cleanup
/flushvar counter |
/flushglobalvar username
```
--------------------------------
### Configure Claude API Settings (config.yaml)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Configuration options specific to connecting with Anthropic's Claude API, managed within `config.yaml`. This includes settings for enabling and controlling prompt caching, which can improve performance but should be used cautiously. The `extendedTTL` option adjusts the cache Time To Live.
```yaml
# config.yaml - Claude-specific settings
claude:
enableSystemPromptCache: false # Enable prompt caching (use cautiously)
cachingAtDepth: -1 # -1 = disabled, 0+ = message history depth
extendedTTL: false # Use 1h TTL instead of 5m (costs more)
# Note: Use prefills for response guidance
# See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/prefill-claude-s-response
```
--------------------------------
### ComfyUI Workflow Configuration (JSON)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Defines a custom image generation workflow for ComfyUI using JSON. This structure outlines the nodes and their connections, including model loading, latent image creation, prompt encoding, and sampling, with placeholders for dynamic values.
```json
{
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": "%scale%",
"denoise": "%denoise%",
"model": ["4", 0],
"negative": ["7", 0],
"positive": ["6", 0],
"sampler_name": "%sampler%",
"scheduler": "%scheduler%",
"seed": "%seed%",
"steps": "%steps%"
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "%model%"
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": "%height%",
"width": "%width%"
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": ["4", 1],
"text": "%prompt%"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": ["4", 1],
"text": "%negative_prompt%"
}
}
}
```
--------------------------------
### LLM Text Generation Commands (stscript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Commands to generate text using connected LLM APIs, with options for character context, raw prompts, custom stop sequences, and triggering normal generation. Outputs can be echoed, displayed in popups, or sent as character messages.
```stscript
// Generate with character context
/gen Write a haiku about autumn |
/echo {{pipe}}
// Generate without character context (raw prompt)
/genraw lock=on Write a one-sentence summary of machine learning. |
/popup AI Says:
{{pipe}}
// Custom stop sequences
/genraw stop=["END", "STOP"] Tell me a short story. END |
/echo {{pipe}}
// Trigger normal generation (like clicking Send)
/trigger
// Insert generated text as character message
/genraw Write a greeting as a pirate. |
/sendas name={{char}} {{pipe}}
// Prompt injection for dynamic context
/inject id=mood position=chat depth=2 The user seems happy today.
/listinjects
/flushinjects
```
--------------------------------
### Image Generation Slash Commands (STScript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Provides a set of slash commands for generating images using integrated Stable Diffusion, ComfyUI, or DALL-E APIs. Commands cover various generation types, including character portraits, scenes, and free-form prompts, with options for negative prompts and silent generation.
```stscript
// Generate character portrait
/sd you
// Generate character face closeup
/sd face
// Generate user persona portrait
/sd me
// Generate scene from chat history
/sd scene
// Generate from last message
/sd last
// Generate from raw last message text
/sd raw_last
// Generate background image
/sd background
// Free-form prompt
/sd a majestic dragon flying over mountains at sunset
// With negative prompt
/sd negative="blurry, low quality" a detailed portrait of an elf warrior
// Include character-specific prefix
/sd {{charPrefix}}, riding a horse through the forest
// Silent generation (no chat message)
/sd quiet=true me | /send Here's my portrait: 
// View character gallery
/show-gallery
// Switch image style preset
/imagine-style "Anime Style"
```
--------------------------------
### Chat Message Management Commands (stscript)
Source: https://context7.com/yuanhuakk/sillytavern-docs-zh/llms.txt
Commands for reading, sending, and manipulating chat messages. Includes options to read message ranges, send messages as different roles, add swipe responses, hide/unhide messages, and delete messages.
```stscript
// Read messages
/messages 0-{{lastMessageId}} | /echo All messages: {{pipe}}
/messages names=off 0-5 | /echo First 6 messages without names
// Get last N messages
/setvar key=start {{lastMessageId}} |
/addvar key=start -2 |
/messages {{getvar::start}}-{{lastMessageId}}
// Send messages as different roles
/send Hello from me!
/sendas name={{char}} *waves* Hello there!
/sys The scene shifts to a moonlit garden.
/comment [OOC: This is a hidden note]
// Add swipe to last AI message
/addswipe Here's an alternative response.
// Hide/unhide messages from prompt
/hide 5-10
/unhide 5
// Delete messages (destructive!)
/del 3
/cut 5-7
/delname "Old Character"
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.