From f2e12c0fd30ddfac78bc42b53013040d453eecc6 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Thu, 8 Jan 2026 22:19:19 +0800 Subject: [PATCH] feat: add "Strength Range" option to LoRA preset parameters dropdown, fixes #386 --- locales/de.json | 6 +++-- locales/en.json | 4 ++- locales/es.json | 6 +++-- locales/fr.json | 6 +++-- locales/he.json | 6 +++-- locales/ja.json | 6 +++-- locales/ko.json | 6 +++-- locales/ru.json | 6 +++-- locales/zh-CN.json | 6 +++-- locales/zh-TW.json | 6 +++-- static/js/components/shared/ModelModal.js | 33 ++++++++++++++++++----- 11 files changed, 66 insertions(+), 25 deletions(-) diff --git a/locales/de.json b/locales/de.json index 9f85f5db..887b59de 100644 --- a/locales/de.json +++ b/locales/de.json @@ -918,11 +918,13 @@ "addPresetParameter": "Voreingestellten Parameter hinzufügen...", "strengthMin": "Stärke Min", "strengthMax": "Stärke Max", + "strengthRange": "Stärkenbereich", "strength": "Stärke", "clipStrength": "Clip-Stärke", "clipSkip": "Clip Skip", "valuePlaceholder": "Wert", - "add": "Hinzufügen" + "add": "Hinzufügen", + "invalidRange": "Ungültiges Bereichsformat. Verwenden Sie x.x-y.y" }, "triggerWords": { "label": "Trigger Words", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/en.json b/locales/en.json index 94f155ae..7ad7fa4d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -918,11 +918,13 @@ "addPresetParameter": "Add preset parameter...", "strengthMin": "Strength Min", "strengthMax": "Strength Max", + "strengthRange": "Strength Range", "strength": "Strength", "clipStrength": "Clip Strength", "clipSkip": "Clip Skip", "valuePlaceholder": "Value", - "add": "Add" + "add": "Add", + "invalidRange": "Invalid range format. Use x.x-y.y" }, "triggerWords": { "label": "Trigger Words", diff --git a/locales/es.json b/locales/es.json index c3056334..2954f48a 100644 --- a/locales/es.json +++ b/locales/es.json @@ -918,11 +918,13 @@ "addPresetParameter": "Añadir parámetro preestablecido...", "strengthMin": "Fuerza mínima", "strengthMax": "Fuerza máxima", + "strengthRange": "Rango de fuerza", "strength": "Fuerza", "clipStrength": "Fuerza de Clip", "clipSkip": "Clip Skip", "valuePlaceholder": "Valor", - "add": "Añadir" + "add": "Añadir", + "invalidRange": "Formato de rango inválido. Use x.x-y.y" }, "triggerWords": { "label": "Palabras clave", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/fr.json b/locales/fr.json index 874d6b58..b9e8aec6 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -918,11 +918,13 @@ "addPresetParameter": "Ajouter un paramètre prédéfini...", "strengthMin": "Force Min", "strengthMax": "Force Max", + "strengthRange": "Gamme de force", "strength": "Force", "clipStrength": "Force Clip", "clipSkip": "Clip Skip", "valuePlaceholder": "Valeur", - "add": "Ajouter" + "add": "Ajouter", + "invalidRange": "Format de plage invalide. Utilisez x.x-y.y" }, "triggerWords": { "label": "Mots-clés", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/he.json b/locales/he.json index a5a87d13..be7744ea 100644 --- a/locales/he.json +++ b/locales/he.json @@ -918,11 +918,13 @@ "addPresetParameter": "הוסף פרמטר קבוע מראש...", "strengthMin": "חוזק מינימלי", "strengthMax": "חוזק מקסימלי", + "strengthRange": "טווח עוצמה", "strength": "חוזק", "clipStrength": "עוצמת CLIP", "clipSkip": "Clip Skip", "valuePlaceholder": "ערך", - "add": "הוסף" + "add": "הוסף", + "invalidRange": "פורמט טווח לא תקין. השתמש ב-x.x-y.y" }, "triggerWords": { "label": "מילות טריגר", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/ja.json b/locales/ja.json index 5688e40c..570b1cd4 100644 --- a/locales/ja.json +++ b/locales/ja.json @@ -918,11 +918,13 @@ "addPresetParameter": "プリセットパラメータを追加...", "strengthMin": "強度最小", "strengthMax": "強度最大", + "strengthRange": "強度範囲", "strength": "強度", "clipStrength": "クリップ強度", "clipSkip": "Clip Skip", "valuePlaceholder": "値", - "add": "追加" + "add": "追加", + "invalidRange": "無効な範囲形式です。x.x-y.y を使用してください" }, "triggerWords": { "label": "トリガーワード", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/ko.json b/locales/ko.json index 6cf1b0e4..4551224c 100644 --- a/locales/ko.json +++ b/locales/ko.json @@ -918,11 +918,13 @@ "addPresetParameter": "프리셋 매개변수 추가...", "strengthMin": "최소 강도", "strengthMax": "최대 강도", + "strengthRange": "강도 범위", "strength": "강도", "clipStrength": "클립 강도", "clipSkip": "클립 스킵", "valuePlaceholder": "값", - "add": "추가" + "add": "추가", + "invalidRange": "잘못된 범위 형식입니다. x.x-y.y를 사용하세요" }, "triggerWords": { "label": "트리거 단어", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/ru.json b/locales/ru.json index c0259d9a..5175625b 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -918,11 +918,13 @@ "addPresetParameter": "Добавить предустановленный параметр...", "strengthMin": "Мин. сила", "strengthMax": "Макс. сила", + "strengthRange": "Диапазон силы", "strength": "Сила", "clipStrength": "Сила клипа", "clipSkip": "Clip Skip", "valuePlaceholder": "Значение", - "add": "Добавить" + "add": "Добавить", + "invalidRange": "Неверный формат диапазона. Используйте x.x-y.y" }, "triggerWords": { "label": "Триггерные слова", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 305f2076..2ec694cf 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -918,11 +918,13 @@ "addPresetParameter": "添加预设参数...", "strengthMin": "最小强度", "strengthMax": "最大强度", + "strengthRange": "强度范围", "strength": "强度", "clipStrength": "Clip 强度", "clipSkip": "Clip Skip", "valuePlaceholder": "数值", - "add": "添加" + "add": "添加", + "invalidRange": "无效的范围格式。请使用 x.x-y.y" }, "triggerWords": { "label": "触发词", @@ -1529,4 +1531,4 @@ "learnMore": "浏览器插件教程" } } -} +} \ No newline at end of file diff --git a/locales/zh-TW.json b/locales/zh-TW.json index 78820d90..664b2f42 100644 --- a/locales/zh-TW.json +++ b/locales/zh-TW.json @@ -918,11 +918,13 @@ "addPresetParameter": "新增預設參數...", "strengthMin": "最小強度", "strengthMax": "最大強度", + "strengthRange": "強度範圍", "strength": "強度", "clipStrength": "Clip 強度", "clipSkip": "Clip Skip", "valuePlaceholder": "數值", - "add": "新增" + "add": "新增", + "invalidRange": "無效的範圍格式。請使用 x.x-y.y" }, "triggerWords": { "label": "觸發詞", @@ -1529,4 +1531,4 @@ "learnMore": "LM Civitai Extension Tutorial" } } -} +} \ No newline at end of file diff --git a/static/js/components/shared/ModelModal.js b/static/js/components/shared/ModelModal.js index 7e8261b1..2dfb86e9 100644 --- a/static/js/components/shared/ModelModal.js +++ b/static/js/components/shared/ModelModal.js @@ -672,6 +672,7 @@ function renderLoraSpecificContent(lora, escapedWords) { + @@ -814,12 +815,21 @@ function setupLoraSpecificFields(filePath) { const selected = this.value; if (selected) { presetValue.style.display = 'inline-block'; - presetValue.min = selected.includes('strength') ? -10 : 0; - presetValue.max = selected.includes('strength') ? 10 : 10; - presetValue.step = 0.5; - if (selected === 'clip_skip') { + if (selected === 'strength_range') { + presetValue.type = 'text'; + presetValue.placeholder = 'e.g. 0.8-1.2'; + presetValue.removeAttribute('min'); + presetValue.removeAttribute('max'); + presetValue.removeAttribute('step'); + } else { presetValue.type = 'number'; - presetValue.step = 1; + presetValue.placeholder = translate('modals.model.usageTips.valuePlaceholder', {}, 'Value'); + presetValue.min = selected.includes('strength') ? -10 : 0; + presetValue.max = selected.includes('strength') ? 10 : 10; + presetValue.step = 0.5; + if (selected === 'clip_skip') { + presetValue.step = 1; + } } // Add auto-focus setTimeout(() => presetValue.focus(), 0); @@ -840,7 +850,18 @@ function setupLoraSpecificFields(filePath) { document.querySelector(`.model-card[data-filepath="${filePath}"]`); const currentPresets = parsePresets(loraCard?.dataset.usage_tips); - currentPresets[key] = parseFloat(value); + if (key === 'strength_range') { + const rangeMatch = value.match(/^(-?\d*\.?\d+)\s*[-~]\s*(-?\d*\.?\d+)$/); + if (rangeMatch) { + currentPresets['strength_min'] = parseFloat(rangeMatch[1]); + currentPresets['strength_max'] = parseFloat(rangeMatch[2]); + } else { + showToast('modals.model.usageTips.invalidRange', {}, 'error', 'Invalid range format. Use x.x-y.y'); + return; + } + } else { + currentPresets[key] = parseFloat(value); + } const newPresetsJson = JSON.stringify(currentPresets); await getModelApiClient().saveModelMetadata(currentPath, { usage_tips: newPresetsJson });