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):
|
||||
|
||||
Reference in New Issue
Block a user