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/tags.js"></script>
|
||||||
<script type="module" src="scripts/secrets.js"></script>
|
<script type="module" src="scripts/secrets.js"></script>
|
||||||
<script type="module" src="scripts/context-template.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>
|
<script type="text/javascript" src="scripts/toolcool-color-picker.js"></script>
|
||||||
|
|
||||||
<title>SillyTavern</title>
|
<title>SillyTavern</title>
|
||||||
|
@ -3575,29 +3575,21 @@ async function getChat() {
|
|||||||
} else {
|
} else {
|
||||||
chat_create_date = humanizedDateTime();
|
chat_create_date = humanizedDateTime();
|
||||||
}
|
}
|
||||||
getChatResult();
|
await getChatResult();
|
||||||
saveChat();
|
await saveChat();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('#send_textarea').click();
|
$('#send_textarea').click();
|
||||||
$('#send_textarea').focus();
|
$('#send_textarea').focus();
|
||||||
}, 200);
|
}, 200);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
getChatResult();
|
await getChatResult();
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChatResult() {
|
async function getChatResult() {
|
||||||
name2 = characters[this_chid].name;
|
name2 = characters[this_chid].name;
|
||||||
if (chat.length > 1) {
|
if (chat.length === 0) {
|
||||||
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 {
|
|
||||||
const firstMes = characters[this_chid].first_mes || default_ch_mes;
|
const firstMes = characters[this_chid].first_mes || default_ch_mes;
|
||||||
chat[0] = {
|
chat[0] = {
|
||||||
name: name2,
|
name: name2,
|
||||||
@ -3609,6 +3601,10 @@ function getChatResult() {
|
|||||||
}
|
}
|
||||||
printMessages();
|
printMessages();
|
||||||
select_selected_character(this_chid);
|
select_selected_character(this_chid);
|
||||||
|
|
||||||
|
if (chat.length === 1) {
|
||||||
|
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openCharacterChat(file_name) {
|
async function openCharacterChat(file_name) {
|
||||||
@ -3806,19 +3802,20 @@ function reloadUserAvatar() {
|
|||||||
//***************SETTINGS****************//
|
//***************SETTINGS****************//
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
async function getSettings(type) {
|
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) {
|
if (data.result != "file not find" && data.settings) {
|
||||||
settings = JSON.parse(data.settings);
|
settings = JSON.parse(data.settings);
|
||||||
if (settings.username !== undefined) {
|
if (settings.username !== undefined) {
|
||||||
@ -3951,17 +3948,6 @@ async function getSettings(type) {
|
|||||||
|
|
||||||
setWorldInfoSettings(settings, data);
|
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 =
|
api_server_textgenerationwebui =
|
||||||
settings.api_server_textgenerationwebui;
|
settings.api_server_textgenerationwebui;
|
||||||
$("#textgenerationwebui_api_url_text").val(
|
$("#textgenerationwebui_api_url_text").val(
|
||||||
@ -3969,15 +3955,13 @@ async function getSettings(type) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
selected_button = settings.selected_button;
|
selected_button = settings.selected_button;
|
||||||
|
|
||||||
|
if (data.enable_extensions) {
|
||||||
|
await loadExtensionSettings(settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_checked_colab) isColab();
|
if (!is_checked_colab) isColab();
|
||||||
},
|
|
||||||
error: function (jqXHR, exception) {
|
|
||||||
console.log(exception);
|
|
||||||
console.log(jqXHR);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectKoboldGuiPreset() {
|
function selectKoboldGuiPreset() {
|
||||||
@ -5694,6 +5678,7 @@ $(document).ready(function () {
|
|||||||
add_mes_without_animation = true;
|
add_mes_without_animation = true;
|
||||||
//console.log('form create submission calling addOneMessage');
|
//console.log('form create submission calling addOneMessage');
|
||||||
addOneMessage(chat[0]);
|
addOneMessage(chat[0]);
|
||||||
|
await eventSource.emit(event_types.MESSAGE_RECEIVED, (chat.length - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#create_button").removeAttr("disabled");
|
$("#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";
|
import { extension_settings, getContext } from "../../extensions.js";
|
||||||
|
|
||||||
const autoModeOptions = {
|
const autoModeOptions = {
|
||||||
@ -152,7 +152,8 @@ async function translateIncomingMessage(messageId) {
|
|||||||
return;
|
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;
|
message.extra.display_text = translation;
|
||||||
|
|
||||||
$(`#chat .mes[mesid="${messageId}"] .mes_text`).html(messageFormatting(translation, message.name, message.is_system, message.is_user));
|
$(`#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",
|
"display_name": "Chat Translation",
|
||||||
"loading_order": 10,
|
"loading_order": 1,
|
||||||
"requires": [],
|
"requires": [],
|
||||||
"optional": [],
|
"optional": [],
|
||||||
"js": "index.js",
|
"js": "index.js",
|
||||||
|
Reference in New Issue
Block a user