mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
- Remove backward compatibility code for `model_type` in `ModelScanner._build_cache_entry()` - Update `CheckpointScanner` to only handle `sub_type` in `adjust_metadata()` and `adjust_cached_entry()` - Delete deprecated aliases `resolve_civitai_model_type` and `normalize_civitai_model_type` from `model_query.py` - Update frontend components (`RecipeModal.js`, `ModelCard.js`, etc.) to use `sub_type` instead of `model_type` - Update API response format to return only `sub_type`, removing `model_type` from service responses - Revise technical documentation to mark Phase 5 as completed and remove outdated TODO items All cleanup tasks for the model type refactoring are now complete, ensuring consistent use of `sub_type` across the codebase.
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
import os
|
|
import logging
|
|
from typing import Dict
|
|
|
|
from .base_model_service import BaseModelService
|
|
from ..utils.models import EmbeddingMetadata
|
|
from ..config import config
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class EmbeddingService(BaseModelService):
|
|
"""Embedding-specific service implementation"""
|
|
|
|
def __init__(self, scanner, update_service=None):
|
|
"""Initialize Embedding service
|
|
|
|
Args:
|
|
scanner: Embedding scanner instance
|
|
update_service: Optional service for remote update tracking.
|
|
"""
|
|
super().__init__("embedding", scanner, EmbeddingMetadata, update_service=update_service)
|
|
|
|
async def format_response(self, embedding_data: Dict) -> Dict:
|
|
"""Format Embedding data for API response"""
|
|
# Get sub_type from cache entry (new canonical field)
|
|
sub_type = embedding_data.get("sub_type", "embedding")
|
|
|
|
return {
|
|
"model_name": embedding_data["model_name"],
|
|
"file_name": embedding_data["file_name"],
|
|
"preview_url": config.get_preview_static_url(embedding_data.get("preview_url", "")),
|
|
"preview_nsfw_level": embedding_data.get("preview_nsfw_level", 0),
|
|
"base_model": embedding_data.get("base_model", ""),
|
|
"folder": embedding_data["folder"],
|
|
"sha256": embedding_data.get("sha256", ""),
|
|
"file_path": embedding_data["file_path"].replace(os.sep, "/"),
|
|
"file_size": embedding_data.get("size", 0),
|
|
"modified": embedding_data.get("modified", ""),
|
|
"tags": embedding_data.get("tags", []),
|
|
"from_civitai": embedding_data.get("from_civitai", True),
|
|
# "usage_count": embedding_data.get("usage_count", 0), # TODO: Enable when embedding usage tracking is implemented
|
|
"notes": embedding_data.get("notes", ""),
|
|
"sub_type": sub_type,
|
|
"favorite": embedding_data.get("favorite", False),
|
|
"update_available": bool(embedding_data.get("update_available", False)),
|
|
"civitai": self.filter_civitai_data(embedding_data.get("civitai", {}), minimal=True)
|
|
}
|
|
|
|
def find_duplicate_hashes(self) -> Dict:
|
|
"""Find Embeddings with duplicate SHA256 hashes"""
|
|
return self.scanner._hash_index.get_duplicate_hashes()
|
|
|
|
def find_duplicate_filenames(self) -> Dict:
|
|
"""Find Embeddings with conflicting filenames"""
|
|
return self.scanner._hash_index.get_duplicate_filenames()
|