File size: 1,999 Bytes
8944fd8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""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