mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-29 06:32:52 +00:00
fix: Images settings cannot be saved without an API key for a feature that is switched off (#32949)
On a fresh install the image generation engine is OpenAI with no key, and saving Admin Settings > Images failed with "OpenAI API Key is required." even with Image Generation switched off, which blocked every change on the page, including setting up Image Edit with another engine. Image Edit had the same problem: with Gemini as its engine and no key, the page refused to save even with Image Edit off. Each engine's key or URL is now only asked for while its feature is on, so switching Image Generation or Image Edit on without one is still refused. Fixes #32835
This commit is contained in:
parent
1740dea1df
commit
6b9237f1a1
1 changed files with 29 additions and 21 deletions
|
|
@ -108,29 +108,37 @@
|
|||
};
|
||||
|
||||
const updateConfigHandler = async () => {
|
||||
if (
|
||||
config.IMAGE_GENERATION_ENGINE === 'automatic1111' &&
|
||||
config.AUTOMATIC1111_BASE_URL === ''
|
||||
) {
|
||||
toast.error($i18n.t('AUTOMATIC1111 Base URL is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
if (config.ENABLE_IMAGE_GENERATION) {
|
||||
if (
|
||||
config.IMAGE_GENERATION_ENGINE === 'automatic1111' &&
|
||||
config.AUTOMATIC1111_BASE_URL === ''
|
||||
) {
|
||||
toast.error($i18n.t('AUTOMATIC1111 Base URL is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
|
||||
return null;
|
||||
} else if (config.IMAGE_GENERATION_ENGINE === 'comfyui' && config.COMFYUI_BASE_URL === '') {
|
||||
toast.error($i18n.t('ComfyUI Base URL is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
return null;
|
||||
} else if (config.IMAGE_GENERATION_ENGINE === 'comfyui' && config.COMFYUI_BASE_URL === '') {
|
||||
toast.error($i18n.t('ComfyUI Base URL is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
|
||||
return null;
|
||||
} else if (config.IMAGE_GENERATION_ENGINE === 'openai' && config.IMAGES_OPENAI_API_KEY === '') {
|
||||
toast.error($i18n.t('OpenAI API Key is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
return null;
|
||||
} else if (
|
||||
config.IMAGE_GENERATION_ENGINE === 'openai' &&
|
||||
config.IMAGES_OPENAI_API_KEY === ''
|
||||
) {
|
||||
toast.error($i18n.t('OpenAI API Key is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
|
||||
return null;
|
||||
} else if (config.IMAGE_GENERATION_ENGINE === 'gemini' && config.IMAGES_GEMINI_API_KEY === '') {
|
||||
toast.error($i18n.t('Gemini API Key is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
return null;
|
||||
} else if (
|
||||
config.IMAGE_GENERATION_ENGINE === 'gemini' &&
|
||||
config.IMAGES_GEMINI_API_KEY === ''
|
||||
) {
|
||||
toast.error($i18n.t('Gemini API Key is required.'));
|
||||
config.ENABLE_IMAGE_GENERATION = false;
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const res = await updateConfig(localStorage.token, {
|
||||
|
|
@ -729,7 +737,7 @@
|
|||
variant="settings"
|
||||
placeholder={$i18n.t('settings.admin.images.imagesGeminiApiKey.label')}
|
||||
bind:value={config.IMAGES_GEMINI_API_KEY}
|
||||
required={true}
|
||||
required={config.ENABLE_IMAGE_GENERATION}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
|
||||
|
|
@ -1031,7 +1039,7 @@
|
|||
variant="settings"
|
||||
placeholder={$i18n.t('settings.admin.images.imagesEditGeminiApiKey.label')}
|
||||
bind:value={config.IMAGES_EDIT_GEMINI_API_KEY}
|
||||
required={true}
|
||||
required={config.ENABLE_IMAGE_EDIT}
|
||||
/>
|
||||
</AdminSettingField>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue