Add typed pair route contracts
This commit is contained in:
+102
-7
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable
|
||||
|
||||
try:
|
||||
@@ -12,7 +13,21 @@ BuildPrompt = Callable[..., dict[str, Any]]
|
||||
AxisRng = Callable[[dict[str, int], str, int, int], Any]
|
||||
|
||||
|
||||
def build_insta_pair_rows(
|
||||
@dataclass(frozen=True)
|
||||
class InstaPairRowsRoute:
|
||||
soft_row: dict[str, Any]
|
||||
hard_row: dict[str, Any]
|
||||
hard_content_rng: Any
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"soft_row": self.soft_row,
|
||||
"hard_row": self.hard_row,
|
||||
"hard_content_rng": self.hard_content_rng,
|
||||
}
|
||||
|
||||
|
||||
def build_insta_pair_rows_result(
|
||||
*,
|
||||
row_number: int,
|
||||
start_index: int,
|
||||
@@ -52,7 +67,7 @@ def build_insta_pair_rows(
|
||||
softcore_item_prompt_label: Callable[[str], str],
|
||||
pov_prompt_directive: Callable[[list[str]], str],
|
||||
pov_composition_prompt: Callable[[Any, list[str]], str],
|
||||
) -> dict[str, Any]:
|
||||
) -> InstaPairRowsRoute:
|
||||
soft_content_rng = axis_rng(parsed_seed_config, "content", seed, row_number + 311)
|
||||
hard_content_rng = axis_rng(parsed_seed_config, "content", seed, row_number + 317)
|
||||
soft_person_rng = axis_rng(parsed_seed_config, "person", seed, row_number)
|
||||
@@ -186,8 +201,88 @@ def build_insta_pair_rows(
|
||||
hard_row["pov_character_labels"] = pov_character_labels
|
||||
hard_row["pov_prompt_directive"] = pov_prompt_directive(pov_character_labels)
|
||||
|
||||
return {
|
||||
"soft_row": soft_row,
|
||||
"hard_row": hard_row,
|
||||
"hard_content_rng": hard_content_rng,
|
||||
}
|
||||
return InstaPairRowsRoute(
|
||||
soft_row=soft_row,
|
||||
hard_row=hard_row,
|
||||
hard_content_rng=hard_content_rng,
|
||||
)
|
||||
|
||||
|
||||
def build_insta_pair_rows(
|
||||
*,
|
||||
row_number: int,
|
||||
start_index: int,
|
||||
seed: int,
|
||||
active_trigger: str,
|
||||
parsed_seed_config: dict[str, int],
|
||||
options: dict[str, Any],
|
||||
ethnicity: str,
|
||||
figure: str,
|
||||
no_plus_women: bool,
|
||||
no_black: bool,
|
||||
character_profile: str | dict[str, Any] | None,
|
||||
character_cast: str | dict[str, Any] | list[Any] | None,
|
||||
character_slot_map: dict[str, dict[str, Any]],
|
||||
pov_character_labels: list[str],
|
||||
hard_women_count: int,
|
||||
hard_men_count: int,
|
||||
soft_category: str,
|
||||
soft_subcategory: str,
|
||||
softcore_level_key: str,
|
||||
hardcore_random_subcategory: str,
|
||||
hardcore_position_config: str | dict[str, Any] | None,
|
||||
location_config: str | dict[str, Any] | None,
|
||||
composition_config: str | dict[str, Any] | None,
|
||||
build_prompt: BuildPrompt,
|
||||
axis_rng: AxisRng,
|
||||
cast_expression_intensity_override: Callable[
|
||||
[float, dict[str, dict[str, Any]], int, int, str],
|
||||
tuple[float | None, str],
|
||||
],
|
||||
context_from_character_slot: Callable[[Any, dict[str, Any], str, str, str, bool, bool], dict[str, Any]],
|
||||
apply_character_context_to_row: Callable[[dict[str, Any], dict[str, Any]], dict[str, Any]],
|
||||
disable_row_expression: Callable[[dict[str, Any], str], dict[str, Any]],
|
||||
slot_softcore_outfit: Callable[[dict[str, Any] | None, Any], str],
|
||||
softcore_outfit: Callable[[Any, str], str],
|
||||
softcore_pose: Callable[[Any, str], str],
|
||||
softcore_item_prompt_label: Callable[[str], str],
|
||||
pov_prompt_directive: Callable[[list[str]], str],
|
||||
pov_composition_prompt: Callable[[Any, list[str]], str],
|
||||
) -> dict[str, Any]:
|
||||
return build_insta_pair_rows_result(
|
||||
row_number=row_number,
|
||||
start_index=start_index,
|
||||
seed=seed,
|
||||
active_trigger=active_trigger,
|
||||
parsed_seed_config=parsed_seed_config,
|
||||
options=options,
|
||||
ethnicity=ethnicity,
|
||||
figure=figure,
|
||||
no_plus_women=no_plus_women,
|
||||
no_black=no_black,
|
||||
character_profile=character_profile,
|
||||
character_cast=character_cast,
|
||||
character_slot_map=character_slot_map,
|
||||
pov_character_labels=pov_character_labels,
|
||||
hard_women_count=hard_women_count,
|
||||
hard_men_count=hard_men_count,
|
||||
soft_category=soft_category,
|
||||
soft_subcategory=soft_subcategory,
|
||||
softcore_level_key=softcore_level_key,
|
||||
hardcore_random_subcategory=hardcore_random_subcategory,
|
||||
hardcore_position_config=hardcore_position_config,
|
||||
location_config=location_config,
|
||||
composition_config=composition_config,
|
||||
build_prompt=build_prompt,
|
||||
axis_rng=axis_rng,
|
||||
cast_expression_intensity_override=cast_expression_intensity_override,
|
||||
context_from_character_slot=context_from_character_slot,
|
||||
apply_character_context_to_row=apply_character_context_to_row,
|
||||
disable_row_expression=disable_row_expression,
|
||||
slot_softcore_outfit=slot_softcore_outfit,
|
||||
softcore_outfit=softcore_outfit,
|
||||
softcore_pose=softcore_pose,
|
||||
softcore_item_prompt_label=softcore_item_prompt_label,
|
||||
pov_prompt_directive=pov_prompt_directive,
|
||||
pov_composition_prompt=pov_composition_prompt,
|
||||
).as_dict()
|
||||
|
||||
Reference in New Issue
Block a user