SillyDevTools [WIP]
Do you hate STScript and wish you could just use JS instead? Do you want to have some handy tools too because you can't do JS? This is the thing for you.
Disclaimer
I can guarantee compatibility with ST versions around 1.12.7 (as of 2024-10-04) but I may not have the time to fix compatibility issues, should they arrive. Such is life. It's also not optimized for mobiles because stupid phoneposters don't deserve it and also not coincidentally I'm too lazy to do it.
Introduction
I have put together a basic Tampermonkey script (though I'm sure you can use other extensions to load it too) to allow native JS execution in SillyTavern, a very basic SDK for you to do so, and a visual devtool/utility set. From where you can also execute JS.
You can find it here: https://stscript.neocities.org/sillydevtools.js
Running the script correctly, you should see a popup allowing the running of custom JS. Be wary that if someone sends you a modified version of this script, they'll be allowed to run JS in your browser regardless of the popup. Otherwise if you press yes, a success snackbar should be shown.
There are two main things you can do with this:
- Use the devtools as they are
- Use the SDK to run your own scripts
DevTools
After going through the popup and loading the script, you should see a new module in the top right corner of your screen. Clicking on it will open the DevTools sidebar. There are some things here you can play around with, both while building your cards or scripts, and while using the cards normally.
Variables
This is nothing special, allows you to see the variables affecting the current conversation.
Injects
Same as variables, it loads the injects for you. Minus the author's note or lorebook stuff that you can access otherwise.
System messages
This section lets you send system/narrator messages.
Execute JS
Possibly the most interesting bit of the whole ordeal. This tool allows you to run custom JS in place, and gives you a bunch of utils/data as the first param of the callback. Check out the init method of the service class in the code to see all the things you have access to. You can also easily extend this list by looking up which modules export what variables, methods, etc.
As noted within the tool, NEVER run JS code you don't trust. Or you'll regret it.
Genraw
It's the same thing as the /genraw
slash command, just more usable. It will automatically send the result as a narrator message into the conversation.
Summarization
This is the piƩce de resistance, and the whole reason why I did this. Using genraw, this section will allow you to execute some sort of CoT message to do a summerization or information retrieval task independently of the characters in the conversation. This makes it easier to edit and delete the generated CoT bits, and makes it easier to edit or reroll the characters' messages that follow. It also gives you better control over response sizes, I guess.
Using the SDK
In the script, there is a config at the very top with some callbacks. Most notably, onStart
. Whatever code you put in here will be executed after the user accepts the popup. You can build your own application here to run in parallel to SillyTavern. To help with this, I have started working on a sort of SDK. By default this will give you access to some of the internals of SillyTavern though the service context, but also to some utility functions that I have set up. Have fun.
Notes/Misc
I intend to work on this thing every now and then, to add more functionality and whatnot. So expect that. But things are kinda barebones. So also expect some jank. For instance, I was too lazy to properly disable buttons during generation, so now they just disappear and reappear. If something breaks, just reload the page.