Merge branch 'feature/exorcism' of https://github.com/city-unit/SillyTavern into feature/exorcism

This commit is contained in:
city-unit
2023-08-21 00:46:47 -04:00
5 changed files with 49 additions and 49 deletions

View File

@@ -2378,10 +2378,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
abortController = new AbortController(); abortController = new AbortController();
} }
if (main_api == 'novel' && quiet_prompt) {
quiet_prompt = adjustNovelInstructionPrompt(quiet_prompt);
}
// OpenAI doesn't need instruct mode. Use OAI main prompt instead. // OpenAI doesn't need instruct mode. Use OAI main prompt instead.
const isInstruct = power_user.instruct.enabled && main_api !== 'openai'; const isInstruct = power_user.instruct.enabled && main_api !== 'openai';
const isImpersonate = type == "impersonate"; const isImpersonate = type == "impersonate";
@@ -2470,6 +2466,11 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
} }
} }
if (quiet_prompt) {
quiet_prompt = substituteParams(quiet_prompt);
quiet_prompt = main_api == 'novel' ? adjustNovelInstructionPrompt(quiet_prompt) : quiet_prompt;
}
if (true === dryRun || if (true === dryRun ||
(online_status != 'no_connection' && this_chid != undefined && this_chid !== 'invalid-safety-id')) { (online_status != 'no_connection' && this_chid != undefined && this_chid !== 'invalid-safety-id')) {
let textareaText; let textareaText;
@@ -7517,7 +7518,7 @@ $(document).ready(function () {
$("#character_search_bar").val("").trigger("input"); $("#character_search_bar").val("").trigger("input");
}); });
$(document).on("click", ".character_select", function() { $(document).on("click", ".character_select", function () {
const id = $(this).attr("chid"); const id = $(this).attr("chid");
selectCharacterById(id); selectCharacterById(id);
}); });

View File

@@ -1,5 +1,4 @@
import { import {
substituteParams,
saveSettingsDebounced, saveSettingsDebounced,
systemUserName, systemUserName,
hideSwipeButtons, hideSwipeButtons,
@@ -513,7 +512,7 @@ function getQuietPrompt(mode, trigger) {
return trigger; return trigger;
} }
return substituteParams(stringFormat(extension_settings.sd.prompts[mode], trigger)); return stringFormat(extension_settings.sd.prompts[mode], trigger);
} }
function processReply(str) { function processReply(str) {
@@ -588,7 +587,7 @@ async function generatePicture(_, trigger, message, callback) {
const callbackOriginal = callback; const callbackOriginal = callback;
callback = async function (prompt, base64Image) { callback = async function (prompt, base64Image) {
const imagePath = base64Image; const imagePath = base64Image;
const imgUrl = `url(${base64Image})`; const imgUrl = `url('${encodeURIComponent(base64Image)}')`;
if ('forceSetBackground' in window) { if ('forceSetBackground' in window) {
forceSetBackground(imgUrl); forceSetBackground(imgUrl);
@@ -652,7 +651,7 @@ async function generatePrompt(quiet_prompt) {
return processReply(reply); return processReply(reply);
} }
async function sendGenerationRequest(generationType, prompt, characterName=null, callback) { async function sendGenerationRequest(generationType, prompt, characterName = null, callback) {
const prefix = generationType !== generationMode.BACKGROUND const prefix = generationType !== generationMode.BACKGROUND
? combinePrefixes(extension_settings.sd.prompt_prefix, getCharacterPrefix()) ? combinePrefixes(extension_settings.sd.prompt_prefix, getCharacterPrefix())
: extension_settings.sd.prompt_prefix; : extension_settings.sd.prompt_prefix;
@@ -862,7 +861,7 @@ async function sdMessageButton(e) {
const message_id = $mes.attr('mesid'); const message_id = $mes.attr('mesid');
const message = context.chat[message_id]; const message = context.chat[message_id];
const characterName = message?.name || context.name2; const characterName = message?.name || context.name2;
const messageText = substituteParams(message?.mes); const messageText = message?.mes;
const hasSavedImage = message?.extra?.image && message?.extra?.title; const hasSavedImage = message?.extra?.image && message?.extra?.title;
if ($icon.hasClass(busyClass)) { if ($icon.hasClass(busyClass)) {

View File

@@ -382,7 +382,7 @@ function getGroupAvatar(group) {
if (!group) { if (!group) {
return $(`<div class="avatar"><img src="${default_avatar}"></div>`); return $(`<div class="avatar"><img src="${default_avatar}"></div>`);
} }
// if isDataURL or if it's a valid local file url // if isDataURL or if it's a valid local file url
if (isValidImageUrl(group.avatar_url)) { if (isValidImageUrl(group.avatar_url)) {
return $(`<div class="avatar"><img src="${group.avatar_url}"></div>`); return $(`<div class="avatar"><img src="${group.avatar_url}"></div>`);
} }
@@ -1132,7 +1132,7 @@ function select_group_chats(groupId, skipAnimation) {
$("#rm_group_automode_label").hide(); $("#rm_group_automode_label").hide();
} }
eventSource.emit('groupSelected', {detail: {id: openGroupId, group: group}}); eventSource.emit('groupSelected', { detail: { id: openGroupId, group: group } });
} }
/** /**

View File

@@ -565,7 +565,7 @@ export function extractDataFromPng(data, identifier = 'chara') {
* @returns {Promise<string>} - Resolves to the saved image's path on the server. * @returns {Promise<string>} - Resolves to the saved image's path on the server.
* Rejects with an error if the upload fails. * Rejects with an error if the upload fails.
*/ */
export async function saveBase64AsFile(base64Data, characterName, filename="", ext) { export async function saveBase64AsFile(base64Data, characterName, filename = "", ext) {
// Construct the full data URL // Construct the full data URL
const format = ext; // Extract the file extension (jpg, png, webp) const format = ext; // Extract the file extension (jpg, png, webp)
const dataURL = `data:image/${format};base64,${base64Data}`; const dataURL = `data:image/${format};base64,${base64Data}`;

View File

@@ -2656,13 +2656,13 @@ app.post('/uploadimage', jsonParser, async (request, response) => {
// Constructing filename and path // Constructing filename and path
let filename = `${Date.now()}.${format}`; let filename = `${Date.now()}.${format}`;
if(request.body.filename){ if (request.body.filename) {
filename = `${request.body.filename}.${format}`; filename = `${request.body.filename}.${format}`;
} }
// if character is defined, save to a sub folder for that character // if character is defined, save to a sub folder for that character
let pathToNewFile = path.join(directories.userImages, filename); let pathToNewFile = path.join(directories.userImages, filename);
if(request.body.ch_name){ if (request.body.ch_name) {
pathToNewFile = path.join(directories.userImages, request.body.ch_name, filename); pathToNewFile = path.join(directories.userImages, request.body.ch_name, filename);
} }
@@ -2672,7 +2672,7 @@ app.post('/uploadimage', jsonParser, async (request, response) => {
await fs.promises.writeFile(pathToNewFile, imageBuffer); await fs.promises.writeFile(pathToNewFile, imageBuffer);
// send the path to the image, relative to the client folder, which means removing the first folder from the path which is 'public' // send the path to the image, relative to the client folder, which means removing the first folder from the path which is 'public'
pathToNewFile = pathToNewFile.split(path.sep).slice(1).join(path.sep); pathToNewFile = pathToNewFile.split(path.sep).slice(1).join(path.sep);
response.send({ path:pathToNewFile }); response.send({ path: pathToNewFile });
} catch (error) { } catch (error) {
console.log(error); console.log(error);
response.status(500).send({ error: "Failed to save the image" }); response.status(500).send({ error: "Failed to save the image" });