mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into webpack
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<div class="flex1 flex-container flexFlowColumn flexNoGap">
|
||||
<label for="caption_multimodal_model" data-i18n="Model">Model</label>
|
||||
<select id="caption_multimodal_model" class="flex1 text_pole">
|
||||
<option data-type="mistral" value="pixtral-latest">pixtral-latest</option>
|
||||
<option data-type="mistral" value="pixtral-12b-latest">pixtral-12b-latest</option>
|
||||
<option data-type="mistral" value="pixtral-12b-2409">pixtral-12b-2409</option>
|
||||
<option data-type="zerooneai" value="yi-vision">yi-vision</option>
|
||||
<option data-type="openai" value="gpt-4-vision-preview">gpt-4-vision-preview</option>
|
||||
|
@@ -89,7 +89,7 @@ function drawChunks(chunks, ids) {
|
||||
$('#tokenized_chunks_display').empty();
|
||||
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let chunk = chunks[i].replace(/▁/g, ' '); // This is a leading space in sentencepiece. More info: Lower one eighth block (U+2581)
|
||||
let chunk = chunks[i].replace(/[▁Ġ]/g, ' '); // This is a leading space in sentencepiece. More info: Lower one eighth block (U+2581)
|
||||
|
||||
// If <0xHEX>, decode it
|
||||
if (/^<0x[0-9A-F]+>$/i.test(chunk)) {
|
||||
|
@@ -160,7 +160,7 @@ function renderTopLogprobs() {
|
||||
let matched = false;
|
||||
for (const [token, probability, log] of candidates) {
|
||||
const container = $('<button class="flex-container flexFlowColumn logprobs_top_candidate"></button>');
|
||||
const tokenNormalized = String(token).replace(/^▁/g, ' ');
|
||||
const tokenNormalized = String(token).replace(/^[▁Ġ]/g, ' ');
|
||||
|
||||
if (token === selectedToken || tokenNormalized === selectedToken) {
|
||||
matched = true;
|
||||
@@ -230,7 +230,7 @@ function onAlternativeClicked(tokenLogprobs, alternative) {
|
||||
const replaceIndex = messageLogprobs.findIndex(x => x === tokenLogprobs);
|
||||
|
||||
const tokens = messageLogprobs.slice(0, replaceIndex + 1).map(({ token }) => token);
|
||||
tokens[replaceIndex] = String(alternative).replace(/^▁/g, ' ');
|
||||
tokens[replaceIndex] = String(alternative).replace(/^[▁Ġ]/g, ' ').replace(/Ċ/g, '\n');
|
||||
|
||||
const prefix = continueFrom || '';
|
||||
const prompt = prefix + tokens.join('');
|
||||
@@ -343,7 +343,7 @@ function createSwipe(messageId, prompt) {
|
||||
* @returns {string}
|
||||
*/
|
||||
function toVisibleWhitespace(input) {
|
||||
return input.replace(/ /g, '·').replace(/▁/g, '·').replace(/\n/g, '↵');
|
||||
return input.replace(/ /g, '·').replace(/[▁Ġ]/g, '·').replace(/[Ċ\n]/g, '↵');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +362,7 @@ function withVirtualWhitespace(text, span) {
|
||||
if (text.match(/\s$/)) {
|
||||
result.push($(document.createTextNode('\u200b')));
|
||||
}
|
||||
if (text.match(/^▁/)) {
|
||||
if (text.match(/^[▁Ġ]/)) {
|
||||
result.unshift(document.createTextNode('\u200b'));
|
||||
}
|
||||
// line breaks are trickier. we don't currently handle consecutive line
|
||||
|
@@ -1610,6 +1610,33 @@ function saveModelList(data) {
|
||||
|
||||
$('#model_blockentropy_select').val(oai_settings.blockentropy_model).trigger('change');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.MISTRALAI) {
|
||||
/** @type {HTMLSelectElement} */
|
||||
const mistralModelSelect = document.querySelector('#model_mistralai_select');
|
||||
if (mistralModelSelect) {
|
||||
const options = Array.from(mistralModelSelect.options);
|
||||
options.forEach((option) => {
|
||||
const existingModel = model_list.find(model => model.id === option.value);
|
||||
if (!existingModel) {
|
||||
option.remove();
|
||||
}
|
||||
});
|
||||
|
||||
const otherOptionsGroup = mistralModelSelect.querySelector('#mistralai_other_models');
|
||||
for (const model of model_list.filter(model => model?.capabilities?.completion_chat)) {
|
||||
if (!options.some(option => option.value === model.id) && otherOptionsGroup) {
|
||||
otherOptionsGroup.append(new Option(model.id, model.id));
|
||||
}
|
||||
}
|
||||
|
||||
const selectedModel = model_list.find(model => model.id === oai_settings.mistralai_model);
|
||||
if (!selectedModel) {
|
||||
oai_settings.mistralai_model = model_list.find(model => model?.capabilities?.completion_chat)?.id;
|
||||
$('#model_mistralai_select').val(oai_settings.mistralai_model).trigger('change');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function appendOpenRouterOptions(model_list, groupModels = false, sort = false) {
|
||||
@@ -4103,6 +4130,8 @@ async function onModelChange() {
|
||||
$('#openai_max_context').attr('max', max_64k);
|
||||
} else if (oai_settings.mistralai_model.includes('pixtral')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.mistralai_model.includes('ministral')) {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
} else {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
}
|
||||
@@ -4660,6 +4689,8 @@ export function isImageInliningSupported() {
|
||||
'chatgpt-4o-latest',
|
||||
'yi-vision',
|
||||
'pixtral-latest',
|
||||
'pixtral-12b-latest',
|
||||
'pixtral-12b',
|
||||
'pixtral-12b-2409',
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user