53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
from app.homelab.anima_prompt import (
|
|
build_character_image_prompt,
|
|
build_draw_self_prompt,
|
|
build_scene_tags_prompt,
|
|
)
|
|
from app.homelab.scene_tags import extract_scene_tags, looks_like_booru_tags, rule_based_scene_tags
|
|
|
|
|
|
def test_build_character_image_prompt_full_body():
|
|
bundle = build_character_image_prompt(
|
|
"wolfgirl, white_hair, pumped_up",
|
|
action_tags="full_body, standing, looking_at_viewer",
|
|
outfit_tags="apron",
|
|
environment_tags="indoors, soft_lighting",
|
|
)
|
|
assert "full_body" in bundle.positive
|
|
assert "standing" in bundle.positive
|
|
assert "apron" in bundle.positive
|
|
assert "pumped_up" not in bundle.positive
|
|
assert "upper_body" not in bundle.positive
|
|
assert "portrait" not in bundle.positive
|
|
|
|
|
|
def test_build_draw_self_prompt_with_action():
|
|
bundle = build_draw_self_prompt(
|
|
"silver_hair, wolf_ears",
|
|
action_tags="full_body, standing",
|
|
outfit_tags="",
|
|
)
|
|
assert "full_body" in bundle.positive
|
|
assert "silver_hair" in bundle.positive
|
|
|
|
|
|
def test_build_draw_self_prompt_lora():
|
|
bundle = build_draw_self_prompt("1girl", lora_name="rin_lora", lora_weight=0.75)
|
|
assert "<lora:rin_lora:0.75>" in bundle.positive
|
|
|
|
|
|
def test_looks_like_booru_tags():
|
|
assert looks_like_booru_tags("1girl, smile, indoors")
|
|
assert not looks_like_booru_tags("draw a picture of a cat on the moon")
|
|
|
|
|
|
def test_rule_based_full_body_russian():
|
|
tags = rule_based_scene_tags("Очень, а в полный рост можешь?", [])
|
|
assert "full_body" in tags["action_tags"]
|
|
assert "portrait" not in tags["action_tags"]
|
|
|
|
|
|
def test_rule_based_outfit_apron():
|
|
tags = rule_based_scene_tags("", [{"role": "assistant", "content": "В фартуке стою у плиты"}])
|
|
assert "apron" in tags["outfit_tags"]
|