- Add clear_all_search_caches() in core/sources/__init__.py and replace 4 individual cache-clearing call sites in __init__.py with the new helper. - Add shared parse_civitai_model_path() in core/type_utils.py and use it from both CivitAI and CivArchive URL parsers to remove duplicated regex logic. - Rename parse_huggingface_url() to get_huggingface_repo_and_file_from_url() in core/resolver.py for clarity. - Add stripModelExtension() and hasModelExtension() utilities (with a single MODEL_EXTENSIONS_REGEX) in web/resolver/utils/render_format_methods.js and replace repeated inline regex patterns across search_panel.js, model_info_methods.js, tabs_loaded_methods.js, and queue_methods.js.
70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
"""
|
|
Model Sources Module
|
|
|
|
Provides search functionality for finding models from various sources.
|
|
"""
|
|
|
|
from ..log_system.log_funcs import create_module_logger # noqa: F401
|
|
|
|
from .popular import search_popular_models, get_popular_model_url
|
|
from .model_list import search_model_list, search_model_list_multiple
|
|
from .huggingface import (
|
|
search_huggingface,
|
|
search_huggingface_for_file,
|
|
get_huggingface_download_url,
|
|
clear_search_cache as clear_huggingface_search_cache,
|
|
)
|
|
from .civitai import (
|
|
search_civitai,
|
|
search_civitai_for_file,
|
|
get_civitai_download_url,
|
|
clear_search_cache as clear_civitai_search_cache,
|
|
)
|
|
from .civarchive import (
|
|
clear_search_cache as clear_civarchive_search_cache,
|
|
is_civarchive_available,
|
|
resolve_civarchive_by_hash,
|
|
resolve_civarchive_model_version,
|
|
search_civarchive,
|
|
search_civarchive_for_file,
|
|
)
|
|
from .lora_manager_archive import (
|
|
clear_search_cache as clear_lora_manager_archive_search_cache,
|
|
get_lora_manager_archive_db_path,
|
|
is_lora_manager_archive_available,
|
|
search_lora_manager_archive,
|
|
search_lora_manager_archive_for_file,
|
|
)
|
|
|
|
def clear_all_search_caches() -> None:
|
|
"""Clear search caches for all external sources."""
|
|
clear_huggingface_search_cache()
|
|
clear_civitai_search_cache()
|
|
clear_civarchive_search_cache()
|
|
clear_lora_manager_archive_search_cache()
|
|
|
|
__all__ = [
|
|
"search_popular_models",
|
|
"get_popular_model_url",
|
|
"search_model_list",
|
|
"search_model_list_multiple",
|
|
"search_huggingface",
|
|
"search_huggingface_for_file",
|
|
"get_huggingface_download_url",
|
|
"search_civitai",
|
|
"search_civitai_for_file",
|
|
"get_civitai_download_url",
|
|
"clear_civarchive_search_cache",
|
|
"is_civarchive_available",
|
|
"resolve_civarchive_by_hash",
|
|
"resolve_civarchive_model_version",
|
|
"search_civarchive",
|
|
"search_civarchive_for_file",
|
|
"clear_lora_manager_archive_search_cache",
|
|
"get_lora_manager_archive_db_path",
|
|
"is_lora_manager_archive_available",
|
|
"search_lora_manager_archive",
|
|
"search_lora_manager_archive_for_file",
|
|
"clear_all_search_caches",
|
|
]
|