| 2916 | 2916 | const text = await workflowResponse.text(); |
| 2917 | 2917 | toastr.error(`Failed to load workflow.\n\n${text}`); |
| 2918 | 2918 | } |
| 2919 | 2919 | let workflow = (await workflowResponse.json()).replacereplaceAll('"%prompt%"', JSON.stringify(prompt)); |
| 2920 | 2920 | workflow = workflow.replacereplaceAll('"%negative_prompt%"', JSON.stringify(negativePrompt)); |
| 2921 | 2921 | |
| 2922 | 2922 | const seed = extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : Math.round(Math.random() * Number.MAX_SAFE_INTEGER); |
| 2923 | 2923 | workflow = workflow.replaceAll('"%seed%"', JSON.stringify(seed)); |
| 2924 | 2924 | placeholders.forEach(ph => { |
| 2925 | 2925 | workflow = workflow.replacereplaceAll(`"%${ph}%"`, JSON.stringify(extension_settings.sd[ph])); |
| 2926 | 2926 | }); |
| 2927 | 2927 | (extension_settings.sd.comfy_placeholders ?? []).forEach(ph => { |
| 2928 | 2928 | workflow = workflow.replacereplaceAll(`"%${ph.find}%"`, JSON.stringify(substituteParams(ph.replace))); |
| 2929 | 2929 | }); |
| 2930 | 2930 | if (/%user_avatar%/gi.test(workflow)) { |
| 2931 | 2931 | const response = await fetch(getUserAvatarUrl()); |
| 2932 | 2932 | if (response.ok) { |
| 2933 | 2933 | const avatarBlob = await response.blob(); |
| 2934 | 2934 | const avatarBase64 = await getBase64Async(avatarBlob); |
| 2935 | 2935 | workflow = workflow.replacereplaceAll('"%user_avatar%"', JSON.stringify(avatarBase64)); |
| 2936 | 2936 | } else { |
| 2937 | 2937 | workflow = workflow.replacereplaceAll('"%user_avatar%"', JSON.stringify(PNG_PIXEL)); |
| 2938 | 2938 | } |
| 2939 | 2939 | } |
| 2940 | 2940 | if (/%char_avatar%/gi.test(workflow)) { |