- We're migrating SillyTavern - Extras to Python 3.11, some of the modules new will be incompatible with old Python 3.10 installs. To migrate using conda, please remove the old environment using
conda remove --name extras --all
and reinstall using the instructions below.
A set of APIs for various SillyTavern extensions.
You need to run the latest version of SillyTavern. Grab it here: How to install, Git repository
All modules, except for Stable Diffusion, run on the CPU by default. However, they can alternatively be configured to use CUDA (with --cuda
command line option). When running all modules simultaneously, you can expect a usage of approximately 6 GB of RAM. Loading Stable Diffusion adds an additional couple of GB to the memory usage.
Try on Colab (will give you a link to Extras API):
Colab link: https://colab.research.google.com/github/SillyTavern/SillyTavern/blob/release/colab/GPU.ipynb
Documentation: https://docs.sillytavern.app/
Default requirements.txt contains only basic packages for text processing
If you want to use the most advanced features (like Stable Diffusion, TTS), change that to requirements-complete.txt in commands below. See Modules section for more details.
If you run on Apple Silicon (M1/M2), use the requirements-silicon.txt file instead.
ERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects
Installing chromadb package requires one of the following:
- Have Visual C++ build tools installed: https://visualstudio.microsoft.com/visual-cpp-build-tools/
- Installing hnswlib from conda:
conda install -c conda-forge hnswlib
You must specify a list of module names to be run in the --enable-modules
command (caption
provided as an example). See Modules section.
- Open colab link
- Select desired "extra" options and start the cell
- Wait for it to finish
- Get an API URL link from colab output under the
### SillyTavern Extensions LINK ###
title - Start SillyTavern with extensions support: set
enableExtensions
totrue
in config.conf - Navigate to SillyTavern extensions menu and put in an API URL and tap "Connect" to load the extensions
There are some folks in the community having success running Extras on their phones via Ubuntu on Termux. This project wasn't made with mobile support in mind, so this guide is provided strictly for your information only: https://rentry.org/STAI-Termux#downloading-and-running-tai-extras
We will NOT provide any support for running this on Android. Direct all your questions to the creator of this guide.
PREREQUISITES
- Install Miniconda: https://docs.conda.io/en/latest/miniconda.html
- (Important!) Read how to use Conda: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html
- Install git: https://git-scm.com/downloads
EXECUTE THESE COMMANDS ONE BY ONE IN THE CONDA COMMAND PROMPT.
TYPE/PASTE EACH COMMAND INTO THE PROMPT, HIT ENTER AND WAIT FOR IT TO FINISH!
- Before the first run, create an environment (let's call it
extras
):
conda create -n extras
- Now activate the newly created env
conda activate extras
- Install Python 3.11
conda install python=3.11
- Install the required system packages
conda install git
- Clone this repository
git clone https://github.com/SillyTavern/SillyTavern-extras
- Navigated to the freshly cloned repository
cd SillyTavern-extras
- Install the project requirements
pip install -r requirements.txt
- Run the Extensions API server
python server.py --enable-modules=caption,summarize,classify
- Copy the Extra's server API URL listed in the console window after it finishes loading up. On local installs, this defaults to
http://localhost:5100
. - Open your SillyTavern config.conf file (located in the base install folder), and look for a line "
const enableExtensions
". Make sure that line has "= true
", and not "= false
". - Start your SillyTavern server
- Open the Extensions panel (via the 'Stacked Blocks' icon at the top of the page), paste the API URL into the input box, and click "Connect" to connect to the Extras extension server.
- To run again, simply activate the environment and run these commands. Be sure to the additional options for server.py (see below) that your setup requires.
conda activate extras
python server.py
- Install Python 3.11: https://www.python.org/downloads/release/python-3114/
- Install git: https://git-scm.com/downloads
- Clone the repo:
git clone https://github.com/SillyTavern/SillyTavern-extras
cd SillyTavern-extras
- Run
python -m pip install -r requirements.txt
- Run
python server.py --enable-modules=caption,summarize,classify
- Get the API URL. Defaults to
http://localhost:5100
if you run locally. - Start SillyTavern with extensions support: set
enableExtensions
totrue
in config.conf - Navigate to SillyTavern extensions menu and put in an API URL and tap "Connect" to load the extensions
Name | Description | Included in default requirements.txt |
---|---|---|
caption |
Image captioning | ✔️ Yes |
summarize |
Text summarization | ✔️ Yes |
classify |
Text sentiment classification | ✔️ Yes |
sd |
Stable Diffusion image generation | ❌ No (✔️ remote) |
silero-tts |
Silero TTS server | ❌ No |
edge-tts |
Microsoft Edge TTS client | ✔️ Yes |
chromadb |
Infinity context server | ❌ No |
Flag | Description |
---|---|
--enable-modules |
Required option. Provide a list of enabled modules. Expects a comma-separated list of module names. See Modules Example: --enable-modules=caption,sd |
--port |
Specify the port on which the application is hosted. Default: 5100 |
--listen |
Host the app on the local network |
--share |
Share the app on CloudFlare tunnel |
--secure |
Adds API key authentication requirements. Highly recommended when paired with share! |
--cpu |
Run the models on the CPU instead of CUDA. Enabled by default. |
--mps or --m1 |
Run the models on Apple Silicon. Only for M1 and M2 processors. |
--cuda |
Uses CUDA (GPU+VRAM) to run modules if it is available. Otherwise, falls back to using CPU. |
--cuda-device |
Specifies a CUDA device to use. Defaults to cuda:0 (first available GPU). |
--summarization-model |
Load a custom summarization model. Expects a HuggingFace model ID. Default: Qiliang/bart-large-cnn-samsum-ChatGPT_v3 |
--classification-model |
Load a custom sentiment classification model. Expects a HuggingFace model ID. Default (6 emotions): nateraw/bert-base-uncased-emotion Other solid option is (28 emotions): joeddav/distilbert-base-uncased-go-emotions-student For Chinese language: touch20032003/xuyuan-trial-sentiment-bert-chinese |
--captioning-model |
Load a custom captioning model. Expects a HuggingFace model ID. Default: Salesforce/blip-image-captioning-large |
--embedding-model |
Load a custom text embedding model. Expects a HuggingFace model ID. Default: sentence-transformers/all-mpnet-base-v2 |
--chroma-host |
Specifies a host IP for a remote ChromaDB server. |
--chroma-port |
Specifies an HTTP port for a remote ChromaDB server. Default: 8000 |
--sd-model |
Load a custom Stable Diffusion image generation model. Expects a HuggingFace model ID. Default: ckpt/anything-v4.5-vae-swapped Must have VAE pre-baked in PyTorch format or the output will look drab! |
--sd-cpu |
Force the Stable Diffusion generation pipeline to run on the CPU. SLOW! |
--sd-remote |
Use a remote SD backend. Supported APIs: sd-webui |
--sd-remote-host |
Specify the host of the remote SD backend Default: 127.0.0.1 |
--sd-remote-port |
Specify the port of the remote SD backend Default: 7860 |
--sd-remote-ssl |
Use SSL for the remote SD backend Default: False |
--sd-remote-auth |
Specify the username:password for the remote SD backend (if required) |
ChromaDB is a blazing fast and open source database that is used for long-term memory when chatting with characters. It can be run in-memory or on a local server on your LAN.
NOTE: You should NOT run ChromaDB on a cloud server. There are no methods for authentication (yet), so unless you want to expose an unauthenticated ChromaDB to the world, run this on a local server in your LAN.
Run the extras server with the chromadb
module enabled (recommended).
Use this if you want to use ChromaDB with docker or host it remotely. If you don't know what that means and only want to use ChromaDB with ST on your local device, use the 'in-memory' instructions instead.
Prerequisites: Docker, Docker compose (make sure you're running in rootless mode with the systemd service enabled if on Linux).
Steps:
- Run
git clone https://github.com/chroma-core/chroma chromadb
andcd chromadb
- Run
docker-compose up -d --build
to build ChromaDB. This may take a long time depending on your system - Once the build process is finished, ChromaDB should be running in the background. You can check with the command
docker ps
- On your client machine, specify your local server ip in the
--chroma-host
argument (ex.--chroma-host=192.168.1.10
)
If you are running ChromaDB on the same machine as SillyTavern, you will have to change the port of one of the services. To do this for ChromaDB:
- Run
docker ps
to get the container ID and thendocker container stop <container ID>
- Enter the ChromaDB git repository
cd chromadb
- Open
docker-compose.yml
and look for the line starting withuvicorn chromadb.app:app
- Change the
--port
argument to whatever port you want. - Look for the
ports
category and change the occurrences of8000
to whatever port you chose in step 4. - Save and exit. Then run
docker-compose up --detach
- On your client machine, make sure to specity the
--chroma-port
argument (ex.--chroma-port=<your-port-here>
) along with the--chroma-host
argument.
GET /api/modules
None
{"modules":["caption", "classify", "summarize"]}
POST /api/caption
{ "image": "base64 encoded image" }
{ "caption": "caption of the posted image" }
POST /api/summarize
{ "text": "text to be summarize", "params": {} }
{ "summary": "summarized text" }
Name | Default value |
---|---|
temperature |
1.0 |
repetition_penalty |
1.0 |
max_length |
500 |
min_length |
200 |
length_penalty |
1.5 |
bad_words |
["\n", '"', "*", "[", "]", "{", "}", ":", "(", ")", "<", ">"] |
POST /api/classify
{ "text": "text to classify sentiment of" }
{
"classification": [
{
"label": "joy",
"score": 1.0
},
{
"label": "anger",
"score": 0.7
},
{
"label": "love",
"score": 0.6
},
{
"label": "sadness",
"score": 0.5
},
{
"label": "fear",
"score": 0.4
},
{
"label": "surprise",
"score": 0.3
}
]
}
NOTES
- Sorted by descending score order
- List of categories defined by the summarization model
- Value range from 0.0 to 1.0
POST /api/image
{ "prompt": "prompt to be generated", "sampler": "DDIM", "steps": 20, "scale": 6, "model": "model_name" }
{ "image": "base64 encoded image" }
NOTES
- Only the "prompt" parameter is required
- Both "sampler" and "model" parameters only work when using a remote SD backend
GET /api/image/models
{ "models": [list of all available model names] }
GET /api/image/samplers
{ "samplers": [list of all available sampler names] }
GET /api/image/model
{ "model": "name of the current loaded model" }
POST /api/image/model
{ "model": "name of the model to load" }
{ "previous_model": "name of the previous model", "current_model": "name of the newly loaded model" }
POST /api/tts/generate
{ "speaker": "speaker voice_id", "text": "text to narrate" }
WAV audio file.
GET /api/tts/speakers
[
{
"name": "en_0",
"preview_url": "http://127.0.0.1:5100/api/tts/sample/en_0",
"voice_id": "en_0"
}
]
GET /api/tts/sample/<voice_id>
WAV audio file.
POST /api/chromadb
{
"chat_id": "chat1 - 2023-12-31",
"messages": [
{
"id": "633a4bd1-8350-46b5-9ef2-f5d27acdecb7",
"date": 1684164339877,
"role": "user",
"content": "Hello, AI world!",
"meta": "this is meta"
},
{
"id": "8a2ed36b-c212-4a1b-84a3-0ffbe0896506",
"date": 1684164411759,
"role": "assistant",
"content": "Hello, Hooman!"
},
]
}
{ "count": 2 }
POST /api/chromadb/query
{
"chat_id": "chat1 - 2023-12-31",
"query": "Hello",
"n_results": 2,
}
[
{
"id": "633a4bd1-8350-46b5-9ef2-f5d27acdecb7",
"date": 1684164339877,
"role": "user",
"content": "Hello, AI world!",
"distance": 0.31,
"meta": "this is meta"
},
{
"id": "8a2ed36b-c212-4a1b-84a3-0ffbe0896506",
"date": 1684164411759,
"role": "assistant",
"content": "Hello, Hooman!",
"distance": 0.29
},
]
POST /api/chromadb/purge
{ "chat_id": "chat1 - 2023-04-12" }
GET /api/edge-tts/list
[{'Name': 'Microsoft Server Speech Text to Speech Voice (af-ZA, AdriNeural)', 'ShortName': 'af-ZA-AdriNeural', 'Gender': 'Female', 'Locale': 'af-ZA', 'SuggestedCodec': 'audio-24khz-48kbitrate-mono-mp3', 'FriendlyName': 'Microsoft Adri Online (Natural) - Afrikaans (South Africa)', 'Status': 'GA', 'VoiceTag': {'ContentCategories': ['General'], 'VoicePersonalities': ['Friendly', 'Positive']}}]
POST /api/edge-tts/generate
{ "text": "Text to narrate", "voice": "af-ZA-AdriNeural", "rate": 0 }
MP3 audio file.