refac/fix: automatic1111 params

This commit is contained in:
Timothy Jaeryang Baek 2025-11-15 15:43:23 -05:00
parent 1b0bce529f
commit 9370b263f5
2 changed files with 16 additions and 12 deletions

View file

@ -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,
)

View file

@ -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