Merge branch 'staging' into webpack
| @@ -56,6 +56,7 @@ | |||
| 56 | user-select: none; | 56 | user-select: none; |
| 57 | height: 100%; | 57 | height: 100%; |
| 58 | overflow-y: auto; | 58 | overflow-y: auto; |
| 59 | word-break: break-all; | ||
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | .logprobs_empty_state { | 62 | .logprobs_empty_state { |
| @@ -482,3 +482,7 @@ label[for="trim_spaces"]:has(input:checked) i.warning { | |||
| 482 | gap: 5px; | 482 | gap: 5px; |
| 483 | margin: 10px 0; | 483 | margin: 10px 0; |
| 484 | } | 484 | } |
| 485 | |||
| 486 | #mistralai_other_models:empty { | ||
| 487 | display: none; | ||
| 488 | } | ||
| @@ -3012,17 +3012,23 @@ | |||
| 3012 | <option value="open-mixtral-8x7b">open-mixtral-8x7b</option> | 3012 | <option value="open-mixtral-8x7b">open-mixtral-8x7b</option> |
| 3013 | <option value="open-mixtral-8x22b">open-mixtral-8x22b</option> | 3013 | <option value="open-mixtral-8x22b">open-mixtral-8x22b</option> |
| 3014 | <option value="open-codestral-mamba">open-codestral-mamba</option> | 3014 | <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> | ||
| 3015 | <option value="mistral-small-latest">mistral-small-latest</option> | 3018 | <option value="mistral-small-latest">mistral-small-latest</option> |
| 3016 | <option value="mistral-medium-latest">mistral-medium-latest</option> | 3019 | <option value="mistral-medium-latest">mistral-medium-latest</option> |
| 3017 | <option value="mistral-large-latest">mistral-large-latest</option> | 3020 | <option value="mistral-large-latest">mistral-large-latest</option> |
| 3018 | <option value="codestral-latest">codestral-latest</option> | 3021 | <option value="codestral-latest">codestral-latest</option> |
| 3019 | <option value="codestral-mamba-latest">codestral-mamba-latest</option> | 3022 | <option value="codestral-mamba-latest">codestral-mamba-latest</option> |
| 3020 | <option value="pixtral-latest">pixtral-latest</option> | 3023 | <option value="pixtral-12b-latest">pixtral-12b-latest</option> |
| 3021 | </optgroup> | 3024 | </optgroup> |
| 3022 | <optgroup label="Sub-versions"> | 3025 | <optgroup label="Sub-versions"> |
| 3023 | <option value="open-mistral-nemo-2407">open-mistral-nemo-2407</option> | 3026 | <option value="open-mistral-nemo-2407">open-mistral-nemo-2407</option> |
| 3024 | <option value="open-mixtral-8x22b-2404">open-mixtral-8x22b-2404</option> | 3027 | <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> | ||
| 3025 | <option value="mistral-tiny-2312">mistral-tiny-2312</option> | 3030 | <option value="mistral-tiny-2312">mistral-tiny-2312</option> |
| 3031 | <option value="mistral-tiny-2407">mistral-tiny-2407</option> | ||
| 3026 | <option value="mistral-small-2312">mistral-small-2312</option> | 3032 | <option value="mistral-small-2312">mistral-small-2312</option> |
| 3027 | <option value="mistral-small-2402">mistral-small-2402</option> | 3033 | <option value="mistral-small-2402">mistral-small-2402</option> |
| 3028 | <option value="mistral-small-2409">mistral-small-2409</option> | 3034 | <option value="mistral-small-2409">mistral-small-2409</option> |
| @@ -3030,9 +3036,11 @@ | |||
| 3030 | <option value="mistral-large-2402">mistral-large-2402</option> | 3036 | <option value="mistral-large-2402">mistral-large-2402</option> |
| 3031 | <option value="mistral-large-2407">mistral-large-2407</option> | 3037 | <option value="mistral-large-2407">mistral-large-2407</option> |
| 3032 | <option value="codestral-2405">codestral-2405</option> | 3038 | <option value="codestral-2405">codestral-2405</option> |
| 3039 | <option value="codestral-2405-blue">codestral-2405-blue</option> | ||
| 3033 | <option value="codestral-mamba-2407">codestral-mamba-2407</option> | 3040 | <option value="codestral-mamba-2407">codestral-mamba-2407</option> |
| 3034 | <option value="pixtral-12b-2409">pixtral-12b-2409</option> | 3041 | <option value="pixtral-12b-2409">pixtral-12b-2409</option> |
| 3035 | </optgroup> | 3042 | </optgroup> |
| 3043 | <optgroup id="mistralai_other_models" label="Other"></optgroup> | ||
| 3036 | </select> | 3044 | </select> |
| 3037 | </div> | 3045 | </div> |
| 3038 | </form> | 3046 | </form> |
| @@ -4,9 +4,9 @@ | |||
| 4 | <head> | 4 | <head> |
| 5 | <base href="/"> | 5 | <base href="/"> |
| 6 | <meta charset="utf-8"> | 6 | <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"> | ||
| 9 | <meta name="apple-mobile-web-app-capable" content="yes"> | 8 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 9 | <meta name="mobile-web-app-capable" content="yes"> | ||
| 10 | <meta name="darkreader-lock"> | 10 | <meta name="darkreader-lock"> |
| 11 | <meta name="robots" content="noindex, nofollow" /> | 11 | <meta name="robots" content="noindex, nofollow" /> |
| 12 | <style> | 12 | <style> |
| @@ -31,8 +31,6 @@ | |||
| 31 | <link href="css/fontawesome.min.css" rel="stylesheet"> | 31 | <link href="css/fontawesome.min.css" rel="stylesheet"> |
| 32 | <link href="css/solid.min.css" rel="stylesheet"> | 32 | <link href="css/solid.min.css" rel="stylesheet"> |
| 33 | <link href="css/user.css" rel="stylesheet"> | 33 | <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> | ||
| 36 | <title>SillyTavern</title> | 34 | <title>SillyTavern</title> |
| 37 | </head> | 35 | </head> |
| 38 | 36 | ||
| @@ -65,8 +63,7 @@ | |||
| 65 | <div id="loginButton" class="menu_button">Login</div> | 63 | <div id="loginButton" class="menu_button">Login</div> |
| 66 | </div> | 64 | </div> |
| 67 | </div> | 65 | </div> |
| 68 | <div id="passwordRecoveryBlock" style="display:none;" | 66 | <div id="passwordRecoveryBlock" style="display:none;" class="flex-container flexFlowColumn alignItemsCenter"> |
| 69 | class="flex-container flexFlowColumn alignItemsCenter"> | ||
| 70 | <div id="recoverMessage"> | 67 | <div id="recoverMessage"> |
| 71 | Recovery code has been posted to the server console. | 68 | Recovery code has been posted to the server console. |
| 72 | </div> | 69 | </div> |
| @@ -84,6 +81,10 @@ | |||
| 84 | </div> | 81 | </div> |
| 85 | </div> | 82 | </div> |
| 86 | </div> | 83 | </div> |
| 84 | </div> | ||
| 85 | |||
| 86 | <script src="lib/jquery-3.5.1.min.js"></script> | ||
| 87 | <script src="scripts/login.js"></script> | ||
| 87 | </body> | 88 | </body> |
| 88 | 89 | ||
| 89 | </html> | 90 | </html> |
| @@ -3201,7 +3201,8 @@ class StreamingProcessor { | |||
| 3201 | } | 3201 | } |
| 3202 | 3202 | ||
| 3203 | onStopStreaming() { | 3203 | onStopStreaming() { |
| 3204 | this.onErrorStreaming(); | 3204 | this.abortController.abort(); |
| 3205 | this.isFinished = true; | ||
| 3205 | } | 3206 | } |
| 3206 | 3207 | ||
| 3207 | /** | 3208 | /** |
| @@ -3246,9 +3247,12 @@ class StreamingProcessor { | |||
| 3246 | console.warn(`Stream stats: ${timestamps.length} tokens, ${seconds.toFixed(2)} seconds, rate: ${Number(timestamps.length / seconds).toFixed(2)} TPS`); | 3247 | console.warn(`Stream stats: ${timestamps.length} tokens, ${seconds.toFixed(2)} seconds, rate: ${Number(timestamps.length / seconds).toFixed(2)} TPS`); |
| 3247 | } | 3248 | } |
| 3248 | catch (err) { | 3249 | catch (err) { |
| 3250 | // in the case of a self-inflicted abort, we have already cleaned up | ||
| 3251 | if (!this.isFinished) { | ||
| 3249 | console.error(err); | 3252 | console.error(err); |
| 3250 | this.onErrorStreaming(); | 3253 | this.onErrorStreaming(); |
| 3251 | return; | 3254 | } |
| 3255 | return this.result; | ||
| 3252 | } | 3256 | } |
| 3253 | 3257 | ||
| 3254 | this.isFinished = true; | 3258 | this.isFinished = true; |
| @@ -4648,7 +4652,6 @@ export function stopGeneration() { | |||
| 4648 | let stopped = false; | 4652 | let stopped = false; |
| 4649 | if (streamingProcessor) { | 4653 | if (streamingProcessor) { |
| 4650 | streamingProcessor.onStopStreaming(); | 4654 | streamingProcessor.onStopStreaming(); |
| 4651 | streamingProcessor = null; | ||
| 4652 | stopped = true; | 4655 | stopped = true; |
| 4653 | } | 4656 | } |
| 4654 | if (abortController) { | 4657 | if (abortController) { |
| @@ -35,7 +35,7 @@ | |||
| 35 | <div class="flex1 flex-container flexFlowColumn flexNoGap"> | 35 | <div class="flex1 flex-container flexFlowColumn flexNoGap"> |
| 36 | <label for="caption_multimodal_model" data-i18n="Model">Model</label> | 36 | <label for="caption_multimodal_model" data-i18n="Model">Model</label> |
| 37 | <select id="caption_multimodal_model" class="flex1 text_pole"> | 37 | <select id="caption_multimodal_model" class="flex1 text_pole"> |
| 38 | <option data-type="mistral" value="pixtral-latest">pixtral-latest</option> | 38 | <option data-type="mistral" value="pixtral-12b-latest">pixtral-12b-latest</option> |
| 39 | <option data-type="mistral" value="pixtral-12b-2409">pixtral-12b-2409</option> | 39 | <option data-type="mistral" value="pixtral-12b-2409">pixtral-12b-2409</option> |
| 40 | <option data-type="zerooneai" value="yi-vision">yi-vision</option> | 40 | <option data-type="zerooneai" value="yi-vision">yi-vision</option> |
| 41 | <option data-type="openai" value="gpt-4-vision-preview">gpt-4-vision-preview</option> | 41 | <option data-type="openai" value="gpt-4-vision-preview">gpt-4-vision-preview</option> |
| @@ -89,7 +89,7 @@ function drawChunks(chunks, ids) { | |||
| 89 | $('#tokenized_chunks_display').empty(); | 89 | $('#tokenized_chunks_display').empty(); |
| 90 | 90 | ||
| 91 | for (let i = 0; i < chunks.length; i++) { | 91 | for (let i = 0; i < chunks.length; i++) { |
| 92 | let chunk = chunks[i].replace(/▁/g, ' '); // This is a leading space in sentencepiece. More info: Lower one eighth block (U+2581) | 92 | let chunk = chunks[i].replace(/[▁Ġ]/g, ' '); // This is a leading space in sentencepiece. More info: Lower one eighth block (U+2581) |
| 93 | 93 | ||
| 94 | // If <0xHEX>, decode it | 94 | // If <0xHEX>, decode it |
| 95 | if (/^<0x[0-9A-F]+>$/i.test(chunk)) { | 95 | if (/^<0x[0-9A-F]+>$/i.test(chunk)) { |
| @@ -160,7 +160,7 @@ function renderTopLogprobs() { | |||
| 160 | let matched = false; | 160 | let matched = false; |
| 161 | for (const [token, probability, log] of candidates) { | 161 | for (const [token, probability, log] of candidates) { |
| 162 | const container = $('<button class="flex-container flexFlowColumn logprobs_top_candidate"></button>'); | 162 | const container = $('<button class="flex-container flexFlowColumn logprobs_top_candidate"></button>'); |
| 163 | const tokenNormalized = String(token).replace(/^▁/g, ' '); | 163 | const tokenNormalized = String(token).replace(/^[▁Ġ]/g, ' '); |
| 164 | 164 | ||
| 165 | if (token === selectedToken || tokenNormalized === selectedToken) { | 165 | if (token === selectedToken || tokenNormalized === selectedToken) { |
| 166 | matched = true; | 166 | matched = true; |
| @@ -230,7 +230,7 @@ function onAlternativeClicked(tokenLogprobs, alternative) { | |||
| 230 | const replaceIndex = messageLogprobs.findIndex(x => x === tokenLogprobs); | 230 | const replaceIndex = messageLogprobs.findIndex(x => x === tokenLogprobs); |
| 231 | 231 | ||
| 232 | const tokens = messageLogprobs.slice(0, replaceIndex + 1).map(({ token }) => token); | 232 | const tokens = messageLogprobs.slice(0, replaceIndex + 1).map(({ token }) => token); |
| 233 | tokens[replaceIndex] = String(alternative).replace(/^▁/g, ' '); | 233 | tokens[replaceIndex] = String(alternative).replace(/^[▁Ġ]/g, ' ').replace(/Ċ/g, '\n'); |
| 234 | 234 | ||
| 235 | const prefix = continueFrom || ''; | 235 | const prefix = continueFrom || ''; |
| 236 | const prompt = prefix + tokens.join(''); | 236 | const prompt = prefix + tokens.join(''); |
| @@ -343,7 +343,7 @@ function createSwipe(messageId, prompt) { | |||
| 343 | * @returns {string} | 343 | * @returns {string} |
| 344 | */ | 344 | */ |
| 345 | function toVisibleWhitespace(input) { | 345 | function toVisibleWhitespace(input) { |
| 346 | return input.replace(/ /g, '·').replace(/▁/g, '·').replace(/\n/g, '↵'); | 346 | return input.replace(/ /g, '·').replace(/[▁Ġ]/g, '·').replace(/[Ċ\n]/g, '↵'); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | /** | 349 | /** |
| @@ -362,7 +362,7 @@ function withVirtualWhitespace(text, span) { | |||
| 362 | if (text.match(/\s$/)) { | 362 | if (text.match(/\s$/)) { |
| 363 | result.push($(document.createTextNode('\u200b'))); | 363 | result.push($(document.createTextNode('\u200b'))); |
| 364 | } | 364 | } |
| 365 | if (text.match(/^▁/)) { | 365 | if (text.match(/^[▁Ġ]/)) { |
| 366 | result.unshift(document.createTextNode('\u200b')); | 366 | result.unshift(document.createTextNode('\u200b')); |
| 367 | } | 367 | } |
| 368 | // line breaks are trickier. we don't currently handle consecutive line | 368 | // line breaks are trickier. we don't currently handle consecutive line |
| @@ -1610,6 +1610,33 @@ function saveModelList(data) { | |||
| 1610 | 1610 | ||
| 1611 | $('#model_blockentropy_select').val(oai_settings.blockentropy_model).trigger('change'); | 1611 | $('#model_blockentropy_select').val(oai_settings.blockentropy_model).trigger('change'); |
| 1612 | } | 1612 | } |
| 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 | } | ||
| 1613 | } | 1640 | } |
| 1614 | 1641 | ||
| 1615 | function appendOpenRouterOptions(model_list, groupModels = false, sort = false) { | 1642 | function appendOpenRouterOptions(model_list, groupModels = false, sort = false) { |
| @@ -4103,6 +4130,8 @@ async function onModelChange() { | |||
| 4103 | $('#openai_max_context').attr('max', max_64k); | 4130 | $('#openai_max_context').attr('max', max_64k); |
| 4104 | } else if (oai_settings.mistralai_model.includes('pixtral')) { | 4131 | } else if (oai_settings.mistralai_model.includes('pixtral')) { |
| 4105 | $('#openai_max_context').attr('max', max_128k); | 4132 | $('#openai_max_context').attr('max', max_128k); |
| 4133 | } else if (oai_settings.mistralai_model.includes('ministral')) { | ||
| 4134 | $('#openai_max_context').attr('max', max_32k); | ||
| 4106 | } else { | 4135 | } else { |
| 4107 | $('#openai_max_context').attr('max', max_32k); | 4136 | $('#openai_max_context').attr('max', max_32k); |
| 4108 | } | 4137 | } |
| @@ -4660,6 +4689,8 @@ export function isImageInliningSupported() { | |||
| 4660 | 'chatgpt-4o-latest', | 4689 | 'chatgpt-4o-latest', |
| 4661 | 'yi-vision', | 4690 | 'yi-vision', |
| 4662 | 'pixtral-latest', | 4691 | 'pixtral-latest', |
| 4692 | 'pixtral-12b-latest', | ||
| 4693 | 'pixtral-12b', | ||
| 4663 | 'pixtral-12b-2409', | 4694 | 'pixtral-12b-2409', |
| 4664 | ]; | 4695 | ]; |
| 4665 | 4696 | ||