Attempted Stability AI API & Stability AI UI fix.
| @@ -368,14 +368,13 @@ function toggleSourceControls() { | ||
| 368 | 368 | const source = $(this).data('sd-source').split(','); |
| 369 | 369 | $(this).toggle(source.includes(extension_settings.sd.source)); |
| 370 | 370 | }); |
| 371 | - const stabilityHiddenControls = $('#sd_steps, #sd_scale, #sd_sampler, #sd_scheduler, #sd_width, #sd_height, #sd_hr_upscaler, #sd_clip_skip, #sd_steps_value, #sd_scale_value'); | |
| 371 | + | |
| 372 | - if (extension_settings.sd.source === sources.stability) { | |
| 372 | + // Special case for resolution dropdown | |
| 373 | - stabilityHiddenControls.hide(); | |
| 373 | + $('#sd_resolution').parent().toggle(extension_settings.sd.source !== sources.stability); | |
| 374 | - $('#sd_resolution').parent().hide(); | |
| 374 | + | |
| 375 | - } else { | |
| 375 | + // Special case for dimensions block | |
| 376 | - stabilityHiddenControls.show(); | |
| 376 | + $('#sd_dimensions_block').toggle(extension_settings.sd.source !== sources.stability); | |
| 377 | 377 | $('#sd_resolutionsd_sampler').parenttoggle()extension_settings.show(sd.source !== sources.stability); |
| 378 | - } | |
| 379 | 378 | } |
| 380 | 379 | |
| 381 | 380 | async function loadSettings() { |
| @@ -1651,17 +1650,29 @@ async function loadModels() { | ||
| 1651 | 1650 | } |
| 1652 | 1651 | } |
| 1653 | 1652 | async function generateStabilityImage(prompt, negativePrompt) { |
| 1653 | + let endpoint; | |
| 1654 | + switch (extension_settings.sd.model) { | |
| 1655 | + case 'stable-image-ultra': | |
| 1656 | + endpoint = '/v2beta/stable-image/generate/ultra'; | |
| 1657 | + break; | |
| 1658 | + case 'stable-image-core': | |
| 1659 | + endpoint = '/v2beta/stable-image/generate/core'; | |
| 1660 | + break; | |
| 1661 | + case 'stable-diffusion-3': | |
| 1662 | + endpoint = '/v2beta/stable-image/generate/sd3'; | |
| 1663 | + break; | |
| 1664 | + default: | |
| 1665 | + throw new Error('Invalid Stability AI model selected'); | |
| 1666 | + } | |
| 1667 | + | |
| 1654 | 1668 | const result = await fetch('/api/sd/stability/generate', { |
| 1655 | 1669 | method: 'POST', |
| 1656 | 1670 | headers: getRequestHeaders(), |
| 1657 | 1671 | body: JSON.stringify({ |
| 1658 | 1672 | key: extension_settings.sd.stability_key, |
| 1673 | + endpoint: endpoint, | |
| 1659 | 1674 | prompt: prompt, |
| 1660 | 1675 | negative_prompt: negativePrompt, |
| 1661 | - model: extension_settings.sd.model, | |
| 1662 | - engine: extension_settings.sd.stability_engine, | |
| 1663 | - width: extension_settings.sd.width, | |
| 1664 | - height: extension_settings.sd.height, | |
| 1665 | 1676 | seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined, |
| 1666 | 1677 | style_preset: extension_settings.sd.stability_style_preset, |
| 1667 | 1678 | aspect_ratio: extension_settings.sd.stability_aspect_ratio, |
| @@ -1678,28 +1689,13 @@ async function generateStabilityImage(prompt, negativePrompt) { | ||
| 1678 | 1689 | } |
| 1679 | 1690 | |
| 1680 | 1691 | |
| 1681 | -async function loadStabilityModels() { | |
| 1682 | - if (!extension_settings.sd.stability_key) { | |
| 1683 | - console.debug('Stability API key is not set.'); | |
| 1684 | - return []; | |
| 1685 | - } | |
| 1686 | - | |
| 1687 | - try { | |
| 1688 | - const response = await fetch('/api/sd/stability/models', { | |
| 1689 | - method: 'GET', | |
| 1690 | - headers: getRequestHeaders(), | |
| 1691 | - }); | |
| 1692 | - | |
| 1693 | - if (!response.ok) { | |
| 1694 | - throw new Error('Failed to fetch Stability AI models'); | |
| 1695 | - } | |
| 1696 | 1692 | |
| 1697 | - const data = await response.json(); | |
| 1693 | +async function loadStabilityModels() { | |
| 1698 | - return data.map(model => ({ value: model.id, text: model.name })); | |
| 1694 | + return [ | |
| 1699 | - } catch (error) { | |
| 1695 | + { value: 'stable-image-ultra', text: 'Stable Image Ultra' }, | |
| 1700 | - console.error('Error fetching Stability AI models:', error); | |
| 1696 | + { value: 'stable-image-core', text: 'Stable Image Core' }, | |
| 1701 | - return []; | |
| 1697 | + { value: 'stable-diffusion-3', text: 'Stable Diffusion 3' }, | |
| 1702 | - } | |
| 1698 | + ]; | |
| 1703 | 1699 | } |
| 1704 | 1700 | |
| 1705 | 1701 | async function loadPollinationsModels() { |