mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat(misc): mark model versions in library for Civitai user models
This commit is contained in:
@@ -687,9 +687,6 @@ class ModelLibraryHandler:
|
|||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if await scanner.check_model_version_exists(version_id_int):
|
|
||||||
continue
|
|
||||||
|
|
||||||
images = version.get("images") or []
|
images = version.get("images") or []
|
||||||
thumbnail_url = None
|
thumbnail_url = None
|
||||||
if images and isinstance(images, list):
|
if images and isinstance(images, list):
|
||||||
@@ -697,6 +694,8 @@ class ModelLibraryHandler:
|
|||||||
if isinstance(first_image, dict):
|
if isinstance(first_image, dict):
|
||||||
thumbnail_url = first_image.get("url")
|
thumbnail_url = first_image.get("url")
|
||||||
|
|
||||||
|
in_library = await scanner.check_model_version_exists(version_id_int)
|
||||||
|
|
||||||
versions.append(
|
versions.append(
|
||||||
{
|
{
|
||||||
"modelId": model_id_int,
|
"modelId": model_id_int,
|
||||||
@@ -707,6 +706,7 @@ class ModelLibraryHandler:
|
|||||||
"tags": tags,
|
"tags": tags,
|
||||||
"baseModel": version.get("baseModel"),
|
"baseModel": version.get("baseModel"),
|
||||||
"thumbnailUrl": thumbnail_url,
|
"thumbnailUrl": thumbnail_url,
|
||||||
|
"inLibrary": in_library,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ async def test_misc_routes_bind_produces_expected_handlers():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_get_civitai_user_models_filters_versions():
|
async def test_get_civitai_user_models_marks_library_versions():
|
||||||
models = [
|
models = [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
@@ -475,6 +475,18 @@ async def test_get_civitai_user_models_filters_versions():
|
|||||||
"tags": ["style"],
|
"tags": ["style"],
|
||||||
"baseModel": "Flux.1",
|
"baseModel": "Flux.1",
|
||||||
"thumbnailUrl": "http://example.com/a1.jpg",
|
"thumbnailUrl": "http://example.com/a1.jpg",
|
||||||
|
"inLibrary": False,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"modelId": 1,
|
||||||
|
"versionId": 101,
|
||||||
|
"modelName": "Model A",
|
||||||
|
"versionName": "v2",
|
||||||
|
"type": "LORA",
|
||||||
|
"tags": ["style"],
|
||||||
|
"baseModel": "Flux.1",
|
||||||
|
"thumbnailUrl": "http://example.com/a2.jpg",
|
||||||
|
"inLibrary": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"modelId": 2,
|
"modelId": 2,
|
||||||
@@ -485,6 +497,18 @@ async def test_get_civitai_user_models_filters_versions():
|
|||||||
"tags": ["embedding"],
|
"tags": ["embedding"],
|
||||||
"baseModel": None,
|
"baseModel": None,
|
||||||
"thumbnailUrl": "http://example.com/e1.jpg",
|
"thumbnailUrl": "http://example.com/e1.jpg",
|
||||||
|
"inLibrary": False,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"modelId": 2,
|
||||||
|
"versionId": 202,
|
||||||
|
"modelName": "Embedding",
|
||||||
|
"versionName": "v2",
|
||||||
|
"type": "TextualInversion",
|
||||||
|
"tags": ["embedding"],
|
||||||
|
"baseModel": None,
|
||||||
|
"thumbnailUrl": None,
|
||||||
|
"inLibrary": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"modelId": 3,
|
"modelId": 3,
|
||||||
@@ -495,6 +519,7 @@ async def test_get_civitai_user_models_filters_versions():
|
|||||||
"tags": ["checkpoint"],
|
"tags": ["checkpoint"],
|
||||||
"baseModel": "SDXL",
|
"baseModel": "SDXL",
|
||||||
"thumbnailUrl": None,
|
"thumbnailUrl": None,
|
||||||
|
"inLibrary": False,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user