Filter LoRA picker options by engine tokens
This commit is contained in:
+19
-13
@@ -32,7 +32,7 @@ export function loraIdentityKey(name: string) {
|
||||
export function isXaigenOnlyLora(name: string) {
|
||||
const base = loraBasename(name)
|
||||
// Include the common `xiagen-` typo so those files stay off AIGen too.
|
||||
return /^(xai|xia)gen/i.test(base) || /klein_snofs|snofs_krea/i.test(base)
|
||||
return String(name || '').replace(/\\/g, '/').split('/').some(part => /^(xai|xia)gen/i.test(part)) || /klein_snofs|snofs_krea/i.test(base)
|
||||
}
|
||||
|
||||
/** Pick the real Comfy filename: exact path, then same basename ignoring `xaigen-`, then suffix/contains. */
|
||||
@@ -293,22 +293,28 @@ export function isSystemGraphLora(name: string) {
|
||||
return false
|
||||
}
|
||||
|
||||
/** Filename hints. `null` means the LoRA can appear in any picker. */
|
||||
/** Engine tokens in paths or basenames; unlabelled files are not picker options. */
|
||||
export function inferLoraUse(name: string): LoraUse[] | null {
|
||||
const imageEngine = imageLoraEngineOf(name)
|
||||
if (imageEngine) return [imageEngine]
|
||||
const id = loraIdentityKey(name)
|
||||
if (/(^|[_-])ltx([_-]|$)|ltx-2/i.test(id)) return ['ltx']
|
||||
if (/minimax|h3_fl2v|fl2v_turbo/i.test(id)) return ['minimax']
|
||||
return null
|
||||
const value = String(name || '').toLowerCase()
|
||||
const uses: LoraUse[] = []
|
||||
if (/minimax/.test(value)) uses.push('minimax')
|
||||
if (/ltx/.test(value)) uses.push('ltx')
|
||||
if (/klein|flux/.test(value)) uses.push('flux')
|
||||
if (/krea/.test(value)) uses.push('krea')
|
||||
return uses.length ? uses : null
|
||||
}
|
||||
|
||||
export function loraMatchesUse(name: string, use: LoraUse) {
|
||||
if (isSystemGraphLora(name)) return false
|
||||
if (use === 'flux' || use === 'krea') return imageLoraEngineOf(name) === use
|
||||
const inferred = inferLoraUse(name)
|
||||
if (!inferred) return true
|
||||
return inferred.includes(use)
|
||||
return !isSystemGraphLora(name) && !!inferLoraUse(name)?.includes(use)
|
||||
}
|
||||
|
||||
/** Saved stacks may contain unlabelled adapters; never carry a known wrong engine. */
|
||||
export function filterLoraStackForUse(stack: unknown, use: LoraUse, xaigen: boolean) {
|
||||
if (use === 'ltx' && !xaigen) return []
|
||||
return filterLoraStackForStudio(stack, xaigen).filter(item => {
|
||||
const uses = inferLoraUse(item.name)
|
||||
return !isSystemGraphLora(item.name) && (!uses || uses.includes(use))
|
||||
})
|
||||
}
|
||||
|
||||
export function filterLorasForUse(names: string[], use: LoraUse) {
|
||||
|
||||
Reference in New Issue
Block a user