Add caption pair target routing
This commit is contained in:
+46
-12
@@ -172,17 +172,24 @@ def _caption_metadata_route_request(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> caption_metadata_routes.CaptionMetadataRouteRequest:
|
||||
return caption_metadata_routes.CaptionMetadataRouteRequest(
|
||||
row=row,
|
||||
detail_level=detail_level,
|
||||
keep_style=keep_style,
|
||||
target=target,
|
||||
)
|
||||
|
||||
|
||||
def _single_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str] | None:
|
||||
def _single_from_row(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str] | None:
|
||||
return caption_metadata_routes.single_from_row(
|
||||
_caption_metadata_route_request(row, detail_level, keep_style),
|
||||
_caption_metadata_route_request(row, detail_level, keep_style, target),
|
||||
_caption_metadata_route_dependencies(),
|
||||
)
|
||||
|
||||
@@ -199,35 +206,60 @@ def _couple_clothing_sentence(clothing: str) -> str:
|
||||
return caption_metadata_routes.couple_clothing_sentence(clothing, _clean_text)
|
||||
|
||||
|
||||
def _couple_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str] | None:
|
||||
def _couple_from_row(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str] | None:
|
||||
return caption_metadata_routes.couple_from_row(
|
||||
_caption_metadata_route_request(row, detail_level, keep_style),
|
||||
_caption_metadata_route_request(row, detail_level, keep_style, target),
|
||||
_caption_metadata_route_dependencies(),
|
||||
)
|
||||
|
||||
|
||||
def _configured_cast_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str] | None:
|
||||
def _configured_cast_from_row(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str] | None:
|
||||
return caption_metadata_routes.configured_cast_from_row(
|
||||
_caption_metadata_route_request(row, detail_level, keep_style),
|
||||
_caption_metadata_route_request(row, detail_level, keep_style, target),
|
||||
_caption_metadata_route_dependencies(),
|
||||
)
|
||||
|
||||
|
||||
def _group_or_layout_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str] | None:
|
||||
def _group_or_layout_from_row(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str] | None:
|
||||
return caption_metadata_routes.group_or_layout_from_row(
|
||||
_caption_metadata_route_request(row, detail_level, keep_style),
|
||||
_caption_metadata_route_request(row, detail_level, keep_style, target),
|
||||
_caption_metadata_route_dependencies(),
|
||||
)
|
||||
|
||||
|
||||
def _insta_of_pair_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str] | None:
|
||||
def _insta_of_pair_from_row(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str] | None:
|
||||
return caption_metadata_routes.insta_of_pair_from_row(
|
||||
_caption_metadata_route_request(row, detail_level, keep_style),
|
||||
_caption_metadata_route_request(row, detail_level, keep_style, target),
|
||||
_caption_metadata_route_dependencies(),
|
||||
)
|
||||
|
||||
|
||||
def _metadata_to_prose(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str]:
|
||||
def _metadata_to_prose(
|
||||
row: dict[str, Any],
|
||||
detail_level: str,
|
||||
keep_style: bool,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str]:
|
||||
for builder in (
|
||||
_insta_of_pair_from_row,
|
||||
_configured_cast_from_row,
|
||||
@@ -235,7 +267,7 @@ def _metadata_to_prose(row: dict[str, Any], detail_level: str, keep_style: bool)
|
||||
_couple_from_row,
|
||||
_group_or_layout_from_row,
|
||||
):
|
||||
result = builder(row, detail_level, keep_style)
|
||||
result = builder(row, detail_level, keep_style, target)
|
||||
if result:
|
||||
prose, method = result
|
||||
return _append_formatter_hints(prose, row), method
|
||||
@@ -346,6 +378,7 @@ def naturalize_caption(
|
||||
detail_level: str = "balanced",
|
||||
style_policy: str = "drop_style_tail",
|
||||
caption_profile: str = caption_policy.CAPTION_PROFILE_DEFAULT,
|
||||
target: str = "auto",
|
||||
) -> tuple[str, str]:
|
||||
"""Rewrite tag-style prompt/caption text into compact natural language."""
|
||||
return caption_format_route.naturalize_caption(
|
||||
@@ -353,6 +386,7 @@ def naturalize_caption(
|
||||
source_text=source_text,
|
||||
metadata_json=metadata_json,
|
||||
input_hint=input_hint,
|
||||
target=target,
|
||||
trigger=trigger,
|
||||
include_trigger=include_trigger,
|
||||
detail_level=detail_level,
|
||||
|
||||
Reference in New Issue
Block a user