+
diff --git a/public/scripts/extensions/attachments/style.css b/public/scripts/extensions/attachments/style.css
index 3c46e7cc9..d2abc4985 100644
--- a/public/scripts/extensions/attachments/style.css
+++ b/public/scripts/extensions/attachments/style.css
@@ -37,3 +37,27 @@
.attachmentListItemCreated {
text-align: right;
}
+
+.attachmentListItemCheckboxContainer,
+.attachmentBulkActionsContainer,
+.attachmentsBulkEditCheckbox {
+ display: none;
+}
+
+@supports selector(:has(*)) {
+ .dataBankAttachments:has(.attachmentsBulkEditCheckbox:checked) .attachmentsBulkEditButton {
+ color: var(--golden);
+ }
+
+ .dataBankAttachments:has(.attachmentsBulkEditCheckbox:checked) .attachmentBulkActionsContainer {
+ display: flex;
+ }
+
+ .dataBankAttachments:has(.attachmentsBulkEditCheckbox:checked) .attachmentListItemCheckboxContainer {
+ display: inline-flex;
+ }
+
+ .dataBankAttachments:has(.attachmentsBulkEditCheckbox:checked) .attachmentFileIcon {
+ display: none;
+ }
+}
diff --git a/public/scripts/extensions/memory/index.js b/public/scripts/extensions/memory/index.js
index a697f89da..2a2fa574d 100644
--- a/public/scripts/extensions/memory/index.js
+++ b/public/scripts/extensions/memory/index.js
@@ -926,5 +926,6 @@ jQuery(async function () {
new SlashCommandArgument('text to summarize', [ARGUMENT_TYPE.STRING], false, false, ''),
],
helpString: 'Summarizes the given text. If no text is provided, the current chat will be summarized. Can specify the source and the prompt to use.',
+ returns: ARGUMENT_TYPE.STRING,
}));
});
diff --git a/public/scripts/extensions/stable-diffusion/comfyWorkflowEditor.html b/public/scripts/extensions/stable-diffusion/comfyWorkflowEditor.html
index b510f29d9..2427fa6fb 100644
--- a/public/scripts/extensions/stable-diffusion/comfyWorkflowEditor.html
+++ b/public/scripts/extensions/stable-diffusion/comfyWorkflowEditor.html
@@ -17,6 +17,7 @@
"%scheduler%"
"%steps%"
"%scale%"
+
"%clip_skip%"
"%width%"
"%height%"
"%user_avatar%"
diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js
index 24c0e6e46..6261ceaa9 100644
--- a/public/scripts/extensions/stable-diffusion/index.js
+++ b/public/scripts/extensions/stable-diffusion/index.js
@@ -18,9 +18,9 @@ import {
formatCharacterAvatar,
substituteParams,
} from '../../../script.js';
-import { getApiUrl, getContext, extension_settings, doExtrasFetch, modules, renderExtensionTemplateAsync } from '../../extensions.js';
+import { getApiUrl, getContext, extension_settings, doExtrasFetch, modules, renderExtensionTemplateAsync, writeExtensionField } from '../../extensions.js';
import { selected_group } from '../../group-chats.js';
-import { stringFormat, initScrollHeight, resetScrollHeight, getCharaFilename, saveBase64AsFile, getBase64Async, delay, isTrueBoolean } from '../../utils.js';
+import { stringFormat, initScrollHeight, resetScrollHeight, getCharaFilename, saveBase64AsFile, getBase64Async, delay, isTrueBoolean, debounce } from '../../utils.js';
import { getMessageTimeStamp, humanizedDateTime } from '../../RossAscends-mods.js';
import { SECRET_KEYS, secret_state } from '../../secrets.js';
import { getNovelUnlimitedImageGeneration, getNovelAnlas, loadNovelSubscriptionData } from '../../nai-settings.js';
@@ -29,6 +29,7 @@ import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
import { resolveVariable } from '../../variables.js';
+import { debounce_timeout } from '../../constants.js';
export { MODULE_NAME };
const MODULE_NAME = 'sd';
@@ -185,6 +186,7 @@ const defaultSettings = {
sampler: 'DDIM',
model: '',
vae: '',
+ seed: -1,
// Automatic1111/Horde exclusives
restore_faces: false,
@@ -229,6 +231,12 @@ const defaultSettings = {
hr_second_pass_steps_max: 150,
hr_second_pass_steps_step: 1,
+ // CLIP skip
+ clip_skip_min: 1,
+ clip_skip_max: 12,
+ clip_skip_step: 1,
+ clip_skip: 1,
+
// NovelAI settings
novel_upscale_ratio_min: 1.0,
novel_upscale_ratio_max: 4.0,
@@ -237,6 +245,7 @@ const defaultSettings = {
novel_anlas_guard: false,
novel_sm: false,
novel_sm_dyn: false,
+ novel_decrisper: false,
// OpenAI settings
openai_style: 'vivid',
@@ -254,6 +263,8 @@ const defaultSettings = {
pollinations_refine: false,
};
+const writePromptFieldsDebounced = debounce(writePromptFields, debounce_timeout.relaxed);
+
function processTriggers(chat, _, abort) {
if (!extension_settings.sd.interactive_mode) {
return;
@@ -381,6 +392,7 @@ async function loadSettings() {
$('#sd_novel_sm').prop('checked', extension_settings.sd.novel_sm);
$('#sd_novel_sm_dyn').prop('checked', extension_settings.sd.novel_sm_dyn);
$('#sd_novel_sm_dyn').prop('disabled', !extension_settings.sd.novel_sm);
+ $('#sd_novel_decrisper').prop('checked', extension_settings.sd.novel_decrisper);
$('#sd_pollinations_enhance').prop('checked', extension_settings.sd.pollinations_enhance);
$('#sd_pollinations_refine').prop('checked', extension_settings.sd.pollinations_refine);
$('#sd_horde').prop('checked', extension_settings.sd.horde);
@@ -404,6 +416,9 @@ async function loadSettings() {
$('#sd_comfy_url').val(extension_settings.sd.comfy_url);
$('#sd_comfy_prompt').val(extension_settings.sd.comfy_prompt);
$('#sd_snap').prop('checked', extension_settings.sd.snap);
+ $('#sd_clip_skip').val(extension_settings.sd.clip_skip);
+ $('#sd_clip_skip_value').text(extension_settings.sd.clip_skip);
+ $('#sd_seed').val(extension_settings.sd.seed);
for (const style of extension_settings.sd.styles) {
const option = document.createElement('option');
@@ -465,7 +480,7 @@ function addPromptTemplates() {
const label = $('
')
.text(modeLabels[name])
.attr('for', `sd_prompt_${name}`)
- .attr('data-i18n', `sd_prompt_${name}`);
+ .attr('data-i18n', `sd_prompt_${name}`);
const textarea = $('
')
.addClass('textarea_compact text_pole')
.attr('id', `sd_prompt_${name}`)
@@ -477,7 +492,7 @@ function addPromptTemplates() {
const button = $('
')
.addClass('menu_button fa-solid fa-undo')
.attr('title', 'Restore default')
- .attr('data-i18n', 'Restore default')
+ .attr('data-i18n', 'Restore default')
.on('click', () => {
textarea.val(promptTemplates[name]);
extension_settings.sd.prompts[name] = promptTemplates[name];
@@ -522,6 +537,42 @@ function onStyleSelect() {
saveSettingsDebounced();
}
+async function onDeleteStyleClick() {
+ const selectedStyle = String($('#sd_style').find(':selected').val());
+ const styleObject = extension_settings.sd.styles.find(x => x.name === selectedStyle);
+
+ if (!styleObject) {
+ return;
+ }
+
+ const confirmed = await callPopup(`Are you sure you want to delete the style "${selectedStyle}"?`, 'confirm', '', { okButton: 'Delete' });
+
+ if (!confirmed) {
+ return;
+ }
+
+ const index = extension_settings.sd.styles.indexOf(styleObject);
+
+ if (index === -1) {
+ return;
+ }
+
+ extension_settings.sd.styles.splice(index, 1);
+ $('#sd_style').find(`option[value="${selectedStyle}"]`).remove();
+
+ if (extension_settings.sd.styles.length > 0) {
+ extension_settings.sd.style = extension_settings.sd.styles[0].name;
+ $('#sd_style').val(extension_settings.sd.style).trigger('change');
+ } else {
+ extension_settings.sd.style = '';
+ $('#sd_prompt_prefix').val('').trigger('input');
+ $('#sd_negative_prompt').val('').trigger('input');
+ $('#sd_style').val('');
+ }
+
+ saveSettingsDebounced();
+}
+
async function onSaveStyleClick() {
const userInput = await callPopup('Enter style name:', 'input', '', { okButton: 'Save' });
@@ -611,9 +662,27 @@ function onChatChanged() {
}
$('#sd_character_prompt_block').show();
+
const key = getCharaFilename(this_chid);
- $('#sd_character_prompt').val(key ? (extension_settings.sd.character_prompts[key] || '') : '');
- $('#sd_character_negative_prompt').val(key ? (extension_settings.sd.character_negative_prompts[key] || '') : '');
+ let characterPrompt = key ? (extension_settings.sd.character_prompts[key] || '') : '';
+ let negativePrompt = key ? (extension_settings.sd.character_negative_prompts[key] || '') : '';
+
+ const context = getContext();
+ const sharedPromptData = context?.characters[this_chid]?.data?.extensions?.sd_character_prompt;
+ const hasSharedData = sharedPromptData && typeof sharedPromptData === 'object';
+
+ if (typeof sharedPromptData?.positive === 'string' && !characterPrompt && sharedPromptData.positive) {
+ characterPrompt = sharedPromptData.positive;
+ extension_settings.sd.character_prompts[key] = characterPrompt;
+ }
+ if (typeof sharedPromptData?.negative === 'string' && !negativePrompt && sharedPromptData.negative) {
+ negativePrompt = sharedPromptData.negative;
+ extension_settings.sd.character_negative_prompts[key] = negativePrompt;
+ }
+
+ $('#sd_character_prompt').val(characterPrompt);
+ $('#sd_character_negative_prompt').val(negativePrompt);
+ $('#sd_character_prompt_share').prop('checked', hasSharedData);
}
function onCharacterPromptInput() {
@@ -621,6 +690,7 @@ function onCharacterPromptInput() {
extension_settings.sd.character_prompts[key] = $('#sd_character_prompt').val();
resetScrollHeight($(this));
saveSettingsDebounced();
+ writePromptFieldsDebounced(this_chid);
}
function onCharacterNegativePromptInput() {
@@ -628,6 +698,7 @@ function onCharacterNegativePromptInput() {
extension_settings.sd.character_negative_prompts[key] = $('#sd_character_negative_prompt').val();
resetScrollHeight($(this));
saveSettingsDebounced();
+ writePromptFieldsDebounced(this_chid);
}
function getCharacterPrefix() {
@@ -691,6 +762,17 @@ function onRefineModeInput() {
saveSettingsDebounced();
}
+function onClipSkipInput() {
+ extension_settings.sd.clip_skip = Number($('#sd_clip_skip').val());
+ $('#sd_clip_skip_value').text(extension_settings.sd.clip_skip);
+ saveSettingsDebounced();
+}
+
+function onSeedInput() {
+ extension_settings.sd.seed = Number($('#sd_seed').val());
+ saveSettingsDebounced();
+}
+
function onScaleInput() {
extension_settings.sd.scale = Number($('#sd_scale').val());
$('#sd_scale_value').text(extension_settings.sd.scale.toFixed(1));
@@ -776,6 +858,7 @@ async function onSourceChange() {
extension_settings.sd.source = $('#sd_source').find(':selected').val();
extension_settings.sd.model = null;
extension_settings.sd.sampler = null;
+ extension_settings.sd.scheduler = null;
toggleSourceControls();
saveSettingsDebounced();
await loadSettingOptions();
@@ -832,6 +915,11 @@ function onNovelSmDynInput() {
saveSettingsDebounced();
}
+function onNovelDecrisperInput() {
+ extension_settings.sd.novel_decrisper = !!$('#sd_novel_decrisper').prop('checked');
+ saveSettingsDebounced();
+}
+
function onPollinationsEnhanceInput() {
extension_settings.sd.pollinations_enhance = !!$('#sd_pollinations_enhance').prop('checked');
saveSettingsDebounced();
@@ -1118,6 +1206,26 @@ async function getAutoRemoteUpscalers() {
}
}
+async function getAutoRemoteSchedulers() {
+ try {
+ const result = await fetch('/api/sd/schedulers', {
+ method: 'POST',
+ headers: getRequestHeaders(),
+ body: JSON.stringify(getSdRequestBody()),
+ });
+
+ if (!result.ok) {
+ throw new Error('SD WebUI returned an error.');
+ }
+
+ const data = await result.json();
+ return data;
+ } catch (error) {
+ console.error(error);
+ return ['N/A'];
+ }
+}
+
async function getVladRemoteUpscalers() {
try {
const result = await fetch('/api/sd/sd-next/upscalers', {
@@ -1138,6 +1246,27 @@ async function getVladRemoteUpscalers() {
}
}
+async function getDrawthingsRemoteUpscalers() {
+ try {
+ const result = await fetch('/api/sd/drawthings/get-upscaler', {
+ 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 ? [data] : ['N/A'];
+ } catch (error) {
+ console.error(error);
+ return ['N/A'];
+ }
+}
+
async function updateAutoRemoteModel() {
try {
const result = await fetch('/api/sd/set-model', {
@@ -1572,6 +1701,21 @@ async function loadDrawthingsModels() {
const data = [{ value: currentModel, text: currentModel }];
+
+ const upscalers = await getDrawthingsRemoteUpscalers();
+
+ if (Array.isArray(upscalers) && upscalers.length > 0) {
+ $('#sd_hr_upscaler').empty();
+
+ for (const upscaler of upscalers) {
+ const option = document.createElement('option');
+ option.innerText = upscaler;
+ option.value = upscaler;
+ option.selected = upscaler === extension_settings.sd.hr_upscaler;
+ $('#sd_hr_upscaler').append(option);
+ }
+ }
+
return data;
} catch (error) {
console.log('Error loading DrawThings API models:', error);
@@ -1697,7 +1841,7 @@ async function loadSchedulers() {
schedulers = ['N/A'];
break;
case sources.auto:
- schedulers = ['N/A'];
+ schedulers = await getAutoRemoteSchedulers();
break;
case sources.novel:
schedulers = ['N/A'];
@@ -1729,6 +1873,11 @@ async function loadSchedulers() {
option.selected = scheduler === extension_settings.sd.scheduler;
$('#sd_scheduler').append(option);
}
+
+ if (!extension_settings.sd.scheduler && schedulers.length > 0 && schedulers[0] !== 'N/A') {
+ extension_settings.sd.scheduler = schedulers[0];
+ $('#sd_scheduler').val(extension_settings.sd.scheduler).trigger('change');
+ }
}
async function loadComfySchedulers() {
@@ -2121,6 +2270,7 @@ async function generateMultimodalPrompt(generationType, quietPrompt) {
}
try {
+ const toast = toastr.info('Generating multimodal caption...', 'Image Generation');
const response = await fetch(avatarUrl);
if (!response.ok) {
@@ -2131,6 +2281,7 @@ async function generateMultimodalPrompt(generationType, quietPrompt) {
const avatarBase64 = await getBase64Async(avatarBlob);
const caption = await getMultimodalCaption(avatarBase64, quietPrompt);
+ toastr.clear(toast);
if (!caption) {
throw new Error('No caption returned from the API.');
@@ -2269,6 +2420,7 @@ async function generateTogetherAIImage(prompt, negativePrompt) {
steps: extension_settings.sd.steps,
width: extension_settings.sd.width,
height: extension_settings.sd.height,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
}),
});
@@ -2293,6 +2445,7 @@ async function generatePollinationsImage(prompt, negativePrompt) {
height: extension_settings.sd.height,
enhance: extension_settings.sd.pollinations_enhance,
refine: extension_settings.sd.pollinations_refine,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
}),
});
@@ -2335,6 +2488,7 @@ async function generateExtrasImage(prompt, negativePrompt) {
hr_scale: extension_settings.sd.hr_scale,
denoising_strength: extension_settings.sd.denoising_strength,
hr_second_pass_steps: extension_settings.sd.hr_second_pass_steps,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
}),
});
@@ -2371,6 +2525,8 @@ async function generateHordeImage(prompt, negativePrompt) {
restore_faces: !!extension_settings.sd.restore_faces,
enable_hr: !!extension_settings.sd.enable_hr,
sanitize: !!extension_settings.sd.horde_sanitize,
+ clip_skip: extension_settings.sd.clip_skip,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
}),
});
@@ -2399,6 +2555,7 @@ async function generateAutoImage(prompt, negativePrompt) {
prompt: prompt,
negative_prompt: negativePrompt,
sampler_name: extension_settings.sd.sampler,
+ scheduler: extension_settings.sd.scheduler,
steps: extension_settings.sd.steps,
cfg_scale: extension_settings.sd.scale,
width: extension_settings.sd.width,
@@ -2409,6 +2566,14 @@ async function generateAutoImage(prompt, negativePrompt) {
hr_scale: extension_settings.sd.hr_scale,
denoising_strength: extension_settings.sd.denoising_strength,
hr_second_pass_steps: extension_settings.sd.hr_second_pass_steps,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
+ // For AUTO1111
+ override_settings: {
+ CLIP_stop_at_last_layers: extension_settings.sd.clip_skip,
+ },
+ override_settings_restore_afterwards: true,
+ // For SD.Next
+ clip_skip: extension_settings.sd.clip_skip,
// Ensure generated img is saved to disk
save_images: true,
send_images: true,
@@ -2449,6 +2614,9 @@ async function generateDrawthingsImage(prompt, negativePrompt) {
restore_faces: !!extension_settings.sd.restore_faces,
enable_hr: !!extension_settings.sd.enable_hr,
denoising_strength: extension_settings.sd.denoising_strength,
+ clip_skip: extension_settings.sd.clip_skip,
+ upscaler_scale: extension_settings.sd.hr_scale,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
// TODO: advanced API parameters: hr, upscaler
}),
});
@@ -2485,8 +2653,10 @@ async function generateNovelImage(prompt, negativePrompt) {
height: height,
negative_prompt: negativePrompt,
upscale_ratio: extension_settings.sd.novel_upscale_ratio,
+ decrisper: extension_settings.sd.novel_decrisper,
sm: sm,
sm_dyn: sm_dyn,
+ seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
}),
});
@@ -2633,6 +2803,7 @@ async function generateComfyImage(prompt, negativePrompt) {
'scale',
'width',
'height',
+ 'clip_skip',
];
const workflowResponse = await fetch('/api/sd/comfy/workflow', {
@@ -2648,7 +2819,9 @@ async function generateComfyImage(prompt, negativePrompt) {
}
let workflow = (await workflowResponse.json()).replace('"%prompt%"', JSON.stringify(prompt));
workflow = workflow.replace('"%negative_prompt%"', JSON.stringify(negativePrompt));
- workflow = workflow.replaceAll('"%seed%"', JSON.stringify(Math.round(Math.random() * Number.MAX_SAFE_INTEGER)));
+
+ const seed = extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : Math.round(Math.random() * Number.MAX_SAFE_INTEGER);
+ workflow = workflow.replaceAll('"%seed%"', JSON.stringify(seed));
placeholders.forEach(ph => {
workflow = workflow.replace(`"%${ph}%"`, JSON.stringify(extension_settings.sd[ph]));
});
@@ -3048,8 +3221,35 @@ $('#sd_dropdown [id]').on('click', function () {
}
});
+async function onCharacterPromptShareInput() {
+ // Not a valid state to share character prompt
+ if (this_chid === undefined || selected_group) {
+ return;
+ }
+
+ const shouldShare = !!$('#sd_character_prompt_share').prop('checked');
+
+ if (shouldShare) {
+ await writePromptFields(this_chid);
+ } else {
+ await writeExtensionField(this_chid, 'sd_character_prompt', null);
+ }
+}
+
+async function writePromptFields(characterId) {
+ const key = getCharaFilename(characterId);
+ const promptPrefix = key ? (extension_settings.sd.character_prompts[key] || '') : '';
+ const negativePromptPrefix = key ? (extension_settings.sd.character_negative_prompts[key] || '') : '';
+ const promptObject = {
+ positive: promptPrefix,
+ negative: negativePromptPrefix,
+ };
+ await writeExtensionField(characterId, 'sd_character_prompt', promptObject);
+}
+
jQuery(async () => {
- SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'imagine',
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'imagine',
callback: generatePicture,
aliases: ['sd', 'img', 'image'],
namedArgumentList: [
@@ -3075,7 +3275,8 @@ jQuery(async () => {
`,
}));
- SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'imagine-comfy-workflow',
+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
+ name: 'imagine-comfy-workflow',
callback: changeComfyWorkflow,
aliases: ['icw'],
unnamedArgumentList: [
@@ -3127,6 +3328,7 @@ jQuery(async () => {
$('#sd_novel_view_anlas').on('click', onViewAnlasClick);
$('#sd_novel_sm').on('input', onNovelSmInput);
$('#sd_novel_sm_dyn').on('input', onNovelSmDynInput);
+ $('#sd_novel_decrisper').on('input', onNovelDecrisperInput);
$('#sd_pollinations_enhance').on('input', onPollinationsEnhanceInput);
$('#sd_pollinations_refine').on('input', onPollinationsRefineInput);
$('#sd_comfy_validate').on('click', validateComfyUrl);
@@ -3138,12 +3340,16 @@ jQuery(async () => {
$('#sd_expand').on('input', onExpandInput);
$('#sd_style').on('change', onStyleSelect);
$('#sd_save_style').on('click', onSaveStyleClick);
+ $('#sd_delete_style').on('click', onDeleteStyleClick);
$('#sd_character_prompt_block').hide();
$('#sd_interactive_mode').on('input', onInteractiveModeInput);
$('#sd_openai_style').on('change', onOpenAiStyleSelect);
$('#sd_openai_quality').on('change', onOpenAiQualitySelect);
$('#sd_multimodal_captioning').on('input', onMultimodalCaptioningInput);
$('#sd_snap').on('input', onSnapInput);
+ $('#sd_clip_skip').on('input', onClipSkipInput);
+ $('#sd_seed').on('input', onSeedInput);
+ $('#sd_character_prompt_share').on('input', onCharacterPromptShareInput);
$('.sd_settings .inline-drawer-toggle').on('click', function () {
initScrollHeight($('#sd_prompt_prefix'));
diff --git a/public/scripts/extensions/stable-diffusion/settings.html b/public/scripts/extensions/stable-diffusion/settings.html
index 417e99c5e..a419162e5 100644
--- a/public/scripts/extensions/stable-diffusion/settings.html
+++ b/public/scripts/extensions/stable-diffusion/settings.html
@@ -182,23 +182,33 @@