mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into parser-v2
This commit is contained in:
@@ -1,11 +1,25 @@
|
||||
import { getStringHash, debounce, waitUntilCondition, extractAllWords } from '../../utils.js';
|
||||
import { getContext, getApiUrl, extension_settings, doExtrasFetch, modules } from '../../extensions.js';
|
||||
import { animation_duration, eventSource, event_types, extension_prompt_roles, extension_prompt_types, generateQuietPrompt, is_send_press, saveSettingsDebounced, substituteParams } from '../../../script.js';
|
||||
import { getStringHash, debounce, waitUntilCondition, extractAllWords, delay } from '../../utils.js';
|
||||
import { getContext, getApiUrl, extension_settings, doExtrasFetch, modules, renderExtensionTemplate } from '../../extensions.js';
|
||||
import {
|
||||
activateSendButtons,
|
||||
deactivateSendButtons,
|
||||
animation_duration,
|
||||
eventSource,
|
||||
event_types,
|
||||
extension_prompt_roles,
|
||||
extension_prompt_types,
|
||||
generateQuietPrompt,
|
||||
is_send_press,
|
||||
saveSettingsDebounced,
|
||||
substituteParams,
|
||||
generateRaw,
|
||||
getMaxContextSize,
|
||||
} from '../../../script.js';
|
||||
import { is_group_generating, selected_group } from '../../group-chats.js';
|
||||
import { registerSlashCommand } from '../../slash-commands.js';
|
||||
import { loadMovingUIState } from '../../power-user.js';
|
||||
import { dragElement } from '../../RossAscends-mods.js';
|
||||
import { getTextTokens, tokenizers } from '../../tokenizers.js';
|
||||
import { getTextTokens, getTokenCount, tokenizers } from '../../tokenizers.js';
|
||||
export { MODULE_NAME };
|
||||
|
||||
const MODULE_NAME = '1_memory';
|
||||
@@ -39,7 +53,13 @@ const summary_sources = {
|
||||
'main': 'main',
|
||||
};
|
||||
|
||||
const defaultPrompt = '[Pause your roleplay. Summarize the most important facts and events that have happened in the chat so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.]';
|
||||
const prompt_builders = {
|
||||
DEFAULT: 0,
|
||||
RAW_BLOCKING: 1,
|
||||
RAW_NON_BLOCKING: 2,
|
||||
};
|
||||
|
||||
const defaultPrompt = '[Pause your roleplay. Summarize the most important facts and events in the story so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.]';
|
||||
const defaultTemplate = '[Summary: {{summary}}]';
|
||||
|
||||
const defaultSettings = {
|
||||
@@ -57,12 +77,21 @@ const defaultSettings = {
|
||||
promptWordsStep: 25,
|
||||
promptInterval: 10,
|
||||
promptMinInterval: 0,
|
||||
promptMaxInterval: 100,
|
||||
promptMaxInterval: 250,
|
||||
promptIntervalStep: 1,
|
||||
promptForceWords: 0,
|
||||
promptForceWordsStep: 100,
|
||||
promptMinForceWords: 0,
|
||||
promptMaxForceWords: 10000,
|
||||
overrideResponseLength: 0,
|
||||
overrideResponseLengthMin: 0,
|
||||
overrideResponseLengthMax: 4096,
|
||||
overrideResponseLengthStep: 16,
|
||||
maxMessagesPerRequest: 0,
|
||||
maxMessagesPerRequestMin: 0,
|
||||
maxMessagesPerRequestMax: 250,
|
||||
maxMessagesPerRequestStep: 1,
|
||||
prompt_builder: prompt_builders.RAW_BLOCKING,
|
||||
};
|
||||
|
||||
function loadSettings() {
|
||||
@@ -87,9 +116,88 @@ function loadSettings() {
|
||||
$('#memory_role').val(extension_settings.memory.role).trigger('input');
|
||||
$(`input[name="memory_position"][value="${extension_settings.memory.position}"]`).prop('checked', true).trigger('input');
|
||||
$('#memory_prompt_words_force').val(extension_settings.memory.promptForceWords).trigger('input');
|
||||
$(`input[name="memory_prompt_builder"][value="${extension_settings.memory.prompt_builder}"]`).prop('checked', true).trigger('input');
|
||||
$('#memory_override_response_length').val(extension_settings.memory.overrideResponseLength).trigger('input');
|
||||
$('#memory_max_messages_per_request').val(extension_settings.memory.maxMessagesPerRequest).trigger('input');
|
||||
switchSourceControls(extension_settings.memory.source);
|
||||
}
|
||||
|
||||
async function onPromptForceWordsAutoClick() {
|
||||
const context = getContext();
|
||||
const maxPromptLength = getMaxContextSize(extension_settings.memory.overrideResponseLength);
|
||||
const chat = context.chat;
|
||||
const allMessages = chat.filter(m => !m.is_system && m.mes).map(m => m.mes);
|
||||
const messagesWordCount = allMessages.map(m => extractAllWords(m)).flat().length;
|
||||
const averageMessageWordCount = messagesWordCount / allMessages.length;
|
||||
const tokensPerWord = getTokenCount(allMessages.join('\n')) / messagesWordCount;
|
||||
const wordsPerToken = 1 / tokensPerWord;
|
||||
const maxPromptLengthWords = Math.round(maxPromptLength * wordsPerToken);
|
||||
// How many words should pass so that messages will start be dropped out of context;
|
||||
const wordsPerPrompt = Math.floor(maxPromptLength / tokensPerWord);
|
||||
// How many words will be needed to fit the allowance buffer
|
||||
const summaryPromptWords = extractAllWords(extension_settings.memory.prompt).length;
|
||||
const promptAllowanceWords = maxPromptLengthWords - extension_settings.memory.promptWords - summaryPromptWords;
|
||||
const averageMessagesPerPrompt = Math.floor(promptAllowanceWords / averageMessageWordCount);
|
||||
const maxMessagesPerSummary = extension_settings.memory.maxMessagesPerRequest || 0;
|
||||
const targetMessagesInPrompt = maxMessagesPerSummary > 0 ? maxMessagesPerSummary : Math.max(0, averageMessagesPerPrompt);
|
||||
const targetSummaryWords = (targetMessagesInPrompt * averageMessageWordCount) + (promptAllowanceWords / 4);
|
||||
|
||||
console.table({
|
||||
maxPromptLength,
|
||||
maxPromptLengthWords,
|
||||
promptAllowanceWords,
|
||||
averageMessagesPerPrompt,
|
||||
targetMessagesInPrompt,
|
||||
targetSummaryWords,
|
||||
wordsPerPrompt,
|
||||
wordsPerToken,
|
||||
tokensPerWord,
|
||||
messagesWordCount,
|
||||
});
|
||||
|
||||
const ROUNDING = 100;
|
||||
extension_settings.memory.promptForceWords = Math.max(1, Math.floor(targetSummaryWords / ROUNDING) * ROUNDING);
|
||||
$('#memory_prompt_words_force').val(extension_settings.memory.promptForceWords).trigger('input');
|
||||
}
|
||||
|
||||
async function onPromptIntervalAutoClick() {
|
||||
const context = getContext();
|
||||
const maxPromptLength = getMaxContextSize(extension_settings.memory.overrideResponseLength);
|
||||
const chat = context.chat;
|
||||
const allMessages = chat.filter(m => !m.is_system && m.mes).map(m => m.mes);
|
||||
const messagesWordCount = allMessages.map(m => extractAllWords(m)).flat().length;
|
||||
const messagesTokenCount = getTokenCount(allMessages.join('\n'));
|
||||
const tokensPerWord = messagesTokenCount / messagesWordCount;
|
||||
const averageMessageTokenCount = messagesTokenCount / allMessages.length;
|
||||
const targetSummaryTokens = Math.round(extension_settings.memory.promptWords * tokensPerWord);
|
||||
const promptTokens = getTokenCount(extension_settings.memory.prompt);
|
||||
const promptAllowance = maxPromptLength - promptTokens - targetSummaryTokens;
|
||||
const maxMessagesPerSummary = extension_settings.memory.maxMessagesPerRequest || 0;
|
||||
const averageMessagesPerPrompt = Math.floor(promptAllowance / averageMessageTokenCount);
|
||||
const targetMessagesInPrompt = maxMessagesPerSummary > 0 ? maxMessagesPerSummary : Math.max(0, averageMessagesPerPrompt);
|
||||
const adjustedAverageMessagesPerPrompt = targetMessagesInPrompt + (averageMessagesPerPrompt - targetMessagesInPrompt) / 4;
|
||||
|
||||
console.table({
|
||||
maxPromptLength,
|
||||
promptAllowance,
|
||||
targetSummaryTokens,
|
||||
promptTokens,
|
||||
messagesWordCount,
|
||||
messagesTokenCount,
|
||||
tokensPerWord,
|
||||
averageMessageTokenCount,
|
||||
averageMessagesPerPrompt,
|
||||
targetMessagesInPrompt,
|
||||
adjustedAverageMessagesPerPrompt,
|
||||
maxMessagesPerSummary,
|
||||
});
|
||||
|
||||
const ROUNDING = 5;
|
||||
extension_settings.memory.promptInterval = Math.max(1, Math.floor(adjustedAverageMessagesPerPrompt / ROUNDING) * ROUNDING);
|
||||
|
||||
$('#memory_prompt_interval').val(extension_settings.memory.promptInterval).trigger('input');
|
||||
}
|
||||
|
||||
function onSummarySourceChange(event) {
|
||||
const value = event.target.value;
|
||||
extension_settings.memory.source = value;
|
||||
@@ -98,8 +206,8 @@ function onSummarySourceChange(event) {
|
||||
}
|
||||
|
||||
function switchSourceControls(value) {
|
||||
$('#memory_settings [data-source]').each((_, element) => {
|
||||
const source = $(element).data('source');
|
||||
$('#memory_settings [data-summary-source]').each((_, element) => {
|
||||
const source = $(element).data('summary-source');
|
||||
$(element).toggle(source === value);
|
||||
});
|
||||
}
|
||||
@@ -130,6 +238,10 @@ function onMemoryPromptIntervalInput() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onMemoryPromptRestoreClick() {
|
||||
$('#memory_prompt').val(defaultPrompt).trigger('input');
|
||||
}
|
||||
|
||||
function onMemoryPromptInput() {
|
||||
const value = $(this).val();
|
||||
extension_settings.memory.prompt = value;
|
||||
@@ -171,6 +283,20 @@ function onMemoryPromptWordsForceInput() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onOverrideResponseLengthInput() {
|
||||
const value = $(this).val();
|
||||
extension_settings.memory.overrideResponseLength = Number(value);
|
||||
$('#memory_override_response_length_value').text(extension_settings.memory.overrideResponseLength);
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onMaxMessagesPerRequestInput() {
|
||||
const value = $(this).val();
|
||||
extension_settings.memory.maxMessagesPerRequest = Number(value);
|
||||
$('#memory_max_messages_per_request_value').text(extension_settings.memory.maxMessagesPerRequest);
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function saveLastValues() {
|
||||
const context = getContext();
|
||||
lastGroupId = context.groupId;
|
||||
@@ -196,6 +322,22 @@ function getLatestMemoryFromChat(chat) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function getIndexOfLatestChatSummary(chat) {
|
||||
if (!Array.isArray(chat) || !chat.length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const reversedChat = chat.slice().reverse();
|
||||
reversedChat.shift();
|
||||
for (let mes of reversedChat) {
|
||||
if (mes.extra && mes.extra.memory) {
|
||||
return chat.indexOf(mes);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
async function onChatEvent() {
|
||||
// Module not enabled
|
||||
if (extension_settings.memory.source === summary_sources.extras) {
|
||||
@@ -359,8 +501,41 @@ async function summarizeChatMain(context, force, skipWIAN) {
|
||||
console.debug('Summarization prompt is empty. Skipping summarization.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('sending summary prompt');
|
||||
const summary = await generateQuietPrompt(prompt, false, skipWIAN);
|
||||
let summary = '';
|
||||
let index = null;
|
||||
|
||||
if (prompt_builders.DEFAULT === extension_settings.memory.prompt_builder) {
|
||||
summary = await generateQuietPrompt(prompt, false, skipWIAN, '', '', extension_settings.memory.overrideResponseLength);
|
||||
}
|
||||
|
||||
if ([prompt_builders.RAW_BLOCKING, prompt_builders.RAW_NON_BLOCKING].includes(extension_settings.memory.prompt_builder)) {
|
||||
const lock = extension_settings.memory.prompt_builder === prompt_builders.RAW_BLOCKING;
|
||||
try {
|
||||
if (lock) {
|
||||
deactivateSendButtons();
|
||||
}
|
||||
|
||||
const { rawPrompt, lastUsedIndex } = await getRawSummaryPrompt(context, prompt);
|
||||
|
||||
if (lastUsedIndex === null || lastUsedIndex === -1) {
|
||||
if (force) {
|
||||
toastr.info('To try again, remove the latest summary.', 'No messages found to summarize');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
summary = await generateRaw(rawPrompt, '', false, false, prompt, extension_settings.memory.overrideResponseLength);
|
||||
index = lastUsedIndex;
|
||||
} finally {
|
||||
if (lock) {
|
||||
activateSendButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const newContext = getContext();
|
||||
|
||||
// something changed during summarization request
|
||||
@@ -371,10 +546,83 @@ async function summarizeChatMain(context, force, skipWIAN) {
|
||||
return;
|
||||
}
|
||||
|
||||
setMemoryContext(summary, true);
|
||||
setMemoryContext(summary, true, index);
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw summarization prompt from the chat context.
|
||||
* @param {object} context ST context
|
||||
* @param {string} prompt Summarization system prompt
|
||||
* @returns {Promise<{rawPrompt: string, lastUsedIndex: number}>} Raw summarization prompt
|
||||
*/
|
||||
async function getRawSummaryPrompt(context, prompt) {
|
||||
/**
|
||||
* Get the memory string from the chat buffer.
|
||||
* @param {boolean} includeSystem Include prompt into the memory string
|
||||
* @returns {string} Memory string
|
||||
*/
|
||||
function getMemoryString(includeSystem) {
|
||||
const delimiter = '\n\n';
|
||||
const stringBuilder = [];
|
||||
const bufferString = chatBuffer.slice().join(delimiter);
|
||||
|
||||
if (includeSystem) {
|
||||
stringBuilder.push(prompt);
|
||||
}
|
||||
|
||||
if (latestSummary) {
|
||||
stringBuilder.push(latestSummary);
|
||||
}
|
||||
|
||||
stringBuilder.push(bufferString);
|
||||
|
||||
return stringBuilder.join(delimiter).trim();
|
||||
}
|
||||
|
||||
const chat = context.chat.slice();
|
||||
const latestSummary = getLatestMemoryFromChat(chat);
|
||||
const latestSummaryIndex = getIndexOfLatestChatSummary(chat);
|
||||
chat.pop(); // We always exclude the last message from the buffer
|
||||
const chatBuffer = [];
|
||||
const PADDING = 64;
|
||||
const PROMPT_SIZE = getMaxContextSize(extension_settings.memory.overrideResponseLength);
|
||||
let latestUsedMessage = null;
|
||||
|
||||
for (let index = latestSummaryIndex + 1; index < chat.length; index++) {
|
||||
const message = chat[index];
|
||||
|
||||
if (!message) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (message.is_system || !message.mes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const entry = `${message.name}:\n${message.mes}`;
|
||||
chatBuffer.push(entry);
|
||||
|
||||
const tokens = getTokenCount(getMemoryString(true), PADDING);
|
||||
await delay(1);
|
||||
|
||||
if (tokens > PROMPT_SIZE) {
|
||||
chatBuffer.pop();
|
||||
break;
|
||||
}
|
||||
|
||||
latestUsedMessage = message;
|
||||
|
||||
if (extension_settings.memory.maxMessagesPerRequest > 0 && chatBuffer.length >= extension_settings.memory.maxMessagesPerRequest) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const lastUsedIndex = context.chat.indexOf(latestUsedMessage);
|
||||
const rawPrompt = getMemoryString(false);
|
||||
return { rawPrompt, lastUsedIndex };
|
||||
}
|
||||
|
||||
async function summarizeChatExtras(context) {
|
||||
function getMemoryString() {
|
||||
return (longMemory + '\n\n' + memoryBuffer.slice().reverse().join('\n\n')).trim();
|
||||
@@ -482,12 +730,24 @@ function onMemoryContentInput() {
|
||||
setMemoryContext(value, true);
|
||||
}
|
||||
|
||||
function onMemoryPromptBuilderInput(e) {
|
||||
const value = Number(e.target.value);
|
||||
extension_settings.memory.prompt_builder = value;
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function reinsertMemory() {
|
||||
const existingValue = $('#memory_contents').val();
|
||||
const existingValue = String($('#memory_contents').val());
|
||||
setMemoryContext(existingValue, false);
|
||||
}
|
||||
|
||||
function setMemoryContext(value, saveToMessage) {
|
||||
/**
|
||||
* Set the summary value to the context and save it to the chat message extra.
|
||||
* @param {string} value Value of a summary
|
||||
* @param {boolean} saveToMessage Should the summary be saved to the chat message extra
|
||||
* @param {number|null} index Index of the chat message to save the summary to. If null, the pre-last message is used.
|
||||
*/
|
||||
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);
|
||||
@@ -497,7 +757,7 @@ function setMemoryContext(value, saveToMessage) {
|
||||
console.debug('Role: ' + extension_settings.memory.role);
|
||||
|
||||
if (saveToMessage && context.chat.length) {
|
||||
const idx = context.chat.length - 2;
|
||||
const idx = index ?? context.chat.length - 2;
|
||||
const mes = context.chat[idx < 0 ? 0 : idx];
|
||||
|
||||
if (!mes.extra) {
|
||||
@@ -573,6 +833,14 @@ function setupListeners() {
|
||||
$('#memory_role').off('click').on('input', onMemoryRoleInput);
|
||||
$('input[name="memory_position"]').off('click').on('change', onMemoryPositionChange);
|
||||
$('#memory_prompt_words_force').off('click').on('input', onMemoryPromptWordsForceInput);
|
||||
$('#memory_prompt_builder_default').off('click').on('input', onMemoryPromptBuilderInput);
|
||||
$('#memory_prompt_builder_raw_blocking').off('click').on('input', onMemoryPromptBuilderInput);
|
||||
$('#memory_prompt_builder_raw_non_blocking').off('click').on('input', onMemoryPromptBuilderInput);
|
||||
$('#memory_prompt_restore').off('click').on('click', onMemoryPromptRestoreClick);
|
||||
$('#memory_prompt_interval_auto').off('click').on('click', onPromptIntervalAutoClick);
|
||||
$('#memory_prompt_words_auto').off('click').on('click', onPromptForceWordsAutoClick);
|
||||
$('#memory_override_response_length').off('click').on('input', onOverrideResponseLengthInput);
|
||||
$('#memory_max_messages_per_request').off('click').on('input', onMaxMessagesPerRequestInput);
|
||||
$('#summarySettingsBlockToggle').off('click').on('click', function () {
|
||||
console.log('saw settings button click');
|
||||
$('#summarySettingsBlock').slideToggle(200, 'swing'); //toggleClass("hidden");
|
||||
@@ -581,91 +849,7 @@ function setupListeners() {
|
||||
|
||||
jQuery(function () {
|
||||
function addExtensionControls() {
|
||||
const settingsHtml = `
|
||||
<div id="memory_settings">
|
||||
<div class="inline-drawer">
|
||||
<div class="inline-drawer-toggle inline-drawer-header">
|
||||
<div class="flex-container alignitemscenter margin0"><b>Summarize</b><i id="summaryExtensionPopoutButton" class="fa-solid fa-window-restore menu_button margin0"></i></div>
|
||||
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
|
||||
</div>
|
||||
<div class="inline-drawer-content">
|
||||
<div id="summaryExtensionDrawerContents">
|
||||
<label for="summary_source">Summarize with:</label>
|
||||
<select id="summary_source">
|
||||
<option value="main">Main API</option>
|
||||
<option value="extras">Extras API</option>
|
||||
</select><br>
|
||||
|
||||
<div class="flex-container justifyspacebetween alignitemscenter">
|
||||
<span class="flex1">Current summary:</span>
|
||||
<div id="memory_restore" class="menu_button flex1 margin0"><span>Restore Previous</span></div>
|
||||
</div>
|
||||
|
||||
<textarea id="memory_contents" class="text_pole textarea_compact" rows="6" placeholder="Summary will be generated here..."></textarea>
|
||||
<div class="memory_contents_controls">
|
||||
<div id="memory_force_summarize" data-source="main" class="menu_button menu_button_icon" title="Trigger a summary update right now." data-i18n="Trigger a summary update right now.">
|
||||
<i class="fa-solid fa-database"></i>
|
||||
<span>Summarize now</span>
|
||||
</div>
|
||||
<label for="memory_frozen" title="Disable automatic summary updates. While paused, the summary remains as-is. You can still force an update by pressing the Summarize now button (which is only available with the Main API)." data-i18n="[title]Disable automatic summary updates. While paused, the summary remains as-is. You can still force an update by pressing the Summarize now button (which is only available with the Main API)."><input id="memory_frozen" type="checkbox" />Pause</label>
|
||||
<label for="memory_skipWIAN" title="Omit World Info and Author's Note from text to be summarized. Only has an effect when using the Main API. The Extras API always omits WI/AN." data-i18n="[title]Omit World Info and Author's Note from text to be summarized. Only has an effect when using the Main API. The Extras API always omits WI/AN."><input id="memory_skipWIAN" type="checkbox" />No WI/AN</label>
|
||||
</div>
|
||||
<div class="memory_contents_controls">
|
||||
<div id="summarySettingsBlockToggle" class="menu_button menu_button_icon" title="Edit summarization prompt, insertion position, etc.">
|
||||
<i class="fa-solid fa-cog"></i>
|
||||
<span>Summary Settings</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="summarySettingsBlock" style="display:none;">
|
||||
<div class="memory_template">
|
||||
<label for="memory_template">Insertion Template</label>
|
||||
<textarea id="memory_template" class="text_pole textarea_compact" rows="2" placeholder="{{summary}} will resolve to the current summary contents."></textarea>
|
||||
</div>
|
||||
<label for="memory_position">Injection Position</label>
|
||||
<div class="radio_group">
|
||||
<label>
|
||||
<input type="radio" name="memory_position" value="2" />
|
||||
Before Main Prompt / Story String
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="memory_position" value="0" />
|
||||
After Main Prompt / Story String
|
||||
</label>
|
||||
<label class="flex-container alignItemsCenter" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
||||
<input type="radio" name="memory_position" value="1" />
|
||||
In-chat @ Depth <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
|
||||
as
|
||||
<select id="memory_role" class="text_pole widthNatural">
|
||||
<option value="0">System</option>
|
||||
<option value="1">User</option>
|
||||
<option value="2">Assistant</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div data-source="main" class="memory_contents_controls">
|
||||
</div>
|
||||
<div data-source="main">
|
||||
<label for="memory_prompt" class="title_restorable">
|
||||
Summary Prompt
|
||||
|
||||
</label>
|
||||
<textarea id="memory_prompt" class="text_pole textarea_compact" rows="6" placeholder="This prompt will be sent to AI to request the summary generation. {{words}} will resolve to the 'Number of words' parameter."></textarea>
|
||||
<label for="memory_prompt_words">Summary length (<span id="memory_prompt_words_value"></span> words)</label>
|
||||
<input id="memory_prompt_words" type="range" value="${defaultSettings.promptWords}" min="${defaultSettings.promptMinWords}" max="${defaultSettings.promptMaxWords}" step="${defaultSettings.promptWordsStep}" />
|
||||
<label for="memory_prompt_interval">Update every <span id="memory_prompt_interval_value"></span> messages</label>
|
||||
<small>0 = disable</small>
|
||||
<input id="memory_prompt_interval" type="range" value="${defaultSettings.promptInterval}" min="${defaultSettings.promptMinInterval}" max="${defaultSettings.promptMaxInterval}" step="${defaultSettings.promptIntervalStep}" />
|
||||
<label for="memory_prompt_words_force">Update every <span id="memory_prompt_words_force_value"></span> words</label>
|
||||
<small>0 = disable</small>
|
||||
<input id="memory_prompt_words_force" type="range" value="${defaultSettings.promptForceWords}" min="${defaultSettings.promptMinForceWords}" max="${defaultSettings.promptMaxForceWords}" step="${defaultSettings.promptForceWordsStep}" />
|
||||
<small>If both sliders are non-zero, then both will trigger summary updates a their respective intervals.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
const settingsHtml = renderExtensionTemplate('memory', 'settings', { defaultSettings });
|
||||
$('#extensions_settings2').append(settingsHtml);
|
||||
setupListeners();
|
||||
$('#summaryExtensionPopoutButton').off('click').on('click', function (e) {
|
||||
|
136
public/scripts/extensions/memory/settings.html
Normal file
136
public/scripts/extensions/memory/settings.html
Normal file
@@ -0,0 +1,136 @@
|
||||
<div id="memory_settings">
|
||||
<div class="inline-drawer">
|
||||
<div class="inline-drawer-toggle inline-drawer-header">
|
||||
<div class="flex-container alignitemscenter margin0">
|
||||
<b>Summarize</b>
|
||||
<i id="summaryExtensionPopoutButton" class="fa-solid fa-window-restore menu_button margin0"></i>
|
||||
</div>
|
||||
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
|
||||
</div>
|
||||
<div class="inline-drawer-content">
|
||||
<div id="summaryExtensionDrawerContents">
|
||||
<label for="summary_source">Summarize with:</label>
|
||||
<select id="summary_source">
|
||||
<option value="main">Main API</option>
|
||||
<option value="extras">Extras API</option>
|
||||
</select><br>
|
||||
|
||||
<div class="flex-container justifyspacebetween alignitemscenter">
|
||||
<span class="flex1">Current summary:</span>
|
||||
<div id="memory_restore" class="menu_button flex1 margin0">
|
||||
<span>Restore Previous</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<textarea id="memory_contents" class="text_pole textarea_compact" rows="6" placeholder="Summary will be generated here..."></textarea>
|
||||
<div class="memory_contents_controls">
|
||||
<div id="memory_force_summarize" data-summary-source="main" class="menu_button menu_button_icon" title="Trigger a summary update right now." data-i18n="Trigger a summary update right now.">
|
||||
<i class="fa-solid fa-database"></i>
|
||||
<span>Summarize now</span>
|
||||
</div>
|
||||
<label for="memory_frozen" title="Disable automatic summary updates. While paused, the summary remains as-is. You can still force an update by pressing the Summarize now button (which is only available with the Main API)." data-i18n="[title]Disable automatic summary updates. While paused, the summary remains as-is. You can still force an update by pressing the Summarize now button (which is only available with the Main API)."><input id="memory_frozen" type="checkbox" />Pause</label>
|
||||
<label data-summary-source="main" for="memory_skipWIAN" title="Omit World Info and Author's Note from text to be summarized. Only has an effect when using the Main API. The Extras API always omits WI/AN." data-i18n="[title]Omit World Info and Author's Note from text to be summarized. Only has an effect when using the Main API. The Extras API always omits WI/AN.">
|
||||
<input id="memory_skipWIAN" type="checkbox" />
|
||||
<span>No WI/AN</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="memory_contents_controls">
|
||||
<div id="summarySettingsBlockToggle" class="menu_button menu_button_icon" title="Edit summarization prompt, insertion position, etc.">
|
||||
<i class="fa-solid fa-cog"></i>
|
||||
<span>Summary Settings</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="summarySettingsBlock" style="display:none;">
|
||||
<div data-summary-source="main">
|
||||
<label>
|
||||
Prompt builder
|
||||
</label>
|
||||
<label class="checkbox_label" for="memory_prompt_builder_raw_blocking" title="Extension will build its own prompt using messages that were not summarized yet. Blocks the chat until the summary is generated.">
|
||||
<input id="memory_prompt_builder_raw_blocking" type="radio" name="memory_prompt_builder" value="1" />
|
||||
<span>Raw, blocking</span>
|
||||
</label>
|
||||
<label class="checkbox_label" for="memory_prompt_builder_raw_non_blocking" title="Extension will build its own prompt using messages that were not summarized yet. Does not block the chat while the summary is being generated. Not all backends support this mode.">
|
||||
<input id="memory_prompt_builder_raw_non_blocking" type="radio" name="memory_prompt_builder" value="2" />
|
||||
<span>Raw, non-blocking</span>
|
||||
</label>
|
||||
<label class="checkbox_label" id="memory_prompt_builder_default" title="Extension will use the regular main prompt builder and add the summary request to it as the last system message.">
|
||||
<input id="memory_prompt_builder_default" type="radio" name="memory_prompt_builder" value="0" />
|
||||
<span>Classic, blocking</span>
|
||||
</label>
|
||||
</div>
|
||||
<div data-summary-source="main">
|
||||
<label for="memory_prompt" class="title_restorable">
|
||||
<span data-i18n="Summary Prompt">Summary Prompt</span>
|
||||
<div id="memory_prompt_restore" title="Restore default prompt" class="right_menu_button">
|
||||
<div class="fa-solid fa-clock-rotate-left"></div>
|
||||
</div>
|
||||
</label>
|
||||
<textarea id="memory_prompt" class="text_pole textarea_compact" rows="6" placeholder="This prompt will be sent to AI to request the summary generation. {{words}} will resolve to the 'Number of words' parameter."></textarea>
|
||||
<label for="memory_prompt_words">Target summary length (<span id="memory_prompt_words_value"></span> words)</label>
|
||||
<input id="memory_prompt_words" type="range" value="{{defaultSettings.promptWords}}" min="{{defaultSettings.promptMinWords}}" max="{{defaultSettings.promptMaxWords}}" step="{{defaultSettings.promptWordsStep}}" />
|
||||
<label for="memory_override_response_length">
|
||||
API response length (<span id="memory_override_response_length_value"></span> tokens)
|
||||
<small class="memory_disabled_hint">0 = default</small>
|
||||
</label>
|
||||
<input id="memory_override_response_length" type="range" value="{{defaultSettings.overrideResponseLength}}" min="{{defaultSettings.overrideResponseLengthMin}}" max="{{defaultSettings.overrideResponseLengthMax}}" step="{{defaultSettings.overrideResponseLengthStep}}" />
|
||||
<label for="memory_max_messages_per_request">
|
||||
[Raw] Max messages per request (<span id="memory_max_messages_per_request_value"></span>)
|
||||
<small class="memory_disabled_hint">0 = unlimited</small>
|
||||
</label>
|
||||
<input id="memory_max_messages_per_request" type="range" value="{{defaultSettings.maxMessagesPerRequest}}" min="{{defaultSettings.maxMessagesPerRequestMin}}" max="{{defaultSettings.maxMessagesPerRequestMax}}" step="{{defaultSettings.maxMessagesPerRequestStep}}" />
|
||||
<h4 data-i18n="Update frequency" class="textAlignCenter">
|
||||
Update frequency
|
||||
</h4>
|
||||
<label for="memory_prompt_interval" class="title_restorable">
|
||||
<span>
|
||||
Update every <span id="memory_prompt_interval_value"></span> messages
|
||||
<small class="memory_disabled_hint">0 = disable</small>
|
||||
</span>
|
||||
<div id="memory_prompt_interval_auto" title="Try to automatically adjust the interval based on the chat metrics." class="right_menu_button">
|
||||
<div class="fa-solid fa-wand-magic-sparkles"></div>
|
||||
</div>
|
||||
</label>
|
||||
<input id="memory_prompt_interval" type="range" value="{{defaultSettings.promptInterval}}" min="{{defaultSettings.promptMinInterval}}" max="{{defaultSettings.promptMaxInterval}}" step="{{defaultSettings.promptIntervalStep}}" />
|
||||
<label for="memory_prompt_words_force" class="title_restorable">
|
||||
<span>
|
||||
Update every <span id="memory_prompt_words_force_value"></span> words
|
||||
<small class="memory_disabled_hint">0 = disable</small>
|
||||
</span>
|
||||
<div id="memory_prompt_words_auto" title="Try to automatically adjust the interval based on the chat metrics." class="right_menu_button">
|
||||
<div class="fa-solid fa-wand-magic-sparkles"></div>
|
||||
</div>
|
||||
</label>
|
||||
<input id="memory_prompt_words_force" type="range" value="{{defaultSettings.promptForceWords}}" min="{{defaultSettings.promptMinForceWords}}" max="{{defaultSettings.promptMaxForceWords}}" step="{{defaultSettings.promptForceWordsStep}}" />
|
||||
<small>If both sliders are non-zero, then both will trigger summary updates at their respective intervals.</small>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="memory_template">
|
||||
<label for="memory_template">Injection Template</label>
|
||||
<textarea id="memory_template" class="text_pole textarea_compact" rows="2" placeholder="{{summary}} will resolve to the current summary contents."></textarea>
|
||||
</div>
|
||||
<label for="memory_position">Injection Position</label>
|
||||
<div class="radio_group">
|
||||
<label>
|
||||
<input type="radio" name="memory_position" value="2" />
|
||||
Before Main Prompt / Story String
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="memory_position" value="0" />
|
||||
After Main Prompt / Story String
|
||||
</label>
|
||||
<label class="flex-container alignItemsCenter" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
||||
<input type="radio" name="memory_position" value="1" />
|
||||
In-chat @ Depth <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
|
||||
as
|
||||
<select id="memory_role" class="text_pole widthNatural">
|
||||
<option value="0">System</option>
|
||||
<option value="1">User</option>
|
||||
<option value="2">Assistant</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -24,4 +24,14 @@ label[for="memory_frozen"] input {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
.memory_disabled_hint {
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
#summarySettingsBlock {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 5px;
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ const sources = {
|
||||
openai: 'openai',
|
||||
comfy: 'comfy',
|
||||
togetherai: 'togetherai',
|
||||
drawthings: 'drawthings',
|
||||
};
|
||||
|
||||
const generationMode = {
|
||||
@@ -217,6 +218,9 @@ const defaultSettings = {
|
||||
vlad_url: 'http://localhost:7860',
|
||||
vlad_auth: '',
|
||||
|
||||
drawthings_url: 'http://localhost:7860',
|
||||
drawthings_auth: '',
|
||||
|
||||
hr_upscaler: 'Latent',
|
||||
hr_scale: 2.0,
|
||||
hr_scale_min: 1.0,
|
||||
@@ -314,6 +318,8 @@ function getSdRequestBody() {
|
||||
return { url: extension_settings.sd.vlad_url, auth: extension_settings.sd.vlad_auth };
|
||||
case sources.auto:
|
||||
return { url: extension_settings.sd.auto_url, auth: extension_settings.sd.auto_auth };
|
||||
case sources.drawthings:
|
||||
return { url: extension_settings.sd.drawthings_url, auth: extension_settings.sd.drawthings_auth };
|
||||
default:
|
||||
throw new Error('Invalid SD source.');
|
||||
}
|
||||
@@ -390,6 +396,8 @@ async function loadSettings() {
|
||||
$('#sd_auto_auth').val(extension_settings.sd.auto_auth);
|
||||
$('#sd_vlad_url').val(extension_settings.sd.vlad_url);
|
||||
$('#sd_vlad_auth').val(extension_settings.sd.vlad_auth);
|
||||
$('#sd_drawthings_url').val(extension_settings.sd.drawthings_url);
|
||||
$('#sd_drawthings_auth').val(extension_settings.sd.drawthings_auth);
|
||||
$('#sd_interactive_mode').prop('checked', extension_settings.sd.interactive_mode);
|
||||
$('#sd_openai_style').val(extension_settings.sd.openai_style);
|
||||
$('#sd_openai_quality').val(extension_settings.sd.openai_quality);
|
||||
@@ -865,6 +873,16 @@ function onVladAuthInput() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onDrawthingsUrlInput() {
|
||||
extension_settings.sd.drawthings_url = $('#sd_drawthings_url').val();
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onDrawthingsAuthInput() {
|
||||
extension_settings.sd.drawthings_auth = $('#sd_drawthings_auth').val();
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onHrUpscalerChange() {
|
||||
extension_settings.sd.hr_upscaler = $('#sd_hr_upscaler').find(':selected').val();
|
||||
saveSettingsDebounced();
|
||||
@@ -931,6 +949,29 @@ async function validateAutoUrl() {
|
||||
}
|
||||
}
|
||||
|
||||
async function validateDrawthingsUrl() {
|
||||
try {
|
||||
if (!extension_settings.sd.drawthings_url) {
|
||||
throw new Error('URL is not set.');
|
||||
}
|
||||
|
||||
const result = await fetch('/api/sd/drawthings/ping', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify(getSdRequestBody()),
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
throw new Error('SD Drawthings returned an error.');
|
||||
}
|
||||
|
||||
await loadSettingOptions();
|
||||
toastr.success('SD Drawthings API connected.');
|
||||
} catch (error) {
|
||||
toastr.error(`Could not validate SD Drawthings API: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function validateVladUrl() {
|
||||
try {
|
||||
if (!extension_settings.sd.vlad_url) {
|
||||
@@ -1018,6 +1059,27 @@ async function getAutoRemoteModel() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getDrawthingsRemoteModel() {
|
||||
try {
|
||||
const result = await fetch('/api/sd/drawthings/get-model', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify(getSdRequestBody()),
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
throw new Error('SD DrawThings API returned an error.');
|
||||
}
|
||||
|
||||
const data = await result.text();
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function onVaeChange() {
|
||||
extension_settings.sd.vae = $('#sd_vae').find(':selected').val();
|
||||
}
|
||||
@@ -1108,6 +1170,9 @@ async function loadSamplers() {
|
||||
case sources.auto:
|
||||
samplers = await loadAutoSamplers();
|
||||
break;
|
||||
case sources.drawthings:
|
||||
samplers = await loadDrawthingsSamplers();
|
||||
break;
|
||||
case sources.novel:
|
||||
samplers = await loadNovelSamplers();
|
||||
break;
|
||||
@@ -1193,6 +1258,22 @@ async function loadAutoSamplers() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDrawthingsSamplers() {
|
||||
// The app developer doesn't provide an API to get these yet
|
||||
return [
|
||||
'UniPC',
|
||||
'DPM++ 2M Karras',
|
||||
'Euler a',
|
||||
'DPM++ SDE Karras',
|
||||
'PLMS',
|
||||
'DDIM',
|
||||
'LCM',
|
||||
'Euler A Substep',
|
||||
'DPM++ SDE Substep',
|
||||
'TCD',
|
||||
];
|
||||
}
|
||||
|
||||
async function loadVladSamplers() {
|
||||
if (!extension_settings.sd.vlad_url) {
|
||||
return [];
|
||||
@@ -1269,6 +1350,9 @@ async function loadModels() {
|
||||
case sources.auto:
|
||||
models = await loadAutoModels();
|
||||
break;
|
||||
case sources.drawthings:
|
||||
models = await loadDrawthingsModels();
|
||||
break;
|
||||
case sources.novel:
|
||||
models = await loadNovelModels();
|
||||
break;
|
||||
@@ -1405,6 +1489,27 @@ async function loadAutoModels() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDrawthingsModels() {
|
||||
if (!extension_settings.sd.drawthings_url) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const currentModel = await getDrawthingsRemoteModel();
|
||||
|
||||
if (currentModel) {
|
||||
extension_settings.sd.model = currentModel;
|
||||
}
|
||||
|
||||
const data = [{ value: currentModel, text: currentModel }];
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log('Error loading DrawThings API models:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadOpenAiModels() {
|
||||
return [
|
||||
{ value: 'dall-e-3', text: 'DALL-E 3' },
|
||||
@@ -1527,6 +1632,9 @@ async function loadSchedulers() {
|
||||
case sources.vlad:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
case sources.drawthings:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
case sources.openai:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
@@ -1589,6 +1697,9 @@ async function loadVaes() {
|
||||
case sources.vlad:
|
||||
vaes = ['N/A'];
|
||||
break;
|
||||
case sources.drawthings:
|
||||
vaes = ['N/A'];
|
||||
break;
|
||||
case sources.openai:
|
||||
vaes = ['N/A'];
|
||||
break;
|
||||
@@ -1717,7 +1828,10 @@ function getRawLastMessage() {
|
||||
continue;
|
||||
}
|
||||
|
||||
return message.mes;
|
||||
return {
|
||||
mes: message.mes,
|
||||
original_avatar: message.original_avatar,
|
||||
};
|
||||
}
|
||||
|
||||
toastr.warning('No usable messages found.', 'Image Generation');
|
||||
@@ -1725,10 +1839,17 @@ function getRawLastMessage() {
|
||||
};
|
||||
|
||||
const context = getContext();
|
||||
const lastMessage = getLastUsableMessage(),
|
||||
characterDescription = context.characters[context.characterId].description,
|
||||
situation = context.characters[context.characterId].scenario;
|
||||
return `((${processReply(lastMessage)})), (${processReply(situation)}:0.7), (${processReply(characterDescription)}:0.5)`;
|
||||
const lastMessage = getLastUsableMessage();
|
||||
const character = context.groupId
|
||||
? context.characters.find(c => c.avatar === lastMessage.original_avatar)
|
||||
: context.characters[context.characterId];
|
||||
|
||||
if (!character) {
|
||||
console.debug('Character not found, using raw message.');
|
||||
return processReply(lastMessage.mes);
|
||||
}
|
||||
|
||||
return `((${processReply(lastMessage.mes)})), (${processReply(character.scenario)}:0.7), (${processReply(character.description)}:0.5)`;
|
||||
}
|
||||
|
||||
async function generatePicture(args, trigger, message, callback) {
|
||||
@@ -1996,6 +2117,9 @@ async function sendGenerationRequest(generationType, prompt, characterName = nul
|
||||
case sources.vlad:
|
||||
result = await generateAutoImage(prefixedPrompt, negativePrompt);
|
||||
break;
|
||||
case sources.drawthings:
|
||||
result = await generateDrawthingsImage(prefixedPrompt, negativePrompt);
|
||||
break;
|
||||
case sources.auto:
|
||||
result = await generateAutoImage(prefixedPrompt, negativePrompt);
|
||||
break;
|
||||
@@ -2178,6 +2302,42 @@ async function generateAutoImage(prompt, negativePrompt) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an image in Drawthings API using the provided prompt and configuration settings.
|
||||
*
|
||||
* @param {string} prompt - The main instruction used to guide the image generation.
|
||||
* @param {string} negativePrompt - The instruction used to restrict the image generation.
|
||||
* @returns {Promise<{format: string, data: string}>} - A promise that resolves when the image generation and processing are complete.
|
||||
*/
|
||||
async function generateDrawthingsImage(prompt, negativePrompt) {
|
||||
const result = await fetch('/api/sd/drawthings/generate', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({
|
||||
...getSdRequestBody(),
|
||||
prompt: prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
sampler_name: extension_settings.sd.sampler,
|
||||
steps: extension_settings.sd.steps,
|
||||
cfg_scale: extension_settings.sd.scale,
|
||||
width: extension_settings.sd.width,
|
||||
height: extension_settings.sd.height,
|
||||
restore_faces: !!extension_settings.sd.restore_faces,
|
||||
enable_hr: !!extension_settings.sd.enable_hr,
|
||||
denoising_strength: extension_settings.sd.denoising_strength,
|
||||
// TODO: advanced API parameters: hr, upscaler
|
||||
}),
|
||||
});
|
||||
|
||||
if (result.ok) {
|
||||
const data = await result.json();
|
||||
return { format: 'png', data: data.images[0] };
|
||||
} else {
|
||||
const text = await result.text();
|
||||
throw new Error(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an image in NovelAI API using the provided prompt and configuration settings.
|
||||
*
|
||||
@@ -2603,6 +2763,8 @@ function isValidState() {
|
||||
return true;
|
||||
case sources.auto:
|
||||
return !!extension_settings.sd.auto_url;
|
||||
case sources.drawthings:
|
||||
return !!extension_settings.sd.drawthings_url;
|
||||
case sources.vlad:
|
||||
return !!extension_settings.sd.vlad_url;
|
||||
case sources.novel:
|
||||
@@ -2745,6 +2907,9 @@ jQuery(async () => {
|
||||
$('#sd_auto_validate').on('click', validateAutoUrl);
|
||||
$('#sd_auto_url').on('input', onAutoUrlInput);
|
||||
$('#sd_auto_auth').on('input', onAutoAuthInput);
|
||||
$('#sd_drawthings_validate').on('click', validateDrawthingsUrl);
|
||||
$('#sd_drawthings_url').on('input', onDrawthingsUrlInput);
|
||||
$('#sd_drawthings_auth').on('input', onDrawthingsAuthInput);
|
||||
$('#sd_vlad_validate').on('click', validateVladUrl);
|
||||
$('#sd_vlad_url').on('input', onVladUrlInput);
|
||||
$('#sd_vlad_auth').on('input', onVladAuthInput);
|
||||
@@ -2756,7 +2921,7 @@ jQuery(async () => {
|
||||
$('#sd_novel_anlas_guard').on('input', onNovelAnlasGuardInput);
|
||||
$('#sd_novel_view_anlas').on('click', onViewAnlasClick);
|
||||
$('#sd_novel_sm').on('input', onNovelSmInput);
|
||||
$('#sd_novel_sm_dyn').on('input', onNovelSmDynInput);;
|
||||
$('#sd_novel_sm_dyn').on('input', onNovelSmDynInput);
|
||||
$('#sd_comfy_validate').on('click', validateComfyUrl);
|
||||
$('#sd_comfy_url').on('input', onComfyUrlInput);
|
||||
$('#sd_comfy_workflow').on('change', onComfyWorkflowChange);
|
||||
|
@@ -36,6 +36,7 @@
|
||||
<option value="horde">Stable Horde</option>
|
||||
<option value="auto">Stable Diffusion Web UI (AUTOMATIC1111)</option>
|
||||
<option value="vlad">SD.Next (vladmandic)</option>
|
||||
<option value="drawthings">DrawThings HTTP API</option>
|
||||
<option value="novel">NovelAI Diffusion</option>
|
||||
<option value="openai">OpenAI (DALL-E)</option>
|
||||
<option value="comfy">ComfyUI</option>
|
||||
@@ -56,6 +57,21 @@
|
||||
<input id="sd_auto_auth" type="text" class="text_pole" placeholder="Example: username:password" value="" />
|
||||
<i><b>Important:</b> run SD Web UI with the <tt>--api</tt> flag! The server must be accessible from the SillyTavern host machine.</i>
|
||||
</div>
|
||||
<div data-sd-source="drawthings">
|
||||
<label for="sd_drawthings_url">DrawThings API URL</label>
|
||||
<div class="flex-container flexnowrap">
|
||||
<input id="sd_drawthings_url" type="text" class="text_pole" placeholder="Example: {{drawthings_url}}" value="{{drawthings_url}}" />
|
||||
<div id="sd_drawthings_validate" class="menu_button menu_button_icon">
|
||||
<i class="fa-solid fa-check"></i>
|
||||
<span data-i18n="Connect">
|
||||
Connect
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<label for="sd_drawthings_auth">Authentication (optional)</label>
|
||||
<input id="sd_drawthings_auth" type="text" class="text_pole" placeholder="Example: username:password" value="" />
|
||||
<i><b>Important:</b> run DrawThings app with HTTP API switch enabled in the UI! The server must be accessible from the SillyTavern host machine.</i>
|
||||
</div>
|
||||
<div data-sd-source="vlad">
|
||||
<label for="sd_vlad_url">SD.Next API URL</label>
|
||||
<div class="flex-container flexnowrap">
|
||||
|
@@ -33,7 +33,7 @@ async function doTokenCounter() {
|
||||
<div id="tokenized_chunks_display" class="wide100p">—</div>
|
||||
<hr>
|
||||
<div>Token IDs:</div>
|
||||
<textarea id="token_counter_ids" class="wide100p textarea_compact" disabled rows="1">—</textarea>
|
||||
<textarea id="token_counter_ids" class="wide100p textarea_compact" readonly rows="1">—</textarea>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
Reference in New Issue
Block a user