mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/SillyTavern/SillyTavern into smartcontext-improvements
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "sillytavern",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sillytavern",
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
|
@@ -49,7 +49,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
||||
},
|
||||
"version": "1.8.2",
|
||||
"version": "1.8.3",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"pkg": "pkg --compress Gzip --no-bytecode --public ."
|
||||
|
@@ -2373,6 +2373,9 @@
|
||||
<label for="import_card_tags"><input id="import_card_tags" type="checkbox" />
|
||||
<span data-i18n="Import Card Tags">Import Card Tags</span>
|
||||
</label>
|
||||
<label for="confirm_message_delete"><input id="confirm_message_delete" type="checkbox" />
|
||||
<span data-i18n="Confirm message deletion">Confirm message deletion</span>
|
||||
</label>
|
||||
<label for="spoiler_free_mode"><input id="spoiler_free_mode" type="checkbox" />
|
||||
<span data-i18n="Spoiler Free Mode">Spolier Free Mode</span>
|
||||
</label>
|
||||
@@ -2816,7 +2819,7 @@
|
||||
<div class="tags rm_tag_filter"></div>
|
||||
</div>
|
||||
<!-- a div containing a dynamically updated count of characters currently displayed -->
|
||||
<div id="rm_character_count" ></div>
|
||||
<div id="rm_character_count"></div>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
@@ -3297,7 +3300,12 @@
|
||||
|
||||
<input class="menu_button delete_entry_button" type="submit" value="Delete Entry" />
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -3616,4 +3624,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
@@ -757,7 +757,6 @@ $.get("/csrf-token").then(async (data) => {
|
||||
|
||||
function checkOnlineStatus() {
|
||||
///////// REMOVED LINES THAT DUPLICATE RA_CHeckOnlineStatus FEATURES
|
||||
|
||||
if (online_status == "no_connection") {
|
||||
$("#online_status_indicator2").css("background-color", "red"); //Kobold
|
||||
$("#online_status_text2").html("No connection...");
|
||||
@@ -1137,10 +1136,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) {
|
||||
mes = mes.replaceAll(substituteParams(power_user.user_prompt_bias), "");
|
||||
}
|
||||
|
||||
const regexResult = getRegexedString(mes, regex_placement.MD_DISPLAY);
|
||||
if (regexResult) {
|
||||
mes = regexResult;
|
||||
}
|
||||
mes = getRegexedString(mes, regex_placement.MD_DISPLAY);
|
||||
|
||||
if (power_user.auto_fix_generated_markdown) {
|
||||
mes = fixMarkdown(mes);
|
||||
@@ -2957,10 +2953,7 @@ export function replaceBiasMarkup(str) {
|
||||
}
|
||||
|
||||
export async function sendMessageAsUser(textareaText, messageBias) {
|
||||
const regexResult = getRegexedString(textareaText, regex_placement.USER_INPUT);
|
||||
if (regexResult) {
|
||||
textareaText = regexResult;
|
||||
}
|
||||
textareaText = getRegexedString(textareaText, regex_placement.USER_INPUT);
|
||||
|
||||
chat[chat.length] = {};
|
||||
chat[chat.length - 1]['name'] = name1;
|
||||
@@ -3561,10 +3554,7 @@ function cleanUpMessage(getMessage, isImpersonate, displayIncompleteSentences =
|
||||
}
|
||||
|
||||
// Regex uses vars, so add before formatting
|
||||
const regexResult = getRegexedString(getMessage, isImpersonate ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT);
|
||||
if (regexResult) {
|
||||
getMessage = regexResult;
|
||||
}
|
||||
getMessage = getRegexedString(getMessage, isImpersonate ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT);
|
||||
|
||||
if (!displayIncompleteSentences && power_user.trim_sentences) {
|
||||
getMessage = end_trim_to_sentence(getMessage, power_user.include_newline);
|
||||
@@ -4995,16 +4985,13 @@ function updateMessage(div) {
|
||||
regexPlacement = regex_placement.SYSTEM;
|
||||
}
|
||||
|
||||
const regexResult = getRegexedString(
|
||||
text = getRegexedString(
|
||||
text,
|
||||
regexPlacement,
|
||||
{
|
||||
characterOverride: regexPlacement === regex_placement.SENDAS ? mes.name : undefined
|
||||
}
|
||||
);
|
||||
if (regexResult) {
|
||||
text = regexResult;
|
||||
}
|
||||
|
||||
if (power_user.trim_spaces) {
|
||||
text = text.trim();
|
||||
@@ -6123,10 +6110,7 @@ async function createOrEditCharacter(e) {
|
||||
) {
|
||||
// MARK - kingbri: Regex on character greeting message
|
||||
// May need to be placed somewhere else
|
||||
const regexResult = getRegexedString(this_ch_mes, regex_placement.AI_OUTPUT);
|
||||
if (regexResult) {
|
||||
this_ch_mes = regexResult;
|
||||
}
|
||||
this_ch_mes = getRegexedString(this_ch_mes, regex_placement.AI_OUTPUT);
|
||||
|
||||
clearChat();
|
||||
chat.length = 0;
|
||||
@@ -6504,7 +6488,12 @@ const swipe_right = () => {
|
||||
}
|
||||
|
||||
export function updateCharacterCount(characterSelector) {
|
||||
const visibleCharacters = $(characterSelector).filter(":visible");
|
||||
const visibleCharacters = $(characterSelector)
|
||||
.not(".hiddenBySearch")
|
||||
.not(".hiddenByTag")
|
||||
.not(".hiddenByGroup")
|
||||
.not(".hiddenByGroupMember")
|
||||
.not(".hiddenByFav");
|
||||
const visibleCharacterCount = visibleCharacters.length;
|
||||
const totalCharacterCount = $(characterSelector).length;
|
||||
|
||||
@@ -7840,9 +7829,11 @@ $(document).ready(function () {
|
||||
|
||||
|
||||
$(document).on("click", ".mes_edit_delete", async function () {
|
||||
const confirmation = await callPopup("Are you sure you want to delete this message?", 'confirm');
|
||||
if (!confirmation) {
|
||||
return;
|
||||
if (power_user.confirm_message_delete) {
|
||||
const confirmation = await callPopup("Are you sure you want to delete this message?", 'confirm');
|
||||
if (!confirmation) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const mes = $(this).closest(".mes");
|
||||
|
@@ -152,7 +152,7 @@ async function visualNovelSetCharacterSprites(container, name, expression) {
|
||||
|
||||
const path = currentSpritePath || defaultSpritePath || '';
|
||||
const img = expressionImage.find('img');
|
||||
setImage(img, path);
|
||||
await setImage(img, path);
|
||||
}
|
||||
expressionImage.toggleClass('hidden', noSprites);
|
||||
} else {
|
||||
@@ -163,7 +163,7 @@ async function visualNovelSetCharacterSprites(container, name, expression) {
|
||||
$('#visual-novel-wrapper').append(template);
|
||||
dragElement($(template[0]));
|
||||
template.toggleClass('hidden', noSprites);
|
||||
setImage(template.find('img'), defaultSpritePath || '');
|
||||
await setImage(template.find('img'), defaultSpritePath || '');
|
||||
const fadeInPromise = new Promise(resolve => {
|
||||
template.fadeIn(250, () => resolve());
|
||||
});
|
||||
@@ -284,7 +284,9 @@ async function setLastMessageSprite(img, avatar, labels) {
|
||||
}
|
||||
}
|
||||
|
||||
function setImage(img, path) {
|
||||
async function setImage(img, path) {
|
||||
// Cohee: If something goes wrong, uncomment this to return to the old behavior
|
||||
/*
|
||||
img.attr('src', path);
|
||||
img.removeClass('default');
|
||||
img.off('error');
|
||||
@@ -293,6 +295,66 @@ function setImage(img, path) {
|
||||
$(this).off('error');
|
||||
$(this).attr('src', '');
|
||||
});
|
||||
*/
|
||||
|
||||
return new Promise(resolve => {
|
||||
const prevExpressionSrc = img.attr('src');
|
||||
const expressionClone = img.clone();
|
||||
const originalId = img.attr('id');
|
||||
|
||||
//only swap expressions when necessary
|
||||
if (prevExpressionSrc !== path && !img.hasClass('expression-animating')) {
|
||||
//clone expression
|
||||
expressionClone.addClass('expression-clone')
|
||||
//make invisible and remove id to prevent double ids
|
||||
//must be made invisible to start because they share the same Z-index
|
||||
expressionClone.attr('id', '').css({ opacity: 0 });
|
||||
//add new sprite path to clone src
|
||||
expressionClone.attr('src', path);
|
||||
//add invisible clone to html
|
||||
expressionClone.appendTo(img.parent());
|
||||
|
||||
const duration = 200;
|
||||
|
||||
//add animation flags to both images
|
||||
//to prevent multiple expression changes happening simultaneously
|
||||
img.addClass('expression-animating')
|
||||
//position absolute prevent the original from jumping around during transition
|
||||
img.css('position', 'absolute')
|
||||
expressionClone.addClass('expression-animating')
|
||||
//fade the clone in
|
||||
expressionClone.css({
|
||||
opacity: 0
|
||||
}).animate({
|
||||
opacity: 1
|
||||
}, duration)
|
||||
//when finshed fading in clone, fade out the original
|
||||
.promise().done(function () {
|
||||
img.animate({
|
||||
opacity: 0
|
||||
}, duration);
|
||||
//remove old expression
|
||||
img.remove();
|
||||
//replace ID so it becomes the new 'original' expression for next change
|
||||
expressionClone.attr('id', originalId);
|
||||
expressionClone.removeClass('expression-animating');
|
||||
resolve();
|
||||
});
|
||||
|
||||
expressionClone.removeClass('expression-clone');
|
||||
|
||||
expressionClone.removeClass('default');
|
||||
expressionClone.off('error');
|
||||
expressionClone.on('error', function () {
|
||||
console.debug('Expression image error', sprite.path);
|
||||
$(this).attr('src', '');
|
||||
$(this).off('error');
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onExpressionsShowDefaultInput() {
|
||||
@@ -620,6 +682,8 @@ async function setExpression(character, expression, force) {
|
||||
console.debug('entered setExpressions');
|
||||
await validateImages(character);
|
||||
const img = $('img.expression');
|
||||
const prevExpressionSrc = img.attr('src');
|
||||
const expressionClone = img.clone()
|
||||
|
||||
const sprite = (spriteCache[character] && spriteCache[character].find(x => x.label === expression));
|
||||
console.debug('checking for expression images to show..');
|
||||
@@ -638,26 +702,67 @@ async function setExpression(character, expression, force) {
|
||||
}
|
||||
|
||||
if (groupMember.name == character) {
|
||||
setImage($(`.expression-holder[data-avatar="${member}"] img`), sprite.path);
|
||||
await setImage($(`.expression-holder[data-avatar="${member}"] img`), sprite.path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//only swap expressions when necessary
|
||||
if (prevExpressionSrc !== sprite.path
|
||||
&& !img.hasClass('expression-animating')) {
|
||||
//clone expression
|
||||
expressionClone.addClass('expression-clone')
|
||||
//make invisible and remove id to prevent double ids
|
||||
//must be made invisible to start because they share the same Z-index
|
||||
expressionClone.attr('id', '').css({ opacity: 0 });
|
||||
//add new sprite path to clone src
|
||||
expressionClone.attr('src', sprite.path);
|
||||
//add invisible clone to html
|
||||
expressionClone.appendTo($("#expression-holder"))
|
||||
|
||||
img.attr('src', sprite.path);
|
||||
img.removeClass('default');
|
||||
img.off('error');
|
||||
img.on('error', function () {
|
||||
console.debug('Expression image error', sprite.path);
|
||||
$(this).attr('src', '');
|
||||
$(this).off('error');
|
||||
if (force && extension_settings.expressions.showDefault) {
|
||||
const duration = 200;
|
||||
|
||||
//add animation flags to both images
|
||||
//to prevent multiple expression changes happening simultaneously
|
||||
img.addClass('expression-animating')
|
||||
//position absolute prevent the original from jumping around during transition
|
||||
img.css('position', 'absolute')
|
||||
expressionClone.addClass('expression-animating')
|
||||
//fade the clone in
|
||||
expressionClone.css({
|
||||
opacity: 0
|
||||
}).animate({
|
||||
opacity: 1
|
||||
}, duration)
|
||||
//when finshed fading in clone, fade out the original
|
||||
.promise().done(function () {
|
||||
img.animate({
|
||||
opacity: 0
|
||||
}, duration);
|
||||
//remove old expression
|
||||
img.remove();
|
||||
//replace ID so it becomes the new 'original' expression for next change
|
||||
expressionClone.attr('id', 'expression-image')
|
||||
expressionClone.removeClass('expression-animating')
|
||||
});
|
||||
|
||||
|
||||
expressionClone.removeClass('expression-clone');
|
||||
|
||||
expressionClone.removeClass('default');
|
||||
expressionClone.off('error');
|
||||
expressionClone.on('error', function () {
|
||||
console.debug('Expression image error', sprite.path);
|
||||
$(this).attr('src', '');
|
||||
$(this).off('error');
|
||||
if (force && extension_settings.expressions.showDefault) {
|
||||
setDefault();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (extension_settings.expressions.showDefault) {
|
||||
setDefault();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (extension_settings.expressions.showDefault) {
|
||||
setDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,8 +770,8 @@ async function setExpression(character, expression, force) {
|
||||
console.debug('setting default');
|
||||
const defImgUrl = `/img/default-expressions/${expression}.png`;
|
||||
//console.log(defImgUrl);
|
||||
img.attr('src', defImgUrl);
|
||||
img.addClass('default');
|
||||
expressionClone.attr('src', defImgUrl);
|
||||
expressionClone.addClass('default');
|
||||
}
|
||||
document.getElementById("expression-holder").style.display = '';
|
||||
}
|
||||
|
@@ -20,6 +20,9 @@
|
||||
|
||||
#visual-novel-wrapper .expression-holder {
|
||||
width: max-content;
|
||||
display: flex;
|
||||
left: unset;
|
||||
right: unset;
|
||||
}
|
||||
|
||||
#visual-novel-wrapper .hidden {
|
||||
@@ -31,21 +34,6 @@
|
||||
object-fit: cover;
|
||||
}*/
|
||||
|
||||
/* .expression-holder {
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
max-height: 90vh;
|
||||
max-width: 90vh;
|
||||
width: calc((100vw - var(--sheldWidth)) /2);
|
||||
position: absolute;
|
||||
padding: 0;
|
||||
filter: drop-shadow(2px 2px 2px #51515199);
|
||||
z-index: 29;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
bottom: 0;
|
||||
} */
|
||||
|
||||
.expression-holder {
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
@@ -55,6 +43,7 @@
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
padding: 0;
|
||||
left: 0;
|
||||
filter: drop-shadow(2px 2px 2px #51515199);
|
||||
z-index: 2;
|
||||
overflow: hidden;
|
||||
@@ -62,8 +51,13 @@
|
||||
}
|
||||
|
||||
img.expression {
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
max-height: 90vh;
|
||||
max-width: 90vh;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
bottom: 0;
|
||||
padding: 0;
|
||||
vertical-align: bottom;
|
||||
object-fit: contain;
|
||||
}
|
||||
@@ -79,6 +73,10 @@ img.expression.default {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.expression-clone {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.debug-image {
|
||||
display: none;
|
||||
visibility: collapse;
|
||||
|
@@ -133,20 +133,7 @@ async function loadSettings() {
|
||||
function onStrategyChange() {
|
||||
console.debug('changing chromadb strat');
|
||||
extension_settings.chromadb.strategy = $('#chromadb_strategy').val();
|
||||
|
||||
$('#chromadb_custom_depth').hide();
|
||||
$('label[for="chromadb_custom_depth"]').hide();
|
||||
$('#chromadb_custom_msg').hide();
|
||||
$('label[for="chromadb_custom_msg"]').hide();
|
||||
|
||||
$('#chromadb_hhaa_wrapperfmt').hide();
|
||||
$('label[for="chromadb_hhaa_wrapperfmt"]').hide();
|
||||
$('#chromadb_hhaa_memoryfmt').hide();
|
||||
$('label[for="chromadb_hhaa_memoryfmt"]').hide();
|
||||
$('#chromadb_hhaa_token_limit').hide();
|
||||
$('label[for="chromadb_hhaa_token_limit"]').hide();
|
||||
|
||||
if(extension_settings.chromadb.strategy === "custom"){
|
||||
if (extension_settings.chromadb.strategy === "custom") {
|
||||
$('#chromadb_custom_depth').show();
|
||||
$('label[for="chromadb_custom_depth"]').show();
|
||||
$('#chromadb_custom_msg').show();
|
||||
@@ -226,6 +213,16 @@ function onFileSplitLengthInput() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onChunkNLInput() {
|
||||
let shouldSplit = $('#onChunkNLInput').is(':checked');
|
||||
if (shouldSplit) {
|
||||
extension_settings.chromadb.file_split_type = "newline";
|
||||
} else {
|
||||
extension_settings.chromadb.file_split_type = "length";
|
||||
}
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function checkChatId(chat_id) {
|
||||
if (!chat_id || chat_id.trim() === '') {
|
||||
toastr.error('Please select a character and try again.');
|
||||
@@ -450,7 +447,7 @@ async function queryMultiMessages(chat_id, query) {
|
||||
const context = getContext();
|
||||
const response = await fetch("/getallchatsofcharacter", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ avatar_url: context.characters[context.characterId].avatar}),
|
||||
body: JSON.stringify({ avatar_url: context.characters[context.characterId].avatar }),
|
||||
headers: getRequestHeaders(),
|
||||
});
|
||||
if (!response.ok) {
|
||||
@@ -492,8 +489,14 @@ async function onSelectInjectFile(e) {
|
||||
try {
|
||||
toastr.info('This may take some time, depending on the file size', 'Processing...');
|
||||
const text = await getFileText(file);
|
||||
|
||||
const split = splitRecursive(text, extension_settings.chromadb.file_split_length).filter(onlyUnique);
|
||||
extension_settings.chromadb.file_split_type = "newline";
|
||||
//allow splitting on newlines or splitrecursively
|
||||
let split = [];
|
||||
if (extension_settings.chromadb.file_split_type == "newline") {
|
||||
split = text.split(/\r?\n/).filter(onlyUnique);
|
||||
} else {
|
||||
split = splitRecursive(text, extension_settings.chromadb.file_split_length).filter(onlyUnique);
|
||||
}
|
||||
const baseDate = Date.now();
|
||||
|
||||
const messages = split.map((m, i) => ({
|
||||
@@ -590,6 +593,9 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
||||
if (!currentChatId)
|
||||
return;
|
||||
|
||||
//log the current settings
|
||||
console.debug("CHROMADB: Current settings: %o", extension_settings.chromadb);
|
||||
|
||||
const selectedStrategy = extension_settings.chromadb.strategy;
|
||||
const recallStrategy = extension_settings.chromadb.recall_strategy;
|
||||
let recallMsg = extension_settings.chromadb.recall_msg || defaultSettings.chroma_default_msg;
|
||||
@@ -599,6 +605,10 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
||||
const messagesToStore = chat.slice(0, -extension_settings.chromadb.keep_context);
|
||||
|
||||
if (messagesToStore.length > 0 && !extension_settings.chromadb.freeze) {
|
||||
//log the messages to store
|
||||
console.debug("CHROMADB: Messages to store: %o", messagesToStore);
|
||||
//log the messages to store length vs keep context
|
||||
console.debug("CHROMADB: Messages to store length vs keep context: %o vs %o", messagesToStore.length, extension_settings.chromadb.keep_context);
|
||||
await addMessages(currentChatId, messagesToStore);
|
||||
}
|
||||
|
||||
@@ -618,18 +628,18 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
||||
}
|
||||
console.log("ChromDB Query text:", queryBlob);
|
||||
|
||||
if (recallStrategy === 'multichat'){
|
||||
if (recallStrategy === 'multichat') {
|
||||
console.log("Utilizing multichat")
|
||||
queriedMessages = await queryMultiMessages(currentChatId, queryBlob);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
queriedMessages = await queryMessages(currentChatId, queryBlob);
|
||||
}
|
||||
|
||||
if(chromaSortStrategy === "date"){
|
||||
if (chromaSortStrategy === "date") {
|
||||
queriedMessages.sort((a, b) => a.date - b.date);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
queriedMessages.sort((a, b) => b.distance - a.distance);
|
||||
}
|
||||
console.log(queriedMessages);
|
||||
@@ -727,10 +737,10 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
||||
let chatset = new Set(chat.map(obj => obj.mes));
|
||||
newChat = newChat.filter(obj => !chatset.has(obj.mes));
|
||||
|
||||
if(chromaDepth === -1){
|
||||
if(chromaDepth === -1) {
|
||||
chat.splice(chat.length, 0, ...newChat);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
chat.splice(chromaDepth, 0, ...newChat);
|
||||
}
|
||||
}
|
||||
@@ -741,7 +751,6 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
|
||||
chat.splice(0, messagesToStore.length, ...newChat);
|
||||
|
||||
}
|
||||
console.log('ChromaDB chat after injection', chat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,6 +846,10 @@ jQuery(async () => {
|
||||
<input type="checkbox" id="chromadb_auto_adjust" />
|
||||
<span>Use % strategy</span>
|
||||
</label>
|
||||
<label class="checkbox_label" for="chromadb_chunk_nl" title="Chunk injected documents on newline instead of at set character size." >
|
||||
<input type="checkbox" id="chromadb_chunk_nl" />
|
||||
<span>Chunk on Newlines</span>
|
||||
</label>
|
||||
<label class="checkbox_label for="chromadb_query_last_only" title="ChromaDB queries only use the most recent message. (Instead of using all messages still in the context.)">
|
||||
<input type="checkbox" id="chromadb_query_last_only" />
|
||||
<span>Query last message only</span>
|
||||
@@ -887,6 +900,7 @@ jQuery(async () => {
|
||||
$('#chromadb_purge').on('click', onPurgeClick);
|
||||
$('#chromadb_export').on('click', onExportClick);
|
||||
$('#chromadb_freeze').on('input', onFreezeInput);
|
||||
$('#chromadb_chunk_nl').on('input', onChunkNLInput);
|
||||
$('#chromadb_auto_adjust').on('input', onAutoAdjustInput);
|
||||
$('#chromadb_query_last_only').on('input', onFullLogQuery);
|
||||
$('#chromadb_keep_context_proportion').on('input', onKeepContextProportionInput);
|
||||
|
@@ -39,14 +39,14 @@ function regexFromString(input) {
|
||||
|
||||
// Parent function to fetch a regexed version of a raw string
|
||||
function getRegexedString(rawString, placement, { characterOverride } = {}) {
|
||||
let finalString = rawString;
|
||||
if (extension_settings.disabledExtensions.includes("regex") || !rawString || placement === undefined) {
|
||||
return;
|
||||
return finalString;
|
||||
}
|
||||
|
||||
let finalString;
|
||||
extension_settings.regex.forEach((script) => {
|
||||
if (script.placement.includes(placement)) {
|
||||
finalString = runRegexScript(script, rawString, { characterOverride });
|
||||
finalString = runRegexScript(script, finalString, { characterOverride });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,17 +55,17 @@ function getRegexedString(rawString, placement, { characterOverride } = {}) {
|
||||
|
||||
// Runs the provided regex script on the given string
|
||||
function runRegexScript(regexScript, rawString, { characterOverride } = {}) {
|
||||
let newString = rawString;
|
||||
if (!regexScript || !!(regexScript.disabled) || !regexScript?.findRegex || !rawString) {
|
||||
return;
|
||||
return newString;
|
||||
}
|
||||
|
||||
let match;
|
||||
let newString;
|
||||
const findRegex = regexFromString(regexScript.substituteRegex ? substituteParams(regexScript.findRegex) : regexScript.findRegex);
|
||||
|
||||
// The user skill issued. Return with nothing.
|
||||
if (!findRegex) {
|
||||
return;
|
||||
return newString;
|
||||
}
|
||||
|
||||
while ((match = findRegex.exec(rawString)) !== null) {
|
||||
|
@@ -121,6 +121,7 @@ let power_user = {
|
||||
play_message_sound: false,
|
||||
play_sound_unfocused: true,
|
||||
auto_save_msg_edits: false,
|
||||
confirm_message_delete: true,
|
||||
|
||||
sort_field: 'name',
|
||||
sort_order: 'asc',
|
||||
@@ -658,6 +659,7 @@ function loadPowerUserSettings(settings, data) {
|
||||
$(`#pygmalion_formatting option[value=${power_user.pygmalion_formatting}]`).attr("selected", true);
|
||||
$(`#send_on_enter option[value=${power_user.send_on_enter}]`).attr("selected", true);
|
||||
$("#import_card_tags").prop("checked", power_user.import_card_tags);
|
||||
$("#confirm_message_delete").prop("checked", power_user.confirm_message_delete !== undefined ? !!power_user.confirm_message_delete : true);
|
||||
$("#spoiler_free_mode").prop("checked", power_user.spoiler_free_mode);
|
||||
$("#collapse-newlines-checkbox").prop("checked", power_user.collapse_newlines);
|
||||
$("#pin-examples-checkbox").prop("checked", power_user.pin_examples);
|
||||
@@ -1725,6 +1727,11 @@ $(document).ready(() => {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#confirm_message_delete").on('input', function () {
|
||||
power_user.confirm_message_delete = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#render_formulas").on("input", function () {
|
||||
power_user.render_formulas = !!$(this).prop('checked');
|
||||
reloadMarkdownProcessor(power_user.render_formulas);
|
||||
|
@@ -226,10 +226,7 @@ async function sendMessageAs(_, text) {
|
||||
|
||||
const name = parts.shift().trim();
|
||||
let mesText = parts.join('\n').trim();
|
||||
const regexResult = getRegexedString(mesText, regex_placement.SENDAS, { characterOverride: name });
|
||||
if (regexResult) {
|
||||
mesText = regexResult;
|
||||
}
|
||||
mesText = getRegexedString(mesText, regex_placement.SENDAS, { characterOverride: name });
|
||||
|
||||
// Messages that do nothing but set bias will be hidden from the context
|
||||
const bias = extractMessageBias(mesText);
|
||||
@@ -273,10 +270,7 @@ async function sendNarratorMessage(_, text) {
|
||||
return;
|
||||
}
|
||||
|
||||
const regexResult = getRegexedString(text, regex_placement.SYSTEM);
|
||||
if (regexResult) {
|
||||
text = regexResult;
|
||||
}
|
||||
text = getRegexedString(text, regex_placement.SYSTEM);
|
||||
|
||||
const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT;
|
||||
// Messages that do nothing but set bias will be hidden from the context
|
||||
|
@@ -3784,6 +3784,11 @@ label[for="extensions_autoconnect"] {
|
||||
color: lightgray;
|
||||
}
|
||||
|
||||
/* possible place for WI Entry header styling */
|
||||
/* .world_entry_form .inline-drawer-header {
|
||||
background-color: var(--SmartThemeShadowColor);
|
||||
} */
|
||||
|
||||
#extensions_settings .inline-drawer-toggle.inline-drawer-header,
|
||||
#extensions_settings2 .inline-drawer-toggle.inline-drawer-header {
|
||||
background-image: linear-gradient(348deg, var(--white30a)2%, var(--grey30a)10%, var(--black70a)95%, var(--SmartThemeQuoteColor)100%);
|
||||
@@ -4413,6 +4418,9 @@ body.waifuMode .expression-holder {
|
||||
bottom: 0;
|
||||
filter: drop-shadow(2px 2px 2px #51515199);
|
||||
z-index: 2;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
/* movingUI*/
|
||||
@@ -4789,16 +4797,13 @@ body.waifuMode .zoomed_avatar {
|
||||
|
||||
body.waifuMode .expression-holder {
|
||||
display: inline;
|
||||
width: unset;
|
||||
max-height: unset;
|
||||
max-width: unset;
|
||||
bottom: unset;
|
||||
left: unset;
|
||||
top: unset;
|
||||
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
width: max-content;
|
||||
margin: 0 auto;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
filter: drop-shadow(2px 2px 2px #51515199);
|
||||
z-index: 1;
|
||||
}
|
||||
@@ -5092,5 +5097,4 @@ body.waifuMode .zoomed_avatar {
|
||||
background-color: var(--SmartThemeBlurTintColor);
|
||||
text-align: center;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
}
|
@@ -268,6 +268,7 @@ function generate_payload(query, variables) {
|
||||
async function request_with_retries(method, attempts = 10) {
|
||||
const url = '';
|
||||
for (let i = 0; i < attempts; i++) {
|
||||
//console.log(method)
|
||||
try {
|
||||
const response = await method();
|
||||
if (response.status === 200) {
|
||||
@@ -276,8 +277,12 @@ async function request_with_retries(method, attempts = 10) {
|
||||
logger.warn(`Server returned a status code of ${response.status} while downloading ${url}. Retrying (${i + 1}/${attempts})...`);
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
console.log(`-------------------ERROR-------------------`)
|
||||
//console.log(logObjectStructure(err, 0, 2));
|
||||
console.log(`Retries: ${i}`)
|
||||
//console.log(`-------------------------------------------`)
|
||||
}
|
||||
await delay(100)
|
||||
}
|
||||
throw new Error(`Failed to download ${url} too many times.`);
|
||||
}
|
||||
@@ -312,7 +317,7 @@ function logObjectStructure(obj, indent = 0, depth = Infinity) {
|
||||
class Client {
|
||||
gql_url = "https://poe.com/api/gql_POST";
|
||||
gql_recv_url = "https://poe.com/api/receive_POST";
|
||||
home_url = "https://poe.com";
|
||||
home_url = "https://poe.com/Sage";
|
||||
settings_url = "https://poe.com/api/settings";
|
||||
|
||||
formkey = "";
|
||||
@@ -396,7 +401,7 @@ class Client {
|
||||
const viewerKeyName = 'viewer'
|
||||
const botNameKeyName = 'chatOfBotHandle'
|
||||
const defaultBotKeyName = 'defaultBotNickname'
|
||||
|
||||
//console.log('this.session.get(this.home_url)')
|
||||
const r = await request_with_retries(() => this.session.get(this.home_url));
|
||||
const jsonRegex = /<script id="__NEXT_DATA__" type="application\/json">(.+?)<\/script>/;
|
||||
const jsonText = jsonRegex.exec(r.data)[1];
|
||||
@@ -472,6 +477,7 @@ class Client {
|
||||
}
|
||||
else {
|
||||
logger.info(`Downloading ${bot.displayName}`);
|
||||
//console.log('this.session.get(url)')
|
||||
r = await request_with_retries(() => this.session.get(url), retries);
|
||||
cached_bots[url] = r;
|
||||
}
|
||||
@@ -505,6 +511,7 @@ class Client {
|
||||
|
||||
async get_channel_data(channel = null) {
|
||||
logger.info('Downloading channel data...');
|
||||
//console.log('this.session.get(this.settings_url)')
|
||||
const r = await request_with_retries(() => this.session.get(this.settings_url));
|
||||
const data = r.data;
|
||||
|
||||
@@ -527,6 +534,10 @@ class Client {
|
||||
const _headers = this.gql_headers;
|
||||
_headers['poe-tag-id'] = md5()(scramblePayload + this.formkey + "WpuLMiXEKKE98j56k");
|
||||
_headers['poe-formkey'] = this.formkey;
|
||||
//console.log(`------GQL HEADERS-----`)
|
||||
//console.log(this.gql_headers)
|
||||
//console.log(`----------------------`)
|
||||
//console.log('sending query..')
|
||||
const r = await request_with_retries(() => this.session.post(this.gql_url, payload, { headers: this.gql_headers }));
|
||||
if (!(r?.data?.data)) {
|
||||
logger.warn(`${queryName} returned an error | Retrying (${i + 1}/20)`);
|
||||
|
Reference in New Issue
Block a user