diff options
| author | tslil <tslil@posteo.de> | 2026-08-03 16:38:11 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-03 16:38:24 +0100 |
| commit | 22cb65c84c2d4484dc46a9aed631cea4a311ba80 (patch) | |
| tree | 9318e7d842a30207e1d72f975ce15e488c272c7b | |
| parent | 7bcb78370635d43c9434e7e40bd9012b73c038a1 (diff) | |
wallpaper.py: go back to gemma4 e4b
| -rwxr-xr-x | wallpaper.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/wallpaper.py b/wallpaper.py index bdd3b37..22295ab 100755 --- a/wallpaper.py +++ b/wallpaper.py @@ -143,24 +143,40 @@ def step_context( def clean_llm_output(text: str) -> str: + # llama-completion end marker. text = re.sub( r"\s*\[\s*end of text\s*\]\s*$", "", text, flags=re.IGNORECASE, ) + + # Gemma 4 reasoning channel. text = re.sub( - r"<think>.*?</think>", + r"<\|channel>thought\s*.*?<channel\|>\s*", "", text, flags=re.DOTALL | re.IGNORECASE, ) + + # DeepSeek/Qwen-style reasoning tags. text = re.sub( - r"<think>.*$", + r"<think>.*?</think>", "", text, flags=re.DOTALL | re.IGNORECASE, ) + + # Detect truncated reasoning rather than sending it to sd-cli. + if re.match( + r"^\s*(?:<\|channel>thought\b|<think>)", + text, + flags=re.IGNORECASE, + ): + raise RuntimeError( + "The model generated reasoning but did not reach a final answer. Check that your llama.cpp build supports '--reasoning off', or increase --llm-max-tokens." + ) + return text.strip() @@ -459,13 +475,13 @@ def parse_args() -> argparse.Namespace: llm.add_argument( "--llm-model-path", type=Path, - default=Path("~/store/weights/Qwen3-8B-Q4_K_M.gguf"), + default=Path("~/store/weights/gemma-4-E4B-it-Q4_K_M.gguf"), help="Model path for generating image prompts.", ) llm.add_argument( "--llm-max-tokens", type=positive_int, - default=384, + default=1024, help="Maximum number of prompt tokens to generate.", ) llm.add_argument( @@ -502,7 +518,7 @@ def parse_args() -> argparse.Namespace: "The weather should be reflected in your prompt where it does not contradict the biome; the biome's climate wins any conflict. " "The season should set the overall mood of the prompt. " "Do not include the time, date, or location in your prompt. " - "Output ONLY the image prompt — no explanation or preamble." + "Output ONLY the image prompt - no explanation or preamble, no thinking." ), help="System prompt for the LLM.", ) @@ -576,7 +592,7 @@ def parse_args() -> argparse.Namespace: ) sd_cli.add_argument( "--sd-cli-explicit-instructions", - default="No railings, no glass, no people, no objects.", + default="No railings, no glass, no people, no objects, no houses.", help="Instructions appended to every diffusion prompt.", ) |
