Centralize helper seed selection

This commit is contained in:
2026-06-27 14:16:03 +02:00
parent c7e4bdc373
commit 7bc08ada47
4 changed files with 57 additions and 39 deletions
+7 -19
View File
@@ -13,6 +13,7 @@ try:
from .prompt_builder import (
subcategory_choices,
)
from .seed_config import configured_seed_from_axes
from .location_config import (
build_composition_pool_json,
build_location_pool_json,
@@ -31,6 +32,7 @@ except ImportError: # Allows local smoke tests from the repository root.
from prompt_builder import (
subcategory_choices,
)
from seed_config import configured_seed_from_axes
from location_config import (
build_composition_pool_json,
build_location_pool_json,
@@ -224,25 +226,11 @@ class SxCPCastBias:
@staticmethod
def _configured_cast_seed(seed_config):
if not seed_config:
return None
if isinstance(seed_config, dict):
raw = seed_config
else:
try:
raw = json.loads(str(seed_config))
except (TypeError, ValueError, json.JSONDecodeError):
return None
if not isinstance(raw, dict):
return None
for key in ("category_seed", "content_seed", "role_seed", "seed", "global_seed"):
try:
value = int(raw.get(key))
except (TypeError, ValueError):
continue
if value >= 0:
return value
return None
return configured_seed_from_axes(
seed_config,
("category", "content", "role"),
extra_keys=("seed", "global_seed"),
)
@staticmethod
def _weight_pairs(weights_text, start_count):