mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/SillyLossy/TavernAI into dev
This commit is contained in:
@ -128,6 +128,8 @@ export {
|
||||
getTokenCount,
|
||||
isStreamingEnabled,
|
||||
getThumbnailUrl,
|
||||
getStoppingStrings,
|
||||
getStatus,
|
||||
chat,
|
||||
this_chid,
|
||||
settings,
|
||||
@ -1013,10 +1015,11 @@ function substituteParams(content, _name1, _name2) {
|
||||
return content;
|
||||
}
|
||||
|
||||
function getStoppingStrings(isImpersonate) {
|
||||
const charString = `"\n${name2}: "`;
|
||||
const userString = is_pygmalion ? `"\nYou: "` : `"\n${name1}: "`;
|
||||
return isImpersonate ? charString : userString;
|
||||
function getStoppingStrings(isImpersonate, wrapInQuotes) {
|
||||
const charString = `\n${name2}: `;
|
||||
const userString = is_pygmalion ? `\nYou: ` : `\n${name1}: `;
|
||||
const result = isImpersonate ? charString : userString;
|
||||
return wrapInQuotes ? `"${result}"` : result;
|
||||
}
|
||||
|
||||
function getSlashCommand(message, type) {
|
||||
@ -1862,7 +1865,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
||||
};
|
||||
|
||||
if (preset_settings != 'gui' || horde_settings.use_horde) {
|
||||
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context);
|
||||
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context, isImpersonate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1886,7 +1889,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
||||
'early_stopping': textgenerationwebui_settings.early_stopping,
|
||||
'seed': textgenerationwebui_settings.seed,
|
||||
'add_bos_token': textgenerationwebui_settings.add_bos_token,
|
||||
'custom_stopping_strings': JSON.stringify(getStoppingStrings(isImpersonate)),
|
||||
'custom_stopping_strings': JSON.stringify(getStoppingStrings(isImpersonate, false)),
|
||||
'truncation_length': max_context,
|
||||
'ban_eos_token': textgenerationwebui_settings.ban_eos_token,
|
||||
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
|
||||
|
@ -38,6 +38,7 @@ const DEFAULT_EXPRESSIONS = [
|
||||
let expressionsList = null;
|
||||
let lastCharacter = undefined;
|
||||
let lastMessage = null;
|
||||
let existingExpressions = [];
|
||||
let inApiCall = false;
|
||||
|
||||
function onExpressionsShowDefaultInput() {
|
||||
@ -96,11 +97,16 @@ async function moduleWorker() {
|
||||
$('.expression_settings .offline_mode').css('display', 'none');
|
||||
}
|
||||
|
||||
// character has no expressions or it is not loaded
|
||||
if (!context.groupId && existingExpressions.length === 0) {
|
||||
lastCharacter = context.groupId || context.characterId;
|
||||
return;
|
||||
}
|
||||
|
||||
// check if last message changed
|
||||
const currentLastMessage = getLastCharacterMessage();
|
||||
if ((lastCharacter === context.characterId || lastCharacter === context.groupId)
|
||||
&& lastMessage === currentLastMessage.mes
|
||||
&& $('img.expression').attr('src')) {
|
||||
&& lastMessage === currentLastMessage.mes) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,6 +169,7 @@ async function validateImages() {
|
||||
}
|
||||
|
||||
imagesValidating = true;
|
||||
existingExpressions = [];
|
||||
const context = getContext();
|
||||
$('.expression_settings').show();
|
||||
$('#image_list').empty();
|
||||
@ -172,18 +179,19 @@ async function validateImages() {
|
||||
return;
|
||||
}
|
||||
|
||||
const IMAGE_LIST = (await getExpressionsList()).map(x => `${x}.png`);
|
||||
const IMAGE_LIST = (await getExpressionsList()).map(x => ({ name: x, file: `${x}.png` }));
|
||||
IMAGE_LIST.forEach((item) => {
|
||||
const image = document.createElement('img');
|
||||
image.src = `/characters/${context.name2}/${item}`;
|
||||
image.src = `/characters/${context.name2}/${item.file}`;
|
||||
image.classList.add('debug-image');
|
||||
image.width = '0px';
|
||||
image.height = '0px';
|
||||
image.onload = function () {
|
||||
$('#image_list').append(getListItem(item, image.src, 'success'));
|
||||
existingExpressions.push(item.name);
|
||||
$('#image_list').append(getListItem(item.file, image.src, 'success'));
|
||||
}
|
||||
image.onerror = function () {
|
||||
$('#image_list').append(getListItem(item, '/img/No-Image-Placeholder.svg', 'failure'));
|
||||
$('#image_list').append(getListItem(item.file, '/img/No-Image-Placeholder.svg', 'failure'));
|
||||
}
|
||||
$('#image_list').prepend(image);
|
||||
});
|
||||
@ -232,29 +240,33 @@ async function getExpressionsList() {
|
||||
|
||||
async function setExpression(character, expression, force) {
|
||||
const filename = `${expression}.png`;
|
||||
const debugImageStatus = document.querySelector(`#image_list div[id="${filename}"] span`);
|
||||
const img = $('img.expression');
|
||||
|
||||
if (!debugImageStatus && !force) {
|
||||
validateImages();
|
||||
setTimeout(() => setExpression(character, expression, false), 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (force || (debugImageStatus && !debugImageStatus.classList.contains('failure'))) {
|
||||
if (force || (existingExpressions.includes(expression))) {
|
||||
//console.log('setting expression from character images folder');
|
||||
const imgUrl = `/characters/${character}/${filename}`;
|
||||
img.attr('src', imgUrl);
|
||||
img.removeClass('default');
|
||||
img.off('error');
|
||||
img.on('error', function() {
|
||||
$(this).attr('src', '');
|
||||
if (force && extension_settings.expressions.showDefault) {
|
||||
setDefault();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (extension_settings.expressions.showDefault) {
|
||||
//console.log('no character images, trying default expressions');
|
||||
const defImgUrl = `/img/default-expressions/${filename}`;
|
||||
//console.log(defImgUrl);
|
||||
img.attr('src', defImgUrl);
|
||||
img.addClass('default');
|
||||
setDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function setDefault() {
|
||||
const defImgUrl = `/img/default-expressions/${filename}`;
|
||||
//console.log(defImgUrl);
|
||||
img.attr('src', defImgUrl);
|
||||
img.addClass('default');
|
||||
}
|
||||
}
|
||||
|
||||
function onClickExpressionImage() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import {
|
||||
saveSettingsDebounced,
|
||||
getStoppingStrings,
|
||||
} from "../script.js";
|
||||
|
||||
export {
|
||||
@ -55,7 +56,7 @@ function loadKoboldSettings(preset) {
|
||||
}
|
||||
}
|
||||
|
||||
function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context) {
|
||||
function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, this_max_context, isImpersonate) {
|
||||
let generate_data = {
|
||||
prompt: finalPromt,
|
||||
gui_settings: false,
|
||||
@ -80,6 +81,7 @@ function getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, thi
|
||||
s7: this_settings.sampler_order[6],
|
||||
use_world_info: false,
|
||||
singleline: kai_settings.single_line,
|
||||
stop_sequence: [getStoppingStrings(isImpersonate, false)],
|
||||
};
|
||||
return generate_data;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
characters,
|
||||
callPopup,
|
||||
token,
|
||||
getStatus,
|
||||
} from "../script.js";
|
||||
import { delay } from "./utils.js";
|
||||
|
||||
@ -345,6 +346,7 @@ $(document).ready(() => {
|
||||
|
||||
$("#pygmalion_formatting").change(function (e) {
|
||||
power_user.pygmalion_formatting = Number($(this).find(":selected").val());
|
||||
getStatus();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user