Spaces:
Running
Running
| """Load juror configurations from YAML.""" | |
| from pathlib import Path | |
| from typing import Any | |
| import yaml | |
| from core.models import JurorConfig | |
| def load_juror_configs(config_path: str | Path | None = None) -> list[JurorConfig]: | |
| """Load all juror configurations from YAML file. | |
| Args: | |
| config_path: Path to jurors.yaml. Defaults to agents/configs/jurors.yaml. | |
| Returns: | |
| List of JurorConfig objects. | |
| """ | |
| if config_path is None: | |
| config_path = Path(__file__).parent / "configs" / "jurors.yaml" | |
| config_path = Path(config_path) | |
| if not config_path.exists(): | |
| raise FileNotFoundError(f"Juror config file not found: {config_path}") | |
| with open(config_path, "r", encoding="utf-8") as f: | |
| data = yaml.safe_load(f) | |
| configs = [] | |
| for juror_data in data.get("jurors", []): | |
| config = JurorConfig( | |
| juror_id=juror_data["juror_id"], | |
| seat_number=juror_data["seat_number"], | |
| name=juror_data["name"], | |
| emoji=juror_data["emoji"], | |
| archetype=juror_data["archetype"], | |
| personality_prompt=juror_data["personality_prompt"], | |
| stubbornness=juror_data["stubbornness"], | |
| volatility=juror_data["volatility"], | |
| influence=juror_data["influence"], | |
| verbosity=juror_data.get("verbosity", 0.5), | |
| initial_lean=juror_data.get("initial_lean", "neutral"), | |
| ) | |
| configs.append(config) | |
| return configs | |
| def get_juror_config(juror_id: str, configs: list[JurorConfig] | None = None) -> JurorConfig | None: | |
| """Get a specific juror config by ID. | |
| Args: | |
| juror_id: The juror ID to find. | |
| configs: Optional list of configs. If None, loads from default path. | |
| Returns: | |
| JurorConfig if found, None otherwise. | |
| """ | |
| if configs is None: | |
| configs = load_juror_configs() | |
| for config in configs: | |
| if config.juror_id == juror_id: | |
| return config | |
| return None | |