mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Unconditional load of extensions. Fixes for translations
This commit is contained in:
@ -64,6 +64,7 @@
|
||||
<script type="module" src="scripts/tags.js"></script>
|
||||
<script type="module" src="scripts/secrets.js"></script>
|
||||
<script type="module" src="scripts/context-template.js"></script>
|
||||
<script type="module" src="scripts/extensions.js"></script>
|
||||
<script type="text/javascript" src="scripts/toolcool-color-picker.js"></script>
|
||||
|
||||
<title>SillyTavern</title>
|
||||
|
@ -3575,29 +3575,21 @@ async function getChat() {
|
||||
} else {
|
||||
chat_create_date = humanizedDateTime();
|
||||
}
|
||||
getChatResult();
|
||||
saveChat();
|
||||
await getChatResult();
|
||||
await saveChat();
|
||||
setTimeout(function () {
|
||||
$('#send_textarea').click();
|
||||
$('#send_textarea').focus();
|
||||
}, 200);
|
||||
} catch (error) {
|
||||
getChatResult();
|
||||
await getChatResult();
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
function getChatResult() {
|
||||
async function getChatResult() {
|
||||
name2 = characters[this_chid].name;
|
||||
if (chat.length > 1) {
|
||||
for (let i = 0; i < chat.length; i++) {
|
||||
const item = chat[i];
|
||||
if (item["is_user"]) {
|
||||
//item['mes'] = item['mes'].replace(default_user_name + ':', name1 + ':');
|
||||
//item['name'] = name1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (chat.length === 0) {
|
||||
const firstMes = characters[this_chid].first_mes || default_ch_mes;
|
||||
chat[0] = {
|
||||
name: name2,
|
||||
@ -3609,6 +3601,10 @@ function getChatResult() {
|
||||
}
|
||||
printMessages();
|
||||
select_selected_character(this_chid);
|
||||
|
||||
if (chat.length === 1) {
|
||||
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
|
||||
}
|
||||
}
|
||||
|
||||
async function openCharacterChat(file_name) {
|
||||
@ -3806,19 +3802,20 @@ function reloadUserAvatar() {
|
||||
//***************SETTINGS****************//
|
||||
///////////////////////////////////////////
|
||||
async function getSettings(type) {
|
||||
//timer
|
||||
const response = await fetch("/getsettings", {
|
||||
method: "POST",
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({}),
|
||||
cache: "no-cache",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
toastr.error('Settings could not be loaded. Try reloading the page.');
|
||||
throw new Error('Error getting settings');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
//console.log('getSettings() pinging server for settings request');
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: "/getsettings",
|
||||
data: JSON.stringify({}),
|
||||
beforeSend: function () { },
|
||||
cache: false,
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
//processData: false,
|
||||
success: function (data) {
|
||||
if (data.result != "file not find" && data.settings) {
|
||||
settings = JSON.parse(data.settings);
|
||||
if (settings.username !== undefined) {
|
||||
@ -3951,17 +3948,6 @@ async function getSettings(type) {
|
||||
|
||||
setWorldInfoSettings(settings, data);
|
||||
|
||||
if (data.enable_extensions) {
|
||||
const src = "scripts/extensions.js";
|
||||
if ($(`script[src="${src}"]`).length === 0) {
|
||||
const script = document.createElement("script");
|
||||
script.type = "module";
|
||||
script.src = src;
|
||||
$("body").append(script);
|
||||
}
|
||||
loadExtensionSettings(settings);
|
||||
}
|
||||
|
||||
api_server_textgenerationwebui =
|
||||
settings.api_server_textgenerationwebui;
|
||||
$("#textgenerationwebui_api_url_text").val(
|
||||
@ -3969,15 +3955,13 @@ async function getSettings(type) {
|
||||
);
|
||||
|
||||
selected_button = settings.selected_button;
|
||||
|
||||
if (data.enable_extensions) {
|
||||
await loadExtensionSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_checked_colab) isColab();
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
console.log(exception);
|
||||
console.log(jqXHR);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function selectKoboldGuiPreset() {
|
||||
@ -4926,7 +4910,7 @@ const swipe_right = () => {
|
||||
chat[chat.length - 1]['swipe_id']++; //make new slot in array
|
||||
if (chat[chat.length - 1].extra) {
|
||||
// if message has memory attached - remove it to allow regen
|
||||
if ( chat[chat.length - 1].extra.memory) {
|
||||
if (chat[chat.length - 1].extra.memory) {
|
||||
delete chat[chat.length - 1].extra.memory;
|
||||
}
|
||||
// ditto for display text
|
||||
@ -5694,6 +5678,7 @@ $(document).ready(function () {
|
||||
add_mes_without_animation = true;
|
||||
//console.log('form create submission calling addOneMessage');
|
||||
addOneMessage(chat[0]);
|
||||
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
|
||||
}
|
||||
}
|
||||
$("#create_button").removeAttr("disabled");
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { eventSource, event_types, getRequestHeaders, messageFormatting, saveSettingsDebounced } from "../../../script.js";
|
||||
import { eventSource, event_types, getRequestHeaders, messageFormatting, saveSettingsDebounced, substituteParams } from "../../../script.js";
|
||||
import { extension_settings, getContext } from "../../extensions.js";
|
||||
|
||||
const autoModeOptions = {
|
||||
@ -152,7 +152,8 @@ async function translateIncomingMessage(messageId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const translation = await translate(message.mes, extension_settings.translate.target_language);
|
||||
const textToTranslate = substituteParams(message.mes, context.name1, message.name);
|
||||
const translation = await translate(textToTranslate, extension_settings.translate.target_language);
|
||||
message.extra.display_text = translation;
|
||||
|
||||
$(`#chat .mes[mesid="${messageId}"] .mes_text`).html(messageFormatting(translation, message.name, message.is_system, message.is_user));
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"display_name": "Chat Translation",
|
||||
"loading_order": 10,
|
||||
"loading_order": 1,
|
||||
"requires": [],
|
||||
"optional": [],
|
||||
"js": "index.js",
|
||||
|
Reference in New Issue
Block a user