format: auto-format code [skip ci]
This commit is contained in:
+8
-17
@@ -794,7 +794,9 @@ def generate( # noqa: PLR0915
|
|||||||
] = None,
|
] = None,
|
||||||
scene_prompt: Annotated[
|
scene_prompt: Annotated[
|
||||||
str | None,
|
str | None,
|
||||||
typer.Option("--scene-prompt", help='Inline scene fragment, comma-separated (e.g. "luxury penthouse, volumetric lighting")'),
|
typer.Option(
|
||||||
|
"--scene-prompt", help='Inline scene fragment, comma-separated (e.g. "luxury penthouse, volumetric lighting")'
|
||||||
|
),
|
||||||
] = None,
|
] = None,
|
||||||
family: Annotated[
|
family: Annotated[
|
||||||
str | None,
|
str | None,
|
||||||
@@ -920,9 +922,7 @@ def generate( # noqa: PLR0915
|
|||||||
character_prompt = ", ".join(str(x) for x in val if str(x).strip())
|
character_prompt = ", ".join(str(x) for x in val if str(x).strip())
|
||||||
if "character_prompt" in mapped and "character_prompt" not in explicit:
|
if "character_prompt" in mapped and "character_prompt" not in explicit:
|
||||||
cp_val = mapped["character_prompt"]
|
cp_val = mapped["character_prompt"]
|
||||||
character_prompt = (
|
character_prompt = cp_val if isinstance(cp_val, str) else ", ".join(str(x) for x in cp_val if str(x).strip())
|
||||||
cp_val if isinstance(cp_val, str) else ", ".join(str(x) for x in cp_val if str(x).strip())
|
|
||||||
)
|
|
||||||
if "scene" in mapped and "scene" not in explicit:
|
if "scene" in mapped and "scene" not in explicit:
|
||||||
sv = mapped["scene"]
|
sv = mapped["scene"]
|
||||||
if isinstance(sv, str):
|
if isinstance(sv, str):
|
||||||
@@ -931,9 +931,7 @@ def generate( # noqa: PLR0915
|
|||||||
scene_prompt = ", ".join(str(x) for x in sv if str(x).strip())
|
scene_prompt = ", ".join(str(x) for x in sv if str(x).strip())
|
||||||
if "scene_prompt" in mapped and "scene_prompt" not in explicit:
|
if "scene_prompt" in mapped and "scene_prompt" not in explicit:
|
||||||
sp_val = mapped["scene_prompt"]
|
sp_val = mapped["scene_prompt"]
|
||||||
scene_prompt = (
|
scene_prompt = sp_val if isinstance(sp_val, str) else ", ".join(str(x) for x in sp_val if str(x).strip())
|
||||||
sp_val if isinstance(sp_val, str) else ", ".join(str(x) for x in sp_val if str(x).strip())
|
|
||||||
)
|
|
||||||
if "rating" in mapped and "rating" not in explicit:
|
if "rating" in mapped and "rating" not in explicit:
|
||||||
rating = mapped["rating"]
|
rating = mapped["rating"]
|
||||||
|
|
||||||
@@ -1150,10 +1148,7 @@ def _run_generation( # noqa: PLR0915
|
|||||||
prompt_parts.extend(scene_elements)
|
prompt_parts.extend(scene_elements)
|
||||||
if not json_output:
|
if not json_output:
|
||||||
origin = f"'{scene}'" if scene else "inline"
|
origin = f"'{scene}'" if scene else "inline"
|
||||||
console.print(
|
console.print(f"[dim]Scene ({origin}, {len(scene_elements)} elements): {', '.join(scene_elements)}[/dim]")
|
||||||
f"[dim]Scene ({origin}, {len(scene_elements)} elements): "
|
|
||||||
f"{', '.join(scene_elements)}[/dim]"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add rating tag based on model family (Pony/Illustrious)
|
# Add rating tag based on model family (Pony/Illustrious)
|
||||||
if rating:
|
if rating:
|
||||||
@@ -1744,11 +1739,7 @@ def style_sweep( # noqa: PLR0915
|
|||||||
elif isinstance(name_val, (list, tuple)):
|
elif isinstance(name_val, (list, tuple)):
|
||||||
inline_out = ", ".join(str(x) for x in name_val if str(x).strip())
|
inline_out = ", ".join(str(x) for x in name_val if str(x).strip())
|
||||||
if prompt_val is not None:
|
if prompt_val is not None:
|
||||||
inline_out = (
|
inline_out = prompt_val if isinstance(prompt_val, str) else ", ".join(str(x) for x in prompt_val if str(x).strip())
|
||||||
prompt_val
|
|
||||||
if isinstance(prompt_val, str)
|
|
||||||
else ", ".join(str(x) for x in prompt_val if str(x).strip())
|
|
||||||
)
|
|
||||||
return name_out, inline_out
|
return name_out, inline_out
|
||||||
|
|
||||||
char_name, char_inline = _split_fragment(tpl_data.get("character"), tpl_data.get("character_prompt"))
|
char_name, char_inline = _split_fragment(tpl_data.get("character"), tpl_data.get("character_prompt"))
|
||||||
@@ -1950,7 +1941,7 @@ def template(
|
|||||||
str | None,
|
str | None,
|
||||||
typer.Option(
|
typer.Option(
|
||||||
"--scene-prompt",
|
"--scene-prompt",
|
||||||
help='Inline scene fragment, comma-separated (merged with --scene into `scene`)',
|
help="Inline scene fragment, comma-separated (merged with --scene into `scene`)",
|
||||||
),
|
),
|
||||||
] = None,
|
] = None,
|
||||||
output: Annotated[Path | None, typer.Option("-o", "--output", help="Save template to file")] = None,
|
output: Annotated[Path | None, typer.Option("-o", "--output", help="Save template to file")] = None,
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ class FragmentLibrary:
|
|||||||
|
|
||||||
def _validate_name(self, name: str) -> None:
|
def _validate_name(self, name: str) -> None:
|
||||||
if not name or not _NAME_RE.match(name):
|
if not name or not _NAME_RE.match(name):
|
||||||
raise ValueError(
|
raise ValueError(f"Invalid {self._singular} name {name!r}: only letters, digits, '.', '_', '-' allowed")
|
||||||
f"Invalid {self._singular} name {name!r}: only letters, digits, '.', '_', '-' allowed"
|
|
||||||
)
|
|
||||||
|
|
||||||
def path(self, name: str) -> Path:
|
def path(self, name: str) -> Path:
|
||||||
"""Return the on-disk path for ``name`` (without ensuring it exists)."""
|
"""Return the on-disk path for ``name`` (without ensuring it exists)."""
|
||||||
@@ -108,9 +106,7 @@ class FragmentLibrary:
|
|||||||
value = str(value)
|
value = str(value)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
value = (
|
value = (
|
||||||
item[1:-1].replace("''", "'")
|
item[1:-1].replace("''", "'") if len(item) >= _MIN_QUOTED_SCALAR_LEN and item[0] == item[-1] == "'" else item
|
||||||
if len(item) >= _MIN_QUOTED_SCALAR_LEN and item[0] == item[-1] == "'"
|
|
||||||
else item
|
|
||||||
)
|
)
|
||||||
elements.append(value)
|
elements.append(value)
|
||||||
return elements
|
return elements
|
||||||
|
|||||||
Reference in New Issue
Block a user