diff --git a/Update-Instructions.txt b/Update-Instructions.txt index b862f8907..f153660b2 100644 --- a/Update-Instructions.txt +++ b/Update-Instructions.txt @@ -22,6 +22,9 @@ You can also try running the 'UpdateAndStart.bat' file, which will almost do the Alternatively, if the command prompt gives you problems (and you have GitHub Desktop installed), you can use the 'Repository' menu and select 'Pull'. The updates are applied automatically and safely. +If you are a developer and use a fork of ST or switch branches regularly, you can use the 'UpdateForkAndStart.bat', which works similarly to 'UpdateAndStart.bat', +but automatically pulls changes into your fork and handles switched branches gracefully by asking if you want to switch back. + Method 2 - ZIP If you insist on installing via a zip, here is the tedious process for doing the update: diff --git a/UpdateForkAndStart.bat b/UpdateForkAndStart.bat new file mode 100644 index 000000000..5052b9aa0 --- /dev/null +++ b/UpdateForkAndStart.bat @@ -0,0 +1,103 @@ +@echo off +@setlocal enabledelayedexpansion +pushd %~dp0 + +echo Checking Git installation +git --version > nul 2>&1 +if %errorlevel% neq 0 ( + echo Git is not installed on this system. Skipping update. + echo If you installed with a zip file, you will need to download the new zip and install it manually. + goto end +) + +REM Checking current branch +FOR /F "tokens=*" %%i IN ('git rev-parse --abbrev-ref HEAD') DO SET CURRENT_BRANCH=%%i +echo Current branch: %CURRENT_BRANCH% + +REM Checking for automatic branch switching configuration +set AUTO_SWITCH= +FOR /F "tokens=*" %%j IN ('git config --local script.autoSwitch') DO SET AUTO_SWITCH=%%j + +SET TARGET_BRANCH=%CURRENT_BRANCH% + +if NOT "!AUTO_SWITCH!"=="" ( + if "!AUTO_SWITCH!"=="s" ( + goto autoswitch-staging + ) + if "!AUTO_SWITCH!"=="r" ( + goto autoswitch-release + ) + + if "!AUTO_SWITCH!"=="staging" ( + :autoswitch-staging + echo Auto-switching to staging branch + git checkout staging + SET TARGET_BRANCH=staging + goto update + ) + if "!AUTO_SWITCH!"=="release" ( + :autoswitch-release + echo Auto-switching to release branch + git checkout release + SET TARGET_BRANCH=release + goto update + ) + + echo Auto-switching defined to stay on current branch + goto update +) + +if "!CURRENT_BRANCH!"=="staging" ( + echo Staying on the current branch + goto update +) +if "!CURRENT_BRANCH!"=="release" ( + echo Staying on the current branch + goto update +) + +echo You are not on 'staging' or 'release'. You are on '!CURRENT_BRANCH!'. +set /p "CHOICE=Do you want to switch to 'staging' (s), 'release' (r), or stay (any other key)? " +if /i "!CHOICE!"=="s" ( + echo Switching to staging branch + git checkout staging + SET TARGET_BRANCH=staging + goto update +) +if /i "!CHOICE!"=="r" ( + echo Switching to release branch + git checkout release + SET TARGET_BRANCH=release + goto update +) + +echo Staying on the current branch + +:update +REM Checking for 'upstream' remote +git remote | findstr "upstream" > nul +if %errorlevel% equ 0 ( + echo Updating and rebasing against 'upstream' + git fetch upstream + git rebase upstream/%TARGET_BRANCH% --autostash + goto install +) + +echo Updating and rebasing against 'origin' +git pull --rebase --autostash origin %TARGET_BRANCH% + + +:install +if %errorlevel% neq 0 ( + echo There were errors while updating. Please check manually. + goto end +) + +echo Installing npm packages and starting server +set NODE_ENV=production +call npm install --no-audit --no-fund --quiet --omit=dev +node server.js %* + +:end +pause +popd diff --git a/public/index.html b/public/index.html index 268ae0f64..62ce4dfcd 100644 --- a/public/index.html +++ b/public/index.html @@ -1167,7 +1167,7 @@
-
+
Multiple swipes per generation
@@ -1228,7 +1228,7 @@
-
+
Epsilon Cutoff
@@ -1236,7 +1236,7 @@
-
+
Eta Cutoff
@@ -1274,7 +1274,7 @@
-
+
Min Length @@ -1284,20 +1284,22 @@
-
+

-
- Smoothing Factor - - -
-
- Smoothing Curve - - +
+
+ Smoothing Factor + + +
+
+ Smoothing Curve + + +
-
+

@@ -1492,7 +1494,7 @@
-
+

CFG
@@ -2040,7 +2042,7 @@

DreamGen API key - +

@@ -5242,12 +5244,12 @@
-
-
-
- +
+
+
+
-
+
@@ -5386,12 +5388,12 @@
-
-
-
- +
+
+
+
-
+
@@ -5699,8 +5701,8 @@
-
-
+
+
diff --git a/public/script.js b/public/script.js index 7d45e9e8d..38ed270cd 100644 --- a/public/script.js +++ b/public/script.js @@ -2028,7 +2028,7 @@ function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll = true forceAvatar: mes.force_avatar, timestamp: timestamp, extra: mes.extra, - tokenCount: mes.extra?.token_count, + tokenCount: mes.extra?.token_count ?? 0, ...formatGenerationTimer(mes.gen_started, mes.gen_finished, mes.extra?.token_count), }; @@ -3237,8 +3237,9 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu } // Inject all Depth prompts. Chat Completion does it separately + let injectedIndices = []; if (main_api !== 'openai') { - doChatInject(coreChat, isContinue); + injectedIndices = doChatInject(coreChat, isContinue); } // Insert character jailbreak as the last user message (if exists, allowed, preferred, and not using Chat Completion) @@ -3656,6 +3657,10 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu return combinedPrompt; }; + finalMesSend.forEach((item, i) => { + item.injected = Array.isArray(injectedIndices) && injectedIndices.includes(i); + }); + let data = { api: main_api, combinedPrompt: null, @@ -3973,9 +3978,10 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu * Injects extension prompts into chat messages. * @param {object[]} messages Array of chat messages * @param {boolean} isContinue Whether the generation is a continuation. If true, the extension prompts of depth 0 are injected at position 1. - * @returns {void} + * @returns {number[]} Array of indices where the extension prompts were injected */ function doChatInject(messages, isContinue) { + const injectedIndices = []; let totalInsertedMessages = 0; messages.reverse(); @@ -4014,10 +4020,16 @@ function doChatInject(messages, isContinue) { const injectIdx = depth + totalInsertedMessages; messages.splice(injectIdx, 0, ...roleMessages); totalInsertedMessages += roleMessages.length; + injectedIndices.push(...Array.from({ length: roleMessages.length }, (_, i) => injectIdx + i)); } } + for (let i = 0; i < injectedIndices.length; i++) { + injectedIndices[i] = messages.length - injectedIndices[i] - 1; + } + messages.reverse(); + return injectedIndices; } function flushWIDepthInjections() { @@ -4563,6 +4575,7 @@ function parseAndSaveLogprobs(data, continueFrom) { logprobs = data?.completion_probabilities?.map(x => parseTextgenLogprobs(x.content, [x])) || null; } break; case textgen_types.APHRODITE: + case textgen_types.MANCER: case textgen_types.TABBY: { logprobs = parseTabbyLogprobs(data) || null; } break; @@ -4617,7 +4630,7 @@ function extractMultiSwipes(data, type) { return swipes; } - if (main_api === 'openai' || (main_api === 'textgenerationwebui' && textgen_settings.type === textgen_types.APHRODITE)) { + if (main_api === 'openai' || (main_api === 'textgenerationwebui' && [MANCER, APHRODITE].includes(textgen_settings.type))) { if (!Array.isArray(data.choices)) { return swipes; } @@ -5657,7 +5670,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') { function highlightSelectedAvatar() { $('#user_avatar_block .avatar-container').removeClass('selected'); - $(`#user_avatar_block .avatar-container[imgfile='${user_avatar}']`).addClass('selected'); + $(`#user_avatar_block .avatar-container[imgfile="${user_avatar}"]`).addClass('selected'); } /** diff --git a/public/scripts/extensions/quick-reply/html/qrEditor.html b/public/scripts/extensions/quick-reply/html/qrEditor.html index 74027cbd7..24a149333 100644 --- a/public/scripts/extensions/quick-reply/html/qrEditor.html +++ b/public/scripts/extensions/quick-reply/html/qrEditor.html @@ -13,7 +13,15 @@
- + + + +
diff --git a/public/scripts/extensions/quick-reply/src/QuickReply.js b/public/scripts/extensions/quick-reply/src/QuickReply.js index c754dc41c..fd3e71810 100644 --- a/public/scripts/extensions/quick-reply/src/QuickReply.js +++ b/public/scripts/extensions/quick-reply/src/QuickReply.js @@ -208,8 +208,23 @@ export class QuickReply { title.addEventListener('input', () => { this.updateTitle(title.value); }); + /**@type {HTMLInputElement}*/ + const wrap = dom.querySelector('#qr--modal-wrap'); + wrap.checked = JSON.parse(localStorage.getItem('qr--wrap')); + wrap.addEventListener('click', () => { + localStorage.setItem('qr--wrap', JSON.stringify(wrap.checked)); + updateWrap(); + }); + const updateWrap = () => { + if (wrap.checked) { + message.style.whiteSpace = 'pre-wrap'; + } else { + message.style.whiteSpace = 'pre'; + } + }; /**@type {HTMLTextAreaElement}*/ const message = dom.querySelector('#qr--modal-message'); + updateWrap(); message.value = this.message; message.addEventListener('input', () => { this.updateMessage(message.value); diff --git a/public/scripts/logprobs.js b/public/scripts/logprobs.js index 44884b898..2aef6e61b 100644 --- a/public/scripts/logprobs.js +++ b/public/scripts/logprobs.js @@ -139,7 +139,7 @@ function renderTopLogprobs() { const candidates = topLogprobs .sort(([, logA], [, logB]) => logB - logA) .map(([text, log]) => { - if (log < 0) { + if (log <= 0) { const probability = Math.exp(log); sum += probability; return [text, probability, log]; diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index d0930fd69..ce16a46fb 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -21,6 +21,8 @@ import { saveChatConditional, setAnimationDuration, ANIMATION_DURATION_DEFAULT, + setActiveGroup, + setActiveCharacter, } from '../script.js'; import { isMobile, initMovingUI, favsToHotswap } from './RossAscends-mods.js'; import { @@ -2306,6 +2308,8 @@ async function doRandomChat() { resetSelectedGroup(); const characterId = Math.floor(Math.random() * characters.length).toString(); setCharacterId(characterId); + setActiveCharacter(characters[characterId]?.avatar); + setActiveGroup(null); await delay(1); await reloadCurrentChat(); return characters[characterId]?.name; diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 1abd1369f..e114ebe5b 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -25,6 +25,8 @@ import { saveChatConditional, sendMessageAsUser, sendSystemMessage, + setActiveCharacter, + setActiveGroup, setCharacterId, setCharacterName, setExtensionPrompt, @@ -1251,11 +1253,15 @@ async function goToCharacterCallback(_, name) { if (characterIndex !== -1) { await openChat(new String(characterIndex)); + setActiveCharacter(characters[characterIndex]?.avatar); + setActiveGroup(null); return characters[characterIndex]?.name; } else { const group = groups.find(it => it.name.toLowerCase() == name.toLowerCase()); if (group) { await openGroupById(group.id); + setActiveCharacter(null); + setActiveGroup(group.id); return group.name; } else { console.warn(`No matches found for name "${name}"`); diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 7f22d0311..b16b67173 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -850,6 +850,7 @@ export function parseTextgenLogprobs(token, logprobs) { switch (settings.type) { case TABBY: case APHRODITE: + case MANCER: case OOBA: { /** @type {Record[]} */ const topLogprobs = logprobs.top_logprobs; @@ -971,6 +972,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'typical_p': settings.typical_p, 'typical': settings.typical_p, 'sampler_seed': settings.seed, + 'seed': settings.seed, 'min_p': settings.min_p, 'repetition_penalty': settings.rep_pen, 'frequency_penalty': settings.freq_pen, @@ -1000,12 +1002,12 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'skip_special_tokens': settings.skip_special_tokens, 'top_a': settings.top_a, 'tfs': settings.tfs, - 'epsilon_cutoff': settings.type === OOBA ? settings.epsilon_cutoff : undefined, - 'eta_cutoff': settings.type === OOBA ? settings.eta_cutoff : undefined, + 'epsilon_cutoff': [OOBA, MANCER].includes(settings.type) ? settings.epsilon_cutoff : undefined, + 'eta_cutoff': [OOBA, MANCER].includes(settings.type) ? settings.eta_cutoff : undefined, 'mirostat_mode': settings.mirostat_mode, 'mirostat_tau': settings.mirostat_tau, 'mirostat_eta': settings.mirostat_eta, - 'custom_token_bans': settings.type === textgen_types.APHRODITE ? + 'custom_token_bans': [APHRODITE, MANCER].includes(settings.type) ? toIntArray(getCustomTokenBans()) : getCustomTokenBans(), 'api_type': settings.type, @@ -1022,7 +1024,6 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'penalty_alpha': settings.type === OOBA ? settings.penalty_alpha : undefined, 'temperature_last': (settings.type === OOBA || settings.type === APHRODITE || settings.type == TABBY) ? settings.temperature_last : undefined, 'do_sample': settings.type === OOBA ? settings.do_sample : undefined, - 'seed': settings.seed, 'guidance_scale': cfgValues?.guidanceScale?.value ?? settings.guidance_scale ?? 1, 'negative_prompt': cfgValues?.negativePrompt ?? substituteParams(settings.negative_prompt) ?? '', 'grammar_string': settings.grammar_string, @@ -1045,6 +1046,17 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, //'logprobs': settings.log_probs_aphrodite, //'prompt_logprobs': settings.prompt_log_probs_aphrodite, }; + + if (settings.type === MANCER) { + params.n = canMultiSwipe ? settings.n : 1; + params.epsilon_cutoff /= 1000; + params.eta_cutoff /= 1000; + params.dynatemp_mode = params.dynamic_temperature ? 1 : 0; + params.dynatemp_min = params.dynatemp_low; + params.dynatemp_max = params.dynatemp_high; + delete params.dynatemp_low, params.dynatemp_high; + } + if (settings.type === APHRODITE) { params = Object.assign(params, aphroditeParams); } else { diff --git a/public/style.css b/public/style.css index eed1de672..de3a08b9a 100644 --- a/public/style.css +++ b/public/style.css @@ -139,6 +139,7 @@ body { ::-webkit-scrollbar { width: 10px; + height: 10px; scrollbar-gutter: stable; } @@ -146,7 +147,7 @@ body { overflow-y: auto !important; } -::-webkit-scrollbar-thumb { +::-webkit-scrollbar-thumb:vertical { background-color: var(--grey7070a); box-shadow: inset 0 0 0 1px var(--black50a); border-radius: 10px; @@ -155,6 +156,15 @@ body { border-top: 20px solid transparent; min-height: 40px; } +::-webkit-scrollbar-thumb:horizontal { + background-color: var(--grey7070a); + box-shadow: inset 0 0 0 1px var(--black50a); + border-radius: 10px; + background-clip: content-box; + border: 2px solid transparent; + border-left: 20px solid transparent; + min-width: 40px; +} table.responsiveTable { width: 100%; @@ -518,6 +528,7 @@ body.reduced-motion #bg_custom { top: 5px; margin-right: 5px; z-index: 2000; + min-width: 55px; } .panelControlBar .drag-grabber {