mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 22:22:11 -03:00
Add filters - base model only for now
This commit is contained in:
@@ -121,6 +121,10 @@ class ApiRoutes:
|
||||
fuzzy = request.query.get('fuzzy', 'false').lower() == 'true'
|
||||
recursive = request.query.get('recursive', 'false').lower() == 'true'
|
||||
|
||||
# Parse base models filter parameter
|
||||
base_models = request.query.get('base_models', '').split(',')
|
||||
base_models = [model.strip() for model in base_models if model.strip()]
|
||||
|
||||
# Validate parameters
|
||||
if page < 1 or page_size < 1 or page_size > 100:
|
||||
return web.json_response({
|
||||
@@ -132,7 +136,7 @@ class ApiRoutes:
|
||||
'error': 'Invalid sort parameter'
|
||||
}, status=400)
|
||||
|
||||
# Get paginated data with search
|
||||
# Get paginated data with search and filters
|
||||
result = await self.scanner.get_paginated_data(
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
@@ -140,7 +144,8 @@ class ApiRoutes:
|
||||
folder=folder,
|
||||
search=search,
|
||||
fuzzy=fuzzy,
|
||||
recursive=recursive # 添加递归参数
|
||||
recursive=recursive,
|
||||
base_models=base_models # Pass base models filter
|
||||
)
|
||||
|
||||
# Format the response data
|
||||
|
||||
@@ -148,7 +148,7 @@ class LoraScanner:
|
||||
|
||||
async def get_paginated_data(self, page: int, page_size: int, sort_by: str = 'name',
|
||||
folder: str = None, search: str = None, fuzzy: bool = False,
|
||||
recursive: bool = False):
|
||||
recursive: bool = False, base_models: list = None):
|
||||
"""Get paginated and filtered lora data
|
||||
|
||||
Args:
|
||||
@@ -159,6 +159,7 @@ class LoraScanner:
|
||||
search: Search term
|
||||
fuzzy: Use fuzzy matching for search
|
||||
recursive: Include subfolders when folder filter is applied
|
||||
base_models: List of base models to filter by
|
||||
"""
|
||||
cache = await self.get_cached_data()
|
||||
|
||||
@@ -180,6 +181,13 @@ class LoraScanner:
|
||||
if item['folder'] == folder
|
||||
]
|
||||
|
||||
# Apply base model filtering
|
||||
if base_models and len(base_models) > 0:
|
||||
filtered_data = [
|
||||
item for item in filtered_data
|
||||
if item.get('base_model') in base_models
|
||||
]
|
||||
|
||||
# 应用搜索过滤
|
||||
if search:
|
||||
if fuzzy:
|
||||
|
||||
@@ -2,10 +2,10 @@ from typing import Optional
|
||||
|
||||
# Base model mapping based on version string
|
||||
BASE_MODEL_MAPPING = {
|
||||
"sd-v1-5": "SD1.5",
|
||||
"sd-v2-1": "SD2.1",
|
||||
"sdxl": "SDXL",
|
||||
"sd-v2": "SD2.0",
|
||||
"sd-v1-5": "SD 1.5",
|
||||
"sd-v2-1": "SD 2.1",
|
||||
"sdxl": "SDXL 1.0",
|
||||
"sd-v2": "SD 2.0",
|
||||
"flux1": "Flux.1 D",
|
||||
"flux.1 d": "Flux.1 D",
|
||||
"illustrious": "IL",
|
||||
|
||||
Reference in New Issue
Block a user