mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' into feature/chromadb
This commit is contained in:
@ -107,7 +107,17 @@ import {
|
|||||||
setPoeOnlineStatus,
|
setPoeOnlineStatus,
|
||||||
} from "./scripts/poe.js";
|
} from "./scripts/poe.js";
|
||||||
|
|
||||||
import { debounce, delay, restoreCaretPosition, saveCaretPosition, end_trim_to_sentence, countOccurrences, isOdd } from "./scripts/utils.js";
|
import {
|
||||||
|
debounce,
|
||||||
|
delay,
|
||||||
|
restoreCaretPosition,
|
||||||
|
saveCaretPosition,
|
||||||
|
end_trim_to_sentence,
|
||||||
|
countOccurrences,
|
||||||
|
isOdd,
|
||||||
|
isElementInViewport,
|
||||||
|
} from "./scripts/utils.js";
|
||||||
|
|
||||||
import { extension_settings, loadExtensionSettings, runGenerationInterceptors } from "./scripts/extensions.js";
|
import { extension_settings, loadExtensionSettings, runGenerationInterceptors } from "./scripts/extensions.js";
|
||||||
import { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand } from "./scripts/slash-commands.js";
|
import { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand } from "./scripts/slash-commands.js";
|
||||||
import {
|
import {
|
||||||
@ -195,6 +205,7 @@ export {
|
|||||||
talkativeness_default,
|
talkativeness_default,
|
||||||
default_ch_mes,
|
default_ch_mes,
|
||||||
extension_prompt_types,
|
extension_prompt_types,
|
||||||
|
setCharListVisible,
|
||||||
}
|
}
|
||||||
|
|
||||||
// API OBJECT FOR EXTERNAL WIRING
|
// API OBJECT FOR EXTERNAL WIRING
|
||||||
@ -801,6 +812,7 @@ function printCharacters() {
|
|||||||
printGroups();
|
printGroups();
|
||||||
sortCharactersList();
|
sortCharactersList();
|
||||||
favsToHotswap();
|
favsToHotswap();
|
||||||
|
setCharListVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCharacters() {
|
async function getCharacters() {
|
||||||
@ -2967,7 +2979,9 @@ function extractNameFromMessage(getMessage, force_name2, isImpersonate) {
|
|||||||
// Like OAI, Poe is very unlikely to send you an incomplete message.
|
// Like OAI, Poe is very unlikely to send you an incomplete message.
|
||||||
// But it doesn't send "name:" either, so we assume that we always have a name
|
// But it doesn't send "name:" either, so we assume that we always have a name
|
||||||
// prepend to have clearer logs when building up a prompt context.
|
// prepend to have clearer logs when building up a prompt context.
|
||||||
if (force_name2 || main_api == 'poe')
|
// Instruct mode needs to have it on to make sure you won't have names lost
|
||||||
|
// if disable in a middle of a solo chat.
|
||||||
|
if (force_name2 || main_api == 'poe' || power_user.instruct.enabled)
|
||||||
this_mes_is_name = true;
|
this_mes_is_name = true;
|
||||||
|
|
||||||
if (isImpersonate) {
|
if (isImpersonate) {
|
||||||
@ -4767,6 +4781,33 @@ const swipe_right = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCharListVisible() {
|
||||||
|
const $children = $("#rm_print_characters_block").children();
|
||||||
|
$children.each(function () {
|
||||||
|
if (isElementInViewport($(this))) {
|
||||||
|
$(this)
|
||||||
|
//.css('opacity', 1);
|
||||||
|
//.css('display', 'flex');
|
||||||
|
.stop(true, false).animate({ opacity: 1 }, { duration: 50, queue: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isElementInViewport($(this)) &&
|
||||||
|
($(this).css('opacity') === '1' || $(this).css('opacity') === undefined)) {
|
||||||
|
//.css('opacity', 0);
|
||||||
|
|
||||||
|
$(this)
|
||||||
|
//.css('opacity', 0);
|
||||||
|
//.css('display', 'none');
|
||||||
|
.stop(true, false).animate({ opacity: 0 }, { duration: 50, queue: false });
|
||||||
|
};
|
||||||
|
/* console.log(`chid ${$(elem).find('.ch_name').text()}
|
||||||
|
inview? ${isElementInViewport($(elem))}
|
||||||
|
opacity? ${$(elem).css('opacity')}`
|
||||||
|
|
||||||
|
); */
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
|
||||||
@ -5688,13 +5729,11 @@ $(document).ready(function () {
|
|||||||
duration: 250,
|
duration: 250,
|
||||||
easing: animation_easing,
|
easing: animation_easing,
|
||||||
});
|
});
|
||||||
console.log('displayed AN panel');
|
|
||||||
|
|
||||||
if ($("#ANBlockToggle")
|
if ($("#ANBlockToggle")
|
||||||
.siblings('.inline-drawer-content')
|
.siblings('.inline-drawer-content')
|
||||||
.css('display') !== 'block') {
|
.css('display') !== 'block') {
|
||||||
$("#ANBlockToggle").click();
|
$("#ANBlockToggle").click();
|
||||||
console.log('opened AN box');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#floatingPrompt").transition({
|
$("#floatingPrompt").transition({
|
||||||
@ -5704,7 +5743,6 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$("#floatingPrompt").hide();
|
$("#floatingPrompt").hide();
|
||||||
console.log('hid AN panel');
|
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -6165,6 +6203,24 @@ $(document).ready(function () {
|
|||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
const $children = $("#rm_print_characters_block").children();
|
||||||
|
const originalHeight = $children.length * $children.first().outerHeight();
|
||||||
|
$("#rm_print_characters_block").css('height', originalHeight);
|
||||||
|
//show and hide charlist divs on pageload (causes load lag)
|
||||||
|
//$children.each(function () { setCharListVisible($(this)) });
|
||||||
|
|
||||||
|
$("#rm_print_characters_block").on('scroll', debounce(function () {
|
||||||
|
const containerHeight = $children.length * $children.first().outerHeight();
|
||||||
|
$("#rm_print_characters_block").css('height', containerHeight);
|
||||||
|
//show and hide on scroll
|
||||||
|
setCharListVisible();
|
||||||
|
}, 1));
|
||||||
|
//delay timer to allow for charlist to populate,
|
||||||
|
//should be set to an onload for rm_print_characters or windows?
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
$(document).on("click", ".mes_edit_delete", function () {
|
$(document).on("click", ".mes_edit_delete", function () {
|
||||||
if (!confirm("Are you sure you want to delete this message?")) {
|
if (!confirm("Are you sure you want to delete this message?")) {
|
||||||
return;
|
return;
|
||||||
|
@ -502,9 +502,10 @@ function tryParseStreamingError(str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkQuotaError(data) {
|
function checkQuotaError(data) {
|
||||||
const errorText = `<h3>You have no credits left to use with this API key.<br>
|
const errorText = `<h3>Encountered an error while processing your request.<br>
|
||||||
Check your billing details on the
|
Check you have credits available on your
|
||||||
<a href="https://platform.openai.com/account/usage" target="_blank">OpenAI website.</a></h3>`;
|
<a href="https://platform.openai.com/account/usage" target="_blank">OpenAI account</a>.<br>
|
||||||
|
If you have sufficient credits, please try again later.</h3>`;
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
reloadCurrentChat,
|
reloadCurrentChat,
|
||||||
getRequestHeaders,
|
getRequestHeaders,
|
||||||
substituteParams,
|
substituteParams,
|
||||||
|
setCharListVisible,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
import { favsToHotswap } from "./RossAscends-mods.js";
|
import { favsToHotswap } from "./RossAscends-mods.js";
|
||||||
import {
|
import {
|
||||||
@ -643,8 +644,8 @@ function loadInstructMode() {
|
|||||||
export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvatar) {
|
export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvatar) {
|
||||||
const includeNames = isNarrator ? false : (power_user.instruct.names || !!selected_group || !!forceAvatar);
|
const includeNames = isNarrator ? false : (power_user.instruct.names || !!selected_group || !!forceAvatar);
|
||||||
const sequence = (isUser || isNarrator) ? power_user.instruct.input_sequence : power_user.instruct.output_sequence;
|
const sequence = (isUser || isNarrator) ? power_user.instruct.input_sequence : power_user.instruct.output_sequence;
|
||||||
const separator = power_user.instruct.wrap ? '\n' : '';
|
const separator = power_user.instruct.wrap ? '\n' : '';
|
||||||
const separatorSequence = power_user.instruct.separator_sequence && !isUser
|
const separatorSequence = power_user.instruct.separator_sequence && !isUser
|
||||||
? power_user.instruct.separator_sequence
|
? power_user.instruct.separator_sequence
|
||||||
: (power_user.instruct.wrap ? '\n' : '');
|
: (power_user.instruct.wrap ? '\n' : '');
|
||||||
const textArray = includeNames ? [sequence, `${name}: ${mes}`, separatorSequence] : [sequence, mes, separatorSequence];
|
const textArray = includeNames ? [sequence, `${name}: ${mes}`, separatorSequence] : [sequence, mes, separatorSequence];
|
||||||
@ -668,7 +669,7 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias) {
|
|||||||
let text = includeNames ? (separator + sequence + separator + `${name}:`) : (separator + sequence);
|
let text = includeNames ? (separator + sequence + separator + `${name}:`) : (separator + sequence);
|
||||||
|
|
||||||
if (!isImpersonate && promptBias) {
|
if (!isImpersonate && promptBias) {
|
||||||
text += (includeNames ? promptBias : (separator + promptBias));
|
text += (includeNames ? promptBias : (separator + promptBias));
|
||||||
}
|
}
|
||||||
|
|
||||||
return text.trimEnd();
|
return text.trimEnd();
|
||||||
@ -718,6 +719,7 @@ function sortCharactersList() {
|
|||||||
for (const item of array) {
|
for (const item of array) {
|
||||||
$(`${item.selector}[${item.attribute}="${item.id}"]`).css({ 'order': orderedList.indexOf(item) });
|
$(`${item.selector}[${item.attribute}="${item.id}"]`).css({ 'order': orderedList.indexOf(item) });
|
||||||
}
|
}
|
||||||
|
setCharListVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortGroupMembers(selector) {
|
function sortGroupMembers(selector) {
|
||||||
@ -882,7 +884,7 @@ $(document).ready(() => {
|
|||||||
// include newline is the child of trim sentences
|
// include newline is the child of trim sentences
|
||||||
// if include newline is checked, trim sentences must be checked
|
// if include newline is checked, trim sentences must be checked
|
||||||
// if trim sentences is unchecked, include newline must be unchecked
|
// if trim sentences is unchecked, include newline must be unchecked
|
||||||
$("#trim_sentences_checkbox").change(function() {
|
$("#trim_sentences_checkbox").change(function () {
|
||||||
power_user.trim_sentences = !!$(this).prop("checked");
|
power_user.trim_sentences = !!$(this).prop("checked");
|
||||||
if (!$(this).prop("checked")) {
|
if (!$(this).prop("checked")) {
|
||||||
$("#include_newline_checkbox").prop("checked", false);
|
$("#include_newline_checkbox").prop("checked", false);
|
||||||
@ -891,7 +893,7 @@ $(document).ready(() => {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#include_newline_checkbox").change(function() {
|
$("#include_newline_checkbox").change(function () {
|
||||||
power_user.include_newline = !!$(this).prop("checked");
|
power_user.include_newline = !!$(this).prop("checked");
|
||||||
if ($(this).prop("checked")) {
|
if ($(this).prop("checked")) {
|
||||||
$("#trim_sentences_checkbox").prop("checked", true);
|
$("#trim_sentences_checkbox").prop("checked", true);
|
||||||
|
@ -80,6 +80,19 @@ export function debounce(func, timeout = 300) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isElementInViewport(el) {
|
||||||
|
if (typeof jQuery === "function" && el instanceof jQuery) {
|
||||||
|
el = el[0];
|
||||||
|
}
|
||||||
|
var rect = el.getBoundingClientRect();
|
||||||
|
return (
|
||||||
|
rect.top >= 0 &&
|
||||||
|
rect.left >= 0 &&
|
||||||
|
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /* or $(window).height() */
|
||||||
|
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /* or $(window).width() */
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function getUniqueName(name, exists) {
|
export function getUniqueName(name, exists) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
let baseName = name;
|
let baseName = name;
|
||||||
@ -218,15 +231,15 @@ export function end_trim_to_sentence(input, include_newline = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function countOccurrences(string, character) {
|
export function countOccurrences(string, character) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
for (let i = 0; i < string.length; i++) {
|
for (let i = 0; i < string.length; i++) {
|
||||||
if (string[i] === character) {
|
if (string[i] === character) {
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return count;
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOdd(number) {
|
export function isOdd(number) {
|
||||||
|
Reference in New Issue
Block a user