Merge branch 'staging' into wi-processing-refactoring
This commit is contained in:
commit
34d6cdfbcc
|
@ -95,3 +95,8 @@ deepl:
|
||||||
formality: default
|
formality: default
|
||||||
# -- SERVER PLUGIN CONFIGURATION --
|
# -- SERVER PLUGIN CONFIGURATION --
|
||||||
enableServerPlugins: false
|
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
|
||||||
|
|
|
@ -678,5 +678,13 @@
|
||||||
{
|
{
|
||||||
"filename": "presets/context/ChatML-Names.json",
|
"filename": "presets/context/ChatML-Names.json",
|
||||||
"type": "context"
|
"type": "context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "presets/context/Gemma 2.json",
|
||||||
|
"type": "context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "presets/instruct/Gemma 2.json",
|
||||||
|
"type": "instruct"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"story_string": "<start_of_turn>user\n{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}}<end_of_turn>",
|
||||||
|
"example_separator": "",
|
||||||
|
"chat_start": "",
|
||||||
|
"use_stop_strings": false,
|
||||||
|
"allow_jailbreak": false,
|
||||||
|
"always_force_name2": true,
|
||||||
|
"trim_sentences": false,
|
||||||
|
"include_newline": false,
|
||||||
|
"single_line": false,
|
||||||
|
"name": "Gemma 2"
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"system_prompt": "Continue writing this story and portray characters realistically.",
|
||||||
|
"input_sequence": "<start_of_turn>user",
|
||||||
|
"output_sequence": "<start_of_turn>model",
|
||||||
|
"last_output_sequence": "",
|
||||||
|
"system_sequence": "<start_of_turn>system",
|
||||||
|
"stop_sequence": "<end_of_turn>",
|
||||||
|
"wrap": true,
|
||||||
|
"macro": true,
|
||||||
|
"names": false,
|
||||||
|
"names_force_groups": false,
|
||||||
|
"activation_regex": "",
|
||||||
|
"system_sequence_prefix": "",
|
||||||
|
"system_sequence_suffix": "",
|
||||||
|
"first_output_sequence": "",
|
||||||
|
"skip_examples": false,
|
||||||
|
"output_suffix": "<end_of_turn>\n",
|
||||||
|
"input_suffix": "<end_of_turn>\n",
|
||||||
|
"system_suffix": "<end_of_turn>\n",
|
||||||
|
"user_alignment_message": "",
|
||||||
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
|
"name": "Gemma 2"
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
},
|
},
|
||||||
"world_info_depth": 2,
|
"world_info_depth": 2,
|
||||||
"world_info_budget": 25,
|
"world_info_budget": 25,
|
||||||
|
"world_info_include_names": true,
|
||||||
"world_info_recursive": true,
|
"world_info_recursive": true,
|
||||||
"world_info_overflow_alert": false,
|
"world_info_overflow_alert": false,
|
||||||
"world_info_case_sensitive": false,
|
"world_info_case_sensitive": false,
|
||||||
|
|
|
@ -3542,6 +3542,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="wiCheckboxes" class="flex1 flex-container flexFlowColumn">
|
<div id="wiCheckboxes" class="flex1 flex-container flexFlowColumn">
|
||||||
|
<label title="Include names with each message into the context for scanning" data-i18n="[title]Include names with each message into the context for scanning" class="checkbox_label flex1">
|
||||||
|
<input id="world_info_include_names" type="checkbox" />
|
||||||
|
<small data-i18n="Include Names" class="whitespacenowrap flex1">
|
||||||
|
Include Names
|
||||||
|
</small>
|
||||||
|
</label>
|
||||||
<label title="Entries can activate other entries by mentioning their keywords" data-i18n="[title]Entries can activate other entries by mentioning their keywords" class="checkbox_label flex1">
|
<label title="Entries can activate other entries by mentioning their keywords" data-i18n="[title]Entries can activate other entries by mentioning their keywords" class="checkbox_label flex1">
|
||||||
<input id="world_info_recursive" type="checkbox" />
|
<input id="world_info_recursive" type="checkbox" />
|
||||||
<small data-i18n="Recursive Scan" class="whitespacenowrap flex1">
|
<small data-i18n="Recursive Scan" class="whitespacenowrap flex1">
|
||||||
|
|
|
@ -501,7 +501,7 @@
|
||||||
"Active World(s) for all chats": "すべてのチャットのアクティブなワールド",
|
"Active World(s) for all chats": "すべてのチャットのアクティブなワールド",
|
||||||
"-- World Info not found --": "-- ワールド情報が見つかりません --",
|
"-- World Info not found --": "-- ワールド情報が見つかりません --",
|
||||||
"Global World Info/Lorebook activation settings": "グローバルワールド情報/Lorebookの有効化設定",
|
"Global World Info/Lorebook activation settings": "グローバルワールド情報/Lorebookの有効化設定",
|
||||||
"Click to expand": "クリックして拡大",
|
"Click to expand": "クリックして展開",
|
||||||
"Scan Depth": "スキャンの深さ",
|
"Scan Depth": "スキャンの深さ",
|
||||||
"Context %": "コンテキスト%",
|
"Context %": "コンテキスト%",
|
||||||
"Budget Cap": "予算キャップ",
|
"Budget Cap": "予算キャップ",
|
||||||
|
@ -965,13 +965,13 @@
|
||||||
"After EM": "↓EM",
|
"After EM": "↓EM",
|
||||||
"Before AN": "著者のメモの前",
|
"Before AN": "著者のメモの前",
|
||||||
"After AN": "著者のメモの後",
|
"After AN": "著者のメモの後",
|
||||||
"at Depth System": "笑笑笑笑",
|
"at Depth System": "指定深度(システム)",
|
||||||
"at Depth User": "👤 こんばんは",
|
"at Depth User": "指定深度(ユーザー)",
|
||||||
"at Depth AI": "🤖 だめだ",
|
"at Depth AI": "指定深度(AI)",
|
||||||
"Depth": "深さ",
|
"Depth": "深さ",
|
||||||
"Order:": "順序:",
|
"Order:": "順序:",
|
||||||
"Order": "順序:",
|
"Order": "順序:",
|
||||||
"Trigger %:": "引き金 %:",
|
"Trigger %:": "発生 %:",
|
||||||
"Probability": "確率",
|
"Probability": "確率",
|
||||||
"Duplicate world info entry": "重複したワールド情報エントリ",
|
"Duplicate world info entry": "重複したワールド情報エントリ",
|
||||||
"Delete world info entry": "世界情報エントリを削除",
|
"Delete world info entry": "世界情報エントリを削除",
|
||||||
|
@ -981,10 +981,10 @@
|
||||||
"Comma separated list": "カンマ区切りリスト",
|
"Comma separated list": "カンマ区切りリスト",
|
||||||
"Switch to plaintext mode": "プレーンテキストモードに切り替える",
|
"Switch to plaintext mode": "プレーンテキストモードに切り替える",
|
||||||
"Logic": "論理",
|
"Logic": "論理",
|
||||||
"AND ANY": "任意のAND",
|
"AND ANY": "AND ANY",
|
||||||
"AND ALL": "すべてのAND",
|
"AND ALL": "AND ALL",
|
||||||
"NOT ALL": "すべてのNOT",
|
"NOT ALL": "NOT ALL",
|
||||||
"NOT ANY": "どれかのNOT",
|
"NOT ANY": "NOT ANY",
|
||||||
"(ignored if empty)": "(空の場合は無視されます)",
|
"(ignored if empty)": "(空の場合は無視されます)",
|
||||||
"Optional Filter": "オプションフィルタ",
|
"Optional Filter": "オプションフィルタ",
|
||||||
"Keywords or Regexes (ignored if empty)": "キーワードまたは正規表現(空の場合は無視されます)",
|
"Keywords or Regexes (ignored if empty)": "キーワードまたは正規表現(空の場合は無視されます)",
|
||||||
|
@ -1004,7 +1004,7 @@
|
||||||
"Filter to Character(s)": "キャラクターにフィルター",
|
"Filter to Character(s)": "キャラクターにフィルター",
|
||||||
"Character Exclusion": "キャラクターの除外",
|
"Character Exclusion": "キャラクターの除外",
|
||||||
"-- Characters not found --": "-- キャラクターが見つかりません --",
|
"-- Characters not found --": "-- キャラクターが見つかりません --",
|
||||||
"Inclusion Group": "含蓋グループ",
|
"Inclusion Group": "包含グループ",
|
||||||
"Inclusion Groups ensure only one entry from a group is activated at a time, if multiple are triggered.Documentation: World Info - Inclusion Group": "包含グループにより、複数のエントリがトリガーされた場合、一度に 1 つのグループから 1 つのエントリのみがアクティブ化されます。カンマで区切られた複数のグループをサポートします。ドキュメント: World Info - 包含グループ",
|
"Inclusion Groups ensure only one entry from a group is activated at a time, if multiple are triggered.Documentation: World Info - Inclusion Group": "包含グループにより、複数のエントリがトリガーされた場合、一度に 1 つのグループから 1 つのエントリのみがアクティブ化されます。カンマで区切られた複数のグループをサポートします。ドキュメント: World Info - 包含グループ",
|
||||||
"Prioritize this entry: When checked, this entry is prioritized out of all selections.If multiple are prioritized, the one with the highest 'Order' is chosen.": "このエントリを優先する: チェックすると、このエントリがすべての選択項目の中で優先されます。複数のエントリを優先する場合は、「順序」が最も高いエントリが選択されます。",
|
"Prioritize this entry: When checked, this entry is prioritized out of all selections.If multiple are prioritized, the one with the highest 'Order' is chosen.": "このエントリを優先する: チェックすると、このエントリがすべての選択項目の中で優先されます。複数のエントリを優先する場合は、「順序」が最も高いエントリが選択されます。",
|
||||||
"Only one entry with the same label will be activated": "同じラベルのエントリが1つだけ有効になります",
|
"Only one entry with the same label will be activated": "同じラベルのエントリが1つだけ有効になります",
|
||||||
|
@ -1014,7 +1014,7 @@
|
||||||
"Use Probability": "確率を使用",
|
"Use Probability": "確率を使用",
|
||||||
"Add Memo": "メモを追加",
|
"Add Memo": "メモを追加",
|
||||||
"Text or token ids": "テキストまたは[トークンID]",
|
"Text or token ids": "テキストまたは[トークンID]",
|
||||||
"close": "近い",
|
"close": "閉じる",
|
||||||
"prompt_manager_edit": "編集",
|
"prompt_manager_edit": "編集",
|
||||||
"prompt_manager_name": "名前",
|
"prompt_manager_name": "名前",
|
||||||
"A name for this prompt.": "このプロンプトの名前。",
|
"A name for this prompt.": "このプロンプトの名前。",
|
||||||
|
|
|
@ -35,6 +35,7 @@ import {
|
||||||
setWorldInfoButtonClass,
|
setWorldInfoButtonClass,
|
||||||
importWorldInfo,
|
importWorldInfo,
|
||||||
wi_anchor_position,
|
wi_anchor_position,
|
||||||
|
world_info_include_names,
|
||||||
} from './scripts/world-info.js';
|
} from './scripts/world-info.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -3500,7 +3501,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||||
// Add WI to prompt (and also inject WI to AN value via hijack)
|
// Add WI to prompt (and also inject WI to AN value via hijack)
|
||||||
// Make quiet prompt available for WIAN
|
// Make quiet prompt available for WIAN
|
||||||
setExtensionPrompt('QUIET_PROMPT', quiet_prompt || '', extension_prompt_types.IN_PROMPT, 0, true);
|
setExtensionPrompt('QUIET_PROMPT', quiet_prompt || '', extension_prompt_types.IN_PROMPT, 0, true);
|
||||||
const chatForWI = coreChat.map(x => `${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);
|
const { worldInfoString, worldInfoBefore, worldInfoAfter, worldInfoExamples, worldInfoDepth } = await getWorldInfoPrompt(chatForWI, this_max_context, dryRun);
|
||||||
setExtensionPrompt('QUIET_PROMPT', '', extension_prompt_types.IN_PROMPT, 0, true);
|
setExtensionPrompt('QUIET_PROMPT', '', extension_prompt_types.IN_PROMPT, 0, true);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
||||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
||||||
import { debounce_timeout } from '../../constants.js';
|
import { debounce_timeout } from '../../constants.js';
|
||||||
import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js';
|
import { SlashCommandEnumValue } from '../../slash-commands/SlashCommandEnumValue.js';
|
||||||
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
|
import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
|
||||||
export { MODULE_NAME };
|
export { MODULE_NAME };
|
||||||
|
|
||||||
const MODULE_NAME = 'sd';
|
const MODULE_NAME = 'sd';
|
||||||
|
@ -3150,7 +3150,12 @@ async function onComfyOpenWorkflowEditorClick() {
|
||||||
}),
|
}),
|
||||||
})).json();
|
})).json();
|
||||||
const editorHtml = $(await $.get('scripts/extensions/stable-diffusion/comfyWorkflowEditor.html'));
|
const editorHtml = $(await $.get('scripts/extensions/stable-diffusion/comfyWorkflowEditor.html'));
|
||||||
const popupResult = callGenericPopup(editorHtml, POPUP_TYPE.CONFIRM, '', { okButton: 'Save', cancelButton: 'Cancel', wide: true, large: true });
|
const saveValue = (/** @type {Popup} */ _popup) => {
|
||||||
|
workflow = $('#sd_comfy_workflow_editor_workflow').val().toString();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
const popup = new Popup(editorHtml, POPUP_TYPE.CONFIRM, '', { okButton: 'Save', cancelButton: 'Cancel', wide: true, large: true, onClosing: saveValue });
|
||||||
|
const popupResult = popup.show();
|
||||||
const checkPlaceholders = () => {
|
const checkPlaceholders = () => {
|
||||||
workflow = $('#sd_comfy_workflow_editor_workflow').val().toString();
|
workflow = $('#sd_comfy_workflow_editor_workflow').val().toString();
|
||||||
$('.sd_comfy_workflow_editor_placeholder_list > li[data-placeholder]').each(function (idx) {
|
$('.sd_comfy_workflow_editor_placeholder_list > li[data-placeholder]').each(function (idx) {
|
||||||
|
@ -3219,7 +3224,7 @@ async function onComfyOpenWorkflowEditorClick() {
|
||||||
headers: getRequestHeaders(),
|
headers: getRequestHeaders(),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
file_name: extension_settings.sd.comfy_workflow,
|
file_name: extension_settings.sd.comfy_workflow,
|
||||||
workflow: $('#sd_comfy_workflow_editor_workflow').val().toString(),
|
workflow: workflow,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
|
@ -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 { textgen_types, textgenerationwebui_settings as textgen_settings, getTextGenServer, getTextGenModel } from './textgen-settings.js';
|
||||||
import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, openRouterModels } from './textgen-models.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;
|
export const CHARACTERS_PER_TOKEN_RATIO = 3.35;
|
||||||
const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown';
|
const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown';
|
||||||
|
@ -39,7 +39,7 @@ export const SENTENCEPIECE_TOKENIZERS = [
|
||||||
//tokenizers.NERD2,
|
//tokenizers.NERD2,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const TEXTGEN_TOKENIZERS = [OOBA, TABBY, KOBOLDCPP, LLAMACPP, APHRODITE];
|
export const TEXTGEN_TOKENIZERS = [OOBA, TABBY, KOBOLDCPP, LLAMACPP, VLLM, APHRODITE];
|
||||||
|
|
||||||
const TOKENIZER_URLS = {
|
const TOKENIZER_URLS = {
|
||||||
[tokenizers.GPT2]: {
|
[tokenizers.GPT2]: {
|
||||||
|
@ -769,6 +769,7 @@ function getTextgenAPITokenizationParams(str) {
|
||||||
api_type: textgen_settings.type,
|
api_type: textgen_settings.type,
|
||||||
url: getTextGenServer(),
|
url: getTextGenServer(),
|
||||||
legacy_api: textgen_settings.legacy_api && (textgen_settings.type === OOBA || textgen_settings.type === APHRODITE),
|
legacy_api: textgen_settings.legacy_api && (textgen_settings.type === OOBA || textgen_settings.type === APHRODITE),
|
||||||
|
vllm_model: textgen_settings.vllm_model,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ export {
|
||||||
world_info_depth,
|
world_info_depth,
|
||||||
world_info_min_activations,
|
world_info_min_activations,
|
||||||
world_info_min_activations_depth_max,
|
world_info_min_activations_depth_max,
|
||||||
|
world_info_include_names,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
world_info_overflow_alert,
|
world_info_overflow_alert,
|
||||||
world_info_case_sensitive,
|
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_min_activations_depth_max = 0; // used when (world_info_min_activations > 0)
|
||||||
|
|
||||||
let world_info_budget = 25;
|
let world_info_budget = 25;
|
||||||
|
let world_info_include_names = true;
|
||||||
let world_info_recursive = false;
|
let world_info_recursive = false;
|
||||||
let world_info_overflow_alert = false;
|
let world_info_overflow_alert = false;
|
||||||
let world_info_case_sensitive = false;
|
let world_info_case_sensitive = false;
|
||||||
|
@ -718,6 +720,7 @@ export function getWorldInfoSettings() {
|
||||||
world_info_min_activations,
|
world_info_min_activations,
|
||||||
world_info_min_activations_depth_max,
|
world_info_min_activations_depth_max,
|
||||||
world_info_budget,
|
world_info_budget,
|
||||||
|
world_info_include_names,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
world_info_overflow_alert,
|
world_info_overflow_alert,
|
||||||
world_info_case_sensitive,
|
world_info_case_sensitive,
|
||||||
|
@ -747,7 +750,7 @@ const worldInfoCache = new Map();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the world info based on chat messages.
|
* 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 {number} maxContext The maximum context size of the generation.
|
||||||
* @param {boolean} isDryRun If true, the function will not emit any events.
|
* @param {boolean} isDryRun If true, the function will not emit any events.
|
||||||
* @typedef {{worldInfoString: string, worldInfoBefore: string, worldInfoAfter: string, worldInfoExamples: any[], worldInfoDepth: any[]}} WIPromptResult
|
* @typedef {{worldInfoString: string, worldInfoBefore: string, worldInfoAfter: string, worldInfoExamples: any[], worldInfoDepth: any[]}} WIPromptResult
|
||||||
|
@ -784,6 +787,8 @@ function setWorldInfoSettings(settings, data) {
|
||||||
world_info_min_activations_depth_max = Number(settings.world_info_min_activations_depth_max);
|
world_info_min_activations_depth_max = Number(settings.world_info_min_activations_depth_max);
|
||||||
if (settings.world_info_budget !== undefined)
|
if (settings.world_info_budget !== undefined)
|
||||||
world_info_budget = Number(settings.world_info_budget);
|
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)
|
if (settings.world_info_recursive !== undefined)
|
||||||
world_info_recursive = Boolean(settings.world_info_recursive);
|
world_info_recursive = Boolean(settings.world_info_recursive);
|
||||||
if (settings.world_info_overflow_alert !== undefined)
|
if (settings.world_info_overflow_alert !== undefined)
|
||||||
|
@ -833,6 +838,7 @@ function setWorldInfoSettings(settings, data) {
|
||||||
$('#world_info_budget_counter').val(world_info_budget);
|
$('#world_info_budget_counter').val(world_info_budget);
|
||||||
$('#world_info_budget').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_recursive').prop('checked', world_info_recursive);
|
||||||
$('#world_info_overflow_alert').prop('checked', world_info_overflow_alert);
|
$('#world_info_overflow_alert').prop('checked', world_info_overflow_alert);
|
||||||
$('#world_info_case_sensitive').prop('checked', world_info_case_sensitive);
|
$('#world_info_case_sensitive').prop('checked', world_info_case_sensitive);
|
||||||
|
@ -3542,7 +3548,7 @@ export async function getSortedEntries() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a scan on the chat and returns the world info activated.
|
* 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 {number} maxContext The maximum context size of the generation.
|
||||||
* @param {boolean} isDryRun Whether to perform a dry run.
|
* @param {boolean} isDryRun Whether to perform a dry run.
|
||||||
* @typedef {{ worldInfoBefore: string, worldInfoAfter: string, EMEntries: any[], WIDepthEntries: any[], allActivatedEntries: Set<any> }} WIActivated
|
* @typedef {{ worldInfoBefore: string, worldInfoAfter: string, EMEntries: any[], WIDepthEntries: any[], allActivatedEntries: Set<any> }} WIActivated
|
||||||
|
@ -4637,6 +4643,11 @@ jQuery(() => {
|
||||||
saveSettings();
|
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').on('input', function () {
|
||||||
world_info_recursive = !!$(this).prop('checked');
|
world_info_recursive = !!$(this).prop('checked');
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
21
server.js
21
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({
|
app.use(cookieSession({
|
||||||
name: userModule.getCookieSessionName(),
|
name: userModule.getCookieSessionName(),
|
||||||
sameSite: 'strict',
|
sameSite: 'strict',
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
maxAge: getSessionCookieAge(),
|
||||||
secret: userModule.getCookieSecret(),
|
secret: userModule.getCookieSecret(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -784,6 +784,7 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
|
||||||
const text = String(request.body.text) || '';
|
const text = String(request.body.text) || '';
|
||||||
const baseUrl = String(request.body.url);
|
const baseUrl = String(request.body.url);
|
||||||
const legacyApi = Boolean(request.body.legacy_api);
|
const legacyApi = Boolean(request.body.legacy_api);
|
||||||
|
const vllmModel = String(request.body.vllm_model) || '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const args = {
|
const args = {
|
||||||
|
@ -814,7 +815,9 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
|
||||||
args.body = JSON.stringify({ 'content': text });
|
args.body = JSON.stringify({ 'content': text });
|
||||||
break;
|
break;
|
||||||
case TEXTGEN_TYPES.VLLM:
|
case TEXTGEN_TYPES.VLLM:
|
||||||
return response.send({ error: true });
|
url += '/tokenize';
|
||||||
|
args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text });
|
||||||
|
break;
|
||||||
case TEXTGEN_TYPES.APHRODITE:
|
case TEXTGEN_TYPES.APHRODITE:
|
||||||
url += '/v1/tokenize';
|
url += '/v1/tokenize';
|
||||||
args.body = JSON.stringify({ 'prompt': text });
|
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 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 ?? []);
|
const ids = legacyApi ? [] : (data?.tokens ?? data?.ids ?? []);
|
||||||
|
|
||||||
return response.send({ count, ids });
|
return response.send({ count, ids });
|
||||||
|
|
Loading…
Reference in New Issue