route refmods per generated chunk
This commit is contained in:
@@ -12,6 +12,15 @@ import sys
|
||||
REFERENCE_IMAGES_V39_TYPE = "H3_CONTINUUM_REFERENCE_IMAGES_V39"
|
||||
|
||||
|
||||
class DumasH3RefModBundle(list):
|
||||
"""H3_REF_MODS list with optional per-chunk routing metadata."""
|
||||
|
||||
def __init__(self, values=(), *, chunk_refs=None):
|
||||
super().__init__(values)
|
||||
self.chunk_refs = tuple(tuple(int(index) for index in refs)
|
||||
for refs in (chunk_refs or ()))
|
||||
|
||||
|
||||
def _continuum_reference_bundle_type():
|
||||
"""Find the upstream H3 bundle class without copying its implementation."""
|
||||
candidates = [
|
||||
@@ -273,6 +282,14 @@ class DumasH3SequencePromptBuilder:
|
||||
if index in referenced_slots
|
||||
]
|
||||
selected_slots = [index for index in range(1, len(refmods) + 1) if index in referenced_slots]
|
||||
selected_position = {slot: position for position, slot in enumerate(selected_slots)}
|
||||
chunk_refs = []
|
||||
for text in authored_text_by_chunk:
|
||||
chunk_refs.append(tuple(
|
||||
selected_position[index]
|
||||
for index in selected_slots
|
||||
if re.search(rf"@R{index}(?![A-Za-z0-9_])", text, re.IGNORECASE)
|
||||
))
|
||||
generated = _refmod_directive(selected_refmods, 1, selected_slots)
|
||||
if generated:
|
||||
directive = "\n\n".join(part for part in (directive, generated) if part)
|
||||
@@ -314,7 +331,7 @@ class DumasH3SequencePromptBuilder:
|
||||
len(active_sequence["clips"]),
|
||||
float(default_chunk_seconds),
|
||||
reference_bundle,
|
||||
selected_refmods,
|
||||
DumasH3RefModBundle(selected_refmods, chunk_refs=chunk_refs),
|
||||
0,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user