Merge branch 'staging' into reasoning-parsing-streaming
| @@ -80,6 +80,8 @@ body: | ||
| 80 | 80 | required: true |
| 81 | 81 | - label: I have checked the [docs](https://docs.sillytavern.app/)  |
| 82 | 82 | required: true |
| 83 | + - label: I confirm that my issue is not related to third-party content, unofficial extension or patch. If in doubt, check with a new [user account](https://docs.sillytavern.app/administration/multi-user/) and with extensions disabled | |
| 84 | + required: true | |
| 83 | 85 | |
| 84 | 86 | - type: markdown |
| 85 | 87 | attributes: |
| @@ -210,3 +210,5 @@ claude: | ||
| 210 | 210 | cachingAtDepth: -1 |
| 211 | 211 | # -- SERVER PLUGIN CONFIGURATION -- |
| 212 | 212 | enableServerPlugins: false |
| 213 | +# Attempt to automatically update server plugins on startup | |
| 214 | +enableServerPluginsAutoUpdate: true | |
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "sillytavern", |
| 3 | 3 | "version": "1.12.1112", |
| 4 | 4 | "lockfileVersion": 3, |
| 5 | 5 | "requires": true, |
| 6 | 6 | "packages": { |
| 7 | 7 | "": { |
| 8 | 8 | "name": "sillytavern", |
| 9 | 9 | "version": "1.12.1112", |
| 10 | 10 | "hasInstallScript": true, |
| 11 | 11 | "license": "AGPL-3.0", |
| 12 | 12 | "dependencies": { |
| @@ -87,7 +87,7 @@ | ||
| 87 | 87 | "type": "git", |
| 88 | 88 | "url": "https://github.com/SillyTavern/SillyTavern.git" |
| 89 | 89 | }, |
| 90 | 90 | "version": "1.12.1112", |
| 91 | 91 | "scripts": { |
| 92 | 92 | "start": "node server.js", |
| 93 | 93 | "debug": "node server.js --inspect", |
| @@ -48,6 +48,13 @@ async function updatePlugins() { | ||
| 48 | 48 | console.log(`Updating plugin ${color.green(directory)}...`); |
| 49 | 49 | const pluginPath = path.join(pluginsPath, directory); |
| 50 | 50 | const pluginRepo = git(pluginPath); |
| 51 | + | |
| 52 | + const isRepo = await pluginRepo.checkIsRepo(); | |
| 53 | + if (!isRepo) { | |
| 54 | + console.log(`Directory ${color.yellow(directory)} is not a Git repository`); | |
| 55 | + continue; | |
| 56 | + } | |
| 57 | + | |
| 51 | 58 | await pluginRepo.fetch(); |
| 52 | 59 | const commitHash = await pluginRepo.revparse(['HEAD']); |
| 53 | 60 | const trackingBranch = await pluginRepo.revparse(['--abbrev-ref', '@{u}']); |
| @@ -5931,6 +5931,7 @@ export async function saveReply(type, getMessage, fromStreaming, title, swipes, | ||
| 5931 | 5931 | chat[chat.length - 1]['extra']['api'] = getGeneratingApi(); |
| 5932 | 5932 | chat[chat.length - 1]['extra']['model'] = getGeneratingModel(); |
| 5933 | 5933 | chat[chat.length - 1]['extra']['reasoning'] = reasoning; |
| 5934 | + chat[chat.length - 1]['extra']['reasoning_duration'] = null; | |
| 5934 | 5935 | if (power_user.message_token_count_enabled) { |
| 5935 | 5936 | const tokenCountText = (reasoning || '') + chat[chat.length - 1]['mes']; |
| 5936 | 5937 | chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0); |
| @@ -5953,6 +5954,7 @@ export async function saveReply(type, getMessage, fromStreaming, title, swipes, | ||
| 5953 | 5954 | chat[chat.length - 1]['extra']['api'] = getGeneratingApi(); |
| 5954 | 5955 | chat[chat.length - 1]['extra']['model'] = getGeneratingModel(); |
| 5955 | 5956 | chat[chat.length - 1]['extra']['reasoning'] = reasoning; |
| 5957 | + chat[chat.length - 1]['extra']['reasoning_duration'] = null; | |
| 5956 | 5958 | if (power_user.message_token_count_enabled) { |
| 5957 | 5959 | const tokenCountText = (reasoning || '') + chat[chat.length - 1]['mes']; |
| 5958 | 5960 | chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0); |
| @@ -5972,6 +5974,7 @@ export async function saveReply(type, getMessage, fromStreaming, title, swipes, | ||
| 5972 | 5974 | chat[chat.length - 1]['extra']['api'] = getGeneratingApi(); |
| 5973 | 5975 | chat[chat.length - 1]['extra']['model'] = getGeneratingModel(); |
| 5974 | 5976 | chat[chat.length - 1]['extra']['reasoning'] += reasoning; |
| 5977 | + // We don't know if the reasoning duration extended, so we don't update it here on purpose. | |
| 5975 | 5978 | if (power_user.message_token_count_enabled) { |
| 5976 | 5979 | const tokenCountText = (reasoning || '') + chat[chat.length - 1]['mes']; |
| 5977 | 5980 | chat[chat.length - 1]['extra']['token_count'] = await getTokenCountAsync(tokenCountText, 0); |
| @@ -5991,6 +5994,7 @@ export async function saveReply(type, getMessage, fromStreaming, title, swipes, | ||
| 5991 | 5994 | chat[chat.length - 1]['extra']['api'] = getGeneratingApi(); |
| 5992 | 5995 | chat[chat.length - 1]['extra']['model'] = getGeneratingModel(); |
| 5993 | 5996 | chat[chat.length - 1]['extra']['reasoning'] = reasoning; |
| 5997 | + chat[chat.length - 1]['extra']['reasoning_duration'] = null; | |
| 5994 | 5998 | if (power_user.trim_spaces) { |
| 5995 | 5999 | getMessage = getMessage.trim(); |
| 5996 | 6000 | } |
| @@ -346,7 +346,7 @@ export class SettingsUi { | ||
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | async addQrSet() { |
| 349 | 349 | const name = await Popup.show.input('Create a new WorldQuick InfoReply Set', 'Enter a name for the new Quick Reply Set:'); |
| 350 | 350 | if (name && name.length > 0) { |
| 351 | 351 | const oldQrs = QuickReplySet.get(name); |
| 352 | 352 | if (oldQrs) { |
| @@ -106,7 +106,7 @@ export function isHiddenReasoningModel() { | ||
| 106 | 106 | { name: 'gemini-2.0-pro-exp', func: FUNCS.startsWith }, |
| 107 | 107 | ]; |
| 108 | 108 | |
| 109 | 109 | const model = getChatCompletionModel() || ''; |
| 110 | 110 | |
| 111 | 111 | const isHidden = hiddenReasoningModels.some(({ name, func }) => func(model, name)); |
| 112 | 112 | return isHidden; |
| @@ -58,9 +58,14 @@ const OPENROUTER_PROVIDERS = [ | ||
| 58 | 58 | 'Minimax', |
| 59 | 59 | 'Nineteen', |
| 60 | 60 | 'Liquid', |
| 61 | + 'InferenceNet', | |
| 62 | + 'Friendli', | |
| 63 | + 'AionLabs', | |
| 64 | + 'Alibaba', | |
| 61 | 65 | 'Nebius', |
| 62 | 66 | 'Chutes', |
| 63 | 67 | 'Kluster', |
| 68 | + 'Targon', | |
| 64 | 69 | '01.AI', |
| 65 | 70 | 'HuggingFace', |
| 66 | 71 | 'Mancer', |
| @@ -1275,7 +1275,8 @@ falai.post('/generate', jsonParser, async (request, response) => { | ||
| 1275 | 1275 | num_inference_steps: request.body.steps, |
| 1276 | 1276 | seed: request.body.seed ?? null, |
| 1277 | 1277 | guidance_scale: request.body.guidance, |
| 1278 | 1278 | enable_safety_checker: false, // Disable general safety checks |
| 1279 | + safety_tolerance: 6 // Make Flux the least strict | |
| 1279 | 1280 | }; |
| 1280 | 1281 | |
| 1281 | 1282 | console.debug('FAL.AI request:', requestBody); |
| @@ -3,8 +3,12 @@ import path from 'node:path'; | ||
| 3 | 3 | import url from 'node:url'; |
| 4 | 4 | |
| 5 | 5 | import express from 'express'; |
| 6 | 6 | import { getConfigValuedefault as git } from './util.jssimple-git'; |
| 7 | -const enableServerPlugins = getConfigValue('enableServerPlugins', false); | |
| 7 | +import { sync as commandExistsSync } from 'command-exists'; | |
| 8 | +import { getConfigValue, color } from './util.js'; | |
| 9 | + | |
| 10 | +const enableServerPlugins = !!getConfigValue('enableServerPlugins', false); | |
| 11 | +const enableServerPluginsAutoUpdate = !!getConfigValue('enableServerPluginsAutoUpdate', true); | |
| 8 | 12 | |
| 9 | 13 | /** |
| 10 | 14 | * Map of loaded plugins. |
| @@ -54,6 +58,8 @@ export async function loadPlugins(app, pluginsPath) { | ||
| 54 | 58 | return emptyFn; |
| 55 | 59 | } |
| 56 | 60 | |
| 61 | + await updatePlugins(pluginsPath); | |
| 62 | + | |
| 57 | 63 | for (const file of files) { |
| 58 | 64 | const pluginFilePath = path.join(pluginsPath, file); |
| 59 | 65 | |
| @@ -70,6 +76,10 @@ export async function loadPlugins(app, pluginsPath) { | ||
| 70 | 76 | await loadFromFile(app, pluginFilePath, exitHooks); |
| 71 | 77 | } |
| 72 | 78 | |
| 79 | + if (loadedPlugins.size > 0) { | |
| 80 | + console.log(`${loadedPlugins.size} server plugin(s) are currently loaded. Make sure you know exactly what they do, and only install plugins from trusted sources!`); | |
| 81 | + } | |
| 82 | + | |
| 73 | 83 | // Call all plugin "exit" functions at once and wait for them to finish |
| 74 | 84 | return () => Promise.all(exitHooks.map(exitFn => exitFn())); |
| 75 | 85 | } |
| @@ -214,3 +224,65 @@ async function initPlugin(app, plugin, exitHooks) { | ||
| 214 | 224 | |
| 215 | 225 | return true; |
| 216 | 226 | } |
| 227 | + | |
| 228 | +/** | |
| 229 | + * Automatically update all git plugins in the ./plugins directory | |
| 230 | + * @param {string} pluginsPath Path to plugins directory | |
| 231 | + */ | |
| 232 | +async function updatePlugins(pluginsPath) { | |
| 233 | + if (!enableServerPluginsAutoUpdate) { | |
| 234 | + return; | |
| 235 | + } | |
| 236 | + | |
| 237 | + const directories = fs.readdirSync(pluginsPath) | |
| 238 | + .filter(file => !file.startsWith('.')) | |
| 239 | + .filter(file => fs.statSync(path.join(pluginsPath, file)).isDirectory()); | |
| 240 | + | |
| 241 | + if (directories.length === 0) { | |
| 242 | + return; | |
| 243 | + } | |
| 244 | + | |
| 245 | + console.log(color.blue('Auto-updating server plugins... Set'), color.yellow('enableServerPluginsAutoUpdate: false'), color.blue('in config.yaml to disable this feature.')); | |
| 246 | + | |
| 247 | + if (!commandExistsSync('git')) { | |
| 248 | + console.error(color.red('Git is not installed. Please install Git to enable auto-updating of server plugins.')); | |
| 249 | + return; | |
| 250 | + } | |
| 251 | + | |
| 252 | + let pluginsToUpdate = 0; | |
| 253 | + | |
| 254 | + for (const directory of directories) { | |
| 255 | + try { | |
| 256 | + const pluginPath = path.join(pluginsPath, directory); | |
| 257 | + const pluginRepo = git(pluginPath); | |
| 258 | + | |
| 259 | + const isRepo = await pluginRepo.checkIsRepo(); | |
| 260 | + if (!isRepo) { | |
| 261 | + continue; | |
| 262 | + } | |
| 263 | + | |
| 264 | + await pluginRepo.fetch(); | |
| 265 | + const commitHash = await pluginRepo.revparse(['HEAD']); | |
| 266 | + const trackingBranch = await pluginRepo.revparse(['--abbrev-ref', '@{u}']); | |
| 267 | + const log = await pluginRepo.log({ | |
| 268 | + from: commitHash, | |
| 269 | + to: trackingBranch, | |
| 270 | + }); | |
| 271 | + | |
| 272 | + if (log.total === 0) { | |
| 273 | + continue; | |
| 274 | + } | |
| 275 | + | |
| 276 | + pluginsToUpdate++; | |
| 277 | + await pluginRepo.pull(); | |
| 278 | + const latestCommit = await pluginRepo.revparse(['HEAD']); | |
| 279 | + console.log(`Plugin ${color.green(directory)} updated to commit ${color.cyan(latestCommit)}`); | |
| 280 | + } catch (error) { | |
| 281 | + console.error(color.red(`Failed to update plugin ${directory}: ${error.message}`)); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + | |
| 285 | + if (pluginsToUpdate === 0) { | |
| 286 | + console.log('All plugins are up to date.'); | |
| 287 | + } | |
| 288 | +} | |