refactor: code cleanup, unify usage of tuples in lora list

This commit is contained in:
Manuel Schmid
2024-05-18 16:46:26 +02:00
parent a78b3841c9
commit 4e610411fb
3 changed files with 6 additions and 13 deletions
+3 -6
View File
@@ -375,22 +375,19 @@ def ordinal_suffix(number: int) -> str:
def get_enabled_loras(loras: list) -> list:
return [[lora[1], lora[2]] for lora in loras if lora[0]]
return [(lora[1], lora[2]) for lora in loras if lora[0]]
def parse_lora_references_from_prompt(prompt: str, loras: List[Tuple[AnyStr, float]], loras_limit: int = 5) -> List[Tuple[AnyStr, float]]:
new_loras = []
updated_loras = []
for token in prompt.split(","):
m = LORAS_PROMPT_PATTERN.match(token)
if m:
new_loras.append((f"{m.group(1)}.safetensors", float(m.group(2))))
updated_loras = []
for lora in loras + new_loras:
if lora[0] != "None":
updated_loras.append(lora)