feat: add model_name and version_name placeholders to download paths, #552

Add support for {model_name} and {version_name} placeholders in download path templates. These new placeholders allow for more flexible and descriptive file organization by including the actual model name and version name in the download directory structure.

Changes include:
- Updated download_manager.py and utils.py to handle new placeholders
- Added placeholders to constants.js for UI reference
- Updated settings modal template to show available placeholders
- Added comprehensive tests to verify placeholder functionality

This enhancement provides users with more control over how downloaded models are organized on their file system.
This commit is contained in:
Will Miao
2025-10-17 16:01:06 +08:00
parent 0ecbdf6f39
commit 10f5588e4a
6 changed files with 49 additions and 2 deletions

View File

@@ -53,6 +53,21 @@ def test_calculate_relative_path_for_model_uses_mappings_and_defaults(isolated_s
assert relative_path == "SDXL-mapped/no tags/Creator"
def test_calculate_relative_path_supports_model_and_version(isolated_settings):
isolated_settings["download_path_templates"]["lora"] = "{model_name}/{version_name}"
model_data = {
"model_name": "Fancy Model",
"base_model": "SDXL",
"tags": ["tag"],
"civitai": {"id": 1, "name": "Version One", "creator": {"username": "Creator"}},
}
relative_path = calculate_relative_path_for_model(model_data, "lora")
assert relative_path == "Fancy Model/Version One"
def test_calculate_recipe_fingerprint_filters_and_sorts():
loras = [
{"hash": "ABC", "strength": 0.1234},