Stop ref wardrobe from fighting live character memory
This commit is contained in:
+10
-4
@@ -4410,12 +4410,13 @@ def _matched_reference_slots(text, ref_slots):
|
|||||||
return matched
|
return matched
|
||||||
|
|
||||||
|
|
||||||
def _reference_context_for_text(text, ref_slots):
|
def _reference_context_for_text(text, ref_slots, include_character_wardrobe=True):
|
||||||
parts = []
|
parts = []
|
||||||
for slot_number, ref in _matched_reference_slots(text, ref_slots):
|
for slot_number, ref in _matched_reference_slots(text, ref_slots):
|
||||||
label = _reference_text(ref.get("name")) or _reference_text(ref.get("id")) or f"reference {slot_number}"
|
label = _reference_text(ref.get("name")) or _reference_text(ref.get("id")) or f"reference {slot_number}"
|
||||||
description = _reference_sentence(ref.get("description"))
|
description = _reference_sentence(ref.get("description"))
|
||||||
wardrobe = _reference_sentence(ref.get("wardrobe"))
|
wardrobe = (_reference_sentence(ref.get("wardrobe"))
|
||||||
|
if include_character_wardrobe else "")
|
||||||
general = _reference_sentence(ref.get("general"))
|
general = _reference_sentence(ref.get("general"))
|
||||||
facts = _reference_fact_sentence(ref, label)
|
facts = _reference_fact_sentence(ref, label)
|
||||||
if ref.get("kind") == "location":
|
if ref.get("kind") == "location":
|
||||||
@@ -6365,8 +6366,9 @@ class H3LongVideos:
|
|||||||
)
|
)
|
||||||
ref_slots = direct_ref_slots
|
ref_slots = direct_ref_slots
|
||||||
direct_ref_count = len(_connected_refs(direct_ref_slots))
|
direct_ref_count = len(_connected_refs(direct_ref_slots))
|
||||||
|
explicit_character_memory = (character_memory or "").strip()
|
||||||
derived_character_memory = _reference_character_memory(ref_slots)
|
derived_character_memory = _reference_character_memory(ref_slots)
|
||||||
effective_character_memory = (character_memory or "").strip() or derived_character_memory
|
effective_character_memory = explicit_character_memory or derived_character_memory
|
||||||
# A pixel budget overrides the preset's SIZE while keeping its aspect ratio,
|
# A pixel budget overrides the preset's SIZE while keeping its aspect ratio,
|
||||||
# so the dropdown chooses the shape and this chooses how big. Scaling from
|
# so the dropdown chooses the shape and this chooses how big. Scaling from
|
||||||
# the preset's own dimensions is what makes 1.00MP reproduce each native
|
# the preset's own dimensions is what makes 1.00MP reproduce each native
|
||||||
@@ -6582,7 +6584,11 @@ class H3LongVideos:
|
|||||||
count_auto=(subject_count_guard == "auto"))
|
count_auto=(subject_count_guard == "auto"))
|
||||||
enriched_gens = []
|
enriched_gens = []
|
||||||
for block in gens:
|
for block in gens:
|
||||||
context = _reference_context_for_text(block, ref_slots)
|
context = _reference_context_for_text(
|
||||||
|
block,
|
||||||
|
ref_slots,
|
||||||
|
include_character_wardrobe=not bool(explicit_character_memory),
|
||||||
|
)
|
||||||
if context:
|
if context:
|
||||||
block = _inject_reference_context(block, context)
|
block = _inject_reference_context(block, context)
|
||||||
enriched_gens.append(block)
|
enriched_gens.append(block)
|
||||||
|
|||||||
@@ -620,6 +620,20 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
|||||||
self.assertIn("Persistent appearance for Mara: silver hair.", context)
|
self.assertIn("Persistent appearance for Mara: silver hair.", context)
|
||||||
self.assertIn("Persistent wardrobe/style for Mara: red jacket.", context)
|
self.assertIn("Persistent wardrobe/style for Mara: red jacket.", context)
|
||||||
|
|
||||||
|
def test_reference_context_can_skip_character_wardrobe_when_live_memory_is_explicit(self):
|
||||||
|
refs = [
|
||||||
|
{"kind": "character", "image": "img1", "name": "Mara", "description": "silver hair", "wardrobe": "red jacket"},
|
||||||
|
]
|
||||||
|
|
||||||
|
context = self.module._reference_context_for_text(
|
||||||
|
"[Generation 1] Mara walks into the room.",
|
||||||
|
refs,
|
||||||
|
include_character_wardrobe=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertIn("Persistent appearance for Mara: silver hair.", context)
|
||||||
|
self.assertNotIn("Persistent wardrobe/style for Mara: red jacket.", context)
|
||||||
|
|
||||||
def test_reference_context_injects_immediately_after_generation_label(self):
|
def test_reference_context_injects_immediately_after_generation_label(self):
|
||||||
block = (
|
block = (
|
||||||
"[Generation 1] Classic sitcom lighting and staging. "
|
"[Generation 1] Classic sitcom lighting and staging. "
|
||||||
|
|||||||
Reference in New Issue
Block a user