Merge branch 'staging' of http://github.com/cohee1207/SillyTavern into staging

This commit is contained in:
Cohee 2023-08-24 18:32:46 +03:00
commit d4bd91f6ec
8 changed files with 83 additions and 4 deletions

View File

@ -129,6 +129,7 @@
"prefer_character_prompt": true, "prefer_character_prompt": true,
"prefer_character_jailbreak": true, "prefer_character_jailbreak": true,
"quick_continue": false, "quick_continue": false,
"continue_on_send": false,
"trim_spaces": true, "trim_spaces": true,
"relaxed_api_urls": false, "relaxed_api_urls": false,
"default_instruct": "", "default_instruct": "",

View File

@ -2827,6 +2827,12 @@
<input id="prefer_character_jailbreak" type="checkbox" /> <input id="prefer_character_jailbreak" type="checkbox" />
<span data-i18n="Prefer Character Card Jailbreak">Prefer Char. JB</span> <span data-i18n="Prefer Character Card Jailbreak">Prefer Char. JB</span>
</label> </label>
<label class="checkbox_label" for="continue_on_send">
<input id="continue_on_send" type="checkbox" />
<span data-i18n="Press Send to continue">
Press "Send" to continue
</span>
</label>
<label class="checkbox_label" for="quick_continue"> <label class="checkbox_label" for="quick_continue">
<input id="quick_continue" type="checkbox" /> <input id="quick_continue" type="checkbox" />
<span data-i18n="Press Send to continue"> <span data-i18n="Press Send to continue">

View File

@ -1,8 +1,8 @@
{ {
"name": "Vicuna 1.1", "name": "Vicuna 1.1",
"system_prompt": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n", "system_prompt": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n",
"input_sequence": "USER: ", "input_sequence": "\nUSER: ",
"output_sequence": "ASSISTANT: ", "output_sequence": "\nASSISTANT: ",
"last_output_sequence": "", "last_output_sequence": "",
"system_sequence": "BEGINNING OF CONVERSATION:", "system_sequence": "BEGINNING OF CONVERSATION:",
"stop_sequence": "", "stop_sequence": "",

View File

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"checkJs": true, "checkJs": true,
"target": "ESNext", "target": "ESNext",
"module": "commonjs", "module": "ESNext",
"allowUmdGlobalAccess": true, "allowUmdGlobalAccess": true,
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
}, },

View File

@ -2320,6 +2320,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
} }
} }
if (!type && !textareaText && power_user.continue_on_send && !selected_group && chat.length && !chat[chat.length - 1]['is_user'] && !chat[chat.length - 1]['is_system']) {
type = 'continue';
}
const isContinue = type == 'continue'; const isContinue = type == 'continue';
if (!dryRun) { if (!dryRun) {
@ -2641,8 +2645,11 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
console.debug('--setting Prompt string'); console.debug('--setting Prompt string');
mesExmString = pinExmString ?? mesExamplesArray.slice(0, count_exm_add).join(''); mesExmString = pinExmString ?? mesExamplesArray.slice(0, count_exm_add).join('');
if (mesSend.length) {
mesSend[mesSend.length - 1] = modifyLastPromptLine(mesSend[mesSend.length - 1]); mesSend[mesSend.length - 1] = modifyLastPromptLine(mesSend[mesSend.length - 1]);
} }
}
function modifyLastPromptLine(lastMesString) { function modifyLastPromptLine(lastMesString) {
// Add quiet generation prompt at depth 0 // Add quiet generation prompt at depth 0
@ -3799,6 +3806,10 @@ async function saveReply(type, getMessage, this_mes_is_name, title) {
type = 'normal'; type = 'normal';
} }
if (chat.length && typeof chat[chat.length - 1]['extra'] !== 'object') {
chat[chat.length - 1]['extra'] = {};
}
let oldMessage = '' let oldMessage = ''
const generationFinished = new Date(); const generationFinished = new Date();
const img = extractImageFromMessage(getMessage); const img = extractImageFromMessage(getMessage);
@ -4356,9 +4367,11 @@ function getFirstMessage() {
const message = { const message = {
name: name2, name: name2,
is_user: false, is_user: false,
is_system: false,
is_name: true, is_name: true,
send_date: getMessageTimeStamp(), send_date: getMessageTimeStamp(),
mes: getRegexedString(firstMes, regex_placement.AI_OUTPUT), mes: getRegexedString(firstMes, regex_placement.AI_OUTPUT),
extra: {},
}; };
if (Array.isArray(alternateGreetings) && alternateGreetings.length > 0) { if (Array.isArray(alternateGreetings) && alternateGreetings.length > 0) {

View File

@ -8,6 +8,7 @@ import {
extractAllWords, extractAllWords,
saveBase64AsFile, saveBase64AsFile,
PAGINATION_TEMPLATE, PAGINATION_TEMPLATE,
waitUntilCondition,
} from './utils.js'; } from './utils.js';
import { RA_CountCharTokens, humanizedDateTime, dragElement, favsToHotswap, getMessageTimeStamp } from "./RossAscends-mods.js"; import { RA_CountCharTokens, humanizedDateTime, dragElement, favsToHotswap, getMessageTimeStamp } from "./RossAscends-mods.js";
import { loadMovingUIState, sortEntitiesList } from './power-user.js'; import { loadMovingUIState, sortEntitiesList } from './power-user.js';
@ -665,6 +666,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
if (streamingProcessor && !streamingProcessor.isFinished) { if (streamingProcessor && !streamingProcessor.isFinished) {
await delay(100); await delay(100);
} else { } else {
await waitUntilCondition(() => streamingProcessor == null, 1000, 10);
messagesBefore++; messagesBefore++;
break; break;
} }

View File

@ -3,6 +3,55 @@ import { waitUntilCondition } from "./utils.js";
const storageKey = "language"; const storageKey = "language";
export const localeData = await fetch("i18n.json").then(response => response.json()); export const localeData = await fetch("i18n.json").then(response => response.json());
function getMissingTranslations() {
const missingData = [];
for (const language of localeData.lang) {
$(document).find("[data-i18n]").each(function () {
const keys = $(this).data("i18n").split(';'); // Multi-key entries are ; delimited
for (const key of keys) {
const attributeMatch = key.match(/\[(\S+)\](.+)/); // [attribute]key
if (attributeMatch) { // attribute-tagged key
const localizedValue = localeData?.[language]?.[attributeMatch[2]];
if (!localizedValue) {
missingData.push({ key, language, value: $(this).attr(attributeMatch[1]) });
}
} else { // No attribute tag, treat as 'text'
const localizedValue = localeData?.[language]?.[key];
if (!localizedValue) {
missingData.push({ key, language, value: $(this).text().trim() });
}
}
}
});
}
// Remove duplicates
const uniqueMissingData = [];
for (const { key, language, value } of missingData) {
if (!uniqueMissingData.some(x => x.key === key && x.language === language && x.value === value)) {
uniqueMissingData.push({ key, language, value });
}
}
// Sort by language, then key
uniqueMissingData.sort((a, b) => a.language.localeCompare(b.language) || a.key.localeCompare(b.key));
// Map to { language: { key: value } }
const missingDataMap = {};
for (const { key, language, value } of uniqueMissingData) {
if (!missingDataMap[language]) {
missingDataMap[language] = {};
}
missingDataMap[language][key] = value;
}
console.table(uniqueMissingData);
console.log(missingDataMap);
}
window["getMissingTranslations"] = getMissingTranslations;
export function applyLocale(root = document) { export function applyLocale(root = document) {
const overrideLanguage = localStorage.getItem("language"); const overrideLanguage = localStorage.getItem("language");
var language = overrideLanguage || navigator.language || navigator.userLanguage; var language = overrideLanguage || navigator.language || navigator.userLanguage;

View File

@ -152,6 +152,7 @@ let power_user = {
prefer_character_prompt: true, prefer_character_prompt: true,
prefer_character_jailbreak: true, prefer_character_jailbreak: true,
quick_continue: false, quick_continue: false,
continue_on_send: false,
trim_spaces: true, trim_spaces: true,
relaxed_api_urls: false, relaxed_api_urls: false,
@ -708,6 +709,7 @@ function loadPowerUserSettings(settings, data) {
$('#relaxed_api_urls').prop("checked", power_user.relaxed_api_urls); $('#relaxed_api_urls').prop("checked", power_user.relaxed_api_urls);
$('#trim_spaces').prop("checked", power_user.trim_spaces); $('#trim_spaces').prop("checked", power_user.trim_spaces);
$('#continue_on_send').prop("checked", power_user.continue_on_send);
$('#quick_continue').prop("checked", power_user.quick_continue); $('#quick_continue').prop("checked", power_user.quick_continue);
$('#mes_continue').css('display', power_user.quick_continue ? '' : 'none'); $('#mes_continue').css('display', power_user.quick_continue ? '' : 'none');
$('#auto_swipe').prop("checked", power_user.auto_swipe); $('#auto_swipe').prop("checked", power_user.auto_swipe);
@ -1968,6 +1970,12 @@ $(document).ready(() => {
saveSettingsDebounced(); saveSettingsDebounced();
}); });
$("#continue_on_send").on("input", function () {
const value = !!$(this).prop('checked');
power_user.continue_on_send = value;
saveSettingsDebounced();
});
$("#quick_continue").on("input", function () { $("#quick_continue").on("input", function () {
const value = !!$(this).prop('checked'); const value = !!$(this).prop('checked');
power_user.quick_continue = value; power_user.quick_continue = value;