Merge branch 'SillyTavern:staging' into staging

This commit is contained in:
Tony Ribeiro 2023-08-15 21:15:45 +02:00 committed by GitHub
commit 3cb2b7a4a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 3 deletions

14
public/img/openrouter.svg Normal file
View File

@ -0,0 +1,14 @@
<svg width="100%" height="100%" viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg" class="Navbar_logo__INhgK" aria-label="Logo">
<g clip-path="url(#clip0_205_3)">
<path d="M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945" stroke-width="90"></path>
<path d="M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"></path>
<path d="M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377" stroke-width="90"></path>
<path d="M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"></path>
</g>
<defs>
<clipPath id="clip0_205_3">
<rect width="512" height="512"></rect>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 777 B

View File

@ -49,7 +49,8 @@
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script>
function applyLocale() {
var language = navigator.language || navigator.userLanguage;
const overrideLanguage = localStorage.getItem("language");
var language = overrideLanguage || navigator.language || navigator.userLanguage;
language = language.toLowerCase();
console.log(language)
//load the appropriate language file
@ -2484,6 +2485,19 @@
</div>
</div>
</div>
<div id="UI-language-block" class="flex-container flexFlowColumn">
<h4>
<span data-i18n="UI Language">UI Language</span>
</h4>
<div class="flex-container flexnowrap alignitemscenter">
<select id="ui_language_select" class="margin0 margin-r5">
<option value="" data-i18n="Browser default">
Browser default
</option>
<option value="en">en</option>
</select>
</div>
</div>
<div id="UI-presets-block" class="flex-container flexFlowColumn">
<h4>
<span data-i18n="UI Theme Preset">UI Theme Preset</span>

View File

@ -1369,9 +1369,21 @@ function messageFormatting(mes, ch_name, isSystem, isUser) {
function insertSVGIcon(mes, extra) {
// Determine the SVG filename
let modelName;
if (extra.api === "openai" && extra.model.toLowerCase().includes("claude")) {
// Claude on OpenRouter or Anthropic
if (extra.api === "openai" && extra.model?.toLowerCase().includes("claude")) {
modelName = "claude";
} else {
}
// OpenAI on OpenRouter
else if (extra.api === "openai" && extra.model?.toLowerCase().includes("openai")) {
modelName = "openai";
}
// OpenRouter website model or other models
else if (extra.api === "openai" && (extra.model === null || extra.model?.toLowerCase().includes("/"))) {
modelName = "openrouter";
}
// Everything else
else {
modelName = extra.api;
}

View File

@ -651,6 +651,7 @@ function onTtsProviderSettingsInput() {
ttsProvider.onSettingsChange()
// Persist changes to SillyTavern tts extension settings
extension_settings.tts[ttsProviderName] = ttsProvider.settings
saveSettingsDebounced()
console.info(`Saved settings ${ttsProviderName} ${JSON.stringify(ttsProvider.settings)}`)

View File

@ -202,6 +202,7 @@ let movingUIPresets = [];
let instruct_presets = [];
const storage_keys = {
ui_language: "language",
fast_ui_mode: "TavernAI_fast_ui_mode",
avatar_style: "TavernAI_avatar_style",
chat_display: "TavernAI_chat_display",
@ -1339,8 +1340,25 @@ function doResetPanels() {
$("#movingUIreset").trigger('click');
}
function addLanguagesToDropdown() {
$.getJSON('i18n.json', function (data) {
if (!Array.isArray(data?.lang)) {
return;
}
for (const lang of data.lang) {
const option = document.createElement('option');
option.value = lang;
option.innerText = lang;
$('#ui_language_select').append(option);
}
const selectedLanguage = localStorage.getItem(storage_keys.ui_language);
if (selectedLanguage) {
$('#ui_language_select').val(selectedLanguage);
}
});
}
function setAvgBG() {
const bgimg = new Image();
@ -2090,6 +2108,18 @@ $(document).ready(() => {
saveSettingsDebounced();
});
$('#ui_language_select').on('change', async function () {
const language = $(this).val();
if (language) {
localStorage.setItem(storage_keys.ui_language, language);
} else {
localStorage.removeItem(storage_keys.ui_language);
}
location.reload();
});
$(window).on('focus', function () {
browser_has_focus = true;
});
@ -2105,4 +2135,5 @@ $(document).ready(() => {
registerSlashCommand('cut', doMesCut, [], ' <span class="monospace">(requred number)</span> cuts the specified message from the chat', true, true);
registerSlashCommand('resetpanels', doResetPanels, ['resetui'], ' resets UI panels to original state.', true, true);
registerSlashCommand('bgcol', setAvgBG, [], ' WIP test of auto-bg avg coloring', true, true);
addLanguagesToDropdown();
});