Use metadata for scene camera profiles

This commit is contained in:
2026-06-27 13:25:36 +02:00
parent 75a71a2df6
commit f811c02641
5 changed files with 194 additions and 11 deletions
+51 -6
View File
@@ -47,10 +47,29 @@ def coworking_composition_prompt(scene_text: Any, composition: Any, subject_kind
return scene_camera_adapters.coworking_composition_prompt(scene_text, composition, subject_kind)
def row_scene_text(row: dict[str, Any]) -> Any:
return row.get("scene_text") or row.get("source_scene_text") or row.get("scene")
def row_scene_theme(row: dict[str, Any]) -> str:
return str(row.get("scene_theme") or row.get("location_theme") or "")
def row_scene_profile_key(row: dict[str, Any]) -> str:
return str(row.get("scene_camera_profile_key") or "")
def apply_contextual_composition(row: dict[str, Any], subject_kind: str) -> dict[str, Any]:
scene_text = row.get("scene_text") or row.get("source_scene_text") or row.get("scene")
scene_text = row_scene_text(row)
old_composition = str(row.get("composition") or "").strip()
new_composition = coworking_composition_prompt(scene_text, old_composition, subject_kind)
new_composition = scene_camera_adapters.contextual_composition_prompt(
scene_text,
old_composition,
subject_kind,
scene_entry=row.get("scene_entry"),
theme=row_scene_theme(row),
profile_key=row_scene_profile_key(row),
)
if not old_composition or new_composition == old_composition:
return row
row["source_composition"] = row.get("source_composition") or old_composition
@@ -70,8 +89,19 @@ def apply_contextual_composition(row: dict[str, Any], subject_kind: str) -> dict
return row
def scene_camera_profile_metadata(scene_text: Any) -> dict[str, str]:
profile = scene_camera_adapters.scene_camera_profile(scene_text)
def scene_camera_profile_metadata(
scene_text: Any = "",
*,
scene_entry: Any = None,
theme: Any = "",
profile_key: Any = "",
) -> dict[str, str]:
profile = scene_camera_adapters.scene_camera_profile(
scene_text,
scene_entry=scene_entry,
theme=theme,
profile_key=profile_key,
)
if not profile:
return {}
return {
@@ -89,6 +119,10 @@ def camera_scene_directive_for_context(
pov_labels: list[str] | None = None,
subject_kind: str = "subjects",
compact_labels: Mapping[str, str] | None = None,
*,
scene_entry: Any = None,
theme: Any = "",
profile_key: Any = "",
) -> tuple[str, dict[str, Any]]:
parsed = camera_policy.parse_camera_config(camera_config)
directive = scene_camera_adapters.camera_scene_directive_for_context(
@@ -97,6 +131,9 @@ def camera_scene_directive_for_context(
pov_labels,
subject_kind,
compact_labels,
scene_entry=scene_entry,
theme=theme,
profile_key=profile_key,
)
return directive, parsed
@@ -141,17 +178,25 @@ def apply_camera_config(
pov_labels = row_pov_labels(row, pov_label_resolver)
subject_kind = row_camera_subject_kind(row)
row = apply_contextual_composition(row, subject_kind)
profile_metadata = scene_camera_profile_metadata(row.get("scene_text") or row.get("source_scene_text") or row.get("scene"))
profile_metadata = scene_camera_profile_metadata(
row_scene_text(row),
scene_entry=row.get("scene_entry"),
theme=row_scene_theme(row),
profile_key=row_scene_profile_key(row),
)
if profile_metadata:
row["scene_camera_profile"] = profile_metadata
row["scene_camera_profile_key"] = profile_metadata.get("key", "")
scene_directive, parsed = camera_scene_directive_for_context(
row.get("scene_text") or row.get("source_scene_text") or row.get("scene"),
row_scene_text(row),
row.get("composition") or row.get("source_composition"),
parsed,
pov_labels,
subject_kind,
compact_labels,
scene_entry=row.get("scene_entry"),
theme=row_scene_theme(row),
profile_key=row_scene_profile_key(row),
)
row["camera_config"] = parsed
row["camera_scene_directive"] = scene_directive