diff --git a/.eslintrc.js b/.eslintrc.js
index 02433c082..b60cf4976 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -45,6 +45,7 @@ module.exports = {
Readability: 'readonly',
isProbablyReaderable: 'readonly',
ePub: 'readonly',
+ diff_match_patch: 'readonly',
},
},
],
diff --git a/default/config.yaml b/default/config.yaml
index 9c8c02de2..2c6f2fa98 100644
--- a/default/config.yaml
+++ b/default/config.yaml
@@ -95,3 +95,8 @@ deepl:
formality: default
# -- SERVER PLUGIN CONFIGURATION --
enableServerPlugins: false
+# User session timeout *in seconds* (defaults to 24 hours).
+## Set to a positive number to expire session after a certain time of inactivity
+## Set to 0 to expire session when the browser is closed
+## Set to a negative number to disable session expiration
+sessionTimeout: 86400
diff --git a/default/content/settings.json b/default/content/settings.json
index c04b88bfb..f558c769f 100644
--- a/default/content/settings.json
+++ b/default/content/settings.json
@@ -13,6 +13,7 @@
},
"world_info_depth": 2,
"world_info_budget": 25,
+ "world_info_include_names": true,
"world_info_recursive": true,
"world_info_overflow_alert": false,
"world_info_case_sensitive": false,
diff --git a/public/index.html b/public/index.html
index 6109568bb..265f5b13a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -3542,6 +3542,12 @@
+
+
diff --git a/public/lib/diff_match_patch.js b/public/lib/diff_match_patch.js
new file mode 100644
index 000000000..2fe320a1b
--- /dev/null
+++ b/public/lib/diff_match_patch.js
@@ -0,0 +1,55 @@
+var diff_match_patch=function(){this.Diff_Timeout=1;this.Diff_EditCost=4;this.Match_Threshold=.5;this.Match_Distance=1E3;this.Patch_DeleteThreshold=.5;this.Patch_Margin=4;this.Match_MaxBits=32},DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff=function(a,b){this[0]=a;this[1]=b};diff_match_patch.Diff.prototype.length=2;diff_match_patch.Diff.prototype.toString=function(){return this[0]+","+this[1]};
+diff_match_patch.prototype.diff_main=function(a,b,c,d){"undefined"==typeof d&&(d=0>=this.Diff_Timeout?Number.MAX_VALUE:(new Date).getTime()+1E3*this.Diff_Timeout);if(null==a||null==b)throw Error("Null input. (diff_main)");if(a==b)return a?[new diff_match_patch.Diff(DIFF_EQUAL,a)]:[];"undefined"==typeof c&&(c=!0);var e=c,f=this.diff_commonPrefix(a,b);c=a.substring(0,f);a=a.substring(f);b=b.substring(f);f=this.diff_commonSuffix(a,b);var g=a.substring(a.length-f);a=a.substring(0,a.length-f);b=b.substring(0,
+b.length-f);a=this.diff_compute_(a,b,e,d);c&&a.unshift(new diff_match_patch.Diff(DIFF_EQUAL,c));g&&a.push(new diff_match_patch.Diff(DIFF_EQUAL,g));this.diff_cleanupMerge(a);return a};
+diff_match_patch.prototype.diff_compute_=function(a,b,c,d){if(!a)return[new diff_match_patch.Diff(DIFF_INSERT,b)];if(!b)return[new diff_match_patch.Diff(DIFF_DELETE,a)];var e=a.length>b.length?a:b,f=a.length>b.length?b:a,g=e.indexOf(f);return-1!=g?(c=[new diff_match_patch.Diff(DIFF_INSERT,e.substring(0,g)),new diff_match_patch.Diff(DIFF_EQUAL,f),new diff_match_patch.Diff(DIFF_INSERT,e.substring(g+f.length))],a.length>b.length&&(c[0][0]=c[2][0]=DIFF_DELETE),c):1==f.length?[new diff_match_patch.Diff(DIFF_DELETE,
+a),new diff_match_patch.Diff(DIFF_INSERT,b)]:(e=this.diff_halfMatch_(a,b))?(b=e[1],f=e[3],a=e[4],e=this.diff_main(e[0],e[2],c,d),c=this.diff_main(b,f,c,d),e.concat([new diff_match_patch.Diff(DIFF_EQUAL,a)],c)):c&&100c);t++){for(var v=-t+p;v<=t-x;v+=2){var n=f+v;var r=v==-t||v!=t&&h[n-1]d)x+=2;else if(y>e)p+=2;else if(m&&(n=f+k-v,0<=n&&n=
+u)return this.diff_bisectSplit_(a,b,r,y,c)}}for(v=-t+w;v<=t-q;v+=2){n=f+v;u=v==-t||v!=t&&l[n-1]d)q+=2;else if(r>e)w+=2;else if(!m&&(n=f+k-v,0<=n&&n=u)))return this.diff_bisectSplit_(a,b,r,y,c)}}return[new diff_match_patch.Diff(DIFF_DELETE,a),new diff_match_patch.Diff(DIFF_INSERT,b)]};
+diff_match_patch.prototype.diff_bisectSplit_=function(a,b,c,d,e){var f=a.substring(0,c),g=b.substring(0,d);a=a.substring(c);b=b.substring(d);f=this.diff_main(f,g,!1,e);e=this.diff_main(a,b,!1,e);return f.concat(e)};
+diff_match_patch.prototype.diff_linesToChars_=function(a,b){function c(a){for(var b="",c=0,g=-1,h=d.length;gd?a=a.substring(c-d):c=a.length?[h,k,l,m,g]:null}if(0>=this.Diff_Timeout)return null;
+var d=a.length>b.length?a:b,e=a.length>b.length?b:a;if(4>d.length||2*e.lengthd[4].length?g:d:d:g;else return null;if(a.length>b.length){d=g[0];e=g[1];var h=g[2];var l=g[3]}else h=g[0],l=g[1],d=g[2],e=g[3];return[d,e,h,l,g[4]]};
+diff_match_patch.prototype.diff_cleanupSemantic=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=0,h=0,l=0,k=0;f=e){if(d>=b.length/2||d>=c.length/2)a.splice(f,0,new diff_match_patch.Diff(DIFF_EQUAL,c.substring(0,d))),a[f-1][1]=b.substring(0,b.length-d),a[f+1][1]=c.substring(d),f++}else if(e>=b.length/2||e>=c.length/2)a.splice(f,0,new diff_match_patch.Diff(DIFF_EQUAL,b.substring(0,e))),a[f-1][0]=DIFF_INSERT,a[f-1][1]=c.substring(0,c.length-e),a[f+1][0]=DIFF_DELETE,
+a[f+1][1]=b.substring(e),f++;f++}f++}};
+diff_match_patch.prototype.diff_cleanupSemanticLossless=function(a){function b(a,b){if(!a||!b)return 6;var c=a.charAt(a.length-1),d=b.charAt(0),e=c.match(diff_match_patch.nonAlphaNumericRegex_),f=d.match(diff_match_patch.nonAlphaNumericRegex_),g=e&&c.match(diff_match_patch.whitespaceRegex_),h=f&&d.match(diff_match_patch.whitespaceRegex_);c=g&&c.match(diff_match_patch.linebreakRegex_);d=h&&d.match(diff_match_patch.linebreakRegex_);var k=c&&a.match(diff_match_patch.blanklineEndRegex_),l=d&&b.match(diff_match_patch.blanklineStartRegex_);
+return k||l?5:c||d?4:e&&!g&&h?3:g||h?2:e||f?1:0}for(var c=1;c=k&&(k=m,g=d,h=e,l=f)}a[c-1][1]!=g&&(g?a[c-1][1]=g:(a.splice(c-
+1,1),c--),a[c][1]=h,l?a[c+1][1]=l:(a.splice(c+1,1),c--))}c++}};diff_match_patch.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;diff_match_patch.whitespaceRegex_=/\s/;diff_match_patch.linebreakRegex_=/[\r\n]/;diff_match_patch.blanklineEndRegex_=/\n\r?\n$/;diff_match_patch.blanklineStartRegex_=/^\r?\n\r?\n/;
+diff_match_patch.prototype.diff_cleanupEfficiency=function(a){for(var b=!1,c=[],d=0,e=null,f=0,g=!1,h=!1,l=!1,k=!1;fb)break;e=c;f=d}return a.length!=g&&a[g][0]===DIFF_DELETE?f:f+(b-e)};
+diff_match_patch.prototype.diff_prettyHtml=function(a){for(var b=[],c=/&/g,d=//g,f=/\n/g,g=0;g");switch(h){case DIFF_INSERT:b[g]=''+l+"";break;case DIFF_DELETE:b[g]=''+l+"";break;case DIFF_EQUAL:b[g]=""+l+""}}return b.join("")};
+diff_match_patch.prototype.diff_text1=function(a){for(var b=[],c=0;cl)throw Error("Invalid number in diff_fromDelta: "+h);h=a.substring(e,e+=l);"="==f[g].charAt(0)?c[d++]=new diff_match_patch.Diff(DIFF_EQUAL,h):c[d++]=
+new diff_match_patch.Diff(DIFF_DELETE,h);break;default:if(f[g])throw Error("Invalid diff operation in diff_fromDelta: "+f[g]);}}if(e!=a.length)throw Error("Delta length ("+e+") does not equal source text length ("+a.length+").");return c};diff_match_patch.prototype.match_main=function(a,b,c){if(null==a||null==b||null==c)throw Error("Null input. (match_main)");c=Math.max(0,Math.min(c,a.length));return a==b?0:a.length?a.substring(c,c+b.length)==b?c:this.match_bitap_(a,b,c):-1};
+diff_match_patch.prototype.match_bitap_=function(a,b,c){function d(a,d){var e=a/b.length,g=Math.abs(c-d);return f.Match_Distance?e+g/f.Match_Distance:g?1:e}if(b.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var e=this.match_alphabet_(b),f=this,g=this.Match_Threshold,h=a.indexOf(b,c);-1!=h&&(g=Math.min(d(0,h),g),h=a.lastIndexOf(b,c+b.length),-1!=h&&(g=Math.min(d(0,h),g)));var l=1<=k;q--){var t=e[a.charAt(q-1)];m[q]=0===w?(m[q+1]<<1|1)&t:(m[q+1]<<1|1)&t|(x[q+1]|x[q])<<1|1|x[q+1];if(m[q]&l&&(t=d(w,q-1),t<=g))if(g=t,h=q-1,h>c)k=Math.max(1,2*c-h);else break}if(d(w+1,c)>g)break;x=m}return h};
+diff_match_patch.prototype.match_alphabet_=function(a){for(var b={},c=0;c=2*this.Patch_Margin&&e&&(this.patch_addContext_(a,h),c.push(a),a=new diff_match_patch.patch_obj,e=0,h=d,f=g)}k!==DIFF_INSERT&&(f+=m.length);k!==DIFF_DELETE&&(g+=m.length)}e&&(this.patch_addContext_(a,h),c.push(a));return c};
+diff_match_patch.prototype.patch_deepCopy=function(a){for(var b=[],c=0;cthis.Match_MaxBits){var k=this.match_main(b,h.substring(0,this.Match_MaxBits),g);-1!=k&&(l=this.match_main(b,h.substring(h.length-this.Match_MaxBits),g+h.length-this.Match_MaxBits),-1==l||k>=l)&&(k=-1)}else k=this.match_main(b,h,
+g);if(-1==k)e[f]=!1,d-=a[f].length2-a[f].length1;else if(e[f]=!0,d=k-g,g=-1==l?b.substring(k,k+h.length):b.substring(k,l+this.Match_MaxBits),h==g)b=b.substring(0,k)+this.diff_text2(a[f].diffs)+b.substring(k+h.length);else if(g=this.diff_main(h,g,!1),h.length>this.Match_MaxBits&&this.diff_levenshtein(g)/h.length>this.Patch_DeleteThreshold)e[f]=!1;else{this.diff_cleanupSemanticLossless(g);h=0;var m;for(l=0;le[0][1].length){var f=b-e[0][1].length;e[0][1]=c.substring(e[0][1].length)+e[0][1];d.start1-=f;d.start2-=f;d.length1+=f;d.length2+=f}d=a[a.length-1];e=d.diffs;
+0==e.length||e[e.length-1][0]!=DIFF_EQUAL?(e.push(new diff_match_patch.Diff(DIFF_EQUAL,c)),d.length1+=b,d.length2+=b):b>e[e.length-1][1].length&&(f=b-e[e.length-1][1].length,e[e.length-1][1]+=c.substring(0,f),d.length1+=f,d.length2+=f);return c};
+diff_match_patch.prototype.patch_splitMax=function(a){for(var b=this.Match_MaxBits,c=0;c2*b?(h.length1+=k.length,e+=k.length,l=!1,h.diffs.push(new diff_match_patch.Diff(g,k)),d.diffs.shift()):(k=k.substring(0,b-h.length1-this.Patch_Margin),h.length1+=k.length,e+=k.length,g===DIFF_EQUAL?(h.length2+=k.length,f+=k.length):l=!1,h.diffs.push(new diff_match_patch.Diff(g,k)),k==d.diffs[0][1]?d.diffs.shift():d.diffs[0][1]=d.diffs[0][1].substring(k.length))}g=this.diff_text2(h.diffs);
+g=g.substring(g.length-this.Patch_Margin);k=this.diff_text1(d.diffs).substring(0,this.Patch_Margin);""!==k&&(h.length1+=k.length,h.length2+=k.length,0!==h.diffs.length&&h.diffs[h.diffs.length-1][0]===DIFF_EQUAL?h.diffs[h.diffs.length-1][1]+=k:h.diffs.push(new diff_match_patch.Diff(DIFF_EQUAL,k)));l||a.splice(++c,0,h)}}};diff_match_patch.prototype.patch_toText=function(a){for(var b=[],c=0;c `${x.name}: ${x.mes}`).reverse();
+ const chatForWI = coreChat.map(x => world_info_include_names ? `${x.name}: ${x.mes}` : x.mes).reverse();
const { worldInfoString, worldInfoBefore, worldInfoAfter, worldInfoExamples, worldInfoDepth } = await getWorldInfoPrompt(chatForWI, this_max_context, dryRun);
setExtensionPrompt('QUIET_PROMPT', '', extension_prompt_types.IN_PROMPT, 0, true);
@@ -4905,6 +4907,9 @@ export function findItemizedPromptSet(itemizedPrompts, incomingMesId) {
PromptArrayItemForRawPromptDisplay = i;
console.log(`wanting to raw display of ArrayItem: ${PromptArrayItemForRawPromptDisplay} which is mesID ${incomingMesId}`);
console.log(itemizedPrompts[thisPromptSet]);
+ break;
+ } else if (itemizedPrompts[i].rawPrompt) {
+ priorPromptArrayItemForRawPromptDisplay = i;
}
}
return thisPromptSet;
@@ -4923,6 +4928,7 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
}
const params = await itemizedParams(itemizedPrompts, thisPromptSet);
+ const flatten = (rawPrompt) => Array.isArray(rawPrompt) ? rawPrompt.map(x => x.content).join('\n') : rawPrompt;
const template = params.this_main_api == 'openai'
? await renderTemplateAsync('itemizationChat', params)
@@ -4930,6 +4936,32 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
const popup = new Popup(template, POPUP_TYPE.TEXT);
+ /** @type {HTMLElement} */
+ const diffPrevPrompt = popup.dlg.querySelector('#diffPrevPrompt');
+ if (priorPromptArrayItemForRawPromptDisplay) {
+ diffPrevPrompt.style.display = '';
+ diffPrevPrompt.addEventListener('click', function () {
+ const dmp = new diff_match_patch();
+ const text1 = flatten(itemizedPrompts[priorPromptArrayItemForRawPromptDisplay].rawPrompt);
+ const text2 = flatten(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);
+
+ dmp.Diff_Timeout = 2.0;
+
+ const d = dmp.diff_main(text1, text2);
+ let ds = dmp.diff_prettyHtml(d);
+ // make it readable
+ ds = ds.replaceAll('background:#e6ffe6;', 'background:#b9f3b9; color:black;');
+ ds = ds.replaceAll('background:#ffe6e6;', 'background:#f5b4b4; color:black;');
+ ds = ds.replaceAll('¶', '');
+ const container = document.createElement('div');
+ container.innerHTML = DOMPurify.sanitize(ds);
+ const rawPromptWrapper = document.getElementById('rawPromptWrapper');
+ rawPromptWrapper.replaceChildren(container);
+ $('#rawPromptPopup').slideToggle();
+ });
+ } else {
+ diffPrevPrompt.style.display = 'none';
+ }
popup.dlg.querySelector('#copyPromptToClipboard').addEventListener('click', function () {
let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt;
let rawPromptValues = rawPrompt;
@@ -4948,16 +4980,11 @@ async function promptItemize(itemizedPrompts, requestedMesId) {
console.log(itemizedPrompts);
console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);
- let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt;
- let rawPromptValues = rawPrompt;
-
- if (Array.isArray(rawPrompt)) {
- rawPromptValues = rawPrompt.map(x => x.content).join('\n');
- }
+ const rawPrompt = flatten(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt);
//let DisplayStringifiedPrompt = JSON.stringify(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt).replace(/\n+/g, '
');
const rawPromptWrapper = document.getElementById('rawPromptWrapper');
- rawPromptWrapper.innerText = rawPromptValues;
+ rawPromptWrapper.innerText = rawPrompt;
$('#rawPromptPopup').slideToggle();
});
@@ -5019,6 +5046,10 @@ async function sendGenerationRequest(type, data) {
* @returns {Promise} Streaming generator
*/
async function sendStreamingRequest(type, data) {
+ if (abortController?.signal?.aborted) {
+ throw new Error('Generation was aborted.');
+ }
+
switch (main_api) {
case 'openai':
return await sendOpenAIRequest(type, data.prompt, streamingProcessor.abortController.signal);
@@ -6109,7 +6140,7 @@ export function changeMainAPI() {
}
if (selectedVal === 'textgenerationwebui' || selectedVal === 'novel') {
- console.log('enabling amount_gen for ooba/novel');
+ console.debug('enabling amount_gen for ooba/novel');
activeItem.amountGenElem.find('input').prop('disabled', false);
activeItem.amountGenElem.css('opacity', 1.0);
}
diff --git a/public/scripts/extensions/memory/index.js b/public/scripts/extensions/memory/index.js
index efd6f5fdd..2bb5c1269 100644
--- a/public/scripts/extensions/memory/index.js
+++ b/public/scripts/extensions/memory/index.js
@@ -804,7 +804,11 @@ function setMemoryContext(value, saveToMessage, index = null) {
const context = getContext();
context.setExtensionPrompt(MODULE_NAME, formatMemoryValue(value), extension_settings.memory.position, extension_settings.memory.depth, false, extension_settings.memory.role);
$('#memory_contents').val(value);
- console.log('Summary set to: ' + value, 'Position: ' + extension_settings.memory.position, 'Depth: ' + extension_settings.memory.depth, 'Role: ' + extension_settings.memory.role);
+
+ const summaryLog = value
+ ? `Summary set to: ${value}. Position: ${extension_settings.memory.position}. Depth: ${extension_settings.memory.depth}. Role: ${extension_settings.memory.role}`
+ : 'Summary has no content';
+ console.debug(summaryLog);
if (saveToMessage && context.chat.length) {
const idx = index ?? context.chat.length - 2;
diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js
index df2a1454c..b0f496126 100644
--- a/public/scripts/extensions/quick-reply/index.js
+++ b/public/scripts/extensions/quick-reply/index.js
@@ -14,6 +14,7 @@ import { SettingsUi } from './src/ui/SettingsUi.js';
const _VERBOSE = true;
+export const debug = (...msg) => _VERBOSE ? console.debug('[QR2]', ...msg) : null;
export const log = (...msg) => _VERBOSE ? console.log('[QR2]', ...msg) : null;
export const warn = (...msg) => _VERBOSE ? console.warn('[QR2]', ...msg) : null;
/**
@@ -206,18 +207,18 @@ const init = async () => {
window['quickReplyApi'] = quickReplyApi;
};
const finalizeInit = async () => {
- log('executing startup');
+ debug('executing startup');
await autoExec.handleStartup();
- log('/executing startup');
+ debug('/executing startup');
- log(`executing queue (${executeQueue.length} items)`);
+ debug(`executing queue (${executeQueue.length} items)`);
while (executeQueue.length > 0) {
const func = executeQueue.shift();
await func();
}
- log('/executing queue');
+ debug('/executing queue');
isReady = true;
- log('READY');
+ debug('READY');
};
await init();
diff --git a/public/scripts/extensions/regex/index.js b/public/scripts/extensions/regex/index.js
index d038ffef7..9e835cf23 100644
--- a/public/scripts/extensions/regex/index.js
+++ b/public/scripts/extensions/regex/index.js
@@ -1,13 +1,13 @@
import { callPopup, characters, eventSource, event_types, getCurrentChatId, reloadCurrentChat, saveSettingsDebounced, this_chid } from '../../../script.js';
import { extension_settings, renderExtensionTemplateAsync, writeExtensionField } from '../../extensions.js';
import { selected_group } from '../../group-chats.js';
+import { callGenericPopup, POPUP_TYPE } from '../../popup.js';
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
import { enumIcons } from '../../slash-commands/SlashCommandCommonEnumsProvider.js';
import { SlashCommandEnumValue, enumTypes } from '../../slash-commands/SlashCommandEnumValue.js';
import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
import { download, getFileText, getSortableDelay, uuidv4 } from '../../utils.js';
-import { resolveVariable } from '../../variables.js';
import { regex_placement, runRegexScript } from './engine.js';
/**
@@ -141,7 +141,7 @@ async function loadRegexScripts() {
await onRegexEditorOpenClick(scriptHtml.attr('id'), isScoped);
});
scriptHtml.find('.move_to_global').on('click', async function () {
- const confirm = await callPopup('Are you sure you want to move this regex script to global?', 'confirm');
+ const confirm = await callGenericPopup('Are you sure you want to move this regex script to global?', POPUP_TYPE.CONFIRM);
if (!confirm) {
return;
@@ -161,7 +161,7 @@ async function loadRegexScripts() {
return;
}
- const confirm = await callPopup('Are you sure you want to move this regex script to scoped?', 'confirm');
+ const confirm = await callGenericPopup('Are you sure you want to move this regex script to scoped?', POPUP_TYPE.CONFIRM);
if (!confirm) {
return;
@@ -176,7 +176,7 @@ async function loadRegexScripts() {
download(fileData, fileName, 'application/json');
});
scriptHtml.find('.delete_regex').on('click', async function () {
- const confirm = await callPopup('Are you sure you want to delete this regex script?', 'confirm');
+ const confirm = await callGenericPopup('Are you sure you want to delete this regex script?', POPUP_TYPE.CONFIRM);
if (!confirm) {
return;
@@ -442,7 +442,7 @@ async function checkEmbeddedRegexScripts() {
if (!localStorage.getItem(checkKey)) {
localStorage.setItem(checkKey, 'true');
const template = await renderExtensionTemplateAsync('regex', 'embeddedScripts', {});
- const result = await callPopup(template, 'confirm', '', { okButton: 'Yes' });
+ const result = await callGenericPopup(template, POPUP_TYPE.CONFIRM, '', { okButton: 'Yes' });
if (result) {
extension_settings.character_allowed_regex.push(avatar);
@@ -493,7 +493,7 @@ jQuery(async () => {
template.find('#regex_import_target_global').on('input', () => target = 'global');
template.find('#regex_import_target_scoped').on('input', () => target = 'scoped');
- await callPopup(template, 'text');
+ await callGenericPopup(template, POPUP_TYPE.TEXT);
const inputElement = this instanceof HTMLInputElement && this;
for (const file of inputElement.files) {
diff --git a/public/scripts/openai.js b/public/scripts/openai.js
index ee48db290..e07d5618a 100644
--- a/public/scripts/openai.js
+++ b/public/scripts/openai.js
@@ -3921,7 +3921,7 @@ async function onModelChange() {
oai_settings.groq_model = value;
}
- if ($(this).is('#model_01ai_select')) {
+ if (value && $(this).is('#model_01ai_select')) {
console.log('01.AI model changed to', value);
oai_settings.zerooneai_model = value;
}
diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js
index e484d2d99..f57de63ff 100644
--- a/public/scripts/power-user.js
+++ b/public/scripts/power-user.js
@@ -1064,19 +1064,19 @@ function applyChatDisplay() {
switch (power_user.chat_display) {
case 0: {
- console.log('applying default chat');
+ console.debug('applying default chat');
$('body').removeClass('bubblechat');
$('body').removeClass('documentstyle');
break;
}
case 1: {
- console.log('applying bubblechat');
+ console.debug('applying bubblechat');
$('body').addClass('bubblechat');
$('body').removeClass('documentstyle');
break;
}
case 2: {
- console.log('applying document style');
+ console.debug('applying document style');
$('body').removeClass('bubblechat');
$('body').addClass('documentstyle');
break;
@@ -3130,6 +3130,7 @@ $(document).ready(() => {
const winHeight = window.innerHeight;
const originalWidth = winWidth * zoomLevel;
const originalHeight = winHeight * zoomLevel;
+ console.log(`Window resize: ${coreTruthWinWidth}x${coreTruthWinHeight} -> ${window.innerWidth}x${window.innerHeight}`);
console.debug(`Zoom: ${zoomLevel}, X:${winWidth}, Y:${winHeight}, original: ${originalWidth}x${originalHeight} `);
return zoomLevel;
});
@@ -3138,7 +3139,6 @@ $(document).ready(() => {
var coreTruthWinHeight = window.innerHeight;
$(window).on('resize', async () => {
- console.log(`Window resize: ${coreTruthWinWidth}x${coreTruthWinHeight} -> ${window.innerWidth}x${window.innerHeight}`);
adjustAutocompleteDebounced();
setHotswapsDebounced();
@@ -3191,7 +3191,7 @@ $(document).ready(() => {
}
}
} else {
- console.log('aborting MUI reset', Object.keys(power_user.movingUIState).length);
+ console.debug('aborting MUI reset', Object.keys(power_user.movingUIState).length);
}
saveSettingsDebounced();
coreTruthWinWidth = window.innerWidth;
diff --git a/public/scripts/samplerSelect.js b/public/scripts/samplerSelect.js
index 4aa0caff6..887bc4488 100644
--- a/public/scripts/samplerSelect.js
+++ b/public/scripts/samplerSelect.js
@@ -307,7 +307,7 @@ async function listSamplers(main_api, arrayOnly = false) {
}
if (arrayOnly) {
- console.log('returning full samplers array');
+ console.debug('returning full samplers array');
return availableSamplers;
}
diff --git a/public/scripts/templates/itemizationChat.html b/public/scripts/templates/itemizationChat.html
index 969a31757..839a96618 100644
--- a/public/scripts/templates/itemizationChat.html
+++ b/public/scripts/templates/itemizationChat.html
@@ -2,6 +2,7 @@
Prompt Itemization
+
Tokenizer: {{selectedTokenizer}}
API Used: {{this_main_api}}
diff --git a/public/scripts/templates/itemizationText.html b/public/scripts/templates/itemizationText.html
index b3855e027..499297be1 100644
--- a/public/scripts/templates/itemizationText.html
+++ b/public/scripts/templates/itemizationText.html
@@ -2,6 +2,7 @@
Prompt Itemization
+
Tokenizer: {{selectedTokenizer}}
API Used: {{this_main_api}}
diff --git a/public/scripts/tokenizers.js b/public/scripts/tokenizers.js
index 001ae02bf..799646a4c 100644
--- a/public/scripts/tokenizers.js
+++ b/public/scripts/tokenizers.js
@@ -7,7 +7,7 @@ import { kai_flags } from './kai-settings.js';
import { textgen_types, textgenerationwebui_settings as textgen_settings, getTextGenServer, getTextGenModel } from './textgen-settings.js';
import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, openRouterModels } from './textgen-models.js';
-const { OOBA, TABBY, KOBOLDCPP, APHRODITE, LLAMACPP, OPENROUTER, DREAMGEN } = textgen_types;
+const { OOBA, TABBY, KOBOLDCPP, VLLM, APHRODITE, LLAMACPP, OPENROUTER, DREAMGEN } = textgen_types;
export const CHARACTERS_PER_TOKEN_RATIO = 3.35;
const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown';
@@ -39,7 +39,7 @@ export const SENTENCEPIECE_TOKENIZERS = [
//tokenizers.NERD2,
];
-export const TEXTGEN_TOKENIZERS = [OOBA, TABBY, KOBOLDCPP, LLAMACPP, APHRODITE];
+export const TEXTGEN_TOKENIZERS = [OOBA, TABBY, KOBOLDCPP, LLAMACPP, VLLM, APHRODITE];
const TOKENIZER_URLS = {
[tokenizers.GPT2]: {
@@ -769,6 +769,7 @@ function getTextgenAPITokenizationParams(str) {
api_type: textgen_settings.type,
url: getTextGenServer(),
legacy_api: textgen_settings.legacy_api && (textgen_settings.type === OOBA || textgen_settings.type === APHRODITE),
+ vllm_model: textgen_settings.vllm_model,
};
}
diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js
index 844773f59..355ac676b 100644
--- a/public/scripts/world-info.js
+++ b/public/scripts/world-info.js
@@ -16,7 +16,7 @@ import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandE
import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';
import { SlashCommandExecutor } from './slash-commands/SlashCommandExecutor.js';
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
-import { Popup } from './popup.js';
+import { callGenericPopup, Popup, POPUP_TYPE } from './popup.js';
export {
world_info,
@@ -24,6 +24,7 @@ export {
world_info_depth,
world_info_min_activations,
world_info_min_activations_depth_max,
+ world_info_include_names,
world_info_recursive,
world_info_overflow_alert,
world_info_case_sensitive,
@@ -83,6 +84,7 @@ let world_info_min_activations = 0; // if > 0, will continue seeking chat until
let world_info_min_activations_depth_max = 0; // used when (world_info_min_activations > 0)
let world_info_budget = 25;
+let world_info_include_names = true;
let world_info_recursive = false;
let world_info_overflow_alert = false;
let world_info_case_sensitive = false;
@@ -710,6 +712,7 @@ export function getWorldInfoSettings() {
world_info_min_activations,
world_info_min_activations_depth_max,
world_info_budget,
+ world_info_include_names,
world_info_recursive,
world_info_overflow_alert,
world_info_case_sensitive,
@@ -739,7 +742,7 @@ const worldInfoCache = new Map();
/**
* Gets the world info based on chat messages.
- * @param {string[]} chat The chat messages to scan.
+ * @param {string[]} chat The chat messages to scan, in reverse order.
* @param {number} maxContext The maximum context size of the generation.
* @param {boolean} isDryRun If true, the function will not emit any events.
* @typedef {{worldInfoString: string, worldInfoBefore: string, worldInfoAfter: string, worldInfoExamples: any[], worldInfoDepth: any[]}} WIPromptResult
@@ -776,6 +779,8 @@ function setWorldInfoSettings(settings, data) {
world_info_min_activations_depth_max = Number(settings.world_info_min_activations_depth_max);
if (settings.world_info_budget !== undefined)
world_info_budget = Number(settings.world_info_budget);
+ if (settings.world_info_include_names !== undefined)
+ world_info_include_names = Boolean(settings.world_info_include_names);
if (settings.world_info_recursive !== undefined)
world_info_recursive = Boolean(settings.world_info_recursive);
if (settings.world_info_overflow_alert !== undefined)
@@ -825,6 +830,7 @@ function setWorldInfoSettings(settings, data) {
$('#world_info_budget_counter').val(world_info_budget);
$('#world_info_budget').val(world_info_budget);
+ $('#world_info_include_names').prop('checked', world_info_include_names);
$('#world_info_recursive').prop('checked', world_info_recursive);
$('#world_info_overflow_alert').prop('checked', world_info_overflow_alert);
$('#world_info_case_sensitive').prop('checked', world_info_case_sensitive);
@@ -3527,7 +3533,7 @@ export async function getSortedEntries() {
/**
* Performs a scan on the chat and returns the world info activated.
- * @param {string[]} chat The chat messages to scan.
+ * @param {string[]} chat The chat messages to scan, in reverse order.
* @param {number} maxContext The maximum context size of the generation.
* @param {boolean} isDryRun Whether to perform a dry run.
* @typedef {{ worldInfoBefore: string, worldInfoAfter: string, EMEntries: any[], WIDepthEntries: any[], allActivatedEntries: Set }} WIActivated
@@ -4218,7 +4224,7 @@ export function checkEmbeddedWorld(chid) {
importEmbeddedWorldInfo(true);
}
};
- callPopup(html, 'confirm', '', { okButton: 'Yes' }).then(checkResult);
+ callGenericPopup(html, POPUP_TYPE.CONFIRM, '', { okButton: 'Yes' }).then(checkResult);
}
else {
toastr.info(
@@ -4533,6 +4539,11 @@ jQuery(() => {
saveSettings();
});
+ $('#world_info_include_names').on('input', function () {
+ world_info_include_names = !!$(this).prop('checked');
+ saveSettings();
+ });
+
$('#world_info_recursive').on('input', function () {
world_info_recursive = !!$(this).prop('checked');
saveSettings();
diff --git a/server.js b/server.js
index eebd23c22..1f226dc68 100644
--- a/server.js
+++ b/server.js
@@ -200,11 +200,30 @@ if (enableCorsProxy) {
});
}
+function getSessionCookieAge() {
+ // Defaults to 24 hours in seconds if not set
+ const configValue = getConfigValue('sessionTimeout', 24 * 60 * 60);
+
+ // Convert to milliseconds
+ if (configValue > 0) {
+ return configValue * 1000;
+ }
+
+ // "No expiration" is just 400 days as per RFC 6265
+ if (configValue < 0) {
+ return 400 * 24 * 60 * 60 * 1000;
+ }
+
+ // 0 means session cookie is deleted when the browser session ends
+ // (depends on the implementation of the browser)
+ return undefined;
+}
+
app.use(cookieSession({
name: userModule.getCookieSessionName(),
sameSite: 'strict',
httpOnly: true,
- maxAge: 24 * 60 * 60 * 1000, // 24 hours
+ maxAge: getSessionCookieAge(),
secret: userModule.getCookieSecret(),
}));
diff --git a/src/endpoints/tokenizers.js b/src/endpoints/tokenizers.js
index 0c8c99034..6b150e32b 100644
--- a/src/endpoints/tokenizers.js
+++ b/src/endpoints/tokenizers.js
@@ -784,6 +784,7 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
const text = String(request.body.text) || '';
const baseUrl = String(request.body.url);
const legacyApi = Boolean(request.body.legacy_api);
+ const vllmModel = String(request.body.vllm_model) || '';
try {
const args = {
@@ -814,7 +815,9 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
args.body = JSON.stringify({ 'content': text });
break;
case TEXTGEN_TYPES.VLLM:
- return response.send({ error: true });
+ url += '/tokenize';
+ args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text });
+ break;
case TEXTGEN_TYPES.APHRODITE:
url += '/v1/tokenize';
args.body = JSON.stringify({ 'prompt': text });
@@ -834,7 +837,7 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
}
const data = await result.json();
- const count = legacyApi ? data?.results[0]?.tokens : (data?.length ?? data?.value ?? data?.tokens?.length);
+ const count = legacyApi ? data?.results[0]?.tokens : (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length);
const ids = legacyApi ? [] : (data?.tokens ?? data?.ids ?? []);
return response.send({ count, ids });