mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-09 20:39:25 -03:00
feat(lora): add lora_syntax_format setting for syntax version toggle (#917)
Adds lora_syntax_format setting (full/legacy) that controls whether <lora:...> syntax uses relative paths (full) or filename only (legacy). Default is legacy for backward compatibility with A1111 convention. The full path format (<lora:relative/path/filename:strength>) enables lossless model resolution across subfolders. Ultraworked with Sisyphus (https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -104,6 +104,30 @@ function removeLoraExtension(fileName = '') {
|
||||
return fileName.replace(/\.(safetensors|ckpt|pt|bin)$/i, '');
|
||||
}
|
||||
|
||||
let _loraSyntaxFormatCache = null;
|
||||
|
||||
function _getLoraSyntaxFormat() {
|
||||
if (typeof _loraSyntaxFormatCache !== 'undefined' && _loraSyntaxFormatCache !== null) {
|
||||
return _loraSyntaxFormatCache;
|
||||
}
|
||||
return 'legacy';
|
||||
}
|
||||
async function _initLoraSyntaxFormat() {
|
||||
try {
|
||||
const response = await api.fetchApi('/lm/settings');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (data.success && data.settings) {
|
||||
_loraSyntaxFormatCache = data.settings.lora_syntax_format || 'legacy';
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
_loraSyntaxFormatCache = 'legacy';
|
||||
}
|
||||
_initLoraSyntaxFormat();
|
||||
|
||||
function parseSearchTokens(term = '') {
|
||||
const include = [];
|
||||
const exclude = [];
|
||||
@@ -231,6 +255,10 @@ const MODEL_BEHAVIORS = {
|
||||
const folder = directories.length ? directories.join('/') + '/' : '';
|
||||
const loraName = folder + baseName;
|
||||
|
||||
const resultName = _getLoraSyntaxFormat() === 'legacy'
|
||||
? baseName
|
||||
: loraName;
|
||||
|
||||
let strength = 1.0;
|
||||
let hasStrength = false;
|
||||
let clipStrength = null;
|
||||
@@ -265,9 +293,9 @@ const MODEL_BEHAVIORS = {
|
||||
}
|
||||
|
||||
if (clipStrength !== null) {
|
||||
return formatAutocompleteInsertion(`<lora:${loraName}:${strength}:${clipStrength}>`);
|
||||
return formatAutocompleteInsertion(`<lora:${resultName}:${strength}:${clipStrength}>`);
|
||||
}
|
||||
return formatAutocompleteInsertion(`<lora:${loraName}:${strength}>`);
|
||||
return formatAutocompleteInsertion(`<lora:${resultName}:${strength}>`);
|
||||
}
|
||||
},
|
||||
embeddings: {
|
||||
|
||||
Reference in New Issue
Block a user