From 9370b263f57308557b136a7523f35cb30b13ed14 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 15 Nov 2025 15:43:23 -0500 Subject: [PATCH] refac/fix: automatic1111 params --- backend/open_webui/config.py | 3 +-- backend/open_webui/routers/images.py | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 264448aa04..49c4c2e666 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -3184,10 +3184,9 @@ try: except json.JSONDecodeError: automatic1111_params = {} - AUTOMATIC1111_PARAMS = PersistentConfig( "AUTOMATIC1111_PARAMS", - "image_generation.automatic1111.api_auth", + "image_generation.automatic1111.api_params", automatic1111_params, ) diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py index 0a1de28cc7..6b7b09f8a1 100644 --- a/backend/open_webui/routers/images.py +++ b/backend/open_webui/routers/images.py @@ -44,18 +44,23 @@ def set_image_model(request: Request, model: str): request.app.state.config.IMAGE_GENERATION_MODEL = model if request.app.state.config.IMAGE_GENERATION_ENGINE in ["", "automatic1111"]: api_auth = get_automatic1111_api_auth(request) - r = requests.get( - url=f"{request.app.state.config.AUTOMATIC1111_BASE_URL}/sdapi/v1/options", - headers={"authorization": api_auth}, - ) - options = r.json() - if model != options["sd_model_checkpoint"]: - options["sd_model_checkpoint"] = model - r = requests.post( + + try: + r = requests.get( url=f"{request.app.state.config.AUTOMATIC1111_BASE_URL}/sdapi/v1/options", - json=options, headers={"authorization": api_auth}, ) + options = r.json() + if model != options["sd_model_checkpoint"]: + options["sd_model_checkpoint"] = model + r = requests.post( + url=f"{request.app.state.config.AUTOMATIC1111_BASE_URL}/sdapi/v1/options", + json=options, + headers={"authorization": api_auth}, + ) + except Exception as e: + log.debug(f"{e}") + return request.app.state.config.IMAGE_GENERATION_MODEL @@ -108,7 +113,7 @@ class ImagesConfig(BaseModel): IMAGES_OPENAI_API_VERSION: str AUTOMATIC1111_BASE_URL: str - AUTOMATIC1111_API_AUTH: str + AUTOMATIC1111_API_AUTH: Optional[dict | str] AUTOMATIC1111_PARAMS: Optional[dict | str] COMFYUI_BASE_URL: str