How to Install SillyTavern on a 768MB Racknerd VPS

My VPS configuration parameters
Racknerd-LADC02
CPU    1
Disk Space 10 GB
Memory 768 MB
Swap 768 MB
Operating System Debian 12 64 bit
If you have never bought a VPS before, see the specific operation process here (supports Alipay alipay)

Doesn't require too many resources; even with a self-used VPN ladder running, you can play SillyTavern at the same time.

1. Disk usage
Before installation:
root@rn-ladc02:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            336M     0  336M   0% /dev
tmpfs            71M  456K   71M   1% /run
/dev/vda1       9.1G  1.5G  7.2G  17% /
tmpfs           355M     0  355M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            71M     0   71M   0% /run/user/0

After installation:
root@rn-ladc02:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            336M     0  336M   0% /dev
tmpfs            71M  476K   71M   1% /run
/dev/vda1       9.1G  2.5G  6.1G  29% /
tmpfs           355M     0  355M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            71M     0   71M   0% /run/user/0

2. Memory usage
Before installation:
root@rn-ladc02:~# free -h
               total        used        free      shared  buff/cache   available
Mem:           709Mi       336Mi        52Mi       1.9Mi       434Mi       372Mi
Swap:          767Mi       3.5Mi       764Mi

After installation and running:
root@rn-ladc02:~# free -h
               total        used        free      shared  buff/cache   available
Mem:           709Mi       446Mi        66Mi       1.8Mi       316Mi       262Mi
Swap:          767Mi       126Mi       641Mi

3. Installation
Install node.js
apt update
apt install nodejs -y

Install SillyTavern
apt install git -y
git clone https://github.com/SillyTavern/SillyTavern -b release
cd SillyTavern
./start.sh

It will ask if you want to install npm and node.js
Answer y (I know this is strange; node.js and npm were clearly installed earlier. Ignore that, just answer y)
Terminal running start.sh, npm not installed prompt asking whether to install nodejs

When you see logs like the following, it means SillyTavern can run.
Compilation complete, SillyTavern listening on 127.0.0.1:8000

First, stop SillyTavern.  Ctrl + C

Next, we'll handle how to make your computer/phone able to access this SillyTavern.
I will use the https method, which requires you to have your own domain. 

4. Caddy reverse proxy
You need to have a domain name, and set up DNS resolution to point to your VPS's IP. 

Install caddy 
(If you used my script to set up a ladder and already installed caddy, skip this step)
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg --yes
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Edit Caddyfile 
nano /etc/caddy/Caddyfile
Caddy config reverse proxying st.icdyct.space to localhost:8000
(If you used my script to set up a ladder and already installed caddy, just append a section to the end of the Caddyfile)

Your domain
{
  reverse_proxy localhost:8000 {
    header_up Host {upstream_hostport}
  }
}

The 8000 is because SillyTavern listens on port 8000 by default.

Restart the caddy service
systemctl restart caddy

Now use your own browser to access https://your domain
You should see a page like this
Site shows Forbidden, edit config.yaml to remove the whitelist block
This page is displayed by SillyTavern, which means your caddy configuration is correct.

In order to use SillyTavern properly, we need to do some further configuration.

5. Modify the SillyTavern config file
nano ~/SillyTavern/config.yaml
(If you did not install SillyTavern in the user directory earlier, find the config file location yourself)

Modify the 4 configuration items shown in the image below, with the values as shown.
setting listen to true and enableForwardedWhitelist to false in nano

basicAuthMode set to true in config.yaml, username and password set by you
Set the username and password to whatever you like.

If you are a Linux newbie, you can also use these 5 commands.
sed -i '/^listen:/s/.*/listen: true/' ~/SillyTavern/config.yaml
sed -i '/^enableForwardedWhitelist:/s/.*/enableForwardedWhitelist: false/' ~/SillyTavern/config.yaml
sed -i '/^basicAuthMode: /s/.*/basicAuthMode: true/' ~/SillyTavern/config.yaml
sed -i '/^  username:/s/.*/  username: 你喜欢的用户名/' ~/SillyTavern/config.yaml
sed -i '/^  password:/s/.*/  password: 你喜欢的密码/' ~/SillyTavern/config.yaml

Restart SillyTavern
~/SillyTavern/start.sh

Now use your browser to visit https://your domain
A page like this should be displayed
Browser login prompt, enter the username and password just set

Log in with the username and password you just set.

Then you can see the SillyTavern interface.
SillyTavern welcome page with Language set to English and character name User

6. SillyTavern Settings
Set the language to Chinese
Arrow in the language dropdown pointing to Simplified Chinese

Set your own name
User role name field filled with Xiaoshuai, with a save button below

Your name will be displayed in the chat list afterwards.

Save.
Red arrow pointing to the save button

Set the API
Red box and arrow at top pointing to the plug icon to open API connection

For API, select Chat Completion
For Chat Completion Source, select Google AI Studio
You can apply for a free API key from Google.
Chat completion source set to Google AI Studio, key field shows missing API key



7. Apply for a Google AI Studio API key
Open a new page and visit https://aistudio.google.com/
Log in to your Google account
Choose to apply for an API key
Google AI Studio page with Get API key outlined in red

Create API key button highlighted in a red box

Copy this content and paste it into the API key field from the previous step.
API key generated popup with copy and close buttons

8. Test whether the API works properly
Connect and Send Test Message buttons highlighted in red boxes

If you see a green light and the command line shows results like this, the API is connected and working properly.
Key saved shown next to green light in status row, prompting Test Message to verify

Google AI Studio request and response in terminal, all safety category thresholds set to OFF

You can check the "Auto-connect to last server" option.
check auto-connect to last server

9. Start telling stories with the AI.
Click "Character" and select the character created by default in the tavern.
Character list with red boxes marking the sidebar icon and default character Seraphina

Enter "Can you speak Chinese?" in the dialog box.
Type Can you speak Chinese in the dialog box

Then you can start telling Chinese stories with the AI. For example,
Message input box at bottom of chat window

10. Run start.sh in the background
If you don't want the tavern to shut down when you disconnect from SSH, you need to find a way to run start.sh in the background.

I choose to use screen

Install 
apt install screen -y

Open a new screen
screen
Run start.sh
~/SillyTavern/start.sh
This way, even if your SSH connection drops, the tavern will not stop running.

For more usage of screen, such as resuming a previously opened screen on the next SSH connection, please Google it yourself or ask GPT. 

========

========
Please see the PDF of the story I told with the AI.
I think the word choice and phrasing at the micro level are quite rich, and the overall structure and design are roughly at the level of a children's bedtime story. Or at the level of children collaborating to tell a story.

========

See also


Comments