Merge pull request #3315 from SillyTavern/extensions-config config.yaml: Group extension settings into one section

bbd85fc823921f882f0785a41fe89a0558d96cdb

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
6 files changed, +65 -23Showing whitespace changes
default/config.yaml+15 -13
@@ -133,24 +133,26 @@ whitelistImportDomains:
133## headers:133## headers:
134## User-Agent: "Googlebot/2.1 (+http://www.google.com/bot.html)"134## User-Agent: "Googlebot/2.1 (+http://www.google.com/bot.html)"
135requestOverrides: []135requestOverrides: []
136# -- EXTENSIONS CONFIGURATION --136
137# EXTENSIONS CONFIGURATION
138extensions:
137 # Enable UI extensions139 # Enable UI extensions
138enableExtensions: true140 enabled: true
139 # Automatically update extensions when a release version changes141 # Automatically update extensions when a release version changes
140enableExtensionsAutoUpdate: true142 autoUpdate: true
143 models:
144 # Enables automatic model download from HuggingFace
145 autoDownload: true
146 # Additional models for extensions. Expects model IDs from HuggingFace model hub in ONNX format
147 classification: Cohee/distilbert-base-uncased-go-emotions-onnx
148 captioning: Xenova/vit-gpt2-image-captioning
149 embedding: Cohee/jina-embeddings-v2-base-en
150 speechToText: Xenova/whisper-small
151 textToSpeech: Xenova/speecht5_tts
152
141# Additional model tokenizers can be downloaded on demand.153# Additional model tokenizers can be downloaded on demand.
142# Disabling will fallback to another locally available tokenizer.154# Disabling will fallback to another locally available tokenizer.
143enableDownloadableTokenizers: true155enableDownloadableTokenizers: true
144# Extension settings
145extras:
146 # Disables automatic model download from HuggingFace
147 disableAutoDownload: false
148 # Extra models for plugins. Expects model IDs from HuggingFace model hub in ONNX format
149 classificationModel: Cohee/distilbert-base-uncased-go-emotions-onnx
150 captioningModel: Xenova/vit-gpt2-image-captioning
151 embeddingModel: Cohee/jina-embeddings-v2-base-en
152 speechToTextModel: Xenova/whisper-small
153 textToSpeechModel: Xenova/speecht5_tts
154# -- OPENAI CONFIGURATION --156# -- OPENAI CONFIGURATION --
155# A placeholder message to use in strict prompt post-processing mode when the prompt doesn't start with a user message157# A placeholder message to use in strict prompt post-processing mode when the prompt doesn't start with a user message
156promptPlaceholder: "[Start a new chat]"158promptPlaceholder: "[Start a new chat]"
jsconfig.json+1 -1
@@ -15,7 +15,7 @@
15 "**/node_modules/**",15 "**/node_modules/**",
16 "**/dist/**",16 "**/dist/**",
17 "**/.git/**",17 "**/.git/**",
18 "public/lib/**",18 "public/**",
19 "backups/**",19 "backups/**",
20 "data/**",20 "data/**",
21 "cache/**",21 "cache/**",
post-install.js+40 -0
@@ -64,6 +64,46 @@ const keyMigrationMap = [
64 newKey: 'backups.chat.throttleInterval',64 newKey: 'backups.chat.throttleInterval',
65 migrate: (value) => value,65 migrate: (value) => value,
66 },66 },
67 {
68 oldKey: 'enableExtensions',
69 newKey: 'extensions.enabled',
70 migrate: (value) => value,
71 },
72 {
73 oldKey: 'enableExtensionsAutoUpdate',
74 newKey: 'extensions.autoUpdate',
75 migrate: (value) => value,
76 },
77 {
78 oldKey: 'extras.disableAutoDownload',
79 newKey: 'extensions.models.autoDownload',
80 migrate: (value) => !value,
81 },
82 {
83 oldKey: 'extras.classificationModel',
84 newKey: 'extensions.models.classification',
85 migrate: (value) => value,
86 },
87 {
88 oldKey: 'extras.captioningModel',
89 newKey: 'extensions.models.captioning',
90 migrate: (value) => value,
91 },
92 {
93 oldKey: 'extras.embeddingModel',
94 newKey: 'extensions.models.embedding',
95 migrate: (value) => value,
96 },
97 {
98 oldKey: 'extras.speechToTextModel',
99 newKey: 'extensions.models.speechToText',
100 migrate: (value) => value,
101 },
102 {
103 oldKey: 'extras.textToSpeechModel',
104 newKey: 'extensions.models.textToSpeech',
105 migrate: (value) => value,
106 },
67];107];
68108
69/**109/**
src/endpoints/settings.js+2 -2
@@ -10,8 +10,8 @@ import { getConfigValue, generateTimestamp, removeOldBackups } from '../util.js'
10import { jsonParser } from '../express-common.js';10import { jsonParser } from '../express-common.js';
11import { getAllUserHandles, getUserDirectories } from '../users.js';11import { getAllUserHandles, getUserDirectories } from '../users.js';
1212
13const ENABLE_EXTENSIONS = getConfigValue('enableExtensions', true);13const ENABLE_EXTENSIONS = !!getConfigValue('extensions.enabled', true);
14const ENABLE_EXTENSIONS_AUTO_UPDATE = getConfigValue('enableExtensionsAutoUpdate', true);14const ENABLE_EXTENSIONS_AUTO_UPDATE = !!getConfigValue('extensions.autoUpdate', true);
15const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false);15const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false);
1616
17// 10 minutes17// 10 minutes
src/endpoints/vectors.js+1 -1
@@ -164,7 +164,7 @@ function getSourceSettings(source, request) {
164 };164 };
165 case 'transformers':165 case 'transformers':
166 return {166 return {
167 model: getConfigValue('extras.embeddingModel', ''),167 model: getConfigValue('extensions.models.embedding', ''),
168 };168 };
169 case 'palm':169 case 'palm':
170 return {170 return {
src/transformers.js+6 -6
@@ -19,31 +19,31 @@ const tasks = {
19 'text-classification': {19 'text-classification': {
20 defaultModel: 'Cohee/distilbert-base-uncased-go-emotions-onnx',20 defaultModel: 'Cohee/distilbert-base-uncased-go-emotions-onnx',
21 pipeline: null,21 pipeline: null,
22 configField: 'extras.classificationModel',22 configField: 'extensions.models.classification',
23 quantized: true,23 quantized: true,
24 },24 },
25 'image-to-text': {25 'image-to-text': {
26 defaultModel: 'Xenova/vit-gpt2-image-captioning',26 defaultModel: 'Xenova/vit-gpt2-image-captioning',
27 pipeline: null,27 pipeline: null,
28 configField: 'extras.captioningModel',28 configField: 'extensions.models.captioning',
29 quantized: true,29 quantized: true,
30 },30 },
31 'feature-extraction': {31 'feature-extraction': {
32 defaultModel: 'Xenova/all-mpnet-base-v2',32 defaultModel: 'Xenova/all-mpnet-base-v2',
33 pipeline: null,33 pipeline: null,
34 configField: 'extras.embeddingModel',34 configField: 'extensions.models.embedding',
35 quantized: true,35 quantized: true,
36 },36 },
37 'automatic-speech-recognition': {37 'automatic-speech-recognition': {
38 defaultModel: 'Xenova/whisper-small',38 defaultModel: 'Xenova/whisper-small',
39 pipeline: null,39 pipeline: null,
40 configField: 'extras.speechToTextModel',40 configField: 'extensions.models.speechToText',
41 quantized: true,41 quantized: true,
42 },42 },
43 'text-to-speech': {43 'text-to-speech': {
44 defaultModel: 'Xenova/speecht5_tts',44 defaultModel: 'Xenova/speecht5_tts',
45 pipeline: null,45 pipeline: null,
46 configField: 'extras.textToSpeechModel',46 configField: 'extensions.models.textToSpeech',
47 quantized: false,47 quantized: false,
48 },48 },
49};49};
@@ -132,7 +132,7 @@ export async function getPipeline(task, forceModel = '') {
132132
133 const cacheDir = path.join(globalThis.DATA_ROOT, '_cache');133 const cacheDir = path.join(globalThis.DATA_ROOT, '_cache');
134 const model = forceModel || getModelForTask(task);134 const model = forceModel || getModelForTask(task);
135 const localOnly = getConfigValue('extras.disableAutoDownload', false);135 const localOnly = !getConfigValue('extensions.models.autoDownload', true);
136 console.log('Initializing transformers.js pipeline for task', task, 'with model', model);136 console.log('Initializing transformers.js pipeline for task', task, 'with model', model);
137 const instance = await pipeline(task, model, { cache_dir: cacheDir, quantized: tasks[task].quantized ?? true, local_files_only: localOnly });137 const instance = await pipeline(task, model, { cache_dir: cacheDir, quantized: tasks[task].quantized ?? true, local_files_only: localOnly });
138 tasks[task].pipeline = instance;138 tasks[task].pipeline = instance;