Merge branch 'staging' into webpack

1c50180daac13759e03b835caf6c0d321b9e69a6

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

9 files changed, +66 -18Ignore whitespace
public/css/logprobs.css+1 -0
@@ -56,6 +56,7 @@
5656 user-select: none;
5757 height: 100%;
5858 overflow-y: auto;
59+ word-break: break-all;
5960}
6061
6162.logprobs_empty_state {
public/css/toggle-dependent.css+4 -0
@@ -482,3 +482,7 @@ label[for="trim_spaces"]:has(input:checked) i.warning {
482482 gap: 5px;
483483 margin: 10px 0;
484484}
485+
486+#mistralai_other_models:empty {
487+ display: none;
488+}
public/index.html+9 -1
@@ -3012,17 +3012,23 @@
30123012 <option value="open-mixtral-8x7b">open-mixtral-8x7b</option>
30133013 <option value="open-mixtral-8x22b">open-mixtral-8x22b</option>
30143014 <option value="open-codestral-mamba">open-codestral-mamba</option>
3015+ <option value="ministral-3b-latest">ministral-3b-latest</option>
3016+ <option value="ministral-8b-latest">ministral-8b-latest</option>
3017+ <option value="mistral-tiny-latest">mistral-tiny-latest</option>
30153018 <option value="mistral-small-latest">mistral-small-latest</option>
30163019 <option value="mistral-medium-latest">mistral-medium-latest</option>
30173020 <option value="mistral-large-latest">mistral-large-latest</option>
30183021 <option value="codestral-latest">codestral-latest</option>
30193022 <option value="codestral-mamba-latest">codestral-mamba-latest</option>
30203023 <option value="pixtral-12b-latest">pixtral-12b-latest</option>
30213024 </optgroup>
30223025 <optgroup label="Sub-versions">
30233026 <option value="open-mistral-nemo-2407">open-mistral-nemo-2407</option>
30243027 <option value="open-mixtral-8x22b-2404">open-mixtral-8x22b-2404</option>
3028+ <option value="ministral-3b-2410">ministral-3b-2410</option>
3029+ <option value="ministral-8b-2410">ministral-8b-2410</option>
30253030 <option value="mistral-tiny-2312">mistral-tiny-2312</option>
3031+ <option value="mistral-tiny-2407">mistral-tiny-2407</option>
30263032 <option value="mistral-small-2312">mistral-small-2312</option>
30273033 <option value="mistral-small-2402">mistral-small-2402</option>
30283034 <option value="mistral-small-2409">mistral-small-2409</option>
@@ -3030,9 +3036,11 @@
30303036 <option value="mistral-large-2402">mistral-large-2402</option>
30313037 <option value="mistral-large-2407">mistral-large-2407</option>
30323038 <option value="codestral-2405">codestral-2405</option>
3039+ <option value="codestral-2405-blue">codestral-2405-blue</option>
30333040 <option value="codestral-mamba-2407">codestral-mamba-2407</option>
30343041 <option value="pixtral-12b-2409">pixtral-12b-2409</option>
30353042 </optgroup>
3043+ <optgroup id="mistralai_other_models" label="Other"></optgroup>
30363044 </select>
30373045 </div>
30383046 </form>
public/login.html+7 -6
@@ -4,9 +4,9 @@
44<head>
55 <base href="/">
66 <meta charset="utf-8">
7- <meta name="viewport"
7+ <meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content">
8- content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no">
98 <meta name="apple-mobile-web-app-capable" content="yes">
9+ <meta name="mobile-web-app-capable" content="yes">
1010 <meta name="darkreader-lock">
1111 <meta name="robots" content="noindex, nofollow" />
1212 <style>
@@ -31,8 +31,6 @@
3131 <link href="css/fontawesome.min.css" rel="stylesheet">
3232 <link href="css/solid.min.css" rel="stylesheet">
3333 <link href="css/user.css" rel="stylesheet">
34- <script src="lib/jquery-3.5.1.min.js"></script>
35- <script src="scripts/login.js"></script>
3634 <title>SillyTavern</title>
3735</head>
3836
@@ -65,8 +63,7 @@
6563 <div id="loginButton" class="menu_button">Login</div>
6664 </div>
6765 </div>
6866 <div id="passwordRecoveryBlock" style="display:none;" class="flex-container flexFlowColumn alignItemsCenter">
69- class="flex-container flexFlowColumn alignItemsCenter">
7067 <div id="recoverMessage">
7168 Recovery code has been posted to the server console.
7269 </div>
@@ -84,6 +81,10 @@
8481 </div>
8582 </div>
8683 </div>
84+ </div>
85+
86+ <script src="lib/jquery-3.5.1.min.js"></script>
87+ <script src="scripts/login.js"></script>
8788</body>
8889
8990</html>
public/script.js+8 -5
@@ -3201,7 +3201,8 @@ class StreamingProcessor {
32013201 }
32023202
32033203 onStopStreaming() {
32043204 this.onErrorStreamingabortController.abort();
3205+ this.isFinished = true;
32053206 }
32063207
32073208 /**
@@ -3246,9 +3247,12 @@ class StreamingProcessor {
32463247 console.warn(`Stream stats: ${timestamps.length} tokens, ${seconds.toFixed(2)} seconds, rate: ${Number(timestamps.length / seconds).toFixed(2)} TPS`);
32473248 }
32483249 catch (err) {
3249- console.error(err);
3250+ // in the case of a self-inflicted abort, we have already cleaned up
3250- this.onErrorStreaming();
3251+ if (!this.isFinished) {
3251- return;
3252+ console.error(err);
3253+ this.onErrorStreaming();
3254+ }
3255+ return this.result;
32523256 }
32533257
32543258 this.isFinished = true;
@@ -4648,7 +4652,6 @@ export function stopGeneration() {
46484652 let stopped = false;
46494653 if (streamingProcessor) {
46504654 streamingProcessor.onStopStreaming();
4651- streamingProcessor = null;
46524655 stopped = true;
46534656 }
46544657 if (abortController) {
public/scripts/extensions/caption/settings.html+1 -1
@@ -35,7 +35,7 @@
3535 <div class="flex1 flex-container flexFlowColumn flexNoGap">
3636 <label for="caption_multimodal_model" data-i18n="Model">Model</label>
3737 <select id="caption_multimodal_model" class="flex1 text_pole">
3838 <option data-type="mistral" value="pixtral-12b-latest">pixtral-12b-latest</option>
3939 <option data-type="mistral" value="pixtral-12b-2409">pixtral-12b-2409</option>
4040 <option data-type="zerooneai" value="yi-vision">yi-vision</option>
4141 <option data-type="openai" value="gpt-4-vision-preview">gpt-4-vision-preview</option>
public/scripts/extensions/token-counter/index.js+1 -1
@@ -89,7 +89,7 @@ function drawChunks(chunks, ids) {
8989 $('#tokenized_chunks_display').empty();
9090
9191 for (let i = 0; i < chunks.length; i++) {
9292 let chunk = chunks[i].replace(/[Ġ]/g, ' '); // This is a leading space in sentencepiece. More info: Lower one eighth block (U+2581)
9393
9494 // If <0xHEX>, decode it
9595 if (/^<0x[0-9A-F]+>$/i.test(chunk)) {
public/scripts/logprobs.js+4 -4
@@ -160,7 +160,7 @@ function renderTopLogprobs() {
160160 let matched = false;
161161 for (const [token, probability, log] of candidates) {
162162 const container = $('<button class="flex-container flexFlowColumn logprobs_top_candidate"></button>');
163163 const tokenNormalized = String(token).replace(/^[Ġ]/g, ' ');
164164
165165 if (token === selectedToken || tokenNormalized === selectedToken) {
166166 matched = true;
@@ -230,7 +230,7 @@ function onAlternativeClicked(tokenLogprobs, alternative) {
230230 const replaceIndex = messageLogprobs.findIndex(x => x === tokenLogprobs);
231231
232232 const tokens = messageLogprobs.slice(0, replaceIndex + 1).map(({ token }) => token);
233233 tokens[replaceIndex] = String(alternative).replace(/^[Ġ]/g, ' ').replace(/Ċ/g, '\n');
234234
235235 const prefix = continueFrom || '';
236236 const prompt = prefix + tokens.join('');
@@ -343,7 +343,7 @@ function createSwipe(messageId, prompt) {
343343 * @returns {string}
344344 */
345345function toVisibleWhitespace(input) {
346346 return input.replace(/ /g, '·').replace(/[Ġ]/g, '·').replace(/\n]/g, '↵');
347347}
348348
349349/**
@@ -362,7 +362,7 @@ function withVirtualWhitespace(text, span) {
362362 if (text.match(/\s$/)) {
363363 result.push($(document.createTextNode('\u200b')));
364364 }
365365 if (text.match(/^[Ġ]/)) {
366366 result.unshift(document.createTextNode('\u200b'));
367367 }
368368 // line breaks are trickier. we don't currently handle consecutive line
public/scripts/openai.js+31 -0
@@ -1610,6 +1610,33 @@ function saveModelList(data) {
16101610
16111611 $('#model_blockentropy_select').val(oai_settings.blockentropy_model).trigger('change');
16121612 }
1613+
1614+ if (oai_settings.chat_completion_source == chat_completion_sources.MISTRALAI) {
1615+ /** @type {HTMLSelectElement} */
1616+ const mistralModelSelect = document.querySelector('#model_mistralai_select');
1617+ if (mistralModelSelect) {
1618+ const options = Array.from(mistralModelSelect.options);
1619+ options.forEach((option) => {
1620+ const existingModel = model_list.find(model => model.id === option.value);
1621+ if (!existingModel) {
1622+ option.remove();
1623+ }
1624+ });
1625+
1626+ const otherOptionsGroup = mistralModelSelect.querySelector('#mistralai_other_models');
1627+ for (const model of model_list.filter(model => model?.capabilities?.completion_chat)) {
1628+ if (!options.some(option => option.value === model.id) && otherOptionsGroup) {
1629+ otherOptionsGroup.append(new Option(model.id, model.id));
1630+ }
1631+ }
1632+
1633+ const selectedModel = model_list.find(model => model.id === oai_settings.mistralai_model);
1634+ if (!selectedModel) {
1635+ oai_settings.mistralai_model = model_list.find(model => model?.capabilities?.completion_chat)?.id;
1636+ $('#model_mistralai_select').val(oai_settings.mistralai_model).trigger('change');
1637+ }
1638+ }
1639+ }
16131640}
16141641
16151642function appendOpenRouterOptions(model_list, groupModels = false, sort = false) {
@@ -4103,6 +4130,8 @@ async function onModelChange() {
41034130 $('#openai_max_context').attr('max', max_64k);
41044131 } else if (oai_settings.mistralai_model.includes('pixtral')) {
41054132 $('#openai_max_context').attr('max', max_128k);
4133+ } else if (oai_settings.mistralai_model.includes('ministral')) {
4134+ $('#openai_max_context').attr('max', max_32k);
41064135 } else {
41074136 $('#openai_max_context').attr('max', max_32k);
41084137 }
@@ -4660,6 +4689,8 @@ export function isImageInliningSupported() {
46604689 'chatgpt-4o-latest',
46614690 'yi-vision',
46624691 'pixtral-latest',
4692+ 'pixtral-12b-latest',
4693+ 'pixtral-12b',
46634694 'pixtral-12b-2409',
46644695 ];
46654696