Support seeded atlas prompt cue variants
This commit is contained in:
@@ -76,6 +76,33 @@ def get_variant(key: str, *, path: str | Path | None = None) -> dict[str, Any]:
|
||||
return {}
|
||||
|
||||
|
||||
def _cue_list(value: Any) -> list[str]:
|
||||
if isinstance(value, dict):
|
||||
value = value.get("prompt_cues") or value.get("cues")
|
||||
if not isinstance(value, list):
|
||||
return []
|
||||
return [str(cue) for cue in value if str(cue).strip()]
|
||||
|
||||
|
||||
def prompt_cue_sets(variant_or_key: dict[str, Any] | str) -> list[list[str]]:
|
||||
variant = get_variant(variant_or_key) if isinstance(variant_or_key, str) else dict(variant_or_key or {})
|
||||
if not variant:
|
||||
return []
|
||||
cue_sets: list[list[str]] = []
|
||||
baseline = _cue_list(variant.get("prompt_cues"))
|
||||
if baseline:
|
||||
cue_sets.append(baseline)
|
||||
for cue_set in variant.get("prompt_variant_cues") or []:
|
||||
cues = _cue_list(cue_set)
|
||||
if cues:
|
||||
cue_sets.append(cues)
|
||||
if not cue_sets:
|
||||
fallback = str(variant.get("canonical_geometry") or "").strip()
|
||||
if fallback:
|
||||
cue_sets.append([fallback])
|
||||
return cue_sets
|
||||
|
||||
|
||||
def reference_paths(key: str, *, path: str | Path | None = None) -> list[Path]:
|
||||
catalog = load_catalog(path)
|
||||
atlas_root = Path(str(catalog.get("atlas_root") or ""))
|
||||
@@ -90,4 +117,3 @@ def reference_paths(key: str, *, path: str | Path | None = None) -> list[Path]:
|
||||
continue
|
||||
paths.append(atlas_root / ref_path)
|
||||
return paths
|
||||
|
||||
|
||||
Reference in New Issue
Block a user