From 78cac2edc2a3fa316a45f6675e4582d4136fcbbb Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Thu, 12 Jun 2025 09:25:00 +0800 Subject: [PATCH] Add DoRA type support. move VALID_LORA_TYPES to utils.constants and update imports in recipe parsers and API routes. --- py/recipes/base.py | 2 +- py/recipes/constants.py | 6 +++--- py/routes/api_routes.py | 6 +++--- py/utils/constants.py | 5 ++++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/py/recipes/base.py b/py/recipes/base.py index 3a7625b6..26fd8479 100644 --- a/py/recipes/base.py +++ b/py/recipes/base.py @@ -7,7 +7,7 @@ import re from typing import Dict, List, Any, Optional, Tuple from abc import ABC, abstractmethod from ..config import config -from .constants import VALID_LORA_TYPES +from ..utils.constants import VALID_LORA_TYPES logger = logging.getLogger(__name__) diff --git a/py/recipes/constants.py b/py/recipes/constants.py index cbff797e..c1d4e383 100644 --- a/py/recipes/constants.py +++ b/py/recipes/constants.py @@ -1,5 +1,8 @@ """Constants used across recipe parsers.""" +# Import VALID_LORA_TYPES from utils.constants +from ..utils.constants import VALID_LORA_TYPES + # Constants for generation parameters GEN_PARAM_KEYS = [ 'prompt', @@ -11,6 +14,3 @@ GEN_PARAM_KEYS = [ 'size', 'clip_skip', ] - -# Valid Lora types -VALID_LORA_TYPES = ['lora', 'locon'] diff --git a/py/routes/api_routes.py b/py/routes/api_routes.py index e6b8906b..cb797e7c 100644 --- a/py/routes/api_routes.py +++ b/py/routes/api_routes.py @@ -13,7 +13,7 @@ from ..services.websocket_manager import ws_manager from ..services.settings_manager import settings import asyncio from .update_routes import UpdateRoutes -from ..utils.constants import PREVIEW_EXTENSIONS, CARD_PREVIEW_WIDTH +from ..utils.constants import PREVIEW_EXTENSIONS, CARD_PREVIEW_WIDTH, VALID_LORA_TYPES from ..utils.exif_utils import ExifUtils from ..services.service_registry import ServiceRegistry @@ -401,8 +401,8 @@ class ApiRoutes: versions = response.get('modelVersions', []) model_type = response.get('type', '') - # Check model type - should be LORA or LoCon - if model_type.lower() not in ['lora', 'locon']: + # Check model type - should be LORA, LoCon, or DORA + if model_type.lower() not in VALID_LORA_TYPES: return web.json_response({ 'error': f"Model type mismatch. Expected LORA or LoCon, got {model_type}" }, status=400) diff --git a/py/utils/constants.py b/py/utils/constants.py index 4ae269bf..59a02ae9 100644 --- a/py/utils/constants.py +++ b/py/utils/constants.py @@ -31,4 +31,7 @@ EXAMPLE_IMAGE_WIDTH = 832 SUPPORTED_MEDIA_EXTENSIONS = { 'images': ['.jpg', '.jpeg', '.png', '.webp', '.gif'], 'videos': ['.mp4', '.webm'] -} \ No newline at end of file +} + +# Valid Lora types +VALID_LORA_TYPES = ['lora', 'locon', 'dora'] \ No newline at end of file