Strengthen H3 reference prompt placement

This commit is contained in:
2026-08-28 09:03:44 +00:00
parent a10a5d7dcf
commit e0b7001593
2 changed files with 10 additions and 14 deletions
+7 -11
View File
@@ -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):