Merge branch 'staging' into neo-server
This commit is contained in:
commit
9d6a791443
|
@ -19,6 +19,8 @@
|
|||
<li data-placeholder="scale" class="sd_comfy_workflow_editor_not_found">"%scale%"</li>
|
||||
<li data-placeholder="width" class="sd_comfy_workflow_editor_not_found">"%width%"</li>
|
||||
<li data-placeholder="height" class="sd_comfy_workflow_editor_not_found">"%height%"</li>
|
||||
<li data-placeholder="user_avatar" class="sd_comfy_workflow_editor_not_found">"%user_avatar%"</li>
|
||||
<li data-placeholder="char_avatar" class="sd_comfy_workflow_editor_not_found">"%char_avatar%"</li>
|
||||
<li><hr></li>
|
||||
<li data-placeholder="seed" class="sd_comfy_workflow_editor_not_found">
|
||||
"%seed%"
|
||||
|
|
|
@ -2111,21 +2111,11 @@ async function generateMultimodalPrompt(generationType, quietPrompt) {
|
|||
let avatarUrl;
|
||||
|
||||
if (generationType == generationMode.USER_MULTIMODAL) {
|
||||
avatarUrl = getUserAvatar(user_avatar);
|
||||
avatarUrl = getUserAvatarUrl();
|
||||
}
|
||||
|
||||
if (generationType == generationMode.CHARACTER_MULTIMODAL || generationType === generationMode.FACE_MULTIMODAL) {
|
||||
const context = getContext();
|
||||
|
||||
if (context.groupId) {
|
||||
const groupMembers = context.groups.find(x => x.id === context.groupId)?.members;
|
||||
const lastMessageAvatar = context.chat?.filter(x => !x.is_system && !x.is_user)?.slice(-1)[0]?.original_avatar;
|
||||
const randomMemberAvatar = Array.isArray(groupMembers) ? groupMembers[Math.floor(Math.random() * groupMembers.length)]?.avatar : null;
|
||||
const avatarToUse = lastMessageAvatar || randomMemberAvatar;
|
||||
avatarUrl = formatCharacterAvatar(avatarToUse);
|
||||
} else {
|
||||
avatarUrl = getCharacterAvatar(context.characterId);
|
||||
}
|
||||
avatarUrl = getCharacterAvatarUrl();
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -2152,6 +2142,24 @@ async function generateMultimodalPrompt(generationType, quietPrompt) {
|
|||
}
|
||||
}
|
||||
|
||||
function getCharacterAvatarUrl() {
|
||||
const context = getContext();
|
||||
|
||||
if (context.groupId) {
|
||||
const groupMembers = context.groups.find(x => x.id === context.groupId)?.members;
|
||||
const lastMessageAvatar = context.chat?.filter(x => !x.is_system && !x.is_user)?.slice(-1)[0]?.original_avatar;
|
||||
const randomMemberAvatar = Array.isArray(groupMembers) ? groupMembers[Math.floor(Math.random() * groupMembers.length)]?.avatar : null;
|
||||
const avatarToUse = lastMessageAvatar || randomMemberAvatar;
|
||||
return formatCharacterAvatar(avatarToUse);
|
||||
} else {
|
||||
return getCharacterAvatar(context.characterId);
|
||||
}
|
||||
}
|
||||
|
||||
function getUserAvatarUrl() {
|
||||
return getUserAvatar(user_avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a prompt using the main LLM API.
|
||||
* @param {string} quietPrompt - The prompt to use for the image generation.
|
||||
|
@ -2636,6 +2644,22 @@ async function generateComfyImage(prompt, negativePrompt) {
|
|||
(extension_settings.sd.comfy_placeholders ?? []).forEach(ph => {
|
||||
workflow = workflow.replace(`"%${ph.find}%"`, JSON.stringify(substituteParams(ph.replace)));
|
||||
});
|
||||
if (/%user_avatar%/gi.test(workflow)) {
|
||||
const response = await fetch(getUserAvatarUrl());
|
||||
if (response.ok) {
|
||||
const avatarBlob = await response.blob();
|
||||
const avatarBase64 = await getBase64Async(avatarBlob);
|
||||
workflow = workflow.replace('"%user_avatar%"', JSON.stringify(avatarBase64));
|
||||
}
|
||||
}
|
||||
if (/%char_avatar%/gi.test(workflow)) {
|
||||
const response = await fetch(getCharacterAvatarUrl());
|
||||
if (response.ok) {
|
||||
const avatarBlob = await response.blob();
|
||||
const avatarBase64 = await getBase64Async(avatarBlob);
|
||||
workflow = workflow.replace('"%char_avatar%"', JSON.stringify(avatarBase64));
|
||||
}
|
||||
}
|
||||
console.log(`{
|
||||
"prompt": ${workflow}
|
||||
}`);
|
||||
|
@ -2649,6 +2673,10 @@ async function generateComfyImage(prompt, negativePrompt) {
|
|||
}`,
|
||||
}),
|
||||
});
|
||||
if (!promptResult.ok) {
|
||||
const text = await promptResult.text();
|
||||
throw new Error(text);
|
||||
}
|
||||
return { format: 'png', data: await promptResult.text() };
|
||||
}
|
||||
|
||||
|
|
|
@ -119,11 +119,15 @@ export class Popup {
|
|||
const keyListener = (evt) => {
|
||||
switch (evt.key) {
|
||||
case 'Escape': {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
this.completeCancelled();
|
||||
window.removeEventListener('keydown', keyListenerBound);
|
||||
break;
|
||||
// does it really matter where we check?
|
||||
const topModal = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)?.closest('.shadow_popup');
|
||||
if (topModal == this.dom) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
this.completeCancelled();
|
||||
window.removeEventListener('keydown', keyListenerBound);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue