Strengthen H3 reference prompt placement
This commit is contained in:
+7
-11
@@ -4416,19 +4416,15 @@ def _inject_reference_context(block, context):
|
||||
text = str(block or "").strip()
|
||||
if not text:
|
||||
return context
|
||||
match = re.match(r"^(\[Generation \d+\]\s*)(.*)$", text, re.S)
|
||||
match = re.match(r"^(\[Generation \d+\]\s*)", text)
|
||||
if not match:
|
||||
return f"{context} {text}".strip()
|
||||
prefix, body = match.groups()
|
||||
body = body.strip()
|
||||
split_at = body.find(". ")
|
||||
if split_at == -1:
|
||||
return f"{prefix}{body} {context}".strip()
|
||||
anchor = body[: split_at + 1]
|
||||
rest = body[split_at + 2 :].strip()
|
||||
if not rest:
|
||||
return f"{prefix}{anchor} {context}".strip()
|
||||
return f"{prefix}{anchor} {context} {rest}".strip()
|
||||
return re.sub(
|
||||
r"^(\[Generation \d+\]\s*)",
|
||||
lambda m: m.group(1) + context + " ",
|
||||
text,
|
||||
count=1,
|
||||
)
|
||||
|
||||
|
||||
def _reference_character_memory(ref_slots):
|
||||
|
||||
@@ -536,7 +536,7 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
self.assertIn("Persistent appearance for Mara: silver hair.", context)
|
||||
self.assertIn("Persistent wardrobe/style for Mara: red jacket.", context)
|
||||
|
||||
def test_reference_context_injects_after_anchor_sentence(self):
|
||||
def test_reference_context_injects_immediately_after_generation_label(self):
|
||||
block = (
|
||||
"[Generation 1] Classic sitcom lighting and staging. "
|
||||
"Duke walks into the room."
|
||||
@@ -547,8 +547,8 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
result,
|
||||
"[Generation 1] Classic sitcom lighting and staging. "
|
||||
"Character facts for Duke: female, 25 years old. "
|
||||
"[Generation 1] Character facts for Duke: female, 25 years old. "
|
||||
"Classic sitcom lighting and staging. "
|
||||
"Duke walks into the room.",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user